Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Remove the dma24_ex method of dealing with BUS_DMA_...



details:   https://anonhg.NetBSD.org/src/rev/2a25fb559c80
branches:  trunk
changeset: 752134:2a25fb559c80
user:      skrll <skrll%NetBSD.org@localhost>
date:      Tue Feb 16 16:56:29 2010 +0000

description:
Remove the dma24_ex method of dealing with BUS_DMA_24BIT and replace
with a uvm managed freelist of pages in the right range.

diffstat:

 sys/arch/hp700/hp700/machdep.c  |  19 +--------
 sys/arch/hp700/hp700/mainbus.c  |  84 ++++++++--------------------------------
 sys/arch/hppa/hppa/pmap.c       |  76 ++++++++++++++++++------------------
 sys/arch/hppa/include/vmparam.h |   5 +-
 4 files changed, 61 insertions(+), 123 deletions(-)

diffs (truncated from 332 to 300 lines):

diff -r 00353b6fe140 -r 2a25fb559c80 sys/arch/hp700/hp700/machdep.c
--- a/sys/arch/hp700/hp700/machdep.c    Tue Feb 16 15:17:17 2010 +0000
+++ b/sys/arch/hp700/hp700/machdep.c    Tue Feb 16 16:56:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.78 2010/02/08 19:02:29 joerg Exp $       */
+/*     $NetBSD: machdep.c,v 1.79 2010/02/16 16:56:29 skrll Exp $       */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.78 2010/02/08 19:02:29 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.79 2010/02/16 16:56:29 skrll Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -247,13 +247,6 @@
 /* Virtual page frame for /dev/mem (see mem.c) */
 vaddr_t vmmap;
 
