From: Arthur Crepin Leblond <arthur@marmottus.net>
To: sashiko-reviews@lists.linux.dev
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v7 3/3] w5100: detect carrier state using link status bit and optional interrupt
Date: Fri, 11 Sep 2026 17:40:02 +0200 [thread overview]
Message-ID: <20260911154002.GC9585@marmottus.net> (raw)
In-Reply-To: <20260905123629.8D1171F00A3E@smtp.kernel.org>
On Sat, Sep 05, 2026 at 12:36:29PM +0000, sashiko-bot@kernel.org wrote:
>> @@ -659,6 +711,15 @@ static int w5100_open(struct net_device *ndev)
>> w5100_hw_start(priv);
>> napi_enable(&priv->napi);
>> netif_start_queue(ndev);
>> +
>> + if (priv->link_irq >= 0)
>> + enable_irq(priv->link_irq);
>> +
>> + if (w5100_get_link(ndev))
>> + netif_carrier_on(ndev);
>
>[Severity: Medium]
>Could this introduce a race condition where a stale link state overwrites
>a newer one? If the physical link state changes exactly after
>w5100_get_link() reads the hardware register but before this thread
>evaluates the result, the newly unmasked edge-triggered interrupt handler
>might run first. The handler would read the new state and update the carrier,
>but then the main thread would resume and apply its stale read, overwriting
>the correct state. Since the interrupt is edge-triggered, no further
>interrupts would correct this until the link changes again.
Yes, I'll bring a mutex/lock to the next patch.
>
>> + else
>> + netif_carrier_off(ndev);
>
>[Severity: High]
>Does this leave the interface permanently stuck without carrier if the
>link_irq is not provided? If the interface is brought up while the cable is
>disconnected, this explicitly calls netif_carrier_off(). Without the optional
>interrupt (which is the case for most legacy device trees), there appears
>to be no polling mechanism to ever turn the carrier back on when a cable is
>subsequently plugged in.
I think the best here imho would be to just keep the original behavior
if there is no link irq set and to not touch netif_carrier_on/off at
all.
w5100/w5200 -> no .get_link, no netif_carrier
w5500 -> .get_link but netif_carrier only if link irq is set
Arthur
next prev parent reply other threads:[~2026-09-11 18:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 12:35 [PATCH net-next v7 0/3] w5100: restore GPIO-based link detection Arthur Crepin Leblond
2026-09-04 12:35 ` [PATCH net-next v7 1/3] dt-bindings: net: wiznet,w5100: convert to DT schema Arthur Crepin Leblond
2026-09-05 12:36 ` sashiko-bot
2026-09-09 12:38 ` netdev-bot+sashiko
2026-09-11 15:30 ` Arthur Crepin Leblond
2026-09-04 12:35 ` [PATCH net-next v7 2/3] dt-bindings: net: wiznet,w5100: add link status interrupt Arthur Crepin Leblond
2026-09-09 12:39 ` netdev-bot+sashiko
2026-09-11 15:33 ` Arthur Crepin Leblond
2026-09-11 15:56 ` Arthur Crepin Leblond
2026-09-04 12:36 ` [PATCH net-next v7 3/3] w5100: detect carrier state using link status bit and optional interrupt Arthur Crepin Leblond
2026-09-05 12:36 ` sashiko-bot
2026-09-11 15:40 ` Arthur Crepin Leblond [this message]
2026-09-09 12:39 ` netdev-bot+sashiko
2026-09-10 11:27 ` Paolo Abeni
2026-09-10 12:28 ` 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=20260911154002.GC9585@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.