Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Mar 2010 18:18:04 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r205090 - head/sys/dev/bge
Message-ID:  <201003121818.o2CII4ri076014@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Fri Mar 12 18:18:04 2010
New Revision: 205090
URL: http://svn.freebsd.org/changeset/base/205090

Log:
  Reorder interrupt handler a bit such that producer/consumer
  index of status block is read first before acknowledging the
  interrupts. Otherwise bge(4) may get stale status block as
  acknowledging an interrupt may yield another status block update.
  
  Reviewed by:	marius

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c	Fri Mar 12 17:55:29 2010	(r205089)
+++ head/sys/dev/bge/if_bge.c	Fri Mar 12 18:18:04 2010	(r205090)
@@ -3654,6 +3654,22 @@ bge_intr(void *xsc)
 #endif
 
 	/*
+	 * Do the mandatory PCI flush as well as get the link status.
+	 */
+	statusword = CSR_READ_4(sc, BGE_MAC_STS) & BGE_MACSTAT_LINK_CHANGED;
+
+	/* Make sure the descriptor ring indexes are coherent. */
+	bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
+	    sc->bge_cdata.bge_status_map,
+	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
+	rx_prod = sc->bge_ldata.bge_status_block->bge_idx[0].bge_rx_prod_idx;
+	tx_cons = sc->bge_ldata.bge_status_block->bge_idx[0].bge_tx_cons_idx;
+	sc->bge_ldata.bge_status_block->bge_status = 0;
+	bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
+	    sc->bge_cdata.bge_status_map,
+	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+
+	/*
 	 * Ack the interrupt by writing something to BGE_MBX_IRQ0_LO.  Don't
 	 * disable interrupts by writing nonzero like we used to, since with
 	 * our current organization this just gives complications and
@@ -3675,22 +3691,6 @@ bge_intr(void *xsc)
 	 */
 	bge_writembx(sc, BGE_MBX_IRQ0_LO, 0);
 
-	/*
-	 * Do the mandatory PCI flush as well as get the link status.
-	 */
-	statusword = CSR_READ_4(sc, BGE_MAC_STS) & BGE_MACSTAT_LINK_CHANGED;
-
-	/* Make sure the descriptor ring indexes are coherent. */
-	bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
-	    sc->bge_cdata.bge_status_map,
-	    BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
-	rx_prod = sc->bge_ldata.bge_status_block->bge_idx[0].bge_rx_prod_idx;
-	tx_cons = sc->bge_ldata.bge_status_block->bge_idx[0].bge_tx_cons_idx;
-	sc->bge_ldata.bge_status_block->bge_status = 0;
-	bus_dmamap_sync(sc->bge_cdata.bge_status_tag,
-	    sc->bge_cdata.bge_status_map,
-	    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
-
 	if ((sc->bge_asicrev == BGE_ASICREV_BCM5700 &&
 	    sc->bge_chipid != BGE_CHIPID_BCM5700_B2) ||
 	    statusword || sc->bge_link_evt)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003121818.o2CII4ri076014>