Source-Changes-HG archive

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

[src/yamt-uio_vmspace]: src/sys/arch adapt bus_dma implementations.



details:   https://anonhg.NetBSD.org/src/rev/76f9a5e405cc
branches:  yamt-uio_vmspace
changeset: 586721:76f9a5e405cc
user:      yamt <yamt%NetBSD.org@localhost>
date:      Sat Feb 18 11:12:18 2006 +0000

description:
adapt bus_dma implementations.

diffstat:

 sys/arch/algor/algor/bus_dma.c               |  38 ++++++++++++--------------
 sys/arch/arc/arc/bus_dma.c                   |  36 ++++++++++++-------------
 sys/arch/arc/jazz/bus_dma_jazz.c             |  27 +++++++++++-------
 sys/arch/arc/jazz/jazzdmatlb.c               |  10 +++---
 sys/arch/arc/jazz/jazzdmatlbvar.h            |   4 +-
 sys/arch/arm/arm32/bus_dma.c                 |  35 ++++++++++--------------
 sys/arch/atari/atari/bus.c                   |  37 +++++++++++---------------
 sys/arch/cobalt/cobalt/bus.c                 |  38 ++++++++++++--------------
 sys/arch/evbppc/evbppc/bus_dma.c             |  34 +++++++++++------------
 sys/arch/ews4800mips/ews4800mips/bus_dma.c   |  36 ++++++++++++-------------
 sys/arch/hp700/hp700/mainbus.c               |  35 ++++++++++--------------
 sys/arch/hpcmips/hpcmips/bus_dma.c           |  36 ++++++++++++-------------
 sys/arch/m68k/m68k/bus_dma.c                 |  38 +++++++++++++-------------
 sys/arch/mips/mips/bus_dma.c                 |  39 +++++++++++++--------------
 sys/arch/playstation2/playstation2/bus_dma.c |  34 +++++++++++------------
 15 files changed, 226 insertions(+), 251 deletions(-)

diffs (truncated from 1516 to 300 lines):

diff -r c4488afc8e48 -r 76f9a5e405cc sys/arch/algor/algor/bus_dma.c
--- a/sys/arch/algor/algor/bus_dma.c    Sat Feb 18 09:47:02 2006 +0000
+++ b/sys/arch/algor/algor/bus_dma.c    Sat Feb 18 11:12:18 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.15 2005/12/11 12:16:08 christos Exp $    */
+/*     $NetBSD: bus_dma.c,v 1.15.2.1 2006/02/18 11:12:18 yamt Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.15 2005/12/11 12:16:08 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.15.2.1 2006/02/18 11:12:18 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -125,8 +125,8 @@
  */
 static int
 _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map,
