From: Arthur Crepin Leblond <arthur@marmottus.net>
To: sashiko-reviews@lists.linux.dev, robh@kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v9 3/3] w5100: detect carrier state using link status bit and optional interrupt
Date: Mon, 21 Sep 2026 12:42:53 +0200 [thread overview]
Message-ID: <20260921104253.GA248881@marmottus.net> (raw)
In-Reply-To: <20260921090432.GA84626@marmottus.net>
On Mon, Sep 21, 2026 at 11:04:34AM +0200, Arthur Crepin Leblond wrote:
>On Sat, Sep 19, 2026 at 03:14:20PM +0000, sashiko-bot@kernel.org wrote:
>>>@@ -448,12 +526,25 @@ 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);
>>>+
>>
>>[Severity: Medium]
>>Is it safe to call disable_irq() here? disable_irq() is a sleepable function,
>>but w5100_restart() can be called from atomic context when using memory-mapped
>>I/O.
>>
>>Looking at w5100_tx_timeout(), which executes in atomic context, the timeout
>>handler falls back to calling w5100_restart() directly if the device cannot
>>sleep:
>>
>>w5100_tx_timeout() {
>> ...
>> if (priv->ops->may_sleep)
>> schedule_work(&priv->restart_work);
>> else
>> w5100_restart(ndev);
>>}
>>
>>While current in-tree drivers might set may_sleep to true, this code path
>>explicitly exists to support may_sleep == false. Could this introduce a
>>'scheduling while atomic' panic for non-sleepable devices?
>
>It looks like all the ops in the spi driver are setting may_sleep to
>true but indeed disable_irq should not be called from an atomic context.
>
>Would disable_irq_nosync just work here? enable_irq is not affected
>from what I understand.
>
>>
>>> netif_stop_queue(ndev);
>>> w5100_hw_reset(priv);
>>>+ enable_irq(priv->irq);
>>> w5100_hw_start(priv);
>>> ndev->stats.tx_errors++;
>>> netif_trans_update(ndev);
>>> netif_wake_queue(ndev);
>>>+
>>>+ if (priv->link_irq > 0) {
>>>+ w5500_report_carrier_state(ndev);
>>>+ enable_irq(priv->link_irq);
>>>+ }
>>
>>[Severity: Medium]
>>Similarly, w5500_report_carrier_state() attempts to acquire a mutex
>>(priv->link_lock).
>>
>>If priv->link_irq > 0 and priv->ops->may_sleep is false, wouldn't taking
>>this mutex in the w5100_tx_timeout() -> w5100_restart() call chain also
>>result in sleeping in atomic context?
>>
>>> }
>>
>
>Maybe I could use a spin lock instead of a mutex.
>
>Arthur
The easiest is probably to always run w5100_restart in worker.
Arthur
next prev parent reply other threads:[~2026-09-21 10:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 15:13 [PATCH net-next v9 0/3] w5100: restore GPIO-based link detection Arthur Crepin Leblond
2026-09-18 15:13 ` [PATCH net-next v9 1/3] dt-bindings: net: wiznet,w5100: convert to DT schema Arthur Crepin Leblond
2026-09-22 15:43 ` netdev-bot+sashiko
2026-09-23 9:12 ` Arthur Crepin Leblond
2026-09-18 15:13 ` [PATCH net-next v9 2/3] dt-bindings: net: wiznet,w5100: add link status interrupt Arthur Crepin Leblond
2026-09-18 15:13 ` [PATCH net-next v9 3/3] w5100: detect carrier state using link status bit and optional interrupt Arthur Crepin Leblond
2026-09-19 15:14 ` sashiko-bot
2026-09-21 9:04 ` Arthur Crepin Leblond
2026-09-21 10:42 ` Arthur Crepin Leblond [this message]
2026-09-22 15:43 ` netdev-bot+sashiko
2026-09-23 9:36 ` 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=20260921104253.GA248881@marmottus.net \
--to=arthur@marmottus.net \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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