From nobody Mon Jun 8 19:54:34 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 D1AB730F535 for ; Wed, 27 May 2026 05:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779860357; cv=none; b=TLlrISgD14Sj3NU+QtmDt1KqVeGy97NnDQbE2FTqBcymbCjUoeM0qNF3XhZ3ku1mlfcn5XNWMkISaTE5JRtgoRQuivIeuHVk9p25027A/23sPcikyF+vyHTt7VEjsVQa0z09xan70jsBm1OyU8U4Mn6ACv0X7uXR207Ovi5HxtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779860357; c=relaxed/simple; bh=y3oSGRmbfAOBxPqPXDgnXVLkFVS7op/0FXe3VArCSJA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Pb2dsCuoEoafcMMtpkHygP3kd2JTBJKygNl1/dbVAJ1xRGGqRMUVzceNwDbCnrh/cL9k7I4Vcfyw63RS9zuvmZRj+aJMgEA190nmPY1Jt5wFZFKt72Ff6q8jv1l362TNXLSUooKfL8BRoUiSvvYXIs+TaRqzzNxBtImTaZUM6FA= 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=i2VJFuwu; arc=none smtp.client-ip=209.85.128.48 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="i2VJFuwu" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4891e5b9c1fso97064265e9.2 for ; Tue, 26 May 2026 22:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779860353; x=1780465153; 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=3mRI8mly2NbR54vqkvITGVjBSIViH+A5ziT0lYtjbs8=; b=i2VJFuwu2IPm9FWO+YD56lYtJDcMkOUCu6IvHYFMRA0Iofwm7sUcC05rVd8JcJ/uDK R/yulY9jfepKL7N8SOTJ8BZYeqDAWGWSLq4UnBCUmi3+nh5/KawZ5XaPqklC3j4p1lBO sgdwnoONqevf800XXm8a6qU26i8Vm1/myKcgEWgiaUhdccI5zvm6zE9jaagSvtWpZ53p VblijiMGUnJjDAwRX+eorsAjFhG7kY2Z4MySOF5LcSNYr9xEjKe/2ajsJ+pHTJt5mMOX nArByNOfF0Iv67Kn8lzvLWNaoxgli9LbZGYk69++jRw1SSG74D5mDyVBQNZWKiPOo88j 8pAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779860353; x=1780465153; 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=3mRI8mly2NbR54vqkvITGVjBSIViH+A5ziT0lYtjbs8=; b=olR4LooN16Qdy/5XEo8cC3J5vkZaOA913af9rh8pWWHR9sprtCbvMmgg+u8nRzQ9s6 K1by7MDrcQ9u03MxTfAUKJ4w3+HepKRVRYGNFbER5FKYVuWCjRxPqfGXau4vgQ0xHSwp cIK4SFmRlMclCaN5dBxMn+ZynXTOfgTIsApENwMozeuDQRbRTp5NbkFZLZzzGKx0TZUk jUh5Pz0LvlSq0zcBpDpEdaGc1GOU0igjt3vNk5ckzQfaH1gIoHpgtvZ46aQCioUvhQse 90jdC4/vT2yyqD83zawQ9ICWqbkDajHdpEwHdKk2SmwfXaH2XsroJSywFWTQ9zDzHp8e HXxQ== X-Forwarded-Encrypted: i=1; AFNElJ8rBYIovSFM6egn0WnyRbyOENAjEDcP1+udTx1IYhPQztgDfTRMO0l/BU9ivggjDrn2Emva3RhFNQcl+Yc=@vger.kernel.org X-Gm-Message-State: AOJu0YzKZgEDzaC8KlsruUbxjFUNVLSNhgWLUsCae4Cp4Ae/fEdlWyji aCptUCbVVf4v6fI+xUDiYW1Y6/SDMZNMtexe7hyOQqFtNIGUbg2EjWJ8 X-Gm-Gg: Acq92OFGURBlst9jLeS5u76Ke/pOWKgoGJo/zS9xsB0zG1/3fyDixqPw8ZkpTWm9/ng EK6/Q0zanCpriiegZxGGiRcn8F8pslQkhau3nbI0ThVkilf81oHjWu66xCILJxJVuOCGfwkVL2O qwb0He9dh5ZoDJLWAskGuG0Is2D2gqhVzI4W0URn4kftobS8ESulGNvB50ByXroQ4cePjkWM8u+ ptQbCjkjtGXjAaTR8JBpuy2OMWDFQJjHrmFINAb+yZgM4RqsNr9LzadEhoTwTNI4omz+e0CaMDy FzVXHiaNieDmQ71DverM7NVqdCPSK+Y0xf4ya/9mrjdvIfnt3iSEep1Pye0xOdxmIasxswJDBRZ PeC2G4J33jBDCo0k3o/a6traOOfW7wMOhAZUSpHueyovjWvfPV+bNFNwg2XVY/Y7hbCEhHtSYuk J+ldPZShEem0AWh4f1P2ASd4g88yAPoJbOit5oyyfsbYlvAE8lvL5SNWfqcl9hJ7K1a/IV4An+Y VmxkcoOcDNP8WfJkacCqrI0We89tRdnix4npk8= X-Received: by 2002:a05:600c:37c8:b0:48f:e230:8cad with SMTP id 5b1f17b1804b1-49042ae0201mr391034895e9.33.1779860353006; Tue, 26 May 2026 22:39:13 -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 5b1f17b1804b1-490838b2b9fsm6502285e9.0.2026.05.26.22.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 22:39:12 -0700 (PDT) From: Petr Wozniak To: netdev@vger.kernel.org Cc: maxime.chevallier@bootlin.com, bjorn@mork.no, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, jan@3e8.eu, Petr Wozniak Subject: [PATCH net-next v8] net: phy: sfp: probe for RollBall I2C-to-MDIO bridge in mdio-i2c Date: Wed, 27 May 2026 07:39:09 +0200 Message-ID: <20260527053909.2118-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 v7 (feedback from Jakub Kicinski): - Rebased on current net-next; no functional changes Changes since v6 (feedback from Maxime Chevallier): - Remove redundant if (ret) checks after i2c_transfer_rollball() calls; the function never returns a positive value (always 0 or negative), so these branches were dead code 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 | 59 ++++++++++++++++++++++++++++++++----- drivers/net/phy/sfp.c | 14 +++++++-- 2 files changed, 63 insertions(+), 10 deletions(-) diff --git a/drivers/net/mdio/mdio-i2c.c b/drivers/net/mdio/mdio-i2c.c index ed20352a5..b88f63234 100644 --- a/drivers/net/mdio/mdio-i2c.c +++ b/drivers/net/mdio/mdio-i2c.c @@ -419,6 +419,50 @@ static int i2c_mii_write_rollball(struct mii_bus *bus,= int phy_id, int devad, 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; + + 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 (result =3D=3D ROLLBALL_CMD_DONE) + return 0; + } + + return -ENODEV; +} + static int i2c_mii_init_rollball(struct i2c_adapter *i2c) { struct i2c_msg msg; @@ -438,11 +482,11 @@ static int i2c_mii_init_rollball(struct i2c_adapter *= i2c) =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 static bool mdio_i2c_check_functionality(struct i2c_adapter *i2c, @@ -487,9 +531,10 @@ struct mii_bus *mdio_i2c_alloc(struct device *parent, = struct i2c_adapter *i2c, 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); mdiobus_free(mii); return ERR_PTR(ret); } diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index bd970f753..7b2c20d78 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -579,6 +579,7 @@ static const struct sfp_quirk sfp_quirks[] =3D { // 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), =20 + 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), @@ -2022,10 +2023,17 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned = int next_state, bool warn) =20 static int sfp_sm_add_mdio_bus(struct sfp *sfp) { - 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) { + 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 --=20 2.51.0