-    void *buf, bus_size_t buflen, struct proc *p, int flags, paddr_t *lastaddrp,
-    int *segp, int first)
+    void *buf, bus_size_t buflen, struct vmspace *vm, int flags,
+    paddr_t *lastaddrp, int *segp, int first)
 {
        bus_size_t sgsize;
        bus_addr_t curaddr, lastaddr, baddr, bmask;
@@ -140,8 +140,8 @@
                /*
                 * Get the physical address for this segment.
                 */
-               if (p != NULL)
-                       (void) pmap_extract(p->p_vmspace->vm_map.pmap,
+               if (!VMSPACE_IS_KERNEL_P(vm))
+                       (void) pmap_extract(vm_map_pmap(&vm->vm_map),
                            vaddr, &curaddr);
                else
                        curaddr = kvtophys(vaddr);
@@ -237,6 +237,7 @@
 {
        paddr_t lastaddr;
        int seg, error;
+       struct vmspace *vm;
 
        /*
         * Make sure that on error condition we return "no valid mappings".
@@ -248,9 +249,15 @@
        if (buflen > map->_dm_size)
                return (EINVAL);
 
+       if (p != NULL) {
+               vm = p->p_vmspace;
+       } else {
+               vm = vmspace_kernel();
+       }
+
        seg = 0;
        error = _bus_dmamap_load_buffer(t, map, buf, buflen,
-           p, flags, &lastaddr, &seg, 1);
+           vm, flags, &lastaddr, &seg, 1);
        if (error == 0) {
                map->dm_mapsize = buflen;
                map->dm_nsegs = seg + 1;
@@ -301,8 +308,8 @@
        for (m = m0; m != NULL && error == 0; m = m->m_next) {
                if (m->m_len == 0)
                        continue;
-               error = _bus_dmamap_load_buffer(t, map,
-                   m->m_data, m->m_len, NULL, flags, &lastaddr, &seg, first);
+               error = _bus_dmamap_load_buffer(t, map, m->m_data, m->m_len,
+                   vmspace_kernel(), flags, &lastaddr, &seg, first);
                first = 0;
        }
        if (error == 0) {
@@ -337,15 +344,6 @@
        resid = uio->uio_resid;
        iov = uio->uio_iov;
 
-       if (uio->uio_segflg == UIO_USERSPACE) {
-               p = uio->uio_lwp ? uio->uio_lwp->l_proc : NULL;
-#ifdef DIAGNOSTIC
-               if (p == NULL)
-                       panic("_bus_dmamap_load_uio: "
-                           "USERSPACE but no proc");
-#endif
-       }
-
        first = 1;
        seg = 0;
        error = 0;
@@ -357,8 +355,8 @@
                minlen = resid < iov[i].iov_len ? resid : iov[i].iov_len;
                addr = (caddr_t)iov[i].iov_base;
 
-               error = _bus_dmamap_load_buffer(t, map,
-                   addr, minlen, p, flags, &lastaddr, &seg, first);
+               error = _bus_dmamap_load_buffer(t, map, addr, minlen,
+                   uio->uio_vmspace, flags, &lastaddr, &seg, first);
                first = 0;
 
                resid -= minlen;
diff -r c4488afc8e48 -r 76f9a5e405cc sys/arch/arc/arc/bus_dma.c
--- a/sys/arch/arc/arc/bus_dma.c        Sat Feb 18 09:47:02 2006 +0000
+++ b/sys/arch/arc/arc/bus_dma.c        Sat Feb 18 11:12:18 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.26 2005/12/11 12:16:37 christos Exp $    */
+/*     $NetBSD: bus_dma.c,v 1.26.2.1 2006/02/18 11:12:18 yamt Exp $    */
 /*     NetBSD: bus_dma.c,v 1.20 2000/01/10 03:24:36 simonb Exp         */
 
 /*-
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.26 2005/12/11 12:16:37 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.26.2.1 2006/02/18 11:12:18 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -57,7 +57,7 @@
 paddr_t        kvtophys(vaddr_t);      /* XXX */
 
 static int     _bus_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t,
-                   void *, bus_size_t, struct proc *, int, paddr_t *,
+                   void *, bus_size_t, struct vmspace *, int, paddr_t *,
                    int *, int);
 
 extern paddr_t avail_start, avail_end; /* from pmap.c */
@@ -147,7 +147,7 @@
  */
 static int
 _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
-    bus_size_t buflen, struct proc *p, int flags, paddr_t *lastaddrp,
+    bus_size_t buflen, struct vmspace *vm, int flags, paddr_t *lastaddrp,
     int *segp, int first)
 {
        bus_size_t sgsize;
@@ -163,8 +163,8 @@
                /*
                 * Get the physical address for this segment.
                 */
-               if (p != NULL) {
-                       (void)pmap_extract(p->p_vmspace->vm_map.pmap,
+               if (!VMSPACE_IS_KERNEL_P(vm))
+                       (void)pmap_extract(vm_map_pmap(&vm->vm_map),
                            vaddr, &curaddr);
                } else
                        curaddr = kvtophys(vaddr);
@@ -241,6 +241,7 @@
 {
        paddr_t lastaddr;
        int seg, error;
+       struct vmspace *vm;
 
        /*
         * Make sure that on error condition we return "no valid mappings".
@@ -252,9 +253,15 @@
        if (buflen > map->_dm_size)
                return EINVAL;
 
+       if (p != NULL) {
+               vm = p->p_vmspace;
+       } else {
+               vm = vmspace_kernel();
+       }
+
        seg = 0;
        error = _bus_dmamap_load_buffer(t, map, buf, buflen,
-           p, flags, &lastaddr, &seg, 1);
+           vm, flags, &lastaddr, &seg, 1);
        if (error == 0) {
                map->dm_mapsize = buflen;
                map->dm_nsegs = seg + 1;
@@ -305,8 +312,8 @@
        for (m = m0; m != NULL && error == 0; m = m->m_next) {
                if (m->m_len == 0)
                        continue;
-               error = _bus_dmamap_load_buffer(t, map,
-                   m->m_data, m->m_len, NULL, flags, &lastaddr, &seg, first);
+               error = _bus_dmamap_load_buffer(t, map, m->m_data, m->m_len,
+                   vmspace_kernel(), flags, &lastaddr, &seg, first);
                first = 0;
        }
        if (error == 0) {
@@ -327,7 +334,6 @@
        paddr_t lastaddr;
        int seg, i, error, first;
        bus_size_t minlen, resid;
-       struct proc *p = NULL;
        struct iovec *iov;
        caddr_t addr;
 
@@ -341,14 +347,6 @@
        resid = uio->uio_resid;
        iov = uio->uio_iov;
 
-       if (uio->uio_segflg == UIO_USERSPACE) {
-               p = uio->uio_lwp ? uio->uio_lwp->l_proc : NULL;
-#ifdef DIAGNOSTIC
-               if (p == NULL)
-                       panic("_bus_dmamap_load_uio: USERSPACE but no proc");
-#endif
-       }
-
        first = 1;
        seg = 0;
        error = 0;
@@ -361,7 +359,7 @@
                addr = (caddr_t)iov[i].iov_base;
 
                error = _bus_dmamap_load_buffer(t, map, addr, minlen,
-                   p, flags, &lastaddr, &seg, first);
+                   uio->uio_vmspace, flags, &lastaddr, &seg, first);
                first = 0;
 
                resid -= minlen;
diff -r c4488afc8e48 -r 76f9a5e405cc sys/arch/arc/jazz/bus_dma_jazz.c
--- a/sys/arch/arc/jazz/bus_dma_jazz.c  Sat Feb 18 09:47:02 2006 +0000
+++ b/sys/arch/arc/jazz/bus_dma_jazz.c  Sat Feb 18 11:12:18 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma_jazz.c,v 1.12 2005/12/11 12:16:39 christos Exp $       */
+/*     $NetBSD: bus_dma_jazz.c,v 1.12.2.1 2006/02/18 11:12:18 yamt Exp $       */
 
 /*-
  * Copyright (C) 2003 Izumi Tsutsui.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma_jazz.c,v 1.12 2005/12/11 12:16:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma_jazz.c,v 1.12.2.1 2006/02/18 11:12:18 yamt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -49,7 +49,7 @@
 } *jazz_tlbmap_t;
 
 static int     jazz_bus_dmamap_alloc_sgmap(bus_dma_tag_t,
-                   bus_dma_segment_t *, int, bus_size_t, struct proc *, int);
+                   bus_dma_segment_t *, int, bus_size_t, int);
 static void    jazz_bus_dmamap_free_sgmap(bus_dma_tag_t,
                    bus_dma_segment_t *, int);
 
@@ -88,7 +88,7 @@
 
 static int
 jazz_bus_dmamap_alloc_sgmap(bus_dma_tag_t t, bus_dma_segment_t *segs,
-    int nsegs, bus_size_t boundary, struct proc *p, int flags)
+    int nsegs, bus_size_t boundary, int flags)
 {
        jazz_dma_pte_t *dmapte;
        bus_addr_t addr;
@@ -208,10 +208,17 @@
                /* just use pre-allocated DMA TLB for the buffer */
                jazz_tlbmap_t tlbmap;
                bus_size_t off;
+               struct vmspace *vm;
+
+               if (p != NULL) {
+                       vm = p->p_vmspace;
+               } else {
+                       vm = vmspace_kernel();
+               }
 
                tlbmap = (jazz_tlbmap_t)map->_dm_cookie;
                off = jazz_dma_page_offs(buf);
-               jazz_dmatlb_map_va(p, (vaddr_t)buf, buflen, tlbmap->ptebase);
+               jazz_dmatlb_map_va(vm, (vaddr_t)buf, buflen, tlbmap->ptebase);
 
                map->dm_segs[0].ds_addr = tlbmap->vaddr + off;
                map->dm_segs[0].ds_len = buflen;
@@ -226,7 +233,7 @@
        if (error == 0) {
                /* allocate DMA TLB for each dmamap segment */
                error = jazz_bus_dmamap_alloc_sgmap(t, map->dm_segs,
-                   map->dm_nsegs, map->_dm_boundary, p, flags);
+                   map->dm_nsegs, map->_dm_boundary, flags);
        }
        return error;
 }
@@ -247,7 +254,7 @@
        error = _bus_dmamap_load_mbuf(t, map, m0, flags);
        if (error == 0) {
                error = jazz_bus_dmamap_alloc_sgmap(t, map->dm_segs,
-                   map->dm_nsegs, map->_dm_boundary, NULL, flags);
+                   map->dm_nsegs, map->_dm_boundary, flags);
        }
        return error;
 }
@@ -268,9 +275,7 @@
        error = jazz_bus_dmamap_load_uio(t, map, uio, flags);
        if (error == 0) {
                error = jazz_bus_dmamap_alloc_sgmap(t, map->dm_segs,
-                   map->dm_nsegs, map->_dm_boundary,
-                   uio->uio_segflg == UIO_USERSPACE ? uio->uio_lwp->l_proc :
-                   NULL, flags);
+                   map->dm_nsegs, map->_dm_boundary, flags);
        }



Home | Main Index | Thread Index | Old Index