mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: cbabroski@nvidia.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bryan.whitehead@microchip.com, UNGLinuxDriver@microchip.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com,
	linux@armlinux.org.uk, Raju.Lakkaraju@microchip.com,
	maxime.chevallier@bootlin.com, yuiko.oshino@microchip.com,
	nb@tipi-net.de, woojung.huh@microchip.com
Subject: Re: [PATCH net-next v2 6/7] net: lan743x: reset the device on TX timeout
Date: Wed, 25 Nov 2026 14:37:07 +0000	[thread overview]
Message-ID: <179561742750.3135.10907427867283855252@kernel.org> (raw)
In-Reply-To: <a6d08d5760ecabea5c77d6001a8281c820873512.1795027003.git.cbabroski@nvidia.com>

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

  reply	other threads:[~2026-11-25 14:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 14:33 [PATCH net-next v2 0/7] net: lan743x: automatically recover from TX hang Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 1/7] net: lan743x: check DMA channel stop and reset results Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko
2026-11-24 14:33 ` [PATCH net-next v2 2/7] net: lan743x: quiesce TX before freeing the rings Chris Babroski
2026-11-24 14:33 ` [PATCH net-next v2 3/7] net: lan743x: start phylink last and stop it first Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko
2026-11-24 14:33 ` [PATCH net-next v2 4/7] net: lan743x: keep the fixed link across reopen Chris Babroski
2026-11-25  0:32   ` Andrew Lunn
2026-11-24 14:33 ` [PATCH net-next v2 5/7] net: lan743x: handle a failed reopen on resume Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko
2026-11-24 14:33 ` [PATCH net-next v2 6/7] net: lan743x: reset the device on TX timeout Chris Babroski
2026-11-25 14:37   ` netdev-bot+sashiko [this message]
2026-11-24 14:33 ` [PATCH net-next v2 7/7] net: lan743x: add byte queue limits support Chris Babroski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179561742750.3135.10907427867283855252@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Raju.Lakkaraju@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bryan.whitehead@microchip.com \
    --cc=cbabroski@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maxime.chevallier@bootlin.com \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=woojung.huh@microchip.com \
    --cc=yuiko.oshino@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®