Re: [PATCH net-next v2 6/7] net: lan743x: reset the device on TX timeout

From: netdev-bot+sashiko

Date: Wed Nov 25 2026 - 09:37:15 EST


Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] A single TX timeout can trigger two back-to-back device resets,
because lan743x_reset_work() does not wait for a dev_watchdog() call…

--

net: lan743x: reset the device on TX timeout

This adds an ndo_tx_timeout handler to the lan743x driver. The handler
schedules a work item that, under rtnl, detaches the netdev, closes it,
soft-resets the DMA controller, reopens it and reattaches it. The patch
also makes lan743x_dmac_init() return an error when the DMAC soft reset
times out.

> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index 228b6ab539a17..3f129a22921e1 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c

[ ... ]

> @@ -3381,6 +3385,12 @@ static int lan743x_netdev_close(struct net_device *netdev)
> struct lan743x_adapter *adapter = netdev_priv(netdev);
> int index;
>
> + /* lan743x_reset_work() takes rtnl, so it cannot be waited for here.
> + * A running one returns if the device is still down when it gets
> + * rtnl, otherwise it resets the reopened device once more.
> + */
> + cancel_work(&adapter->reset_work);
> +
> lan743x_phylink_disconnect(adapter);
>
> synchronize_net();

[ ... ]

> @@ -3485,6 +3495,57 @@ static int lan743x_netdev_stop(struct net_device *netdev)
> return lan743x_netdev_close(netdev);
> }
>
> +static void lan743x_reset_work(struct work_struct *work)
> +{
> + struct lan743x_adapter *adapter =
> + container_of(work, struct lan743x_adapter, reset_work);
> + struct net_device *netdev = adapter->netdev;
> + int ret;
> +
> + rtnl_lock();
> +
> + if (!netif_running(netdev) || !netif_device_present(netdev))
> + goto unlock;
> +
> + netdev_warn(netdev, "resetting after TX timeout\n");
> +
> + netif_device_detach(netdev);
> + lan743x_netdev_close(netdev);

[Severity: Low]
Can one TX timeout cause two resets in a row here?

netif_device_detach() only clears __LINK_STATE_PRESENT. It does not take
dev->tx_global_lock. dev_watchdog() holds that lock while it checks
presence, scans the queues, prints a message and calls ndo_tx_timeout():

net/sched/sch_generic.c:dev_watchdog() {
spin_lock(&dev->tx_global_lock);
if (!qdisc_tx_is_noop(dev)) {
if (netif_device_present(dev) &&
netif_running(dev) &&
netif_carrier_ok(dev)) {
...
netdev_crit(dev, "NETDEV WATCHDOG: CPU: %d: transmit queue %u timed out %u ms\n",
...
netif_freeze_queues(dev);
dev->netdev_ops->ndo_tx_timeout(dev, i);
...
}

This interleaving looks possible:

CPU0 (dev_watchdog) CPU1 (lan743x_reset_work)
spin_lock(tx_global_lock)
netif_device_present() is true
netif_device_detach()
lan743x_netdev_close()
cancel_work() /* work is running,
not pending */
netdev_crit(...)
lan743x_netdev_tx_timeout()
schedule_work() /* requeues */
spin_unlock(tx_global_lock)
netif_tx_disable() /* waits on
tx_global_lock */

The netif_tx_disable() call in lan743x_netdev_close() is the first point
that serializes against dev_watchdog() through tx_global_lock. It runs
after cancel_work(), so nothing cancels the requeued work.

When the first reset calls netif_device_attach(), the requeued work sees
netif_running() and netif_device_present() both true. It then runs the
full detach/close/dmac_init/open/attach sequence a second time. That
means a second link flap and a second PTP clock unregister and register,
which can give the clock a new /dev/ptpN again.

The ndo_stop path does not have this window. There,
__dev_close_many()->dev_deactivate_many()->netdev_watchdog_down() stops
the watchdog before ndo_stop runs cancel_work(). The commit message only
accepts an extra reset for the ndo_stop/reopen race.

Would moving cancel_work() after netif_tx_disable() in
lan743x_netdev_close() close this window?

> +
> + ret = lan743x_dmac_init(adapter);
> + if (ret) {

[ ... ]

> +static void lan743x_netdev_tx_timeout(struct net_device *netdev,
> + unsigned int txqueue)
> +{
> + struct lan743x_adapter *adapter = netdev_priv(netdev);
> +
> + schedule_work(&adapter->reset_work);
> +}

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795027003.git.cbabroski%40nvidia.com