summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2006-05-12 20:48:20 +0000
committerBrad Smith <brad@cvs.openbsd.org>2006-05-12 20:48:20 +0000
commit14386d7e3174d157ac5bf93f4ae751d8c0517992 (patch)
treee6cd66e29b287d3c4eb1f58f05058fb87fa50668
parent3a1a208b741df59910fb9e108226cba78f3ee915 (diff)
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. From NetBSD ok martin@
-rw-r--r--sys/arch/alpha/dev/bus_dma.c7
-rw-r--r--sys/arch/alpha/dev/sgmap_typedep.c5
-rw-r--r--sys/arch/alpha/include/bus.h13
-rw-r--r--sys/arch/alpha/isa/isadma_bounce.c4
4 files changed, 23 insertions, 6 deletions
diff --git a/sys/arch/alpha/dev/bus_dma.c b/sys/arch/alpha/dev/bus_dma.c
index 6a2bf65b4f3..906d9169769 100644
--- a/sys/arch/alpha/dev/bus_dma.c
+++ b/sys/arch/alpha/dev/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.17 2006/04/13 14:41:08 brad Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.18 2006/05/12 20:48:19 brad Exp $ */
/* $NetBSD: bus_dma.c,v 1.40 2000/07/17 04:47:56 thorpej Exp $ */
/*-
@@ -106,6 +106,7 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
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);
@@ -268,6 +269,7 @@ _bus_dmamap_load_direct(t, map, buf, buflen, p, flags)
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.
@@ -319,6 +321,7 @@ _bus_dmamap_load_mbuf_direct(t, map, m0, flags)
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.
@@ -382,6 +385,7 @@ _bus_dmamap_load_uio_direct(t, map, uio, flags)
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.
@@ -423,6 +427,7 @@ _bus_dmamap_unload(t, map)
*/
map->dm_mapsize = 0;
map->dm_nsegs = 0;
+ map->_dm_window = NULL;
}
/*
diff --git a/sys/arch/alpha/dev/sgmap_typedep.c b/sys/arch/alpha/dev/sgmap_typedep.c
index e5164260582..af24d7340a0 100644
--- a/sys/arch/alpha/dev/sgmap_typedep.c
+++ b/sys/arch/alpha/dev/sgmap_typedep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sgmap_typedep.c,v 1.7 2006/04/13 14:41:08 brad Exp $ */
+/* $OpenBSD: sgmap_typedep.c,v 1.8 2006/05/12 20:48:19 brad Exp $ */
/* $NetBSD: sgmap_typedep.c,v 1.17 2001/07/19 04:27:37 thorpej Exp $ */
/*-
@@ -216,6 +216,7 @@ __C(SGMAP_TYPE,_load)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
if (error == 0) {
map->dm_mapsize = buflen;
map->dm_nsegs = 1;
+ map->_dm_window = t;
} else if (t->_next_window != NULL) {
/* Give the next window a chance. */
error = bus_dmamap_load(t->_next_window, map, buf, buflen,
@@ -265,6 +266,7 @@ __C(SGMAP_TYPE,_load_mbuf)(bus_dma_tag_t t, bus_dmamap_t map,
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;
@@ -342,4 +344,5 @@ __C(SGMAP_TYPE,_unload)(bus_dma_tag_t t, bus_dmamap_t map,
/* Mark the mapping invalid. */
map->dm_mapsize = 0;
map->dm_nsegs = 0;
+ map->_dm_window = NULL;
}
diff --git a/sys/arch/alpha/include/bus.h b/sys/arch/alpha/include/bus.h
index e42d3037850..adb8c1421fc 100644
--- a/sys/arch/alpha/include/bus.h
+++ b/sys/arch/alpha/include/bus.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus.h,v 1.23 2006/04/27 15:17:07 mickey Exp $ */
+/* $OpenBSD: bus.h,v 1.24 2006/05/12 20:48:19 brad Exp $ */
/* $NetBSD: bus.h,v 1.10 1996/12/02 22:19:32 cgd Exp $ */
/*
@@ -594,9 +594,11 @@ struct alpha_bus_dma_tag {
#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, a, s, op) \
- (*(t)->_dmamap_sync)((t), (p), (a), (s), (op))
+ (void)(t), \
+ (*(p)->_dm_window->_dmamap_sync)((p)->_dm_window, (p), (a), (s), (op))
#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) \
@@ -629,6 +631,11 @@ struct alpha_bus_dmamap {
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 --git a/sys/arch/alpha/isa/isadma_bounce.c b/sys/arch/alpha/isa/isadma_bounce.c
index e8daf4c18f5..508583cfa6c 100644
--- a/sys/arch/alpha/isa/isadma_bounce.c
+++ b/sys/arch/alpha/isa/isadma_bounce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isadma_bounce.c,v 1.5 2002/06/25 21:33:21 miod Exp $ */
+/* $OpenBSD: isadma_bounce.c,v 1.6 2006/05/12 20:48:19 brad Exp $ */
/* $NetBSD: isadma_bounce.c,v 1.3 2000/06/29 09:02:57 mrg Exp $ */
/*-
@@ -262,6 +262,7 @@ isadma_bounce_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
/* ...so isadma_bounce_dmamap_sync() knows we're bouncing */
cookie->id_flags |= ID_IS_BOUNCING;
+ map->_dm_window = t;
return (0);
}
@@ -333,6 +334,7 @@ isadma_bounce_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map,
/* ...so isadma_bounce_dmamap_sync() knows we're bouncing */
cookie->id_flags |= ID_IS_BOUNCING;
+ map->_dm_window = t;
return (0);
}