[Midnightbsd-cvs] src [9785] trunk/sys/dev/bce/if_bce.c: Check for spurious interrupts only when using INTx.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Feb 22 08:34:58 EST 2018


Revision: 9785
          http://svnweb.midnightbsd.org/src/?rev=9785
Author:   laffer1
Date:     2018-02-22 08:34:57 -0500 (Thu, 22 Feb 2018)
Log Message:
-----------
Check for spurious interrupts only when using INTx.

Modified Paths:
--------------
    trunk/sys/dev/bce/if_bce.c

Modified: trunk/sys/dev/bce/if_bce.c
===================================================================
--- trunk/sys/dev/bce/if_bce.c	2018-02-22 13:34:15 UTC (rev 9784)
+++ trunk/sys/dev/bce/if_bce.c	2018-02-22 13:34:57 UTC (rev 9785)
@@ -7873,7 +7873,7 @@
 /* interrupt causes (PHY, TX, RX).                                          */
 /*                                                                          */
 /* Returns:                                                                 */
-/*   0 for success, positive value for failure.                             */
+/*   Nothing.                                                               */
 /****************************************************************************/
 static void
 bce_intr(void *xsc)
@@ -7895,16 +7895,16 @@
 	DBRUN(sc->interrupts_generated++);
 
 	/* Synchnorize before we read from interface's status block */
-	bus_dmamap_sync(sc->status_tag, sc->status_map,
-	    BUS_DMASYNC_POSTREAD);
+	bus_dmamap_sync(sc->status_tag, sc->status_map, BUS_DMASYNC_POSTREAD);
 
 	/*
-	 * If the hardware status block index
-	 * matches the last value read by the
-	 * driver and we haven't asserted our
-	 * interrupt then there's nothing to do.
+	 * If the hardware status block index matches the last value read
+	 * by the driver and we haven't asserted our interrupt then there's
+	 * nothing to do.  This may only happen in case of INTx due to the
+	 * interrupt arriving at the CPU before the status block is updated.
 	 */
-	if ((sc->status_block->status_idx == sc->last_status_idx) &&
+	if ((sc->bce_flags & (BCE_USING_MSI_FLAG | BCE_USING_MSIX_FLAG)) == 0 &&
+	    sc->status_block->status_idx == sc->last_status_idx &&
 	    (REG_RD(sc, BCE_PCICFG_MISC_STATUS) &
 	     BCE_PCICFG_MISC_STATUS_INTA_VALUE)) {
 		DBPRINT(sc, BCE_VERBOSE_INTR, "%s(): Spurious interrupt.\n",
@@ -7992,11 +7992,9 @@
 		if ((hw_rx_cons == sc->hw_rx_cons) &&
 		    (hw_tx_cons == sc->hw_tx_cons))
 			break;
-
 	}
 
-	bus_dmamap_sync(sc->status_tag,	sc->status_map,
-	    BUS_DMASYNC_PREREAD);
+	bus_dmamap_sync(sc->status_tag,	sc->status_map, BUS_DMASYNC_PREREAD);
 
 	/* Re-enable interrupts. */
 	bce_enable_intr(sc, 0);
@@ -8121,6 +8119,8 @@
 
 	ifp = sc->bce_ifp;
 
+	bus_dmamap_sync(sc->stats_tag, sc->stats_map, BUS_DMASYNC_POSTREAD);
+
 	stats = (struct statistics_block *) sc->stats_block;
 
 	/*
@@ -8648,6 +8648,8 @@
 
 		stats = (struct statistics_block *) sc->stats_block;
 		bzero(stats, sizeof(struct statistics_block));
+		bus_dmamap_sync(sc->stats_tag, sc->stats_map,
+		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 		/* Clear the internal H/W statistics counters. */
 		REG_WR(sc, BCE_HC_COMMAND, BCE_HC_COMMAND_CLR_STAT_NOW);
@@ -10633,6 +10635,8 @@
 {
 	struct status_block *sblk;
 
+	bus_dmamap_sync(sc->status_tag, sc->status_map, BUS_DMASYNC_POSTREAD);
+
 	sblk = sc->status_block;
 
 	BCE_PRINTF(
@@ -10695,6 +10699,8 @@
 {
 	struct statistics_block *sblk;
 
+	bus_dmamap_sync(sc->stats_tag, sc->stats_map, BUS_DMASYNC_POSTREAD);
+
 	sblk = sc->stats_block;
 
 	BCE_PRINTF(



More information about the Midnightbsd-cvs mailing list