mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arthur Crepin Leblond <arthur@marmottus.net>
To: netdev-bot+sashiko@kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, arnd@arndb.de,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v11 3/3] w5100: detect carrier state using link status bit and optional interrupt
Date: Wed, 30 Sep 2026 10:28:45 +0200	[thread overview]
Message-ID: <20260930082845.GA84786@marmottus.net> (raw)
In-Reply-To: <179059099826.3145.7654211997843249181@kernel.org>

On Mon, Sep 28, 2026 at 10:23:18AM +0000, netdev-bot+sashiko@kernel.org wrote:
>> +static irqreturn_t w5500_detect_link_interrupt(int irq, void *ndev_instance)
>> +{
>> +	struct net_device *ndev = ndev_instance;
>> +
>> +	if (netif_running(ndev))
>> +		w5500_report_carrier_state(ndev);
>> +
>> +	return IRQ_HANDLED;
>> +}
>
>[Severity: Low]
>What happens if all three PHYCFGR reads in w5500_get_phycfgr_lnk() fail on
>the link-up edge?

The driver will log the error but I do not think this patch can much
more than that.

>[ ... ]
>
>> @@ -448,12 +531,28 @@ static void w5100_restart(struct net_device *ndev)
>>  {
>>  	struct w5100_priv *priv = netdev_priv(ndev);
>>
>> +	if (!netif_running(ndev) || !netif_device_present(ndev))
>> +		return;
>> +
>> +	disable_irq(priv->irq);
>> +	if (priv->link_irq > 0)
>> +		disable_irq(priv->link_irq);
>> +
>>  	netif_stop_queue(ndev);
>> +	w5100_hw_close(priv);
>> +	flush_work(&priv->rx_work);
>> +	flush_work(&priv->tx_work);
>>  	w5100_hw_reset(priv);
>
>[Severity: Low]
>This isn't a bug introduced by this patch, but netif_stop_queue() doesn't
>wait for an ndo_start_xmit that is already running. Can w5100_start_tx()
>still queue tx_work after flush_work(&priv->tx_work) here?
>
>w5100_start_tx() {
>	...
>	if (priv->ops->may_sleep) {
>		WARN_ON(priv->tx_skb);
>		priv->tx_skb = skb;
>		queue_work(priv->xfer_wq, &priv->tx_work);
>	...
>}
>
>If it can, tx_work could issue SPI transfers at the same time as
>w5100_hw_reset() during tx timeout recovery. The baseline w5100_restart()
>had no flush at all, so this patch narrows the window rather than opening
>it.

True, the low risk still exists.

>[ ... ]
>
>> @@ -667,13 +772,40 @@ static int w5100_stop(struct net_device *ndev)
>>  	struct w5100_priv *priv = netdev_priv(ndev);
>>
>>  	netif_info(priv, ifdown, ndev, "shutting down\n");
>> -	w5100_hw_close(priv);
>> -	netif_carrier_off(ndev);
>> +
>> +	disable_irq(priv->irq);
>> +	if (priv->link_irq > 0)
>> +		disable_irq(priv->link_irq);
>> +
>>  	netif_stop_queue(ndev);
>>  	napi_disable(&priv->napi);
>> +
>> +	cancel_work_sync(&priv->restart_work);
>
>[Severity: Medium]
>Can a restart_work that is already running wake the queue again after the
>netif_stop_queue() above?
>

With the correct timing, technically yes it could.

>[ ... ]
>
>> @@ -839,10 +1011,11 @@ static int w5100_suspend(struct device *dev)
>>  	struct w5100_priv *priv = netdev_priv(ndev);
>>
>>  	if (netif_running(ndev)) {
>> -		netif_carrier_off(ndev);
>> +		mutex_lock(&priv->link_lock);
>>  		netif_device_detach(ndev);
>> +		mutex_unlock(&priv->link_lock);
>>
>> -		w5100_hw_close(priv);
>> +		w5100_stop(ndev);
>>  	}
>>  	return 0;
>>  }
>
>[Severity: Medium]
>What happens if the core calls ndo_stop between this suspend and the
>matching resume?
>
>Here w5100_stop() disables both irqs and calls napi_disable(). However,
>__LINK_STATE_START stays set, and suspend takes neither rtnl nor the netdev
>lock.
>
>A kernel-initiated dev_close() can run during the suspend window, for
>example from cleanup_net() on the non-freezable netns workqueue. In that
>case w5100_stop() runs a second time:
>
>__dev_close_many()
>  w5100_stop()
>    disable_irq(priv->irq)          <- disable depth now 2
>    napi_disable(&priv->napi)
>      napi_disable_locked()         <- SCHED/NPSVC still set from the
>                                       first napi_disable()
>
>napi_disable_locked() would then spin forever in usleep_range() while
>holding rtnl.
>
>After that, netif_running() is false, so w5100_resume() skips w5100_open().
>The irq disable depth stays raised, and a later ifup leaves both irqs
>disabled.
>
>Before this patch, suspend only called w5100_hw_close(), which touched
>neither NAPI nor the irq disable depth.
>

Taking rtnl_lock/unlock in suspend/resume could close this gap
but it is again probably something very unlikely to happen.

Arthur

  reply	other threads:[~2026-09-30  8:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  9:48 [PATCH net-next v11 0/3] w5100: restore GPIO-based link detection Arthur Crepin Leblond
2026-09-24  9:48 ` [PATCH net-next v11 1/3] dt-bindings: net: wiznet,w5100: convert to DT schema Arthur Crepin Leblond
2026-09-28 10:23   ` netdev-bot+sashiko
2026-09-24  9:48 ` [PATCH net-next v11 2/3] dt-bindings: net: wiznet,w5100: add link status interrupt Arthur Crepin Leblond
2026-09-24 16:57   ` Conor Dooley
2026-09-28 10:23   ` netdev-bot+sashiko
2026-09-24  9:48 ` [PATCH net-next v11 3/3] w5100: detect carrier state using link status bit and optional interrupt Arthur Crepin Leblond
2026-09-28 10:23   ` netdev-bot+sashiko
2026-09-30  8:28     ` Arthur Crepin Leblond [this message]
2026-09-30  0:40 ` [PATCH net-next v11 0/3] w5100: restore GPIO-based link detection patchwork-bot+netdevbpf
2026-09-30  7:17   ` Arthur Crepin Leblond

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=20260930082845.GA84786@marmottus.net \
    --to=arthur@marmottus.net \
    --cc=andrew+netdev@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    /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®