Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci bge: Fix bge_ring_map bus_dmamap_sync POST{READ,...



details:   https://anonhg.NetBSD.org/src/rev/9b21a3e43ec5
branches:  trunk
changeset: 368945:9b21a3e43ec5
user:      skrll <skrll%NetBSD.org@localhost>
date:      Sun Aug 14 08:42:33 2022 +0000

description:
bge: Fix bge_ring_map bus_dmamap_sync POST{READ,WRITE} operations.

When the range of ring entries wraps around sync from the start of the
ring to the last entry.

diffstat:

 sys/dev/pci/if_bge.c |  22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diffs (73 lines):

diff -r 3c284d1df820 -r 9b21a3e43ec5 sys/dev/pci/if_bge.c
--- a/sys/dev/pci/if_bge.c      Sun Aug 14 07:49:33 2022 +0000
+++ b/sys/dev/pci/if_bge.c      Sun Aug 14 08:42:33 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bge.c,v 1.373 2022/08/07 08:37:48 skrll Exp $       */
+/*     $NetBSD: if_bge.c,v 1.374 2022/08/14 08:42:33 skrll Exp $       */
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.373 2022/08/07 08:37:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.374 2022/08/14 08:42:33 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -4437,12 +4437,13 @@
                    sizeof(struct bge_rx_bd);
                bus_dmamap_sync(sc->bge_dmatag, sc->bge_ring_map,
                    toff, tlen, BUS_DMASYNC_POSTREAD);
-               tosync = -tosync;
+               tosync = rx_prod;
+               toff = offset;
        }
 
        if (tosync != 0) {
                bus_dmamap_sync(sc->bge_dmatag, sc->bge_ring_map,
-                   offset, tosync * sizeof(struct bge_rx_bd),
+                   toff, tosync * sizeof(struct bge_rx_bd),
                    BUS_DMASYNC_POSTREAD);
        }
 
@@ -4596,9 +4597,10 @@
            sizeof(struct bge_status_block),
            BUS_DMASYNC_POSTREAD);
 
+       const uint16_t hw_cons_idx =
+           sc->bge_rdata->bge_status_block.bge_idx[0].bge_tx_cons_idx;
        offset = offsetof(struct bge_ring_data, bge_tx_ring);
-       tosync = sc->bge_rdata->bge_status_block.bge_idx[0].bge_tx_cons_idx -
-           sc->bge_tx_saved_considx;
+       tosync = hw_cons_idx - sc->bge_tx_saved_considx;
 
        if (tosync != 0)
                rnd_add_uint32(&sc->rnd_source, tosync);
@@ -4610,12 +4612,13 @@
                    sizeof(struct bge_tx_bd);
                bus_dmamap_sync(sc->bge_dmatag, sc->bge_ring_map,
                    toff, tlen, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
-               tosync = -tosync;
+               tosync = hw_cons_idx;
+               toff = offset;
        }
 
        if (tosync != 0) {
                bus_dmamap_sync(sc->bge_dmatag, sc->bge_ring_map,
-                   offset, tosync * sizeof(struct bge_tx_bd),
+                   toff, tosync * sizeof(struct bge_tx_bd),
                    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
        }
 
@@ -4623,8 +4626,7 @@
         * Go through our tx ring and free mbufs for those
         * frames that have been sent.
         */
-       while (sc->bge_tx_saved_considx !=
-           sc->bge_rdata->bge_status_block.bge_idx[0].bge_tx_cons_idx) {
+       while (sc->bge_tx_saved_considx != hw_cons_idx) {
                uint32_t idx = sc->bge_tx_saved_considx;
                cur_tx = &sc->bge_rdata->bge_tx_ring[idx];
                if (cur_tx->bge_flags & BGE_TXBDFLAG_END)



Home | Main Index | Thread Index | Old Index