Module Name:    src
Committed By:   jakllsch
Date:           Thu Jul 16 20:14:18 UTC 2009

Modified Files:
        src/sys/dev/pci: if_bce.c

Log Message:
Correctly bus_dmamap_sync() the transmit descriptors.
Previously the sync could run off the end and not sync
the beginning of the ring.  Logic gleaned from if_nfe.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/pci/if_bce.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/if_bce.c
diff -u src/sys/dev/pci/if_bce.c:1.25 src/sys/dev/pci/if_bce.c:1.26
--- src/sys/dev/pci/if_bce.c:1.25	Wed May  6 09:25:15 2009
+++ src/sys/dev/pci/if_bce.c	Thu Jul 16 20:14:17 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bce.c,v 1.25 2009/05/06 09:25:15 cegger Exp $	 */
+/* $NetBSD: if_bce.c,v 1.26 2009/07/16 20:14:17 jakllsch Exp $	 */
 
 /*
  * Copyright (c) 2003 Clifford Wright. All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.25 2009/05/06 09:25:15 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bce.c,v 1.26 2009/07/16 20:14:17 jakllsch Exp $");
 
 #include "bpfilter.h"
 #include "vlan.h"
@@ -604,10 +604,25 @@
 			txsfree--;
 		}
 		/* sync descriptors being used */
-		bus_dmamap_sync(sc->bce_dmatag, sc->bce_ring_map,
-			  sizeof(struct bce_dma_slot) * txstart + PAGE_SIZE,
-			     sizeof(struct bce_dma_slot) * dmamap->dm_nsegs,
-				BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+		if ( sc->bce_txsnext > txstart ) {
+			bus_dmamap_sync(sc->bce_dmatag, sc->bce_ring_map,
+			    PAGE_SIZE + sizeof(struct bce_dma_slot) * txstart,
+			    sizeof(struct bce_dma_slot) * dmamap->dm_nsegs,
+			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+		} else {
+			bus_dmamap_sync(sc->bce_dmatag, sc->bce_ring_map,
+			    PAGE_SIZE + sizeof(struct bce_dma_slot) * txstart,
+			    sizeof(struct bce_dma_slot) *
+			    (BCE_NTXDESC - txstart),
+			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+			if ( sc->bce_txsnext != 0 ) {
+				bus_dmamap_sync(sc->bce_dmatag,
+				    sc->bce_ring_map, PAGE_SIZE,
+				    sc->bce_txsnext *
+				    sizeof(struct bce_dma_slot),
+				    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+			}
+		}
 
 		/* Give the packet to the chip. */
 		bus_space_write_4(sc->bce_btag, sc->bce_bhandle, BCE_DMA_DPTR,

Reply via email to