Subject: patch for PixelStamp DMA memory
To: None <port-pmax@netbsd.org>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: port-pmax
Date: 03/30/1999 16:19:52
Seems like no one picked up the ball to run with this, so I made the
trivial changes needed to make the PixelStamp driver be able to get its
DMA memory without an awful hack.
To reiterate what this patch does: It places the first 8M of RAM onto a
separate, lower-priority free list, which will only be used by the VM
system if the default free list (which has memory > 8M) is exhausted.
This means that the PixelStamp driver should be able to allocate memory
within its constraints without magically reserving the amount of space
needed + slop in machdep.c. (bus_dmamem_alloc() is what you want for
allocating the memory in the `px' driver.)
I haven't tested it yet, but it's basically what the i386 port does for
ISA DMA'able memory.
This patch should be committed before the 1.4 branch is made.
-- Jason R. Thorpe <thorpej@nas.nasa.gov>
Index: include/vmparam.h
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/include/vmparam.h,v
retrieving revision 1.8
diff -c -r1.8 vmparam.h
*** vmparam.h 1998/07/08 04:43:19 1.8
--- vmparam.h 1999/03/31 00:12:23
***************
*** 5,14 ****
/*
* DECstation has one physical memory segment.
*/
! #define VM_PHYSSEG_MAX 1
! #define VM_NFREELIST 1
#define VM_FREELIST_DEFAULT 0
/* pcb base */
/*#define pcbb(p) ((u_int)(p)->p_addr) */
--- 5,17 ----
/*
* DECstation has one physical memory segment.
*/
! #define VM_PHYSSEG_MAX 2 /* 2 free lists */
! #define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH
! #define VM_PHYSSEG_NOADD /* can't add RAM after vm_mem_init */
! #define VM_NFREELIST 2
#define VM_FREELIST_DEFAULT 0
+ #define VM_FREELIST_FIRST8 1
/* pcb base */
/*#define pcbb(p) ((u_int)(p)->p_addr) */
Index: pmax/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/pmax/machdep.c,v
retrieving revision 1.133
diff -c -r1.133 machdep.c
*** machdep.c 1999/03/28 01:56:41 1.133
--- machdep.c 1999/03/31 00:12:23
***************
*** 482,492 ****
/*
* Load the rest of the available pages into the VM system.
*/
first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
last = mem_clusters[0].start + mem_clusters[0].size;
! uvm_page_physload(atop(first), atop(last), atop(first), atop(last),
! VM_FREELIST_DEFAULT);
/*
* Initialize error message buffer (at end of core).
--- 482,503 ----
/*
* Load the rest of the available pages into the VM system.
+ * Put the first 8M of RAM onto a lower-priority free list, since
+ * some TC boards (e.g. PixelStamp boards) are only able to DMA
+ * into this region, and we want them to have a fighting chance of
+ * allocating their DMA memory during autoconfiguratoin.
*/
first = round_page(MIPS_KSEG0_TO_PHYS(kernend));
last = mem_clusters[0].start + mem_clusters[0].size;
! if (last <= (8 * 1024 * 1024)) {
! uvm_page_physload(atop(first), atop(last), atop(first),
! atop(last), VM_FREELIST_DEFAULT);
! } else {
! uvm_page_physload(atop(first), atop(8 * 1024 * 1024),
! atop(first), atop(8 * 1024 * 1024), VM_FREELIST_FIRST8);
! uvm_page_physload(atop(8 * 1024 * 1024), atop(last),
! atop(8 * 1024 * 1024), atop(last), VM_FREELIST_DEFAULT);
! }
/*
* Initialize error message buffer (at end of core).