Skip to content

Commit 84823ff

Browse files
esbendavem330
authored andcommitted
net: ll_temac: Fix race condition causing TX hang
It is possible that the interrupt handler fires and frees up space in the TX ring in between checking for sufficient TX ring space and stopping the TX queue in temac_start_xmit. If this happens, the queue wake from the interrupt handler will occur before the queue is stopped, causing a lost wakeup and the adapter's transmit hanging. To avoid this, after stopping the queue, check again whether there is sufficient space in the TX ring. If so, wake up the queue again. This is a port of the similar fix in axienet driver, commit 7de4428 ("net: axienet: Fix race condition causing TX hang"). Fixes: 23ecc4b ("net: ll_temac: fix checksum offload logic") Signed-off-by: Esben Haabendal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6132c1d commit 84823ff

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

drivers/net/ethernet/xilinx/ll_temac_main.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,9 @@ static void temac_start_xmit_done(struct net_device *ndev)
788788
stat = be32_to_cpu(cur_p->app0);
789789
}
790790

791+
/* Matches barrier in temac_start_xmit */
792+
smp_mb();
793+
791794
netif_wake_queue(ndev);
792795
}
793796

@@ -830,9 +833,19 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
830833
cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
831834

832835
if (temac_check_tx_bd_space(lp, num_frag + 1)) {
833-
if (!netif_queue_stopped(ndev))
834-
netif_stop_queue(ndev);
835-
return NETDEV_TX_BUSY;
836+
if (netif_queue_stopped(ndev))
837+
return NETDEV_TX_BUSY;
838+
839+
netif_stop_queue(ndev);
840+
841+
/* Matches barrier in temac_start_xmit_done */
842+
smp_mb();
843+
844+
/* Space might have just been freed - check again */
845+
if (temac_check_tx_bd_space(lp, num_frag))
846+
return NETDEV_TX_BUSY;
847+
848+
netif_wake_queue(ndev);
836849
}
837850

838851
cur_p->app0 = 0;

0 commit comments

Comments
 (0)