From: sashiko-bot@kernel.org
To: "Arthur Crepin Leblond" <arthur@marmottus.net>
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: Sat, 05 Sep 2026 12:36:29 +0000 [thread overview]
Message-ID: <20260905123629.8D1171F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260904-wiznet-link-gpio-v7-3-69f01b70c96f@marmottus.net>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Interface becomes permanently stuck in NO-CARRIER if brought up without a cable and link_irq is not provided.
- [Medium] Race condition in w5100_open() and w5100_resume() causes permanent incorrect carrier state due to stale read.
--
commit 25ad966bc1cae0a5e447949792be215c893866af
Author: Arthur Crepin Leblond <arthur@marmottus.net>
w5100: detect carrier state using link status bit and optional interrupt
This commit adds link status detection for w5500 devices using the PHY
Configuration register. It also introduces an optional interrupt to track
subsequent link state changes.
> diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c
> index 53d8dc642fbd6..ecb99621d0a1e 100644
> --- a/drivers/net/ethernet/wiznet/w5100.c
> +++ b/drivers/net/ethernet/wiznet/w5100.c
[ ... ]
> @@ -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.
> + 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.
> +
> return 0;
> }
[ ... ]
> @@ -857,6 +952,12 @@ static int w5100_resume(struct device *dev)
> w5100_hw_start(priv);
>
> netif_device_attach(ndev);
> +
> + if (priv->link_irq >= 0)
> + enable_irq(priv->link_irq);
> +
> + if (w5100_get_link(ndev))
> + netif_carrier_on(ndev);
[Severity: Medium]
Could this face the same race condition as w5100_open()? The edge-triggered
interrupt is enabled before the local state read, so a concurrent physical
link change could trigger the interrupt handler, update the carrier, and
then be overwritten by the stale state read here.
> }
> return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-wiznet-link-gpio-v7-0-69f01b70c96f@marmottus.net?part=3
next prev parent reply other threads:[~2026-09-05 12:36 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 [this message]
2026-09-11 15:40 ` Arthur Crepin Leblond
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=20260905123629.8D1171F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=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.