Commit bf9cf80cab81e ("net: macb: Fix tx/rx malfunction after phy link down and up") initializes queue->tx_head and queue->tx_tail to zero without holding queue->tx_ptr_lock. As established in commit 99537d5c476c ("net: macb: Relocate mog_init_rings() callback from macb_mac_link_up() to macb_open()"), macb_start_xmit() and macb_mac_link_up() can execute concurrently. Consequently, modifying the TX pointers without locking creates a race condition. To resolve this, this patch ensures that the netif tx queues are stopped before the device is registered via register_netdev(). The TX queues are now enabled only at the end of macb_mac_link_up() rather than during macb_open(). This avoids concurrent execution of macb_mac_link_up() and macb_start_xmit() thus avoiding the race condition. This is consistent with the behavior of macb_mac_link_down(), which also stops the tx queues. Signed-off-by: Ingo Rohloff --- drivers/net/ethernet/cadence/macb_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 43cd013bb70e..2fe0e843627f 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -2973,8 +2973,6 @@ static int macb_open(struct net_device *dev) if (err) goto phy_off; - netif_tx_start_all_queues(dev); - if (bp->ptp_info) bp->ptp_info->ptp_init(dev); @@ -5607,6 +5605,7 @@ static int macb_probe(struct platform_device *pdev) if (err) goto err_out_phy_exit; + netif_tx_stop_all_queues(dev); netif_carrier_off(dev); err = register_netdev(dev); -- 2.52.0