net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T
Subsystems (4)
v3 cover net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T
Some "OEM SFP-10G-T" copper modules have no RollBall I2C-to-MDIO bridge, but the SFP-10G-T quirk forces RollBall on all of them. The PHY probe then retries for over nine minutes under rtnl_lock before the module links up without a PHY. This series skips the PHY probe for the bridge-less revisions A and B, and leaves other revisions, which do have a bridge, unchanged.
Patch 1 moves sfp_strlen() so the fixup can use it, with no functional change. Patch 2 adds the fixup.
This does not re-introduce the generic RollBall bridge probe reverted in commit b521003c27eb ("Revert "net: phy: sfp: probe for RollBall I2C-to-MDIO bridge in mdio-i2c""): the probe path, its timeouts and the MDIO bus creation for genuine RollBall modules are untouched. Further bridge-less revisions of this part number may exist; they can be added once their lack of a bridge is confirmed on hardware.
Changes in v3:
- Target net-next and drop the Fixes: tag: rev A never worked without the stall, so this is not a regression (Andrew Lunn).
- Split the sfp_strlen() move into its own patch (Andrew Lunn).
Changes in v2:
- Match the vendor revision with sfp_strlen(), so NUL-padded revisions are accepted like the rest of the quirk matching.
- Spell out in the commit message how the rev B module reaches this quirk entry (its part number depends on the peer speed).
v2: https://lore.kernel.org/netdev/[email protected]/
v1: https://lore.kernel.org/netdev/[email protected]/
Daniel Pawlik (2):
net: sfp: move sfp_strlen() above the quirk fixups
net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T revisions A and
B
drivers/net/phy/sfp.c | 54 +++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-)
Signature · 1 line
2.56.1
PATCH v3 1/2 net: sfp: move sfp_strlen() above the quirk fixups
sfp_strlen() is defined after the quirk table, so the fixups that the table references cannot use it. Move it above the fixups so that the next patch can match a vendor revision with the same space and NUL padding rules as the vendor name and part number matching.
No functional change.
--- drivers/net/phy/sfp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
drivers/net/phy/sfp.c +14 -14
@@ -482,6 +482,20 @@ static void sfp_fixup_rollball_cc(struct sfp *sfp) sfp->id.base.extended_cc =SFF8024_ECC_10GBASE_T_SFI ; } +static size_t sfp_strlen (const char *str,size_t maxlen) +{ +size_t size, i; + +/* Trailing characters should be filled with space chars, but +* some manufacturers can't read SFF-8472 and use NUL. +*/ +for (i =0 , size =0 ; i < maxlen; i++) +if (str[i] !=' ' && str[i] !='\0' ) + size = i +1 ; + +return size; +} +static void sfp_quirk_2500basex (const struct sfp_eeprom_id *id,struct sfp_module_caps *caps) {
@@ -660,20 +674,6 @@ static const struct sfp_quirk sfp_quirks[] = { SFP_QUIRK_S("ZOERAX", "SFP-2.5G-T", sfp_quirk_oem_2_5g), }; -static size_t sfp_strlen (const char *str,size_t maxlen) -{ -size_t size, i; - -/* Trailing characters should be filled with space chars, but -* some manufacturers can't read SFF-8472 and use NUL. -*/ -for (i =0 , size =0 ; i < maxlen; i++) -if (str[i] !=' ' && str[i] !='\0' ) - size = i +1 ; - -return size; -} -static bool sfp_match (const char *qs,const char *str,size_t len,bool prefix) {size_t qs_len;
Signature · 1 line
2.56.1
Re: [PATCH net-next v3 1/2] net: sfp: move sfp_strlen() above the quirk fixups
Quoted 8 lines · Daniel Pawlik
sfp_strlen()is defined after the quirk table, so the fixups that the table references cannot use it. Move it above the fixups so that the next patch can match a vendor revision with the same space and NUL padding rules as the vendor name and part number matching.No functional change.
Signed-off-by Daniel Pawlik <[email protected]>
Andrew
PATCH v3 2/2 net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T revisions A and B
In reply to Daniel Pawlik"OEM SFP-10G-T" modules with vendor revision "A" have no RollBall I2C-to-MDIO bridge: page 3 of the 0x51 EEPROM passively echoes written bytes, so every RollBall command times out. With instrumented mdio-i2c, the CMD register reads back exactly the written command byte (0x02) forever, with no DONE and no I2C errors. 0x56 reads back all 0xff, so the PHY is not reachable at all. A genuine RollBall module with the same vendor and part number (revision "02", AQR113C PHY) on the same board answers DONE on the first poll and its PHY attaches within ~2 seconds. A rev B module with an RTL8261BE PHY, reported on the OpenWrt tracker, hits the same RollBall timeouts. The bridge probe added by commit 8fe125892f40 ("net: phy: sfp: probe for RollBall I2C-to-MDIO bridge in mdio-i2c"), since reverted, found no bridge on it, after which the module worked.
That module reaches this quirk entry only because its part number is "SFP-10G-T" at that point: it is a rate-adapting module which reports "SFP-10G-T" with a 2.5G or faster peer and "SFP-10G-T-I" with a 1G peer, and only the former matches this entry, which is the sole entry forcing RollBall on it. The "SFP-10G-T-I" variant matches no quirk and keeps the default behaviour either way.
Because the SFP-10G-T quirk forces RollBall, the kernel retries the PHY probe 25 times at ~21 seconds per attempt, i.e. for over nine minutes, before giving up and falling back to inband mode. 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: insertion and removal of a module in another cage is only processed after the current attempt ends. In one test, a module pulled from the other cage kept being polled by phylib until the attempt ended, triggering a WARN from phy_error_precise().
Give the SFP-10G-T entry its own fixup that skips the PHY probe for revisions "A" and "B", while keeping the forced extended compliance code so that the module still links up in 10GBASE-R inband mode as before. Other revisions keep the RollBall fixup unchanged.
Tested on a Banana Pi BPI-R4 with rev A and rev 02 modules: the rev A module links up at 10G ~16 s after insertion instead of over nine minutes, and the rev 02 module is unaffected. No rev B module was available for testing; its match is based on the report above.[1]
[1] https://github.com/openwrt/openwrt/pull/22910
--- drivers/net/phy/sfp.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/net/phy/sfp.c +25 -1
@@ -496,6 +496,30 @@ static size_t sfp_strlen(const char *str, size_t maxlen)return size; } +static void sfp_fixup_oem_10gt (struct sfp *sfp) +{ +char rev = sfp->id.base.vendor_rev[0 ]; + +/* Revisions A and B of this module have no RollBall I2C-to-MDIO +* bridge (on rev A, page 3 of the 0x51 EEPROM just echoes written +* bytes), so every RollBall command times out and the PHY probe +* keeps retrying for over nine minutes, holding rtnl_lock for ~20 +* seconds per attempt. The PHY is not accessible at all, so use the +* module without one. +*/ +if (sfp_strlen (sfp->id.base.vendor_rev,4 ) ==1 && + (rev =='A' || rev =='B' )) { +dev_info (sfp->dev, +"rev %c has no RollBall MDIO bridge, not probing for a PHY\n" , + rev); + sfp->mdio_protocol =MDIO_I2C_NONE ; + sfp->id.base.extended_cc =SFF8024_ECC_10GBASE_T_SFI ; +return ; + } + +sfp_fixup_rollball_cc (sfp); +} +static void sfp_quirk_2500basex (const struct sfp_eeprom_id *id,struct sfp_module_caps *caps) {
@@ -643,7 +667,7 @@ static const struct sfp_quirk sfp_quirks[] = {// OEM SFP-GE-T is a 1000Base-T module with broken TX_FAULT indicator SFP_QUIRK_F ("OEM" ,"SFP-GE-T" , sfp_fixup_ignore_tx_fault), -SFP_QUIRK_F ("OEM" ,"SFP-10G-T" , sfp_fixup_rollball_cc), +SFP_QUIRK_F ("OEM" ,"SFP-10G-T" , sfp_fixup_oem_10gt),SFP_QUIRK_S ("OEM" ,"SFP-2.5G-T" , sfp_quirk_oem_2_5g),SFP_QUIRK_S ("OEM" ,"SFP-2.5G-BX10-D" , sfp_quirk_2500basex), SFP_QUIRK_S("OEM", "SFP-2.5G-BX10-U", sfp_quirk_2500basex),
Signature · 1 line
2.56.1
Andrew Lunn
maintainerRe: [PATCH net-next v3 2/2] net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T revisions A and B
Quoted 6 lines
drivers/net/phy/sfp.c +6
-0+static void sfp_fixup_oem_10gt (struct sfp *sfp) +{ +char rev = sfp->id.base.vendor_rev[0 ]; + +/* Revisions A and B of this module have no RollBall I2C-to-MDIO +* bridge (on rev A, page 3 of the 0x51 EEPROM just echoes written
drivers/net/phy/sfp.c static size_t sfp_strlen(const char *str, size_t maxlen) · line 514
Quoted 10 lines
drivers/net/phy/sfp.c +10
-0+* bytes), so every RollBall command times out and the PHY probe +* keeps retrying for over nine minutes, holding rtnl_lock for ~20 +* seconds per attempt. The PHY is not accessible at all, so use the +* module without one. +*/ +if (sfp_strlen (sfp->id.base.vendor_rev,4 ) ==1 && + (rev =='A' || rev =='B' )) { +dev_info (sfp->dev, +"rev %c has no RollBall MDIO bridge, not probing for a PHY\n" , + rev);
Quirks don't print anything. Please change this to dev_debug(), or remove it.
Otherwise this looks good.
Andrew
Re: [PATCH net-next v3 2/2] net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T revisions A and B
pt., 20 lis 2026 o 13:56 Andrew Lunn <[email protected]> napisał(a):
Quoted 2 lines
Quirks don't print anything. Please change this to
dev_debug(), or remove it.
Will switch to dev_dbg() in v4, thanks.
Dan
pw-bot: cr
pt., 20 lis 2026 o 13:56 Andrew Lunn <[email protected]> napisał(a):
Quoted 25 lines
Quoted 7 lines
drivers/net/phy/sfp.c +6
-0+static void sfp_fixup_oem_10gt (struct sfp *sfp) +{ +char rev = sfp->id.base.vendor_rev[0 ]; + +/* Revisions A and B of this module have no RollBall I2C-to-MDIO +* bridge (on rev A, page 3 of the 0x51 EEPROM just echoes written drivers/net/phy/sfp.c static size_t sfp_strlen(const char *str, size_t maxlen) · line 514
Quoted 10 lines
drivers/net/phy/sfp.c +10
-0+* bytes), so every RollBall command times out and the PHY probe +* keeps retrying for over nine minutes, holding rtnl_lock for ~20 +* seconds per attempt. The PHY is not accessible at all, so use the +* module without one. +*/ +if (sfp_strlen (sfp->id.base.vendor_rev,4 ) ==1 && + (rev =='A' || rev =='B' )) { +dev_info (sfp->dev, +"rev %c has no RollBall MDIO bridge, not probing for a PHY\n" , + rev);Quirks don't print anything. Please change this to
dev_debug(), or remove it.Otherwise this looks good.
Andrew
[email protected]
AI reviewRe: [PATCH net-next v3 2/2] net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T revisions A and B
In reply to Daniel PawlikThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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] This is speculative.
- [Low] Missing Fixes: tag.
--
net: sfp: skip PHY probe on bridge-less OEM SFP-10G-T revisions A and B
This patch gives the "OEM"/"SFP-10G-T" quirk entry its own fixup. For a single-character vendor revision of "A" or "B", the fixup sets MDIO_I2C_NONE and forces the 10GBASE-T SFI extended compliance code, so the module comes up in 10GBASE-R inband mode and skips the RollBall PHY probe retries, which can take over nine minutes. All other revisions still get sfp_fixup_rollball_cc().
Quoted 12 lines
drivers/net/phy/sfp.c +4
-0@@ -496,6 +496,30 @@ static size_t sfp_strlen(const char *str, size_t maxlen)return size; } +static void sfp_fixup_oem_10gt (struct sfp *sfp) +{ +char rev = sfp->id.base.vendor_rev[0 ]; +
[ ... ]
drivers/net/phy/sfp.c static size_t sfp_strlen(const char *str, size_t maxlen) · line 515
Quoted 6 lines
drivers/net/phy/sfp.c +6
-0+if (sfp_strlen (sfp->id.base.vendor_rev,4 ) ==1 && + (rev =='A' || rev =='B' )) { +dev_info (sfp->dev, +"rev %c has no RollBall MDIO bridge, not probing for a PHY\n" , + rev); + sfp->mdio_protocol =MDIO_I2C_NONE ;
[Severity: Medium]
This concern is speculative. Is a one-character vendor_rev, together with the vendor string "OEM", enough to conclude that a module has no RollBall bridge?
"OEM" is a placeholder vendor name that many unrelated manufacturers use, and "A" and "B" are very common revision values. With MDIO_I2C_NONE set here, sfp_sm_add_mdio_bus() creates no MDIO bus, and sfp_sm_probe_for_phy() takes this path:
case MDIO_I2C_NONE:
break;So no PHY is ever probed or attached.
Commit 324e88cbe3b7, which added the original OEM/SFP-10G-T RollBall quirk for RollBall/Hilink modules, does not record which revision it was tested with. The rev B match is based only on the OpenWrt report, since no rev B module was available for testing.
If an OEM/SFP-10G-T rev A or rev B module with a working RollBall bridge does exist, it had its PHY attached before this patch, and after it the PHY is never probed. On a module that does not rate-adapt, could a copper link below 10G then come up with a host interface that does not match the PHY's system-side mode?
The patch does narrow the match compared with the old quirk. The earlier runtime bridge probe from commit 8fe125892f40 was also reverted.
Could the match use something more specific than the revision letter, or could a missing bridge be detected some other way?
Quoted 6 lines
drivers/net/phy/sfp.c +6
-0+ sfp->id.base.extended_cc =SFF8024_ECC_10GBASE_T_SFI ; +return ; + } + +sfp_fixup_rollball_cc (sfp); +}
[ ... ]
drivers/net/phy/sfp.c static const struct sfp_quirk sfp_quirks[] = { · line 670
Quoted 6 lines
drivers/net/phy/sfp.c +1
-1@@ -643,7 +667,7 @@ static const struct sfp_quirk sfp_quirks[] = {// OEM SFP-GE-T is a 1000Base-T module with broken TX_FAULT indicator SFP_QUIRK_F ("OEM" ,"SFP-GE-T" , sfp_fixup_ignore_tx_fault), - SFP_QUIRK_F("OEM", "SFP-10G-T", sfp_fixup_rollball_cc), + SFP_QUIRK_F("OEM", "SFP-10G-T", sfp_fixup_oem_10gt),
[Severity: Low]
Should this patch carry a Fixes: tag?
The stall comes from this quirk entry, which forces MDIO_I2C_ROLLBALL with a 1 second phy_t_retry on every OEM SFP-10G-T module. SFP_S_INIT sets sm_phy_retries to R_PHY_RETRY (25), and SFP_S_INIT_PHY keeps retrying sfp_sm_probe_for_phy() while it returns -ENODEV.
The quirk line was added by commit 324e88cbe3b7. Something like this might work:
Quoted 1 line
drivers/net/phy/sfp.c +0
-0SFP_QUIRK_S("OEM", "SFP-2.5G-T", sfp_quirk_oem_2_5g),
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120063756.3677554-1-pawlik.dan%40gmail.com