Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/marvell The bus_dmamap_sync(PREREAD) is unnecessary ...



details:   https://anonhg.NetBSD.org/src/rev/f7063517ff07
branches:  trunk
changeset: 348222:f7063517ff07
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Mon Oct 10 14:23:35 2016 +0000

description:
The bus_dmamap_sync(PREREAD) is unnecessary for sent mbuf.
Moreover bus_dmamap_sync(POSTWRITE), before unload.

diffstat:

 sys/dev/marvell/if_mvxpe.c |  28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diffs (82 lines):

diff -r fd3fe325a502 -r f7063517ff07 sys/dev/marvell/if_mvxpe.c
--- a/sys/dev/marvell/if_mvxpe.c        Mon Oct 10 13:28:24 2016 +0000
+++ b/sys/dev/marvell/if_mvxpe.c        Mon Oct 10 14:23:35 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mvxpe.c,v 1.13 2016/06/10 13:27:14 ozaki-r Exp $    */
+/*     $NetBSD: if_mvxpe.c,v 1.14 2016/10/10 14:23:35 kiyohara Exp $   */
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
  * All rights reserved.
@@ -25,7 +25,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.13 2016/06/10 13:27:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mvxpe.c,v 1.14 2016/10/10 14:23:35 kiyohara Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -1141,6 +1141,7 @@
 {
        struct mvxpe_rx_ring *rx = MVXPE_RX_RING(sc, q);
        struct mvxpe_tx_ring *tx = MVXPE_TX_RING(sc, q);
+       struct mbuf *m;
        int i;
 
        KASSERT_RX_MTX(sc, q);
@@ -1157,11 +1158,15 @@
 
        /* Tx handle */
        for (i = 0; i < MVXPE_TX_RING_CNT; i++) {
-               if (MVXPE_TX_MBUF(sc, q, i) == NULL)
+               m = MVXPE_TX_MBUF(sc, q, i);
+               if (m == NULL)
                        continue;
+               MVXPE_TX_MBUF(sc, q, i) = NULL;
+               bus_dmamap_sync(sc->sc_dmat,
+                   MVXPE_TX_MAP(sc, q, i), 0, m->m_pkthdr.len,
+                   BUS_DMASYNC_POSTWRITE);
                bus_dmamap_unload(sc->sc_dmat, MVXPE_TX_MAP(sc, q, i));
-               m_freem(MVXPE_TX_MBUF(sc, q, i));
-               MVXPE_TX_MBUF(sc, q, i) = NULL;
+               m_freem(m);
        }
        tx->tx_dma = tx->tx_cpu = 0;
                tx->tx_used = 0;
@@ -2141,7 +2146,7 @@
        MVXPE_TX_MBUF(sc, q, tx->tx_cpu) = m;
        bus_dmamap_sync(sc->sc_dmat,
            MVXPE_TX_MAP(sc, q, tx->tx_cpu), 0, m->m_pkthdr.len,
-           BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
+           BUS_DMASYNC_PREWRITE);
 
        /* load to tx descriptors */
        start = tx->tx_cpu;
@@ -2302,6 +2307,7 @@
 {
        struct mvxpe_tx_ring *tx = MVXPE_TX_RING(sc, q);
        struct mvxpe_tx_desc *t;
+       struct mbuf *m;
        uint32_t ptxs, ptxsu, ndesc;
        int i;
 
@@ -2342,12 +2348,16 @@
                        }
                        error = 1;
                }
-               if (MVXPE_TX_MBUF(sc, q, tx->tx_dma) != NULL) {
+               m = MVXPE_TX_MBUF(sc, q, tx->tx_dma);
+               if (m != NULL) {
                        KASSERT((t->command & MVXPE_TX_CMD_F) != 0);
+                       MVXPE_TX_MBUF(sc, q, tx->tx_dma) = NULL;
+                       bus_dmamap_sync(sc->sc_dmat,
+                           MVXPE_TX_MAP(sc, q, tx->tx_dma), 0, m->m_pkthdr.len,
+                           BUS_DMASYNC_POSTWRITE);
                        bus_dmamap_unload(sc->sc_dmat,
                            MVXPE_TX_MAP(sc, q, tx->tx_dma));
-                       m_freem(MVXPE_TX_MBUF(sc, q, tx->tx_dma));
-                       MVXPE_TX_MBUF(sc, q, tx->tx_dma) = NULL;
+                       m_freem(m);
                        sc->sc_tx_pending--;
                }
                else



Home | Main Index | Thread Index | Old Index