aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
index 266b055c2360..69d699f0730a 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c
@@ -1372,19 +1372,23 @@ void bnx2x_stats_handle(struct bnx2x *bp, enum bnx2x_stats_event event)
1372 * that context in case someone is in the middle of a transition. 1372 * that context in case someone is in the middle of a transition.
1373 * For other events, wait a bit until lock is taken. 1373 * For other events, wait a bit until lock is taken.
1374 */ 1374 */
1375 if (!mutex_trylock(&bp->stats_lock)) { 1375 if (down_trylock(&bp->stats_lock)) {
1376 if (event == STATS_EVENT_UPDATE) 1376 if (event == STATS_EVENT_UPDATE)
1377 return; 1377 return;
1378 1378
1379 DP(BNX2X_MSG_STATS, 1379 DP(BNX2X_MSG_STATS,
1380 "Unlikely stats' lock contention [event %d]\n", event); 1380 "Unlikely stats' lock contention [event %d]\n", event);
1381 mutex_lock(&bp->stats_lock); 1381 if (unlikely(down_timeout(&bp->stats_lock, HZ / 10))) {
1382 BNX2X_ERR("Failed to take stats lock [event %d]\n",
1383 event);
1384 return;
1385 }
1382 } 1386 }
1383 1387
1384 bnx2x_stats_stm[state][event].action(bp); 1388 bnx2x_stats_stm[state][event].action(bp);
1385 bp->stats_state = bnx2x_stats_stm[state][event].next_state; 1389 bp->stats_state = bnx2x_stats_stm[state][event].next_state;
1386 1390
1387 mutex_unlock(&bp->stats_lock); 1391 up(&bp->stats_lock);
1388 1392
1389 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp)) 1393 if ((event != STATS_EVENT_UPDATE) || netif_msg_timer(bp))
1390 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n", 1394 DP(BNX2X_MSG_STATS, "state %d -> event %d -> state %d\n",
@@ -1970,7 +1974,11 @@ int bnx2x_stats_safe_exec(struct bnx2x *bp,
1970 /* Wait for statistics to end [while blocking further requests], 1974 /* Wait for statistics to end [while blocking further requests],
1971 * then run supplied function 'safely'. 1975 * then run supplied function 'safely'.
1972 */ 1976 */
1973 mutex_lock(&bp->stats_lock); 1977 rc = down_timeout(&bp->stats_lock, HZ / 10);
1978 if (unlikely(rc)) {
1979 BNX2X_ERR("Failed to take statistics lock for safe execution\n");
1980 goto out_no_lock;
1981 }
1974 1982
1975 bnx2x_stats_comp(bp); 1983 bnx2x_stats_comp(bp);
1976 while (bp->stats_pending && cnt--) 1984 while (bp->stats_pending && cnt--)
@@ -1988,7 +1996,7 @@ out:
1988 /* No need to restart statistics - if they're enabled, the timer 1996 /* No need to restart statistics - if they're enabled, the timer
1989 * will restart the statistics. 1997 * will restart the statistics.
1990 */ 1998 */
1991 mutex_unlock(&bp->stats_lock); 1999 up(&bp->stats_lock);
1992 2000out_no_lock:
1993 return rc; 2001 return rc;
1994} 2002}