diff options
author | Vladislav Zolotarov <vladz@broadcom.com> | 2011-08-02 04:35:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-08-02 04:35:43 -0400 |
commit | 87b7ba3d24a25cf18aece447de27d7804fa9668c (patch) | |
tree | 3d47489b40ee858ddc093069a8723c2d9a63fcf8 /drivers/net/bnx2x/bnx2x_cmn.c | |
parent | 22019b17821ab3543090827491e465c5816cbcd6 (diff) |
bnx2x: Prevent restarting Tx during bnx2x_nic_unload
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x/bnx2x_cmn.c')
-rw-r--r-- | 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 5b0dba6d4efa..d724a18b5285 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) | |||
1989 | return -EINVAL; | 1989 | return -EINVAL; |
1990 | } | 1990 | } |
1991 | 1991 | ||
1992 | /* | ||
1993 | * It's important to set the bp->state to the value different from | ||
1994 | * BNX2X_STATE_OPEN and only then stop the Tx. Otherwise bnx2x_tx_int() | ||
1995 | * may restart the Tx from the NAPI context (see bnx2x_tx_int()). | ||
1996 | */ | ||
1997 | bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT; | ||
1998 | smp_mb(); | ||
1999 | |||
1992 | /* Stop Tx */ | 2000 | /* Stop Tx */ |
1993 | bnx2x_tx_disable(bp); | 2001 | bnx2x_tx_disable(bp); |
1994 | 2002 | ||
1995 | #ifdef BCM_CNIC | 2003 | #ifdef BCM_CNIC |
1996 | bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD); | 2004 | bnx2x_cnic_notify(bp, CNIC_CTL_STOP_CMD); |
1997 | #endif | 2005 | #endif |
1998 | bp->state = BNX2X_STATE_CLOSING_WAIT4_HALT; | ||
1999 | smp_mb(); | ||
2000 | 2006 | ||
2001 | bp->rx_mode = BNX2X_RX_MODE_NONE; | 2007 | bp->rx_mode = BNX2X_RX_MODE_NONE; |
2002 | 2008 | ||