diff options
author | Dmitry Kravkov <dmitry@broadcom.com> | 2011-11-13 04:34:30 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-13 16:03:56 -0500 |
commit | 4a025f49d3f2f2f39b474af360c81a5587b41657 (patch) | |
tree | 5f9ae3a4eecfd197839dc9ba5ab2c67710a6945f | |
parent | 8304859adc213df9f69a86e06164683f76cd5d49 (diff) | |
download | linux-4a025f49d3f2f2f39b474af360c81a5587b41657.tar.gz linux-4a025f49d3f2f2f39b474af360c81a5587b41657.tar.bz2 linux-4a025f49d3f2f2f39b474af360c81a5587b41657.zip |
bnx2x: prevent race in statistics flow
The race may cause access of registers while MAC hw block is
in reset state. As a result syslog will show error messages.
We can prevent this by using state from local variable.
Signed-off-by: Dmitry Kravkov <dmitry@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c index 02ac6a771bf9..3034f0e31938 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c @@ -1349,12 +1349,14 @@ void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event) enum bnx2x_stats_state state; if (unlikely(bp->panic)) return; - bnx2x_stats_stm[bp->stats_state][event].action(bp); + spin_lock_bh(&bp->stats_lock); state = bp->stats_state; bp->stats_state = bnx2x_stats_stm[state][event].next_state; spin_unlock_bh(&bp->stats_lock); + bnx2x_stats_stm[state][event].action(bp); + if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", state, event, bp->stats_state); |