Skip to content

Commit c650e04

Browse files
Ganji Aravinddavem330
authored andcommitted
cxgb4: Fix race between loopback and normal Tx path
Even after Tx queues are marked stopped, there exists a small window where the current packet in the normal Tx path is still being sent out and loopback selftest ends up corrupting the same Tx ring. So, ensure selftest takes the Tx lock to synchronize access the Tx ring. Fixes: 7235ffa ("cxgb4: add loopback ethtool self-test") Signed-off-by: Ganji Aravind <[email protected]> Reviewed-by: Jesse Brandeburg <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3359564 commit c650e04

File tree

1 file changed

+5
-1
lines changed
  • drivers/net/ethernet/chelsio/cxgb4

1 file changed

+5
-1
lines changed

drivers/net/ethernet/chelsio/cxgb4/sge.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2561,11 +2561,14 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev)
25612561
lb->loopback = 1;
25622562

25632563
q = &adap->sge.ethtxq[pi->first_qset];
2564+
__netif_tx_lock(q->txq, smp_processor_id());
25642565

25652566
reclaim_completed_tx(adap, &q->q, -1, true);
25662567
credits = txq_avail(&q->q) - ndesc;
2567-
if (unlikely(credits < 0))
2568+
if (unlikely(credits < 0)) {
2569+
__netif_tx_unlock(q->txq);
25682570
return -ENOMEM;
2571+
}
25692572

25702573
wr = (void *)&q->q.desc[q->q.pidx];
25712574
memset(wr, 0, sizeof(struct tx_desc));
@@ -2598,6 +2601,7 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev)
25982601
init_completion(&lb->completion);
25992602
txq_advance(&q->q, ndesc);
26002603
cxgb4_ring_tx_db(adap, &q->q, ndesc);
2604+
__netif_tx_unlock(q->txq);
26012605

26022606
/* wait for the pkt to return */
26032607
ret = wait_for_completion_timeout(&lb->completion, 10 * HZ);

0 commit comments

Comments
 (0)