Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Use separate function pointers for dmamap_sync pre-...



details:   https://anonhg.NetBSD.org/src/rev/fdedc85dcf98
branches:  trunk
changeset: 535409:fdedc85dcf98
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Aug 17 20:46:26 2002 +0000

description:
Use separate function pointers for dmamap_sync pre- vs post- operations.
Change the bus_dmamap_sync() macro to test the ops argument against pre-
and post- constants.  The compiler will optimize out dead code because
of the constants.  Since post- operations are not needed on ARM (except
for ISA bounce buffers), this eliminate a large number of function calls
which are noops, each of which cost at least 6 cycles just in the call
and return overhead (not to mention whatever other useless work the
compiler decides to do in the callee).

diffstat:

 sys/arch/arm/footbridge/footbridge_pci.c     |   5 +++--
 sys/arch/arm/footbridge/isa/isadma_machdep.c |   5 +++--
 sys/arch/arm/include/bus.h                   |  16 ++++++++++++----
 sys/arch/arm/ixp12x0/ixp12x0_pci_dma.c       |   6 +++---
 sys/arch/arm/xscale/i80312.c                 |   5 +++--
 sys/arch/arm/xscale/i80321.c                 |   8 +++++---
 sys/arch/evbarm/ifpga/ifpga_pci.c            |   5 +++--
 sys/arch/evbarm/integrator/int_bus_dma.c     |   5 +++--
 sys/arch/shark/isa/isadma_machdep.c          |   5 +++--
 9 files changed, 38 insertions(+), 22 deletions(-)

diffs (200 lines):

diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/arm/footbridge/footbridge_pci.c
--- a/sys/arch/arm/footbridge/footbridge_pci.c  Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/arm/footbridge/footbridge_pci.c  Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: footbridge_pci.c,v 1.4 2001/09/05 16:17:35 matt Exp $  */
+/*     $NetBSD: footbridge_pci.c,v 1.5 2002/08/17 20:46:26 thorpej Exp $       */
 
 /*
  * Copyright (c) 1997,1998 Mark Brinicombe.
@@ -111,7 +111,8 @@
        _bus_dmamap_load_uio,
        _bus_dmamap_load_raw,
        _bus_dmamap_unload,
-       _bus_dmamap_sync,
+       _bus_dmamap_sync,       /* pre */
+       NULL,                   /* post */
        _bus_dmamem_alloc,
        _bus_dmamem_free,
        _bus_dmamem_map,
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/arm/footbridge/isa/isadma_machdep.c
--- a/sys/arch/arm/footbridge/isa/isadma_machdep.c      Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/arm/footbridge/isa/isadma_machdep.c      Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isadma_machdep.c,v 1.2 2002/07/31 17:34:24 thorpej Exp $       */
+/*     $NetBSD: isadma_machdep.c,v 1.3 2002/08/17 20:46:26 thorpej Exp $       */
 
 #define ISA_DMA_STATS
 
@@ -106,7 +106,8 @@
        _isa_bus_dmamap_load_uio,
        _isa_bus_dmamap_load_raw,
        _isa_bus_dmamap_unload,
