Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm Make IS_BOUNCING a map flag and use it to simpl...
details: https://anonhg.NetBSD.org/src/rev/3172616e720a
branches: trunk
changeset: 782167:3172616e720a
user: matt <matt%NetBSD.org@localhost>
date: Fri Oct 19 13:46:07 2012 +0000
description:
Make IS_BOUNCING a map flag and use it to simplify code and to avoid calling
the sync routines if (COHERENT|IS_BOUNCING) == COHERENT. (this eeks out a
little bit more performance).
diffstat:
sys/arch/arm/arm32/bus_dma.c | 26 +++++++++++++-------------
sys/arch/arm/include/bus_defs.h | 3 ++-
sys/arch/arm/include/bus_funcs.h | 4 +++-
3 files changed, 18 insertions(+), 15 deletions(-)
diffs (136 lines):
diff -r 1e2ede38618a -r 3172616e720a sys/arch/arm/arm32/bus_dma.c
--- a/sys/arch/arm/arm32/bus_dma.c Fri Oct 19 12:44:39 2012 +0000
+++ b/sys/arch/arm/arm32/bus_dma.c Fri Oct 19 13:46:07 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.62 2012/10/19 11:57:58 matt Exp $ */
+/* $NetBSD: bus_dma.c,v 1.63 2012/10/19 13:46:07 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#define _ARM32_BUS_DMA_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.62 2012/10/19 11:57:58 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.63 2012/10/19 13:46:07 matt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -270,6 +270,7 @@
map->_dm_buftype = buftype;
/* ...so _bus_dmamap_sync() knows we're bouncing */
+ map->_dm_flags |= _BUS_DMAMAP_IS_BOUNCING;
cookie->id_flags |= _BUS_DMA_IS_BOUNCING;
return 0;
}
@@ -436,6 +437,7 @@
if (cookie->id_flags & _BUS_DMA_IS_BOUNCING) {
STAT_INCR(bounced_unloads);
cookie->id_flags &= ~_BUS_DMA_IS_BOUNCING;
+ map->_dm_flags &= ~_BUS_DMAMAP_IS_BOUNCING;
}
} else
#endif
@@ -502,6 +504,7 @@
if (cookie->id_flags & _BUS_DMA_IS_BOUNCING) {
STAT_INCR(bounced_unloads);
cookie->id_flags &= ~_BUS_DMA_IS_BOUNCING;
+ map->_dm_flags &= ~_BUS_DMAMAP_IS_BOUNCING;
}
} else
#endif
@@ -760,14 +763,11 @@
_bus_dmamap_sync_linear(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
bus_size_t len, int ops)
{
-#ifdef _ARM32_NEED_BUS_DMA_BOUNCE
- struct arm32_bus_dma_cookie * const cookie = map->_dm_cookie;
- bool bouncing = (cookie != NULL && (cookie->id_flags & _BUS_DMA_IS_BOUNCING));
-#endif
bus_dma_segment_t *ds = map->dm_segs;
vaddr_t va = (vaddr_t) map->_dm_origbuf;
#ifdef _ARM32_NEED_BUS_DMA_BOUNCE
- if (bouncing) {
+ if (map->_dm_flags & _BUS_DMAMAP_IS_BOUNCING) {
+ struct arm32_bus_dma_cookie * const cookie = map->_dm_cookie;
va = (vaddr_t) cookie->id_bouncebuf;
}
#endif
@@ -902,8 +902,6 @@
_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
bus_size_t len, int ops)
{
- bool bouncing = false;
-
#ifdef DEBUG_DMA
printf("dmamap_sync: t=%p map=%p offset=%lx len=%lx ops=%x\n",
t, map, offset, len, ops);
@@ -940,8 +938,9 @@
* POSTWRITE -- Nothing.
*/
#ifdef _ARM32_NEED_BUS_DMA_BOUNCE
- struct arm32_bus_dma_cookie * const cookie = map->_dm_cookie;
- bouncing = (cookie != NULL && (cookie->id_flags & _BUS_DMA_IS_BOUNCING));
+ const bool bouncing = (map->_dm_flags & _BUS_DMA_IS_BOUNCING);
+#else
+ const bool bouncing = false;
#endif
const int pre_ops = ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
@@ -951,6 +950,7 @@
#ifdef _ARM32_NEED_BUS_DMA_BOUNCE
if (bouncing && (ops & BUS_DMASYNC_PREWRITE)) {
+ struct arm32_bus_dma_cookie * const cookie = map->_dm_cookie;
STAT_INCR(write_bounces);
char * const dataptr = (char *)cookie->id_bouncebuf + offset;
/*
@@ -1045,10 +1045,10 @@
#ifdef _ARM32_NEED_BUS_DMA_BOUNCE
bounce_it:
if ((ops & BUS_DMASYNC_POSTREAD) == 0
- || cookie == NULL
- || (cookie->id_flags & _BUS_DMA_IS_BOUNCING) == 0)
+ || (map->_dm_flags & _BUS_DMAMAP_IS_BOUNCING) == 0)
return;
+ struct arm32_bus_dma_cookie * const cookie = map->_dm_cookie;
char * const dataptr = (char *)cookie->id_bouncebuf + offset;
STAT_INCR(read_bounces);
/*
diff -r 1e2ede38618a -r 3172616e720a sys/arch/arm/include/bus_defs.h
--- a/sys/arch/arm/include/bus_defs.h Fri Oct 19 12:44:39 2012 +0000
+++ b/sys/arch/arm/include/bus_defs.h Fri Oct 19 13:46:07 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_defs.h,v 1.3 2012/10/17 20:17:18 matt Exp $ */
+/* $NetBSD: bus_defs.h,v 1.4 2012/10/19 13:46:07 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -300,6 +300,7 @@
* Private flags stored in the DMA map.
*/
#define _BUS_DMAMAP_COHERENT 0x10000 /* no cache flush necessary on sync */
+#define _BUS_DMAMAP_IS_BOUNCING 0x20000 /* is bouncing current xfer */
/* Forwards needed by prototypes below. */
struct mbuf;
diff -r 1e2ede38618a -r 3172616e720a sys/arch/arm/include/bus_funcs.h
--- a/sys/arch/arm/include/bus_funcs.h Fri Oct 19 12:44:39 2012 +0000
+++ b/sys/arch/arm/include/bus_funcs.h Fri Oct 19 13:46:07 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_funcs.h,v 1.3 2012/09/18 05:47:27 matt Exp $ */
+/* $NetBSD: bus_funcs.h,v 1.4 2012/10/19 13:46:07 matt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -587,6 +587,8 @@
(*(t)->_dmamap_unload)((t), (p))
#define bus_dmamap_sync(t, p, o, l, ops) \
do { \
+ if (((p)->_dm_flags & (_BUS_DMAMAP_COHERENT|_BUS_DMAMAP_IS_BOUNCING)) == _BUS_DMAMAP_COHERENT) \
+ break; \
if (((ops) & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0 \
&& (t)->_dmamap_sync_pre != NULL) \
(*(t)->_dmamap_sync_pre)((t), (p), (o), (l), (ops)); \
Home |
Main Index |
Thread Index |
Old Index