[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

i386 _proper_ dma'ble memory allocation



re
this fixes the long-standing bug in the i386 dma'ble memory
allocation. in short -- prefer higher physical memory segments
for busses (say pci) rather than exhausting the below-16m
segment that is much more favourable for isa.
please test.
cu

-- 
    paranoic mickey       (my employers have changed but, the name has remained)

Index: i386/machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.332
diff -u -r1.332 machdep.c
--- i386/machdep.c	18 Nov 2005 17:11:57 -0000	1.332
+++ i386/machdep.c	21 Nov 2005 18:11:11 -0000
@@ -4160,12 +4166,16 @@
 	/* Always round the size. */
 	size = round_page(size);
 
+	TAILQ_INIT(&mlist);
 	/*
 	 * Allocate pages from the VM system.
+	 * For non-ISA mappings first try higher memory segments.
 	 */
-	TAILQ_INIT(&mlist);
-	error = uvm_pglistalloc(size, low, high,
-	    alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
+	if (high <= ISA_DMA_BOUNCE_THRESHOLD || (error = uvm_pglistalloc(size,
+	    round_page(ISA_DMA_BOUNCE_THRESHOLD), high, alignment, boundary,
+	    &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0)))
+		error = uvm_pglistalloc(size, low, high, alignment, boundary,
+		    &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
 	if (error)
 		return (error);
 
Index: isa/isa_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/isa_machdep.c,v
retrieving revision 1.51
diff -u -r1.51 isa_machdep.c
--- isa/isa_machdep.c	29 Nov 2004 20:15:40 -0000	1.51
+++ isa/isa_machdep.c	21 Nov 2005 17:57:20 -0000
@@ -144,11 +144,6 @@
 
 #include "isadma.h"
 
-/*
- * ISA can only DMA to 0-16M.
- */
-#define	ISA_DMA_BOUNCE_THRESHOLD	0x00ffffff
-
 extern	paddr_t avail_end;
 
 #define	IDTVEC(name)	__CONCAT(X,name)
Index: isa/isa_machdep.h
===================================================================
RCS file: /cvs/src/sys/arch/i386/isa/isa_machdep.h,v
retrieving revision 1.19
diff -u -r1.19 isa_machdep.h
--- isa/isa_machdep.h	2 Jun 2003 23:27:47 -0000	1.19
+++ isa/isa_machdep.h	21 Nov 2005 17:57:39 -0000
@@ -83,6 +83,11 @@
 #include <machine/bus.h>
 
 /*
+ * ISA can only DMA to 0-16M.
+ */
+#define	ISA_DMA_BOUNCE_THRESHOLD	0x00ffffff
+
+/*
  * XXX THIS FILE IS A MESS.  copyright: berkeley's probably.
  * contents from isavar.h and isareg.h, mostly the latter.
  * perhaps charles's?



Visit your host, monkey.org