-       _isa_bus_dmamap_sync,
+       _isa_bus_dmamap_sync,           /* pre */
+       _isa_bus_dmamap_sync,           /* post */
        _isa_bus_dmamem_alloc,
        _bus_dmamem_free,
        _bus_dmamem_map,
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/arm/include/bus.h
--- a/sys/arch/arm/include/bus.h        Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/arm/include/bus.h        Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.7 2002/08/14 20:50:37 thorpej Exp $  */
+/*     $NetBSD: bus.h,v 1.8 2002/08/17 20:46:27 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -712,7 +712,9 @@
        int     (*_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t,
                    bus_dma_segment_t *, int, bus_size_t, int));
        void    (*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
-       void    (*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
+       void    (*_dmamap_sync_pre) __P((bus_dma_tag_t, bus_dmamap_t,
+                   bus_addr_t, bus_size_t, int));
+       void    (*_dmamap_sync_post) __P((bus_dma_tag_t, bus_dmamap_t,
                    bus_addr_t, bus_size_t, int));
 
        /*
@@ -744,8 +746,14 @@
 #define        bus_dmamap_unload(t, p)                                 \
        (*(t)->_dmamap_unload)((t), (p))
 #define        bus_dmamap_sync(t, p, o, l, ops)                        \
-       (void)((t)->_dmamap_sync ?                              \
-           (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0)
+do {                                                                   \
+       if (((ops) & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0   \
+           && (t)->_dmamap_sync_pre != NULL)                           \
+               (*(t)->_dmamap_sync_pre)((t), (p), (o), (l), (ops));    \
+       else if (((ops) & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) != 0 \
+                && (t)->_dmamap_sync_post != NULL)                          \
+               (*(t)->_dmamap_sync_post)((t), (p), (o), (l), (ops));        \
+} while (/*CONSTCOND*/0)
 
 #define        bus_dmamem_alloc(t, s, a, b, sg, n, r, f)               \
        (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/arm/ixp12x0/ixp12x0_pci_dma.c
--- a/sys/arch/arm/ixp12x0/ixp12x0_pci_dma.c    Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/arm/ixp12x0/ixp12x0_pci_dma.c    Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ixp12x0_pci_dma.c,v 1.2 2002/07/31 17:34:24 thorpej Exp $ */
+/*     $NetBSD: ixp12x0_pci_dma.c,v 1.3 2002/08/17 20:46:27 thorpej Exp $ */
 /*
  * Copyright (c) 2002
  *     Ichiro FUKUHARA <ichiro%ichiro.org@localhost>.
@@ -56,8 +56,8 @@
        dmat->_dmamap_load_uio = _bus_dmamap_load_uio;
        dmat->_dmamap_load_raw = _bus_dmamap_load_raw;
        dmat->_dmamap_unload = _bus_dmamap_unload;
-       dmat->_dmamap_sync = _bus_dmamap_sync;
-
+       dmat->_dmamap_sync_pre = _bus_dmamap_sync;
+       dmat->_dmamap_sync_post = NULL;
        dmat->_dmamem_alloc = _bus_dmamem_alloc;
        dmat->_dmamem_free = _bus_dmamem_free;
        dmat->_dmamem_map = _bus_dmamem_map;
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/arm/xscale/i80312.c
--- a/sys/arch/arm/xscale/i80312.c      Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/arm/xscale/i80312.c      Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i80312.c,v 1.10 2002/08/01 19:55:03 thorpej Exp $      */
+/*     $NetBSD: i80312.c,v 1.11 2002/08/17 20:46:27 thorpej Exp $      */
 
 /*
  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
@@ -331,7 +331,8 @@
        dmat->_dmamap_load_uio = _bus_dmamap_load_uio;
        dmat->_dmamap_load_raw = _bus_dmamap_load_raw;
        dmat->_dmamap_unload = _bus_dmamap_unload;
-       dmat->_dmamap_sync = _bus_dmamap_sync;
+       dmat->_dmamap_sync_pre = _bus_dmamap_sync;
+       dmat->_dmamap_sync_post = NULL;
 
        dmat->_dmamem_alloc = _bus_dmamem_alloc;
        dmat->_dmamem_free = _bus_dmamem_free;
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/arm/xscale/i80321.c
--- a/sys/arch/arm/xscale/i80321.c      Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/arm/xscale/i80321.c      Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i80321.c,v 1.6 2002/08/01 19:40:08 thorpej Exp $       */
+/*     $NetBSD: i80321.c,v 1.7 2002/08/17 20:46:28 thorpej Exp $       */
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -303,7 +303,8 @@
        dmat->_dmamap_load_uio = _bus_dmamap_load_uio;
        dmat->_dmamap_load_raw = _bus_dmamap_load_raw;
        dmat->_dmamap_unload = _bus_dmamap_unload;
-       dmat->_dmamap_sync = _bus_dmamap_sync;
+       dmat->_dmamap_sync_pre = _bus_dmamap_sync;
+       dmat->_dmamap_sync_post = NULL;
 
        dmat->_dmamem_alloc = _bus_dmamem_alloc;
        dmat->_dmamem_free = _bus_dmamem_free;
@@ -332,7 +333,8 @@
        dmat->_dmamap_load_uio = _bus_dmamap_load_uio;
        dmat->_dmamap_load_raw = _bus_dmamap_load_raw;
        dmat->_dmamap_unload = _bus_dmamap_unload;
-       dmat->_dmamap_sync = _bus_dmamap_sync;
+       dmat->_dmamap_sync_pre = _bus_dmamap_sync;
+       dmat->_dmamap_sync_post = NULL;
 
        dmat->_dmamem_alloc = _bus_dmamem_alloc;
        dmat->_dmamem_free = _bus_dmamem_free;
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/evbarm/ifpga/ifpga_pci.c
--- a/sys/arch/evbarm/ifpga/ifpga_pci.c Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/evbarm/ifpga/ifpga_pci.c Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ifpga_pci.c,v 1.3 2002/07/31 17:34:26 thorpej Exp $    */
+/*     $NetBSD: ifpga_pci.c,v 1.4 2002/08/17 20:46:28 thorpej Exp $    */
 
 /*
  * Copyright (c) 2001 ARM Ltd
@@ -127,7 +127,8 @@
        _bus_dmamap_load_uio,
        _bus_dmamap_load_raw,
        _bus_dmamap_unload,
-       _bus_dmamap_sync,
+       _bus_dmamap_sync,       /* pre */
+       NULL,                   /* post */
        _bus_dmamem_alloc,
        _bus_dmamem_free,
        _bus_dmamem_map,
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/evbarm/integrator/int_bus_dma.c
--- a/sys/arch/evbarm/integrator/int_bus_dma.c  Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/evbarm/integrator/int_bus_dma.c  Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: int_bus_dma.c,v 1.10 2002/07/31 17:34:26 thorpej Exp $ */
+/*     $NetBSD: int_bus_dma.c,v 1.11 2002/08/17 20:46:28 thorpej Exp $ */
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -72,7 +72,8 @@
        dmat->_dmamap_load_uio = _bus_dmamap_load_uio;
        dmat->_dmamap_load_raw = _bus_dmamap_load_raw;
        dmat->_dmamap_unload = _bus_dmamap_unload;
-       dmat->_dmamap_sync = _bus_dmamap_sync;
+       dmat->_dmamap_sync_pre = _bus_dmamap_sync;
+       dmat->_dmamap_sync_post = NULL;
 
        dmat->_dmamem_alloc = _bus_dmamem_alloc;
        dmat->_dmamem_free = _bus_dmamem_free;
diff -r 2f99e67cd371 -r fdedc85dcf98 sys/arch/shark/isa/isadma_machdep.c
--- a/sys/arch/shark/isa/isadma_machdep.c       Sat Aug 17 19:54:30 2002 +0000
+++ b/sys/arch/shark/isa/isadma_machdep.c       Sat Aug 17 20:46:26 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isadma_machdep.c,v 1.2 2002/07/31 17:34:26 thorpej Exp $       */
+/*     $NetBSD: isadma_machdep.c,v 1.3 2002/08/17 20:46:29 thorpej Exp $       */
 
 #define ISA_DMA_STATS
 
@@ -105,7 +105,8 @@
        _isa_bus_dmamap_load_uio,
        _isa_bus_dmamap_load_raw,
        _isa_bus_dmamap_unload,
-       _isa_bus_dmamap_sync,
+       _isa_bus_dmamap_sync,           /* pre */
+       _isa_bus_dmamap_sync,           /* post */
        _isa_bus_dmamem_alloc,
        _bus_dmamem_free,
        _bus_dmamem_map,



Home | Main Index | Thread Index | Old Index