-/*
- * Certain devices need DMA'able memory below the 16MB boundary.
- */
-#define        DMA24_SIZE      (128 * 1024)
-struct extent *dma24_ex;
-long dma24_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
-
 /* Our exported CPU info; we can have only one. */
 struct cpu_info cpu_info_store = {
 #ifdef MULTIPROCESSOR
@@ -495,14 +488,6 @@
        vstart += MSGBUFSIZE;
        vstart = round_page(vstart);
 
-       /* Allocate the 24-bit DMA region. */
-       dma24_ex = extent_create("dma24", vstart, vstart + DMA24_SIZE, M_DEVBUF,
-           (void *)dma24_ex_storage, sizeof(dma24_ex_storage),
-           EX_NOCOALESCE|EX_NOWAIT);
-       vstart += DMA24_SIZE;
-       vstart = round_page(vstart);
-
-
        if (usebtlb) {
                /* Allocate and initialize the BTLB slots array. */
                btlb_slots = (struct btlb_slot *) ALIGN(vstart);
diff -r 00353b6fe140 -r 2a25fb559c80 sys/arch/hp700/hp700/mainbus.c
--- a/sys/arch/hp700/hp700/mainbus.c    Tue Feb 16 15:17:17 2010 +0000
+++ b/sys/arch/hp700/hp700/mainbus.c    Tue Feb 16 16:56:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.61 2010/02/12 22:34:39 skrll Exp $       */
+/*     $NetBSD: mainbus.c,v 1.62 2010/02/16 16:56:29 skrll Exp $       */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.61 2010/02/12 22:34:39 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.62 2010/02/16 16:56:29 skrll Exp $");
 
 #include "locators.h"
 #include "power.h"
@@ -113,7 +113,6 @@
 
 /* from machdep.c */
 extern struct extent *hp700_io_extent;
-extern struct extent *dma24_ex;
 
 u_int8_t mbus_r1(void *, bus_space_handle_t, bus_size_t);
 u_int16_t mbus_r2(void *, bus_space_handle_t, bus_size_t);
@@ -1192,33 +1191,8 @@
         * Allocate physical pages from the VM system.
         */
        TAILQ_INIT(mlist);
-       error = uvm_pglistalloc(size, low, high, 0, 0,
-                               mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
-
-       /*
-        * If the allocation failed, and this is a 24-bit
-        * device, see if we have space left in the 24-bit
-        * region.
-        */
-       if (error == ENOMEM && (flags & BUS_DMA_24BIT) && dma24_ex != NULL) {
-               error = extent_alloc(dma24_ex, size, alignment, 0, 0, &pa);
-               if (!error) {
-                       free(mlist, M_DEVBUF);
-                       /*
-                        * A _ds_mlist value of NULL is the
-                        * signal to mbus_dmamem_map that no
-                        * real mapping needs to be done, and
-                        * it is the signal to mbus_dmamem_free
-                        * that an extent_free is needed.
-                        */
-                       *rsegs = 1;
-                       segs[0].ds_addr = 0;
-                       segs[0].ds_len = size;
-                       segs[0]._ds_va = (vaddr_t)pa;
-                       segs[0]._ds_mlist = NULL;
-                       return (0);
-               }
-       }
+       error = uvm_pglistalloc(size, low, high, 0, 0, mlist, nsegs,
+           (flags & BUS_DMA_NOWAIT) == 0);
 
        /* If we don't have the pages. */
        if (error) {
@@ -1226,15 +1200,10 @@
                return (error);
        }
 
-       /*
-        * Since, at least as of revision 1.17 of uvm_pglist.c,
-        * uvm_pglistalloc ignores its nsegs argument, we need
-        * to check that the pages returned conform to the
-        * caller's segment requirements.
-        */
        pa_next = 0;
        seg = -1;
-       for (m = TAILQ_FIRST(mlist); m != NULL; m = TAILQ_NEXT(m,pageq.queue)) {
+
+       TAILQ_FOREACH(m, mlist, pageq.queue) {
                pa = VM_PAGE_TO_PHYS(m);
                if (pa != pa_next) {
                        if (++seg >= nsegs) {
@@ -1269,17 +1238,16 @@
 void
 mbus_dmamem_free(void *v, bus_dma_segment_t *segs, int nsegs)
 {
-
+       struct pglist *mlist;
        /*
         * Return the list of physical pages back to the VM system.
         */
-       if (segs[0]._ds_mlist != NULL) {
-               uvm_pglistfree(segs[0]._ds_mlist);
-               free(segs[0]._ds_mlist, M_DEVBUF);
-       } else {
-               extent_free(dma24_ex, segs[0]._ds_va, segs[0].ds_len,
-                               EX_NOWAIT);
-       }
+       mlist = segs[0]._ds_mlist;
+       if (mlist == NULL)
+               return;
+       
+       uvm_pglistfree(mlist);
+       free(mlist, M_DEVBUF);
 }
 
 /*
@@ -1299,17 +1267,9 @@
 
        size = round_page(size);
 
-       /* 24-bit memory needs no mapping. */
-       if (segs[0]._ds_mlist == NULL) {
-               if (size > segs[0].ds_len)
-                       panic("mbus_dmamem_map: size botch");
-               *kvap = (void *)segs[0]._ds_va;
-               return (0);
-       }
-
        /* Get a chunk of kernel virtual space. */
        va = uvm_km_alloc(kernel_map, size, 0, UVM_KMF_VAONLY | kmflags);
-       if (va == 0)
+       if (__predict_false(va == 0))
                return (ENOMEM);
 
        /* Stash that in the first segment. */
@@ -1321,7 +1281,9 @@
        TAILQ_FOREACH(pg, pglist, pageq.queue) {
                KASSERT(size != 0);
                pa = VM_PAGE_TO_PHYS(pg);
-               pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, PMAP_NOCACHE);
+               pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE,
+                   PMAP_NOCACHE);
+
                va += PAGE_SIZE;
                size -= PAGE_SIZE;
        }
@@ -1337,17 +1299,7 @@
 mbus_dmamem_unmap(void *v, void *kva, size_t size)
 {
 
-#ifdef DIAGNOSTIC
-       if ((u_long)kva & PAGE_MASK)
-               panic("mbus_dmamem_unmap");
-#endif
-
-       /*
-        * XXX fredette - this is gross, but it is needed
-        * to support the 24-bit DMA address stuff.
-        */
-       if (dma24_ex != NULL && kva < (void *) (1 << 24))
-               return;
+       KASSERT(((vaddr_t)kva & PAGE_MASK) == 0);
 
        size = round_page(size);
        pmap_kremove((vaddr_t)kva, size);
diff -r 00353b6fe140 -r 2a25fb559c80 sys/arch/hppa/hppa/pmap.c
--- a/sys/arch/hppa/hppa/pmap.c Tue Feb 16 15:17:17 2010 +0000
+++ b/sys/arch/hppa/hppa/pmap.c Tue Feb 16 16:56:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.63 2009/12/18 19:20:35 skrll Exp $  */
+/*     $NetBSD: pmap.c,v 1.64 2010/02/16 16:56:30 skrll Exp $  */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.63 2009/12/18 19:20:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.64 2010/02/16 16:56:30 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -667,6 +667,39 @@
        return (pv);
 }
 
+#define        FIRST_16M atop(16 * 1024 * 1024)
+
+static void
+pmap_page_physload(paddr_t spa, paddr_t epa)
+{
+
+       if (spa < FIRST_16M && epa <= FIRST_16M) {
+               DPRINTF(PDB_INIT, ("%s: phys segment 0x%05lx 0x%05lx\n",
+                   __func__, spa, epa));
+
+               uvm_page_physload(spa, epa, spa, epa, VM_FREELIST_ISADMA);
+       } else if (spa < FIRST_16M && epa > FIRST_16M) {
+               DPRINTF(PDB_INIT, ("%s: phys segment 0x%05lx 0x%05lx\n",
+                   __func__, spa, FIRST_16M));
+
+               uvm_page_physload(spa, FIRST_16M, spa, FIRST_16M,
+                   VM_FREELIST_ISADMA);
+
+               DPRINTF(PDB_INIT, ("%s: phys segment 0x%05lx 0x%05lx\n",
+                   __func__, FIRST_16M, epa));
+
+               uvm_page_physload(FIRST_16M, epa, FIRST_16M, epa,
+                   VM_FREELIST_DEFAULT);
+       } else {
+               DPRINTF(PDB_INIT, ("%s: phys segment 0x%05lx 0x%05lx\n",
+                   __func__, spa, epa));
+
+               uvm_page_physload(spa, epa, spa, epa, VM_FREELIST_DEFAULT);
+       }
+
+       availphysmem += epa - spa;
+}
+
 /*
  * Bootstrap the system enough to run with virtual memory.
  * Map the kernel's code, data and bss, and allocate the system page table.
@@ -686,7 +719,6 @@
        extern int resvphysmem;
        vsize_t btlb_entry_min, btlb_entry_max, btlb_entry_got;
        paddr_t ksrx, kerx, ksro, kero, ksrw, kerw;
-       paddr_t phys_start, phys_end;
        extern int usebtlb;
 
        /* Provided by the linker script */
@@ -973,41 +1005,9 @@
 
        availphysmem = 0;
 
-       /* The first segment runs from [resvmem..ksrx). */
-       phys_start = resvmem;
-       phys_end = atop(ksrx);
-
-       DPRINTF(PDB_INIT, ("%s: phys segment 0x%05x 0x%05x\n", __func__,
-           (u_int)phys_start, (u_int)phys_end));
-       if (phys_end > phys_start) {
-               uvm_page_physload(phys_start, phys_end,
-                       phys_start, phys_end, VM_FREELIST_DEFAULT);
-               availphysmem += phys_end - phys_start;
-       }
-
-       /* The second segment runs from [kero..ksrw). */
-       phys_start = atop(kero);
-       phys_end = atop(ksrw);
-
-       DPRINTF(PDB_INIT, ("%s: phys segment 0x%05x 0x%05x\n", __func__,
-           (u_int)phys_start, (u_int)phys_end));
-       if (phys_end > phys_start) {
-               uvm_page_physload(phys_start, phys_end,
-                       phys_start, phys_end, VM_FREELIST_DEFAULT);
-               availphysmem += phys_end - phys_start;
-       }
-
-       /* The third segment runs from [kerw..physmem). */
-       phys_start = atop(kerw);
-       phys_end = physmem;
-
-       DPRINTF(PDB_INIT, ("%s: phys segment 0x%05x 0x%05x\n", __func__,



Home | Main Index | Thread Index | Old Index