From: netdev-bot+sashiko@kernel.org
To: ansuelsmth@gmail.com
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, willemb@google.com,
horms@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org,
rdunlap@infradead.org, lorenzo@kernel.org, hkallweit1@gmail.com,
linux@armlinux.org.uk, maxime.chevallier@bootlin.com,
p.zabel@pengutronix.de, nathan@kernel.org,
ndesaulniers@google.com, morbo@google.com,
justinstitt@google.com, rmk+kernel@armlinux.org.uk,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, llvm@lists.linux.dev,
zhengping.zhang@airoha.com
Subject: Re: [PATCH net-next v23 07/15] net: sfp: support deferred module insertion
Date: Mon, 30 Nov 2026 23:47:43 +0000 [thread overview]
Message-ID: <179608246397.3146.5781345525320123745@kernel.org> (raw)
In-Reply-To: <20261129230558.612526-8-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new deferral only covers a PCS dependency that is missing
when module_insert() runs.
--
net: sfp: support deferred module insertion
This lets an upstream device defer SFP module insertion. If its
module_insert() callback returns -EAGAIN, the module stays in
SFP_MOD_WAITDEV. A new sfp_upstream_retry_module() helper lets the
upstream retry the insertion once the missing dependency (e.g. a PCS
provider) has registered.
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 915156743701b..e5ddd62318bf9 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
[ ... ]
> @@ -2830,6 +2836,8 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
> /* Report the module insertion to the upstream device */
> err = sfp_module_insert(sfp->sfp_bus, &sfp->id,
> sfp->quirk);
> + if (err == -EAGAIN)
> + break;
> if (err < 0) {
> sfp_sm_mod_next(sfp, SFP_MOD_ERROR, 0);
> break;
[ ... ]
> @@ -3091,6 +3099,14 @@ static void sfp_stop(struct sfp *sfp)
> sfp_sm_event(sfp, SFP_E_DEV_DOWN);
> }
>
> +static void sfp_retry_module(struct sfp *sfp)
> +{
> + mutex_lock(&sfp->sm_mutex);
> + if (sfp->sm_mod_state == SFP_MOD_WAITDEV)
> + __sfp_sm_event(sfp, SFP_E_UPSTREAM_RETRY);
> + mutex_unlock(&sfp->sm_mutex);
> +}
[Severity: Medium]
Does this retry cover modules that have may_have_phy set?
sfp_retry_module() only acts while sm_mod_state is SFP_MOD_WAITDEV. The
only way to stay in that state is for sfp_module_insert() in
sfp_sm_module() to return -EAGAIN.
Copper modules have may_have_phy set. These are e1000_base_t modules, or
modules with the 10G/5G/2.5GBASE-T extended compliance codes that
sfp_module_parse_may_have_phy() checks for. For them,
phylink_sfp_module_insert() returns before any PCS-dependent
configuration:
drivers/net/phy/phylink.c:phylink_sfp_module_insert() {
...
/* If this module may have a PHY connecting later, defer until later */
if (pl->sfp_may_have_phy)
return 0;
...
}
So the module moves to SFP_MOD_PRESENT, and the PCS dependency is only
checked later in sfp_sm_main().
If the PCS provider has not registered yet, both paths there seem to end
in SFP_S_FAIL.
When a PHY is found:
sfp_sm_probe_for_phy()->sfp_add_phy()->phylink_sfp_connect_phy()
->phylink_sfp_config_phy()
This fails because the host interface (e.g. SGMII) is not yet in
pl->supported_interfaces.
When no PHY is found:
sfp_module_start()->phylink_sfp_module_start()
->phylink_sfp_config_optical()
This returns -EINVAL with "no common interface modes".
Both failures lead here:
drivers/net/phy/sfp.c:sfp_sm_main() {
...
} else if (ret) {
sfp_sm_next(sfp, SFP_S_FAIL, 0);
break;
}
if (sfp_module_start(sfp->sfp_bus)) {
sfp_sm_next(sfp, SFP_S_FAIL, 0);
break;
}
...
}
Later, when the provider registers, this chain runs:
phylink_update_pcs()->phylink_sfp_retry_module()
->sfp_upstream_retry_module()->sfp_retry_module()
sfp_retry_module() then sees sm_mod_state == SFP_MOD_PRESENT and does
nothing.
Would the link then stay down until the module is re-plugged, or the
interface is cycled with ifdown/ifup?
The later patch in this series, "net: phylink: support late PCS provider
attach", only returns -EAGAIN when !caps->may_have_phy. So the rest of
the series doesn't seem to cover this case either.
The commit message starts with a general description ("when the
upstream device needs a dependency that is not yet available"). Only the
last sentence narrows it to optical SFPs. If leaving out copper and
may_have_phy modules is intended, could the commit message say so?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129230558.612526-1-ansuelsmth%40gmail.com
next prev parent reply other threads:[~2026-11-30 23:47 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 23:05 [PATCH net-next v23 00/15] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-11-29 23:05 ` [PATCH net-next v23 01/15] net: phylink: make PCS phylink instance access RCU protected Christian Marangi
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 02/15] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-11-29 23:05 ` [PATCH net-next v23 03/15] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 04/15] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 05/15] net: phylink: make phylink_validate state locked Christian Marangi
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 06/15] net: phylink: add capabilities helpers and track modified advertising Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 07/15] net: sfp: support deferred module insertion Christian Marangi
2026-11-30 23:47 ` netdev-bot+sashiko [this message]
2026-11-29 23:05 ` [PATCH net-next v23 08/15] net: phylink: support PCS provider release Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 09/15] net: phylink: support late PCS provider attach Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 10/15] net: Document PCS subsystem Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 11/15] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-11-29 23:05 ` [PATCH net-next v23 12/15] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 13/15] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 14/15] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:47 ` netdev-bot+sashiko
2026-11-29 23:05 ` [PATCH net-next v23 15/15] net: airoha: add phylink support Christian Marangi
2026-11-30 23:25 ` sashiko-bot
2026-11-30 23:48 ` netdev-bot+sashiko
2026-11-29 23:09 ` [PATCH net-next v23 00/15] net: pcs: Introduce support for fwnode PCS netdev-bot+sinfo
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=179608246397.3146.5781345525320123745@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=justinstitt@google.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=llvm@lists.linux.dev \
--cc=lorenzo@kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=willemb@google.com \
--cc=zhengping.zhang@airoha.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