summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-05-08 18:42:08 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-05-08 18:42:08 +0000
commit7b358d538e466ebcf6cfb38854d5c956a796334c (patch)
treef30b203bb8a8ac08b80af1f76efece5030048902 /sys
parentd5d82b7603a15d62361a97e81cd7c3ab892b78f5 (diff)
Add a new page freelist, to which memory suitable for 32-bit dma on
xbridge(4) is assigned. Then, make bus_dmamem_alloc() allocate from this range only. This is transparent on O2, and makes sure the bus_dma memory address will fit in the 2GB direct map of xbridge(4) chips - this is necessary for PCI devices which do not handle 64 bit dma addresses.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sgi/include/vmparam.h5
-rw-r--r--sys/arch/sgi/sgi/bus_dma.c35
-rw-r--r--sys/arch/sgi/sgi/ip32_machdep.c3
-rw-r--r--sys/arch/sgi/sgi/machdep.c10
-rw-r--r--sys/arch/sgi/sgi/sginode.c27
-rw-r--r--sys/arch/sgi/xbow/xheart.c6
6 files changed, 67 insertions, 19 deletions
diff --git a/sys/arch/sgi/include/vmparam.h b/sys/arch/sgi/include/vmparam.h
index ba4d5e73e58..33f33aa2ff2 100644
--- a/sys/arch/sgi/include/vmparam.h
+++ b/sys/arch/sgi/include/vmparam.h
@@ -1,10 +1,13 @@
-/* $OpenBSD: vmparam.h,v 1.2 2008/04/07 22:41:52 miod Exp $ */
+/* $OpenBSD: vmparam.h,v 1.3 2009/05/08 18:42:04 miod Exp $ */
#ifndef _SGI_VMPARAM_H_
#define _SGI_VMPARAM_H_
#define VM_PHYSSEG_MAX 32 /* Max number of physical memory segments */
+#define VM_NFREELIST 2
+#define VM_FREELIST_DMA32 1 /* memory under 2GB suitable for DMA */
+
#include <mips64/vmparam.h>
#endif /* _SGI_VMPARAM_H_ */
diff --git a/sys/arch/sgi/sgi/bus_dma.c b/sys/arch/sgi/sgi/bus_dma.c
index 16037fa9ff8..15c1b11ca5b 100644
--- a/sys/arch/sgi/sgi/bus_dma.c
+++ b/sys/arch/sgi/sgi/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.10 2009/04/20 00:42:06 oga Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.11 2009/05/08 18:42:06 miod Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -40,6 +40,7 @@
#include <machine/autoconf.h>
#include <machine/bus.h>
+#include <sgi/sgi/ip30.h>
/*
* Common function for DMA map creation. May be called by bus-specific
@@ -439,8 +440,36 @@ _dmamem_alloc(t, size, alignment, boundary, segs, nsegs, rsegs, flags)
int *rsegs;
int flags;
{
- return (_dmamem_alloc_range(t, size, alignment, boundary,
- segs, nsegs, rsegs, flags, (paddr_t)0, (paddr_t)-1));
+ vaddr_t low;
+ vaddr_t high;
+
+ /*
+ * Limit bus_dma'able memory to the first 2GB of physical memory.
+ * XXX This should be lifted if flags & BUS_DMA_64BIT for
+ * XXX drivers which do not need 32 bit DMA on IP27/30/35.
+ */
+ switch (sys_config.system_type) {
+#if defined(TGT_OCTANE)
+ case SGI_OCTANE:
+ low = IP30_MEMORY_BASE;
+ high = (2U << 30) - 1 + IP30_MEMORY_BASE;
+ break;
+#endif
+#if defined(TGT_ORIGIN200) || defined(TGT_ORIGIN2000)
+ case SGI_O200:
+ case SGI_O300:
+ low = 0;
+ high = (2U << 30) - 1;
+ break;
+#endif
+ default:
+ low = 0;
+ high = (vaddr_t)-1;
+ break;
+ }
+
+ return _dmamem_alloc_range(t, size, alignment, boundary,
+ segs, nsegs, rsegs, flags, low, high);
}
/*
diff --git a/sys/arch/sgi/sgi/ip32_machdep.c b/sys/arch/sgi/sgi/ip32_machdep.c
index 7b66d1a6295..f2b6f31a114 100644
--- a/sys/arch/sgi/sgi/ip32_machdep.c
+++ b/sys/arch/sgi/sgi/ip32_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip32_machdep.c,v 1.4 2009/04/12 17:53:02 miod Exp $ */
+/* $OpenBSD: ip32_machdep.c,v 1.5 2009/05/08 18:42:07 miod Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -116,6 +116,7 @@ crime_configure_memory(void)
m->mem_first_page = first_page;
m->mem_last_page = last_page;
}
+ m->mem_freelist = VM_FREELIST_DEFAULT;
physmem += atop(size);
}
}
diff --git a/sys/arch/sgi/sgi/machdep.c b/sys/arch/sgi/sgi/machdep.c
index 2f9a8c28d11..48fdb2f6e67 100644
--- a/sys/arch/sgi/sgi/machdep.c
+++ b/sys/arch/sgi/sgi/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.64 2009/04/25 20:38:32 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.65 2009/05/08 18:42:07 miod Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -336,6 +336,7 @@ mips_init(int argc, void *argv, caddr_t boot_esym)
for (i = 0; i < MAXMEMSEGS && mem_layout[i].mem_first_page != 0; i++) {
u_int32_t fp, lp;
u_int32_t firstkernpage, lastkernpage;
+ unsigned int freelist;
paddr_t firstkernpa, lastkernpa;
if (IS_XKPHYS((vaddr_t)start))
@@ -352,13 +353,14 @@ mips_init(int argc, void *argv, caddr_t boot_esym)
fp = mem_layout[i].mem_first_page;
lp = mem_layout[i].mem_last_page;
+ freelist = mem_layout[i].mem_freelist;
/* Account for kernel and kernel symbol table. */
if (fp >= firstkernpage && lp < lastkernpage)
continue; /* In kernel. */
if (lp < firstkernpage || fp > lastkernpage) {
- uvm_page_physload(fp, lp, fp, lp, VM_FREELIST_DEFAULT);
+ uvm_page_physload(fp, lp, fp, lp, freelist);
continue; /* Outside kernel. */
}
@@ -368,11 +370,11 @@ mips_init(int argc, void *argv, caddr_t boot_esym)
lp = firstkernpage;
else { /* Need to split! */
u_int32_t xp = firstkernpage;
- uvm_page_physload(fp, xp, fp, xp, VM_FREELIST_DEFAULT);
+ uvm_page_physload(fp, xp, fp, xp, freelist);
fp = lastkernpage;
}
if (lp > fp)
- uvm_page_physload(fp, lp, fp, lp, VM_FREELIST_DEFAULT);
+ uvm_page_physload(fp, lp, fp, lp, freelist);
}
diff --git a/sys/arch/sgi/sgi/sginode.c b/sys/arch/sgi/sgi/sginode.c
index c2be0b76f91..619f664407d 100644
--- a/sys/arch/sgi/sgi/sginode.c
+++ b/sys/arch/sgi/sgi/sginode.c
@@ -1,5 +1,4 @@
-#define DEBUG
-/* $OpenBSD: sginode.c,v 1.4 2009/05/06 20:08:00 miod Exp $ */
+/* $OpenBSD: sginode.c,v 1.5 2009/05/08 18:42:07 miod Exp $ */
/*
* Copyright (c) 2008, 2009 Miodrag Vallat.
*
@@ -280,7 +279,9 @@ kl_add_memory_ip27(int16_t *sizes, unsigned int cnt)
/*
* Walk the existing segment list to find if we
* are adjacent to an existing segment, or the
- * next free segment to use if not.
+ * next free segment to use if not (unless doing
+ * this would cross the 2GB boundary we need for
+ * 32 bit DMA memory).
*
* Note that since we do not know in which order
* we'll find our nodes, we have to check for
@@ -292,14 +293,16 @@ kl_add_memory_ip27(int16_t *sizes, unsigned int cnt)
if (md->mem_first_page == 0)
break;
- if (md->mem_first_page == lp) {
+ if (md->mem_first_page == lp &&
+ lp != atop(2 << 30)) {
md->mem_first_page = fp;
physmem += np;
md = NULL;
break;
}
- if (md->mem_last_page == fp) {
+ if (md->mem_last_page == fp &&
+ fp != atop(2 << 30)) {
md->mem_last_page = lp;
physmem += np;
md = NULL;
@@ -309,6 +312,8 @@ kl_add_memory_ip27(int16_t *sizes, unsigned int cnt)
if (descno != MAXMEMSEGS && md != NULL) {
md->mem_first_page = fp;
md->mem_last_page = lp;
+ md->mem_freelist = lp <= atop(2 << 30) ?
+ VM_FREELIST_DMA32 : VM_FREELIST_DEFAULT;
physmem += np;
md = NULL;
}
@@ -366,7 +371,9 @@ kl_add_memory_ip35(int16_t *sizes, unsigned int cnt)
/*
* Walk the existing segment list to find if we
* are adjacent to an existing segment, or the
- * next free segment to use if not.
+ * next free segment to use if not (unless doing
+ * this would cross the 2GB boundary we need for
+ * 32 bit DMA memory).
*
* Note that since we do not know in which order
* we'll find our nodes, we have to check for
@@ -378,14 +385,16 @@ kl_add_memory_ip35(int16_t *sizes, unsigned int cnt)
if (md->mem_first_page == 0)
break;
- if (md->mem_first_page == lp) {
+ if (md->mem_first_page == lp &&
+ lp != atop(2 << 30)) {
md->mem_first_page = fp;
physmem += np;
md = NULL;
break;
}
- if (md->mem_last_page == fp) {
+ if (md->mem_last_page == fp &&
+ fp != atop(2 << 30)) {
md->mem_last_page = lp;
physmem += np;
md = NULL;
@@ -395,6 +404,8 @@ kl_add_memory_ip35(int16_t *sizes, unsigned int cnt)
if (descno != MAXMEMSEGS && md != NULL) {
md->mem_first_page = fp;
md->mem_last_page = lp;
+ md->mem_freelist = lp <= atop(2 << 30) ?
+ VM_FREELIST_DMA32 : VM_FREELIST_DEFAULT;
physmem += np;
md = NULL;
}
diff --git a/sys/arch/sgi/xbow/xheart.c b/sys/arch/sgi/xbow/xheart.c
index 1b283f20bad..3d1ee8b2f56 100644
--- a/sys/arch/sgi/xbow/xheart.c
+++ b/sys/arch/sgi/xbow/xheart.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xheart.c,v 1.6 2009/04/18 14:48:09 miod Exp $ */
+/* $OpenBSD: xheart.c,v 1.7 2009/05/08 18:42:07 miod Exp $ */
/*
* Copyright (c) 2008 Miodrag Vallat.
@@ -287,7 +287,9 @@ xheart_intr_establish(int (*func)(void *), void *arg, int intrbit,
ih->ih_arg = arg;
ih->ih_level = level;
ih->ih_irq = intrbit;
- evcount_attach(&ih->ih_count, name, &ih->ih_level, &evcount_intr);
+ if (name != NULL)
+ evcount_attach(&ih->ih_count, name, &ih->ih_level,
+ &evcount_intr);
intrhand[intrbit] = ih;
sc->sc_intrmask |= 1UL << intrbit;