Skip to content

Commit d667f78

Browse files
gobenjidavem330
authored andcommitted
bna: Add synchronization for tx ring.
We received two reports of BUG_ON in bnad_txcmpl_process() where hw_consumer_index appeared to be ahead of producer_index. Out of order write/read of these variables could explain these reports. bnad_start_xmit(), as a producer of tx descriptors, has a few memory barriers sprinkled around writes to producer_index and the device's doorbell but they're not paired with anything in bnad_txcmpl_process(), a consumer. Since we are synchronizing with a device, we must use mandatory barriers, not smp_*. Also, I didn't see the purpose of the last smp_mb() in bnad_start_xmit(). Signed-off-by: Benjamin Poirier <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f91d718 commit d667f78

File tree

1 file changed

+2
-2
lines changed
  • drivers/net/ethernet/brocade/bna

1 file changed

+2
-2
lines changed

drivers/net/ethernet/brocade/bna/bnad.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ bnad_txcmpl_process(struct bnad *bnad, struct bna_tcb *tcb)
177177
return 0;
178178

179179
hw_cons = *(tcb->hw_consumer_index);
180+
rmb();
180181
cons = tcb->consumer_index;
181182
q_depth = tcb->q_depth;
182183

@@ -3094,15 +3095,14 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev)
30943095
BNA_QE_INDX_INC(prod, q_depth);
30953096
tcb->producer_index = prod;
30963097

3097-
smp_mb();
3098+
wmb();
30983099

30993100
if (unlikely(!test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags)))
31003101
return NETDEV_TX_OK;
31013102

31023103
skb_tx_timestamp(skb);
31033104

31043105
bna_txq_prod_indx_doorbell(tcb);
3105-
smp_mb();
31063106

31073107
return NETDEV_TX_OK;
31083108
}

0 commit comments

Comments
 (0)