Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/alpha Keep track of which DMA window was actually u...



details:   https://anonhg.NetBSD.org/src/rev/882f07cf617b
branches:  trunk
changeset: 526148:882f07cf617b
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Apr 26 04:15:18 2002 +0000

description:
Keep track of which DMA window was actually used to map the
request (not always the passed in DMA tag if we try direct-map
and then fall back to sgmap-mapped).  Use the actual window
when performing dmamap_sync and dmamap_unload operations.

Fixes DMA resource leak on systems with 2G+ RAM.  Thanks to
Matt Thomas for help debugging this.

diffstat:

 sys/arch/alpha/common/bus_dma.c       |   9 +++++++--
 sys/arch/alpha/common/sgmap_typedep.c |   8 ++++++--
 sys/arch/alpha/include/bus.h          |  13 ++++++++++---
 sys/arch/alpha/isa/isadma_bounce.c    |   6 ++++--
 4 files changed, 27 insertions(+), 9 deletions(-)

diffs (175 lines):

diff -r 39180f047139 -r 882f07cf617b sys/arch/alpha/common/bus_dma.c
--- a/sys/arch/alpha/common/bus_dma.c   Fri Apr 26 03:58:41 2002 +0000
+++ b/sys/arch/alpha/common/bus_dma.c   Fri Apr 26 04:15:18 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.48 2001/09/10 21:19:09 chris Exp $ */
+/* $NetBSD: bus_dma.c,v 1.49 2002/04/26 04:15:18 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 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.48 2001/09/10 21:19:09 chris Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.49 2002/04/26 04:15:18 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -103,6 +103,7 @@
        map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
        map->dm_mapsize = 0;            /* no valid mappings */
        map->dm_nsegs = 0;
+       map->_dm_window = NULL;
 
        *dmamp = map;
        return (0);
@@ -250,6 +251,7 @@
        if (error == 0) {
                map->dm_mapsize = buflen;
                map->dm_nsegs = seg + 1;
+               map->_dm_window = t;
        } else if (t->_next_window != NULL) {
                /*
                 * Give the next window a chance.
@@ -296,6 +298,7 @@
        if (error == 0) {
                map->dm_mapsize = m0->m_pkthdr.len;
                map->dm_nsegs = seg + 1;
+               map->_dm_window = t;
        } else if (t->_next_window != NULL) {
                /*
                 * Give the next window a chance.
@@ -357,6 +360,7 @@
        if (error == 0) {
                map->dm_mapsize = uio->uio_resid;
                map->dm_nsegs = seg + 1;
+               map->_dm_window = t;
        } else if (t->_next_window != NULL) {
                /*
                 * Give the next window a chance.
@@ -391,6 +395,7 @@
         */
        map->dm_mapsize = 0;
        map->dm_nsegs = 0;
+       map->_dm_window = NULL;
 }
 
 /*
diff -r 39180f047139 -r 882f07cf617b sys/arch/alpha/common/sgmap_typedep.c
--- a/sys/arch/alpha/common/sgmap_typedep.c     Fri Apr 26 03:58:41 2002 +0000
+++ b/sys/arch/alpha/common/sgmap_typedep.c     Fri Apr 26 04:15:18 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.22 2001/07/19 18:20:20 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.23 2002/04/26 04:15:18 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-__KERNEL_RCSID(0, "$NetBSD: sgmap_typedep.c,v 1.22 2001/07/19 18:20:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgmap_typedep.c,v 1.23 2002/04/26 04:15:18 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -231,6 +231,7 @@
        if (error == 0) {
                map->dm_mapsize = buflen;
                map->dm_nsegs = 1;
+               map->_dm_window = t;
        } else {
                map->_dm_flags &= ~(BUS_DMA_READ|BUS_DMA_WRITE);
                if (t->_next_window != NULL) {
@@ -284,6 +285,7 @@
        if (error == 0) {
                map->dm_mapsize = m0->m_pkthdr.len;
                map->dm_nsegs = seg;
+               map->_dm_window = t;
        } else {
                /* Need to back out what we've done so far. */
                map->dm_nsegs = seg - 1;
@@ -359,6 +361,7 @@
        if (error == 0) {
                map->dm_mapsize = uio->uio_resid;
                map->dm_nsegs = seg;
+               map->_dm_window = t;
        } else {
                /* Need to back out what we've done so far. */
                map->dm_nsegs = seg - 1;
@@ -441,4 +444,5 @@
        /* Mark the mapping invalid. */
        map->dm_mapsize = 0;
        map->dm_nsegs = 0;
+       map->_dm_window = NULL;
 }
diff -r 39180f047139 -r 882f07cf617b sys/arch/alpha/include/bus.h
--- a/sys/arch/alpha/include/bus.h      Fri Apr 26 03:58:41 2002 +0000
+++ b/sys/arch/alpha/include/bus.h      Fri Apr 26 04:15:18 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus.h,v 1.46 2001/09/04 05:31:27 thorpej Exp $ */
+/* $NetBSD: bus.h,v 1.47 2002/04/26 04:15:19 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -669,9 +669,11 @@
 #define        bus_dmamap_load_raw(t, m, sg, n, s, f)                  \
        (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
 #define        bus_dmamap_unload(t, p)                                 \
-       (*(t)->_dmamap_unload)((t), (p))
+       (void)(t),                                              \
+       (*(p)->_dm_window->_dmamap_unload)((p)->_dm_window, (p))
 #define        bus_dmamap_sync(t, p, o, l, ops)                        \
-       (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops))
+       (void)(t),                                              \
+       (*(p)->_dm_window->_dmamap_sync)((p)->_dm_window, (p), (o), (l), (ops))
 #define        bus_dmamem_alloc(t, s, a, b, sg, n, r, f)               \
        (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
 #define        bus_dmamem_free(t, sg, n)                               \
@@ -704,6 +706,11 @@
        void            *_dm_cookie;
 
        /*
+        * The DMA window that we ended up being mapped in.
+        */
+       bus_dma_tag_t   _dm_window;
+
+       /*
         * PUBLIC MEMBERS: these are used by machine-independent code.
         */
        bus_size_t      dm_mapsize;     /* size of the mapping */
diff -r 39180f047139 -r 882f07cf617b sys/arch/alpha/isa/isadma_bounce.c
--- a/sys/arch/alpha/isa/isadma_bounce.c        Fri Apr 26 03:58:41 2002 +0000
+++ b/sys/arch/alpha/isa/isadma_bounce.c        Fri Apr 26 04:15:18 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isadma_bounce.c,v 1.3 2000/06/29 09:02:57 mrg Exp $ */
+/* $NetBSD: isadma_bounce.c,v 1.4 2002/04/26 04:15:19 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.3 2000/06/29 09:02:57 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isadma_bounce.c,v 1.4 2002/04/26 04:15:19 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -265,6 +265,7 @@
 
        /* ...so isadma_bounce_dmamap_sync() knows we're bouncing */
        cookie->id_flags |= ID_IS_BOUNCING;
+       map->_dm_window = t;
        return (0);
 }
 
@@ -336,6 +337,7 @@
 
        /* ...so isadma_bounce_dmamap_sync() knows we're bouncing */
        cookie->id_flags |= ID_IS_BOUNCING;
+       map->_dm_window = t;
        return (0);
 }
 



Home | Main Index | Thread Index | Old Index