aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2x/bnx2x_main.c
diff options
context:
space:
mode:
authorDmitry Kravkov <dmitry@broadcom.com>2010-10-05 23:27:41 -0400
committerDavid S. Miller <davem@davemloft.net>2010-10-06 17:10:37 -0400
commit8fe23fbd94af5a4c117fd0eb2f1c3f492f79efe8 (patch)
tree211c6742d3719304eda84ecea6e9441979146298 /drivers/net/bnx2x/bnx2x_main.c
parentfb3bff178e722fe88b5ab02319c9636da0980e25 (diff)
bnx2x: change type of spq_left to atomic
The field is now accessed from different contexts. 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>
Diffstat (limited to 'drivers/net/bnx2x/bnx2x_main.c')
-rw-r--r--drivers/net/bnx2x/bnx2x_main.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/net/bnx2x/bnx2x_main.c b/drivers/net/bnx2x/bnx2x_main.c
index 238e38f051f..2c04b97f85a 100644
--- a/drivers/net/bnx2x/bnx2x_main.c
+++ b/drivers/net/bnx2x/bnx2x_main.c
@@ -1161,8 +1161,8 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp,
1161 break; 1161 break;
1162 } 1162 }
1163 1163
1164 bp->spq_left++; 1164 smp_mb__before_atomic_inc();
1165 1165 atomic_inc(&bp->spq_left);
1166 /* push the change in fp->state and towards the memory */ 1166 /* push the change in fp->state and towards the memory */
1167 smp_wmb(); 1167 smp_wmb();
1168 1168
@@ -2432,7 +2432,7 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
2432 2432
2433 spin_lock_bh(&bp->spq_lock); 2433 spin_lock_bh(&bp->spq_lock);
2434 2434
2435 if (!bp->spq_left) { 2435 if (!atomic_read(&bp->spq_left)) {
2436 BNX2X_ERR("BUG! SPQ ring full!\n"); 2436 BNX2X_ERR("BUG! SPQ ring full!\n");
2437 spin_unlock_bh(&bp->spq_lock); 2437 spin_unlock_bh(&bp->spq_lock);
2438 bnx2x_panic(); 2438 bnx2x_panic();
@@ -2472,7 +2472,7 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
2472 * somewhere between the spin_lock and spin_unlock. Thus no 2472 * somewhere between the spin_lock and spin_unlock. Thus no
2473 * more explict memory barrier is needed. 2473 * more explict memory barrier is needed.
2474 */ 2474 */
2475 bp->spq_left--; 2475 atomic_dec(&bp->spq_left);
2476 2476
2477 DP(BNX2X_MSG_SP/*NETIF_MSG_TIMER*/, 2477 DP(BNX2X_MSG_SP/*NETIF_MSG_TIMER*/,
2478 "SPQE[%x] (%x:%x) command %d hw_cid %x data (%x:%x) " 2478 "SPQE[%x] (%x:%x) command %d hw_cid %x data (%x:%x) "
@@ -2480,7 +2480,7 @@ int bnx2x_sp_post(struct bnx2x *bp, int command, int cid,
2480 bp->spq_prod_idx, (u32)U64_HI(bp->spq_mapping), 2480 bp->spq_prod_idx, (u32)U64_HI(bp->spq_mapping),
2481 (u32)(U64_LO(bp->spq_mapping) + 2481 (u32)(U64_LO(bp->spq_mapping) +
2482 (void *)bp->spq_prod_bd - (void *)bp->spq), command, 2482 (void *)bp->spq_prod_bd - (void *)bp->spq), command,
2483 HW_CID(bp, cid), data_hi, data_lo, type, bp->spq_left); 2483 HW_CID(bp, cid), data_hi, data_lo, type, atomic_read(&bp->spq_left));
2484 2484
2485 bnx2x_sp_prod_update(bp); 2485 bnx2x_sp_prod_update(bp);
2486 spin_unlock_bh(&bp->spq_lock); 2486 spin_unlock_bh(&bp->spq_lock);
@@ -3290,7 +3290,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
3290 sw_prod = bp->eq_prod; 3290 sw_prod = bp->eq_prod;
3291 3291
3292 DP(BNX2X_MSG_SP, "EQ: hw_cons %u sw_cons %u bp->spq_left %u\n", 3292 DP(BNX2X_MSG_SP, "EQ: hw_cons %u sw_cons %u bp->spq_left %u\n",
3293 hw_cons, sw_cons, bp->spq_left); 3293 hw_cons, sw_cons, atomic_read(&bp->spq_left));
3294 3294
3295 for (; sw_cons != hw_cons; 3295 for (; sw_cons != hw_cons;
3296 sw_prod = NEXT_EQ_IDX(sw_prod), sw_cons = NEXT_EQ_IDX(sw_cons)) { 3296 sw_prod = NEXT_EQ_IDX(sw_prod), sw_cons = NEXT_EQ_IDX(sw_cons)) {
@@ -3360,7 +3360,8 @@ next_spqe:
3360 spqe_cnt++; 3360 spqe_cnt++;
3361 } /* for */ 3361 } /* for */
3362 3362
3363 bp->spq_left++; 3363 smp_mb__before_atomic_inc();
3364 atomic_add(spqe_cnt, &bp->spq_left);
3364 3365
3365 bp->eq_cons = sw_cons; 3366 bp->eq_cons = sw_cons;
3366 bp->eq_prod = sw_prod; 3367 bp->eq_prod = sw_prod;
@@ -3737,8 +3738,8 @@ void bnx2x_update_coalesce(struct bnx2x *bp)
3737static void bnx2x_init_sp_ring(struct bnx2x *bp) 3738static void bnx2x_init_sp_ring(struct bnx2x *bp)
3738{ 3739{
3739 spin_lock_init(&bp->spq_lock); 3740 spin_lock_init(&bp->spq_lock);
3741 atomic_set(&bp->spq_left, MAX_SPQ_PENDING);
3740 3742
3741 bp->spq_left = MAX_SPQ_PENDING;
3742 bp->spq_prod_idx = 0; 3743 bp->spq_prod_idx = 0;
3743 bp->dsb_sp_prod = BNX2X_SP_DSB_INDEX; 3744 bp->dsb_sp_prod = BNX2X_SP_DSB_INDEX;
3744 bp->spq_prod_bd = bp->spq; 3745 bp->spq_prod_bd = bp->spq;