netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bnx2x: Prevent restarting Tx during bnx2x_nic_unload
@ 2011-08-02  7:52 Vlad Zolotarov
  2011-08-02  8:35 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Vlad Zolotarov @ 2011-08-02  7:52 UTC (permalink / raw)
  To: Dave Miller; +Cc: netdev@vger.kernel.org, Eilon Greenstein

Tx queues were stopped before  bp->state was changed to a value different 
from BNX2X_STATE_OPEN, which allowed the bnx2x_tx_int() called from the 
NAPI context to re-enable it. This then allowed the netdev->ndo_start_xmit() 
to be called in the middle of the function reset and rings freeing. 

This patch changes bp->state to a value different 
from BNX2X_STATE_OPEN BEFORE disabling the Tx queues in order to restore the
broken protection against the above race in the bnx2x_tx_int().

Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
---
 drivers/net/bnx2x/bnx2x_cmn.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnx2x/bnx2x_cmn.c b/drivers/net/bnx2x/bnx2x_cmn.c
index 5b0dba6..d724a18 100644
--- a/drivers/net/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/bnx2x/bnx2x_cmn.c
@@ -1989,14 +1989,20 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode)
 		return -EINVAL;
 	}
 
+	/*
+	 * It's important to set the bp->state to the value different from
+	 * BNX2X_STATE_OPEN and only then stop the Tx. Otherwise bnx2x_tx_int()
+	 * may restart the Tx from the NAPI context (see bnx2x_tx_int()).
+	 */
+	bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT;
+	smp_mb();
+
 	/* Stop Tx */
 	bnx2x_tx_disable(bp);
 
 #ifdef BCM_CNIC
 	bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD);
 #endif
-	bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT;
-	smp_mb();
 
 	bp->rx_mode = BNX2X_RX_MODE_NONE;
 
-- 
1.7.4.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] bnx2x: Prevent restarting Tx during bnx2x_nic_unload
  2011-08-02  7:52 [PATCH net] bnx2x: Prevent restarting Tx during bnx2x_nic_unload Vlad Zolotarov
@ 2011-08-02  8:35 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-08-02  8:35 UTC (permalink / raw)
  To: vladz; +Cc: netdev, eilong

From: "Vlad Zolotarov" <vladz@broadcom.com>
Date: Tue, 2 Aug 2011 10:52:37 +0300

> Tx queues were stopped before  bp->state was changed to a value different 
> from BNX2X_STATE_OPEN, which allowed the bnx2x_tx_int() called from the 
> NAPI context to re-enable it. This then allowed the netdev->ndo_start_xmit() 
> to be called in the middle of the function reset and rings freeing. 
> 
> This patch changes bp->state to a value different 
> from BNX2X_STATE_OPEN BEFORE disabling the Tx queues in order to restore the
> broken protection against the above race in the bnx2x_tx_int().
> 
> Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
> Signed-off-by: Eilon Greenstein <eilong@broadcom.com>

Applied, thansk Vlad.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-02  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-02  7:52 [PATCH net] bnx2x: Prevent restarting Tx during bnx2x_nic_unload Vlad Zolotarov
2011-08-02  8:35 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).