summaryrefslogtreecommitdiff
path: root/sys/arch/mips64
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2012-03-19 21:56:50 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2012-03-19 21:56:50 +0000
commit3878465307b8010631b215296da1e11a958e1b5a (patch)
treefab8c208ad2e04becd3043907106215390721bd8 /sys/arch/mips64
parente10c65965f0e0fdd1af4ab73756732a7f477b84d (diff)
On sgi, use CKSEG0 addresses whenever possible for pmap_map_direct and u area
pages. This will allow R5000-based systems with physical memory fitting in CKSEG0 to use 16KB pages and direct maps (since only XKPHYS accesses trigger the XKPHYS coherency errata on these processors). Tested on IP32, IP30 and IP27 (and loongson too as well).
Diffstat (limited to 'sys/arch/mips64')
-rw-r--r--sys/arch/mips64/mips64/pmap.c43
-rw-r--r--sys/arch/mips64/mips64/vm_machdep.c12
2 files changed, 42 insertions, 13 deletions
diff --git a/sys/arch/mips64/mips64/pmap.c b/sys/arch/mips64/mips64/pmap.c
index d3edd57e995..96ebbbe9358 100644
--- a/sys/arch/mips64/mips64/pmap.c
+++ b/sys/arch/mips64/mips64/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.55 2012/03/19 20:42:26 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.56 2012/03/19 21:56:49 miod Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -140,7 +140,6 @@ static struct pmap kernel_pmap_store
/ sizeof(struct pmap)];
struct pmap *const kernel_pmap_ptr = kernel_pmap_store;
-psize_t mem_size; /* memory size in bytes */
vaddr_t virtual_start; /* VA of first avail page (after kernel bss)*/
vaddr_t virtual_end; /* VA of last avail page (end of kernel AS) */
@@ -437,16 +436,14 @@ pmap_steal_memory(vsize_t size, vaddr_t *vstartp, vaddr_t *vendp)
#ifdef __sgi__
/*
- * If we are running with a 32 bit ARCBios (i.e. kernel
- * linked in CKSEG0), return a CKSEG0 address whenever possible.
+ * Return a CKSEG0 address whenever possible.
*/
- if (IS_XKPHYS((vaddr_t)&pmap_steal_memory) ||
- pa + size >= CKSEG_SIZE)
- va = PHYS_TO_XKPHYS(pa, CCA_CACHED);
- else
+ if (pa + size < CKSEG_SIZE)
va = PHYS_TO_CKSEG0(pa);
-#else
+ else
va = PHYS_TO_XKPHYS(pa, CCA_CACHED);
+#else
+ va = PHYS_TO_XKPHYS(pa, CCA_CACHED);
#endif
bzero((void *)va, size);
@@ -1651,7 +1648,19 @@ vaddr_t
pmap_map_direct(vm_page_t pg)
{
paddr_t pa = VM_PAGE_TO_PHYS(pg);
- vaddr_t va = PHYS_TO_XKPHYS(pa, CCA_CACHED);
+ vaddr_t va;
+
+#ifdef __sgi__
+ /*
+ * Return a CKSEG0 address whenever possible.
+ */
+ if (pa < CKSEG_SIZE)
+ va = PHYS_TO_CKSEG0(pa);
+ else
+ va = PHYS_TO_XKPHYS(pa, CCA_CACHED);
+#else
+ va = PHYS_TO_XKPHYS(pa, CCA_CACHED);
+#endif
return va;
}
@@ -1659,9 +1668,19 @@ pmap_map_direct(vm_page_t pg)
vm_page_t
pmap_unmap_direct(vaddr_t va)
{
- paddr_t pa = XKPHYS_TO_PHYS(va);
- vm_page_t pg = PHYS_TO_VM_PAGE(pa);
+ paddr_t pa;
+ vm_page_t pg;
+#ifdef __sgi__
+ if (va >= CKSEG0_BASE)
+ pa = CKSEG0_TO_PHYS(va);
+ else
+ pa = XKPHYS_TO_PHYS(va);
+#else
+ pa = XKPHYS_TO_PHYS(va);
+#endif
+
+ pg = PHYS_TO_VM_PAGE(pa);
if (CpuCacheAliasMask)
Mips_HitInvalidateDCache(curcpu(), va, pa, PAGE_SIZE);
diff --git a/sys/arch/mips64/mips64/vm_machdep.c b/sys/arch/mips64/mips64/vm_machdep.c
index 7ed194dea94..ff823b6aea9 100644
--- a/sys/arch/mips64/mips64/vm_machdep.c
+++ b/sys/arch/mips64/mips64/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.24 2010/11/24 21:16:28 miod Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.25 2012/03/19 21:56:49 miod Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1992, 1993
@@ -76,8 +76,18 @@ cpu_fork(p1, p2, stack, stacksize, func, arg)
/* replace p_addr with a direct translation address */
p2->p_md.md_uarea = (vaddr_t)p2->p_addr;
pmap_extract(pmap_kernel(), p2->p_md.md_uarea, &pa);
+#ifdef __sgi__
+ /*
+ * Return a CKSEG0 address whenever possible.
+ */
+ if (pa < CKSEG_SIZE)
+ p2->p_addr = (void *)PHYS_TO_CKSEG0(pa);
+ else
+ p2->p_addr = (void *)PHYS_TO_XKPHYS(pa, CCA_CACHED);
+#else
p2->p_addr = (void *)PHYS_TO_XKPHYS(pa, CCA_CACHED);
#endif
+#endif
pcb = &p2->p_addr->u_pcb;
/*