* [PATCH net-next v5] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe
@ 2026-11-25 16:54 Daniel Pawlik
2026-12-03 8:24 ` Daniel Pawlik
2026-12-04 1:39 ` willemb
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Pawlik @ 2026-11-25 16:54 UTC (permalink / raw)
To: kabel, andrew, hkallweit1, linux
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
petr.wozniak, maxime.chevallier, olek2, Daniel Pawlik
Modules without a RollBall I2C-to-MDIO bridge time out on every RollBall
command, but the quirks for such modules force MDIO_I2C_ROLLBALL. The
PHY probe then retries 25 times at ~21 seconds per attempt, i.e. for
over nine minutes, before the module links up without a PHY. Each
attempt runs from sfp_timeout() with rtnl_lock held, so for the whole
window every rtnl user on the system stalls in ~21 second chunks,
including the state machines of other SFP cages: in one test, pulling a
module from another cage was only processed after the current attempt
ended, triggering a WARN from phy_error_precise().
mdio-i2c reports a RollBall command timeout as 0xffff, both for a
bridge that is still booting and for a module without a bridge. Do one
cheap MDIO read of the PHY ID before the full PHY probe and return
-ENODEV on 0xffff: the existing 25 x 1 s retry loop still protects
slow-booting genuine bridges, but a failed attempt costs one read
instead of a full probe timing out on every register.
The ID register is used because phylib ignores a C45 MMD whose ID reads
all-ones when matching drivers, so a PHY failing this check could not
bind a driver through that MMD anyway.
The trade-off is a shorter window for a bridge that stays completely
silent: the retry loop now gives up after about 45 seconds instead of
the ~9 minutes the slow probe accidentally provided. The RollBall
fixup allows modules to block PHY access for up to 25 seconds after
insertion, so this should be sufficient.
Tested on a Banana Pi BPI-R4 with a bridge-less "OEM SFP-10G-T" rev A
module and a genuine rev 02 module with an AQR113C: the rev A module
links up at 10G 57 s after boot instead of over nine minutes, and the
rev 02 module attaches its PHY as before.
Suggested-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Daniel Pawlik <pawlik.dan@gmail.com>
Link: https://lore.kernel.org/netdev/20260624084814.20972-1-petr.wozniak@gmail.com/
---
Replaces the revision-quirk approach of v4 with the generic check
suggested by Marek Behún, using the PHY ID register per his and Andrew
Lunn's review. This also drops the sfp_strlen() move from v4, making
this a single patch.
v4: https://lore.kernel.org/netdev/20261121091235.1447291-1-pawlik.dan@gmail.com/
v3: https://lore.kernel.org/netdev/20261120063756.3677554-1-pawlik.dan@gmail.com/
v2: https://lore.kernel.org/netdev/20261118221450.1764790-1-pawlik.dan@gmail.com/
v1: https://lore.kernel.org/netdev/20261116093605.294365-1-pawlik.dan@gmail.com/
---
drivers/net/phy/sfp.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 915156743701..9582dd21aee8 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -2249,6 +2249,7 @@ static int sfp_sm_add_mdio_bus(struct sfp *sfp)
static int sfp_sm_probe_for_phy(struct sfp *sfp)
{
int err = 0;
+ int ret;
switch (sfp->mdio_protocol) {
case MDIO_I2C_NONE:
@@ -2263,6 +2264,16 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
break;
case MDIO_I2C_ROLLBALL:
+ /* mdio-i2c reports a RollBall command timeout as 0xffff, both
+ * for a bridge that is still booting and for a module without
+ * a bridge. Retry after one cheap read instead of a full PHY
+ * probe, which times out on every register under rtnl_lock.
+ */
+ ret = mdiobus_c45_read(sfp->i2c_mii, SFP_PHY_ADDR_ROLLBALL,
+ MDIO_MMD_PMAPMD, MII_PHYSID1);
+ if (ret == 0xffff)
+ return -ENODEV;
+
err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR_ROLLBALL, true);
break;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next v5] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe
2026-11-25 16:54 [PATCH net-next v5] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe Daniel Pawlik
@ 2026-12-03 8:24 ` Daniel Pawlik
2026-12-04 1:39 ` willemb
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Pawlik @ 2026-12-03 8:24 UTC (permalink / raw)
To: kabel, andrew, hkallweit1, linux
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
petr.wozniak, maxime.chevallier, olek2, szymon.datko
Replying to the AI review at
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125165417.3422927-1-pawlik.dan%40gmail.com
> Should this have a Fixes: tag?
No. The module never worked without the stall, so this is not a
regression; Andrew asked to drop the tag and target net-next during
the v2 review.
> Is this check stricter than what phylib does itself?
Yes, on purpose. It relies on the PMA/PMD identifier, which Clause 45
makes mandatory, being readable once the bridge is up. The RollBall
PHYs I know of (AQR113C, RTL8221B, 88X3310) expose it, and Andrew noted
on v4 that a real 0xffff upper ID would be a vendor bug. A transient
timeout only costs one of the 25 retry attempts. I can add a sentence
stating this assumption to the commit message if a v6 is wanted.
Also, the reporter of the rev B module tested this version: it works,
with the expected ~30 s fallback instead of ~9 minutes:
https://github.com/openwrt/openwrt/pull/22910#issuecomment-7192738906
Dan
śr., 25 lis 2026 o 17:54 Daniel Pawlik <pawlik.dan@gmail.com> napisał(a):
>
> Modules without a RollBall I2C-to-MDIO bridge time out on every RollBall
> command, but the quirks for such modules force MDIO_I2C_ROLLBALL. The
> PHY probe then retries 25 times at ~21 seconds per attempt, i.e. for
> over nine minutes, before the module links up without a PHY. Each
> attempt runs from sfp_timeout() with rtnl_lock held, so for the whole
> window every rtnl user on the system stalls in ~21 second chunks,
> including the state machines of other SFP cages: in one test, pulling a
> module from another cage was only processed after the current attempt
> ended, triggering a WARN from phy_error_precise().
>
> mdio-i2c reports a RollBall command timeout as 0xffff, both for a
> bridge that is still booting and for a module without a bridge. Do one
> cheap MDIO read of the PHY ID before the full PHY probe and return
> -ENODEV on 0xffff: the existing 25 x 1 s retry loop still protects
> slow-booting genuine bridges, but a failed attempt costs one read
> instead of a full probe timing out on every register.
>
> The ID register is used because phylib ignores a C45 MMD whose ID reads
> all-ones when matching drivers, so a PHY failing this check could not
> bind a driver through that MMD anyway.
>
> The trade-off is a shorter window for a bridge that stays completely
> silent: the retry loop now gives up after about 45 seconds instead of
> the ~9 minutes the slow probe accidentally provided. The RollBall
> fixup allows modules to block PHY access for up to 25 seconds after
> insertion, so this should be sufficient.
>
> Tested on a Banana Pi BPI-R4 with a bridge-less "OEM SFP-10G-T" rev A
> module and a genuine rev 02 module with an AQR113C: the rev A module
> links up at 10G 57 s after boot instead of over nine minutes, and the
> rev 02 module attaches its PHY as before.
>
> Suggested-by: Marek Behún <kabel@kernel.org>
> Signed-off-by: Daniel Pawlik <pawlik.dan@gmail.com>
> Link: https://lore.kernel.org/netdev/20260624084814.20972-1-petr.wozniak@gmail.com/
>
> ---
>
> Replaces the revision-quirk approach of v4 with the generic check
> suggested by Marek Behún, using the PHY ID register per his and Andrew
> Lunn's review. This also drops the sfp_strlen() move from v4, making
> this a single patch.
>
> v4: https://lore.kernel.org/netdev/20261121091235.1447291-1-pawlik.dan@gmail.com/
> v3: https://lore.kernel.org/netdev/20261120063756.3677554-1-pawlik.dan@gmail.com/
> v2: https://lore.kernel.org/netdev/20261118221450.1764790-1-pawlik.dan@gmail.com/
> v1: https://lore.kernel.org/netdev/20261116093605.294365-1-pawlik.dan@gmail.com/
> ---
> drivers/net/phy/sfp.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 915156743701..9582dd21aee8 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -2249,6 +2249,7 @@ static int sfp_sm_add_mdio_bus(struct sfp *sfp)
> static int sfp_sm_probe_for_phy(struct sfp *sfp)
> {
> int err = 0;
> + int ret;
>
> switch (sfp->mdio_protocol) {
> case MDIO_I2C_NONE:
> @@ -2263,6 +2264,16 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
> break;
>
> case MDIO_I2C_ROLLBALL:
> + /* mdio-i2c reports a RollBall command timeout as 0xffff, both
> + * for a bridge that is still booting and for a module without
> + * a bridge. Retry after one cheap read instead of a full PHY
> + * probe, which times out on every register under rtnl_lock.
> + */
> + ret = mdiobus_c45_read(sfp->i2c_mii, SFP_PHY_ADDR_ROLLBALL,
> + MDIO_MMD_PMAPMD, MII_PHYSID1);
> + if (ret == 0xffff)
> + return -ENODEV;
> +
> err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR_ROLLBALL, true);
> break;
> }
> --
> 2.56.1
>
--
Z poważaniem,
Daniel Pawlik
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net-next v5] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe
2026-11-25 16:54 [PATCH net-next v5] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe Daniel Pawlik
2026-12-03 8:24 ` Daniel Pawlik
@ 2026-12-04 1:39 ` willemb
1 sibling, 0 replies; 3+ messages in thread
From: willemb @ 2026-12-04 1:39 UTC (permalink / raw)
To: Daniel Pawlik, kabel, andrew, hkallweit1, linux
Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
petr.wozniak, maxime.chevallier, olek2, Daniel Pawlik
Daniel Pawlik wrote:
> Modules without a RollBall I2C-to-MDIO bridge time out on every RollBall
> command, but the quirks for such modules force MDIO_I2C_ROLLBALL. The
> PHY probe then retries 25 times at ~21 seconds per attempt, i.e. for
> over nine minutes, before the module links up without a PHY. Each
> attempt runs from sfp_timeout() with rtnl_lock held, so for the whole
> window every rtnl user on the system stalls in ~21 second chunks,
> including the state machines of other SFP cages: in one test, pulling a
> module from another cage was only processed after the current attempt
> ended, triggering a WARN from phy_error_precise().
> mdio-i2c reports a RollBall command timeout as 0xffff, both for a
> bridge that is still booting and for a module without a bridge. Do one
> cheap MDIO read of the PHY ID before the full PHY probe and return
> -ENODEV on 0xffff: the existing 25 x 1 s retry loop still protects
> slow-booting genuine bridges, but a failed attempt costs one read
> instead of a full probe timing out on every register.
> The ID register is used because phylib ignores a C45 MMD whose ID reads
> all-ones when matching drivers, so a PHY failing this check could not
> bind a driver through that MMD anyway.
> The trade-off is a shorter window for a bridge that stays completely
> silent: the retry loop now gives up after about 45 seconds instead of
> the ~9 minutes the slow probe accidentally provided. The RollBall
> fixup allows modules to block PHY access for up to 25 seconds after
> insertion, so this should be sufficient.
> Tested on a Banana Pi BPI-R4 with a bridge-less "OEM SFP-10G-T" rev A
> module and a genuine rev 02 module with an AQR113C: the rev A module
> links up at 10G 57 s after boot instead of over nine minutes, and the
> rev 02 module attaches its PHY as before.
> Suggested-by: Marek Behún <kabel@kernel.org>
> Signed-off-by: Daniel Pawlik <pawlik.dan@gmail.com>
> Link:
> https://lore.kernel.org/netdev/20260624084814.20972-1-petr.wozniak@gmail.com/
> ---
> Replaces the revision-quirk approach of v4 with the generic check
> suggested by Marek Behún, using the PHY ID register per his and Andrew
> Lunn's review. This also drops the sfp_strlen() move from v4, making
> this a single patch.
> v4:
> https://lore.kernel.org/netdev/20261121091235.1447291-1-pawlik.dan@gmail.com/
> v3:
> https://lore.kernel.org/netdev/20261120063756.3677554-1-pawlik.dan@gmail.com/
> v2:
> https://lore.kernel.org/netdev/20261118221450.1764790-1-pawlik.dan@gmail.com/
> v1:
> https://lore.kernel.org/netdev/20261116093605.294365-1-pawlik.dan@gmail.com/
> ---
> drivers/net/phy/sfp.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
> diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
> index 915156743701..9582dd21aee8 100644
> --- a/drivers/net/phy/sfp.c
> +++ b/drivers/net/phy/sfp.c
> @@ -2249,6 +2249,7 @@ static int sfp_sm_add_mdio_bus(struct sfp *sfp)
> static int sfp_sm_probe_for_phy(struct sfp *sfp)
> {
> int err = 0;
> + int ret;
> switch (sfp->mdio_protocol) {
> case MDIO_I2C_NONE:
> @@ -2263,6 +2264,16 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp)
> break;
> case MDIO_I2C_ROLLBALL:
> + /* mdio-i2c reports a RollBall command timeout as 0xffff, both
> + * for a bridge that is still booting and for a module without
> + * a bridge. Retry after one cheap read instead of a full PHY
> + * probe, which times out on every register under rtnl_lock.
> + */
> + ret = mdiobus_c45_read(sfp->i2c_mii, SFP_PHY_ADDR_ROLLBALL,
> + MDIO_MMD_PMAPMD, MII_PHYSID1);
> + if (ret == 0xffff)
> + return -ENODEV;
> +
ret < 0 from mdiobus_c45_read() is ignored and falls through to
sfp_sm_probe_phy(). On a persistent I2C error (e.g. module
hot-unplugged during
the retry window or an I2C bus timeout in i2c_rollball_mii_cmd()), this
triggers
a redundant failing I2C transfer under rtnl_lock; on a transient I2C
error on a
bridge-less or booting module, it bypasses the 0xffff guard and falls
straight
into the ~21 s full C45 scan.
Handle ret < 0 explicitly. Note that sfp_sm_main() transitions to
SFP_S_FAIL
without logging on non--ENODEV errors and treats -ENODEV as retryable
(and some
I2C controller drivers can return -ENODEV), whereas
get_phy_c45_devs_in_pkg()
maps all negative reads to -EIO and sfp_sm_probe_phy() logs via
dev_err():
if (ret < 0) {
dev_err(sfp->dev, "mdiobus read returned %pe\n", ERR_PTR(ret));
return -EIO;
}
> err = sfp_sm_probe_phy(sfp, SFP_PHY_ADDR_ROLLBALL, true);
> break;
> }
> --
> 2.56.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 1:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 16:54 [PATCH net-next v5] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe Daniel Pawlik
2026-12-03 8:24 ` Daniel Pawlik
2026-12-04 1:39 ` willemb
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox