Skip to content

Commit 5680790

Browse files
committed
Merge branch 'cxgb4-Fix-ethtool-selftest-flits-calculation'
Ganji Aravind says: ==================== cxgb4: Fix ethtool selftest flits calculation Patch 1 will fix work request size calculation for loopback selftest. Patch 2 will fix race between loopback selftest and normal Tx handler. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents ab97a28 + c650e04 commit 5680790

File tree

1 file changed

+7
-3
lines changed
  • drivers/net/ethernet/chelsio/cxgb4

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,19 +2553,22 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev)
25532553

25542554
pkt_len = ETH_HLEN + sizeof(CXGB4_SELFTEST_LB_STR);
25552555

2556-
flits = DIV_ROUND_UP(pkt_len + sizeof(struct cpl_tx_pkt) +
2557-
sizeof(*wr), sizeof(__be64));
2556+
flits = DIV_ROUND_UP(pkt_len + sizeof(*cpl) + sizeof(*wr),
2557+
sizeof(__be64));
25582558
ndesc = flits_to_desc(flits);
25592559

25602560
lb = &pi->ethtool_lb;
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)