From nobody Sun May 24 21:38:45 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 359A13655F8 for ; Thu, 21 May 2026 02:58:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779332283; cv=none; b=UILDFU8kS+lvg7fgQTT3ZVAGqFXnnBQcHYHuKusTnGJnaq/u60JzSeHIaM22HuunT9Qq9j4mQuZPI/UhgUrTzVZjsij7fcu3XEcKKKUt0UXZtguLF/fzcseuOpMiK89Qkwnpcf9skRT8x9ztuKcgOYVgG7nO/EEam+2TXuIvRd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779332283; c=relaxed/simple; bh=ohfN6xnsyyhwKmHo97zfhgAs3Ize1J6t/BwHoxDoQ1s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lTnGHccmI8GXyJMJ03kYz9JSxMIjq6zRDtuZxXQOIM75agz2YZ/eSnrxWyQzDYphAEW8o8biUqVqg6qima1VGqdFABPK2r7Im9aRvT3nKfAt41Saw11NoXMbj4cJjQhj2USGTgSbtIZ2cv6VnGqbk1oi8uqpOv6ISzTrhMVbH6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RxhsNqWl; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RxhsNqWl" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-441209fb77eso3531744f8f.1 for ; Wed, 20 May 2026 19:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779332281; x=1779937081; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b6wzXBilwDaEqTrdj11rHbLJY7P7PclyJf2gWIGAYeg=; b=RxhsNqWlZBsF7HSKv8fH4r8ATYV22uI6hHJ4l0MS7Vs3K3oRtE1dMt698FemiA0UDg A4c59agXp4QiLj3+ckBdSFCegUU39ire4jz4YS75g1PsXLKUk5p3D9szlTAKuxAr9YmY wDXJ6iL/Hb6Rv17HdSpOotVstb33Fx2saOK1C3YZtEW+3nABRhebUd8CSdt/nL8qzq+f YDQ1jbV7Cua3ov0CLlxIzImjRVGlLBekTss4y/2cnrrXzBA4DOSlfjikt4WBoYLNS4YU iw5X3dd+NmsNpiSpdej4VnGvK0F3YpQhhL2wlesM07qIewXz18z0tl/f2IA41Bv7xoqj ihTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779332281; x=1779937081; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b6wzXBilwDaEqTrdj11rHbLJY7P7PclyJf2gWIGAYeg=; b=MdyhpNjhPbg+TbOwyQdJy6q3KzgYcBXIJoX4VSowsOH/VL5Z3FAUw14bi76B8vt1Aq /wvYI5UCL5E9WH4SY5l3KnzHfiqkQkOKwdEwNlxTiOgsopIcZuj56AWHk9cUhQ8KxbDL Jzj/51HWz18POEEdULymZTcrSLEOXvBXZtQgOgMAE0CVQ69G/1yeIUVzhWxuVbS5NIkh SqpoCA9EhLDoI24b6FSZZlxDd15yGRwQ7GbwRQ/HszHEgvGdLbkzBOKu25xe5Opia54M m66oQI+HHh1mwR6miENaVojVjDRF8/dEolQ/5+LGNQC7uCzO9GYPae8SnB+lfGkAmOM/ nP6Q== X-Gm-Message-State: AOJu0Yxmo+DIKvFud541P7sO9BzV0AUl5M6tEYY2VjsI2QLoDbqb3800 woZaMS157GpJgy79DqSeOFyyxYYQs5ULP1Oxlk32V8mWw8KrlQypwv5t X-Gm-Gg: Acq92OGFyPNRTMKIhZyhKcPQu3RQirMv46I+DTwXvbWsROTLXMfckHJTyfmLYHjfxVi CfMqDhpsOY9FI3dTdgkr2+Tr8uwvdpfluK1tZKIm+lu79Oa2tBMMOH96+NpeOFvl+5wM4PvGqc/ Ri4boml1lbIrgya40x1ylckzQ4jr8c+3BG5gJ6ft68UwtIsX7BaBdBdROVC0cpMnjl7lm6zoLbu Yt+TJoNpl2/SV7+IMhypD1t8no1s1/RlvhN0eM4TURSbfLD5Ld3O6jM+7CANJRRO1bPdVPGL9gD udFIA+yn/A729lQcFTq8Rsi/iDwfIqB6yFJ4r2Duh22L+oZmfKy3PHFD0Q3Y4Ynm8zeNPyUh8m2 EGH7ccRSfbihB0VEyKlm8f+t7Le20tmF8b+lFLRvQes90vDVVQQbtrJPo/lIzW0RpeDDckMQK6S rRnglkY9503VXiCulgO9y7ieAftao2s0W4jRtl3p5jUMSkWAOXXqNYNjqyaNSDhejcwZXvvlzDX 2XRlqZNJZnAm9nE6Q== X-Received: by 2002:a5d:6f10:0:b0:449:cd74:7432 with SMTP id ffacd0b85a97d-45ea34ab49bmr878157f8f.15.1779332280425; Wed, 20 May 2026 19:58:00 -0700 (PDT) Received: from localhost.localdomain (ip-89-176-136-191.bb.vodafone.cz. [89.176.136.191]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45da0a1a22csm58114198f8f.19.2026.05.20.19.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2026 19:57:58 -0700 (PDT) From: Petr Wozniak To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, maxime.chevallier@bootlin.com, bjorn@mork.no, linux-phy@lists.infradead.org, jan@3e8.eu Subject: [PATCH net-next v6] net: phy: sfp: probe for RollBall I2C-to-MDIO bridge in mdio-i2c Date: Thu, 21 May 2026 04:57:55 +0200 Message-ID: <20260521025755.24649-1-petr.wozniak@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The "OEM"/"SFP-10G-T" quirk entry in sfp_fixup_rollball_cc() unconditionally forces MDIO_I2C_ROLLBALL for all modules matching that vendor/part-number combination. This works for modules that genuinely implement a RollBall I2C-to-MDIO bridge, but silently breaks modules that share the same EEPROM strings without having such a bridge. The Realtek RTL8261BE-CG is one such module: a pure copper 10G SFP+ media converter with no I2C-to-MDIO bridge. Its EEPROM reports vendor=3D"OEM", part=3D"SFP-10G-T-I", and -- critically -- Vendor OUI 00:00:00, making OUI-based differentiation impossible. With MDIO_I2C_ROLLBALL forced, the module silently ACKs the unlock password write, the MDIO bus is created, but no PHY responds; the SFP state machine cycles through the RollBall PHY-probe retry window before reporting no PHY. Move the probe into i2c_mii_init_rollball() in mdio-i2c.c, where the RollBall protocol constants are already defined. After sending the unlock password, issue a CMD_READ and poll for CMD_DONE up to 200 ms (10 x 20 ms, matching the existing rollball poll tolerance). A genuine RollBall bridge asserts CMD_DONE within that window; modules without a bridge never do, so i2c_mii_init_rollball() returns -ENODEV. mdio_i2c_alloc() propagates -ENODEV to the caller to signal that no bridge is present and PHY probing should be skipped. sfp_sm_add_mdio_bus() catches -ENODEV and transitions sfp->mdio_protocol to MDIO_I2C_NONE so the rest of the state machine skips PHY probing for this module. Any I2C-level error (NACK, timeout) during the probe is also treated as -ENODEV: if the module does not respond at I2C address 0x51 at all, there is certainly no RollBall bridge there, and SFP initialization should not abort. The probe writes are safe with respect to SFP EEPROM integrity: only modules explicitly listed in the quirk table enter this path, and the RollBall password unlock write to 0x51 was already issued by i2c_mii_init_rollball() before the probe for all such modules. Any module without a device at 0x51 NACKs the transfer and is treated as -ENODEV. Add "OEM"/"SFP-10G-T-I" to the quirk table so RTL8261BE modules enter the probe path; genuine RollBall modules continue to work as before. Signed-off-by: Petr Wozniak Reviewed-by: Maxime Chevallier --- Changes since v5 (Sashiko AI review): - Treat I2C NACK/errors in i2c_mii_init_rollball() as -ENODEV so modules without a 0x51 EEPROM do not abort SFP initialization - Replace fixed 70 ms wait with 10 x 20 ms poll (total 200 ms), matching the existing i2c_rollball_mii_poll() tolerance and preventing false -ENODEV on slow RollBall bridges Changes since v4 (feedback from Maxime Chevallier): - Fix commit message: replace "stalls" with accurate description of the RollBall PHY-probe retry window - Fix variable declaration order in i2c_mii_probe_rollball() to follow reverse-xmas tree (descending line length) - Remove spurious alignment space on "SFP-10G-T" quirk entry - Document that -ENODEV from mdio_i2c_alloc() means no bridge present, PHY probing should be skipped Changes since v3 (feedback from Jakub Kicinski): - Drop spurious Tested-by: tag -- author and tester are the same person - Use PATCH net-next subject prefix - Move -ENODEV handling from sfp_i2c_mdiobus_create() into sfp_sm_add_mdio_bus() so bus-creation code does not mutate sfp->mdio_protocol; the state machine is the correct place for protocol-state transitions - Split combined variable declaration for clarity Changes since v2: - Compile-tested and hardware-tested on BPI-R4 (MT7988A, 6.12.87) - RTL8261BE (OEM/SFP-10G-T-I): probes MDIO_I2C_NONE, link Up 10Gbps - Genuine RollBall (OEM/SFP-10G-T): bridge detected, link Up 10Gbps drivers/net/mdio/mdio-i2c.c | 65 ++++++++++++++++++++++++++++++------ drivers/net/phy/sfp.c | 16 ++++++++-- 2 files changed, 68 insertions(+), 13 deletions(-) --- a/drivers/net/mdio/mdio-i2c.c +++ b/drivers/net/mdio/mdio-i2c.c @@ -352,6 +352,54 @@ return 0; } =20 +static int i2c_mii_probe_rollball(struct i2c_adapter *i2c) +{ + u8 data_buf[] =3D { ROLLBALL_DATA_ADDR, 0x01, 0x00, 0x00 }; + u8 cmd_buf[] =3D { ROLLBALL_CMD_ADDR, ROLLBALL_CMD_READ }; + u8 cmd_addr =3D ROLLBALL_CMD_ADDR; + struct i2c_msg msgs[2]; + u8 result; + int ret; + int i; + + msgs[0].addr =3D ROLLBALL_PHY_I2C_ADDR; + msgs[0].flags =3D 0; + msgs[0].len =3D sizeof(data_buf); + msgs[0].buf =3D data_buf; + msgs[1].addr =3D ROLLBALL_PHY_I2C_ADDR; + msgs[1].flags =3D 0; + msgs[1].len =3D sizeof(cmd_buf); + msgs[1].buf =3D cmd_buf; + + ret =3D i2c_transfer_rollball(i2c, msgs, ARRAY_SIZE(msgs)); + if (ret < 0) + return -ENODEV; + if (ret) + return ret; + + msgs[0].addr =3D ROLLBALL_PHY_I2C_ADDR; + msgs[0].flags =3D 0; + msgs[0].len =3D 1; + msgs[0].buf =3D &cmd_addr; + msgs[1].addr =3D ROLLBALL_PHY_I2C_ADDR; + msgs[1].flags =3D I2C_M_RD; + msgs[1].len =3D 1; + msgs[1].buf =3D &result; + + for (i =3D 0; i < 10; i++) { + msleep(20); + ret =3D i2c_transfer_rollball(i2c, msgs, ARRAY_SIZE(msgs)); + if (ret < 0) + return -ENODEV; + if (ret) + return ret; + if (result =3D=3D ROLLBALL_CMD_DONE) + return 0; + } + + return -ENODEV; +} + static int i2c_mii_init_rollball(struct i2c_adapter *i2c) { struct i2c_msg msg; @@ -371,11 +419,11 @@ =20 ret =3D i2c_transfer(i2c, &msg, 1); if (ret < 0) - return ret; - else if (ret !=3D 1) + return -ENODEV; + if (ret !=3D 1) return -EIO; - else - return 0; + + return i2c_mii_probe_rollball(i2c); } =20 struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *= i2c, @@ -399,9 +447,12 @@ case MDIO_I2C_ROLLBALL: ret =3D i2c_mii_init_rollball(i2c); if (ret < 0) { - dev_err(parent, - "Cannot initialize RollBall MDIO I2C protocol: %d\n", - ret); + if (ret !=3D -ENODEV) + dev_err(parent, + "Cannot initialize RollBall MDIO I2C protocol: %d\n", + ret); + /* -ENODEV propagates to caller: no bridge present, + * PHY probing should be skipped for this module. */ mdiobus_free(mii); return ERR_PTR(ret); } --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -607,6 +607,7 @@ SFP_QUIRK_S("TP-LINK", "TL-SM410U", sfp_quirk_oem_2_5g), =20 SFP_QUIRK_F("ETU", "ESP-T5-R", sfp_fixup_rollball_cc), + SFP_QUIRK_F("OEM", "SFP-10G-T-I", sfp_fixup_rollball), SFP_QUIRK_F("OEM", "SFP-10G-T", sfp_fixup_rollball_cc), 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), @@ -2029,10 +2030,18 @@ dev_info(sfp->dev, "probing phy device through the [%s] protocol\n", mdio_i2c_proto_type(sfp->mdio_protocol)); =20 - if (sfp->mdio_protocol !=3D MDIO_I2C_NONE) - return sfp_i2c_mdiobus_create(sfp); + int ret; =20 - return 0; + if (sfp->mdio_protocol =3D=3D MDIO_I2C_NONE) + return 0; + + ret =3D sfp_i2c_mdiobus_create(sfp); + if (ret =3D=3D -ENODEV) { + /* Probe confirmed no bridge present; skip PHY discovery. */ + sfp->mdio_protocol =3D MDIO_I2C_NONE; + return 0; + } + return ret; } =20 /* Probe a SFP for a PHY device if the module supports copper - the PHY -- 2.51.0