🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26843

[PATCH net-next v6] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe

#26843
From: Daniel Pawlik
Date: Fri, 04 Dec 2026 09:34
100 lines
15148 bytes
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. This relies on the PMA/PMD
identifier, which Clause 45 makes mandatory, being readable once the
bridge is up, as it is on the RollBall PHYs seen so far, such as the
AQR113C and RTL8221B.

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/

---

Changes in v6:
- Handle a negative return from the MDIO read: log it and return -EIO,
  as the full PHY probe does, instead of falling through to the full
  probe (Willem de Bruijn).
- State in the commit message that the check relies on the PMA/PMD
  identifier being readable once the bridge is up.

Changes in v5:
- Replace 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.

v5: https://lore.kernel.org/netdev/20261125165417.3422927-1-pawlik.dan@gmail.com/
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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index 915156743701..1253beba53d7 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,21 @@ 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;
+		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
Technical Details
Message-ID: <20261204093408.1391147-1-pawlik.dan@gmail.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377219-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377219-linux-kernel-netdev=dewy.ru
From: pawlik.dan@gmail.com (Daniel Pawlik)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v6] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe
Date: Fri,  4 Dec 2026 10:34:08 +0100
Organization: Usenet Network
Message-ID: <20261204093408.1391147-1-pawlik.dan@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2727671"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XHNEbXMENcC+kjaVmbBjVm+o/xk= sha256:U70ifx3EiStTubZi41QGtFwZFkqfY0uq29SraQw/K6g=
	sha1:GwMhkAYDkCeGYpjmDdivUaZHKt4= sha256:XoADFMTTWA9ymfDV/Eq8gg7LFIkTPI620w+MIcM0toM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E70BC117B75; Fri,  4 Dec 2026 12:34:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.297
X-Spam-Status: No, score=-3.297 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id u78upLJG7fve;
	Fri,  4 Dec 2026 12:34:43 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377219-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8FB29117B80; Fri,  4 Dec 2026 12:34:34 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id CF69928F34; Fri,  4 Dec 2026 09:34:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796376867;
	b=4DTzoukC5D6yP7Y+K7yfbSNRJsvnpcopdlEjUm62jJsLNgv49MyNa+R7NKSSiOdk/yEg
	 SXgnogNcwR92O7ELoUgQMISemJ3Rn8eAxF39eqmcMbfrzvd43WjsyHG+RP8m/E0XzkIJu
	 7rBhARXz4vONJKFYeiDCPGJAn+qSBloQFk75a27Bp34rqV2QSgAXIRJHv4T0mMEcT6ZXm
	 5OySb0IqjITpTIuVhxkqQ3uqkF+m4wK1Ts98GET96t4rBlgRORr8jVTqgeLWBarhAfDYT
	 0jaBrbKsziTJDbumXMHnIAlxcHyowR1nFYWY1PrloaDL9uDqMKxS2Vcvru/xiAxReLw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796376867;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=kZJbnZC/Ab41ryJ2GgqcQ8syooMKb39xaqrYEIFS+BU=;
	b=hIdI3DoV1KPHWsKHVrrxs8Mdv+A2ZCQrLP32Au+UVXJdlnudZmW+iaPar0hwV9UtIjxH
	 SkKaRV3Oppq6mn42zkiE8VJIT+NXrqJp77kGRQgAqAXz/zfFeeCFp/mBqSak5e7BAzxPk
	 tuRGce7paxrEgHQtS0D9eBtBsqvyRdq+22w7vcYVgRkPFkV4xDwlOHsy1GAIb59fYRQOC
	 IdE5gPSW8tUkTQWlpgQgNxN02kdEekYwJKA+uz+9yettCqhGFHJ8qo95U8snI4S/GkQS/
	 pe/RtIMC+mmm8WJA6hLMTSxlr6UnhY6HOKJRSOAXx2ITuCVyJclKcJ4hI1N1iRZZu+w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XT7Nm6YC;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 12BF2606A333;
	Fri,  4 Dec 2026 09:34:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XT7Nm6YC
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.44
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796376866;
	b=1hhBIIWYb4YrgJuSTf1hsnd7UfIzUY0uOe9y/B3zsJFP/ioxFi2Zbj1IG4Ammzbx+2p6
	 mxfRJmAk3h2Sfp1d1xxLUICKeqL/WMozukRqUmVMFC9XO8Sw0JX6LZRxAmVMdQ0auxNzi
	 VDeWIZ34XARrmGTBz+lIdtM6J91CXy5IBVh0yocZ5MoRLgHafNttkKMpzScc7vSj/n86l
	 iorOTKIqIuj3PAufXbLrJ7v6c2MzrKHuEIlBs18qyQiNTcrU6Y55pHZxdlHUcBJW4FiX7
	 7NKGBMWAtsGMssTd93k1wIxNl0V2vf4RcoZ7G1HKfc19clzizGkr4tY0Tmkb3b54JpA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796376866;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=kZJbnZC/Ab41ryJ2GgqcQ8syooMKb39xaqrYEIFS+BU=;
	b=EZbCeKkxJ1lMXki++KA9snl4F3MZt1YSClINYeSofokiNc0T2kMEVKbtRNHd+Kpd8exl
	 sCaxMoVXia5SqgEBz53tZbsCZ+PrASxFc/7HDhmEsMxVaVD5a3In165Q+xuzRIC43P3SV
	 Dy+wWaHCvHxcIzJJzPuYr1yuq901ej9/E5AorFyiR94c67Qa1NNRzRbQTRc9bSRhfQqKc
	 urDIMsuvBg7iEfw4LEvMqo8QZcNCLcpOoRK4FJ3Q/QOuED5MNq5AaJgmusxg7qCCzw0tb
	 kW99qmCx1XfA9WlnpCPs1iWnqp9bDw16FVh407UH63nTx4Rnx3ERPZKACwkKUFfAcEw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=XT7Nm6YC;
	arc=none smtp.remote-ip=209.85.208.44
X-Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2E4F606A322
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 09:34:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D2E4F606A322
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-6bb06dc1fffso860893a12.3
        for <netdev@vger.kernel.org>; Fri, 04 Dec 2026 01:34:25 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796376864; x=1796981664; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:mime-version:message-id:date
         :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=kZJbnZC/Ab41ryJ2GgqcQ8syooMKb39xaqrYEIFS+BU=;
        b=XT7Nm6YCQKN7vFa8mos765U2mpvmma8GmpIeLzna3j2A/OzazrBpU7d2jXeaqDoGZf
         W8PW0YTkzAwnfZLOejqUxpJbp3VAHFNoGJIMLFbf3iDOkubA8F6orUByarIPn0/66hfy
         qkWwNj515PdfnHXU0Gy78xERXMb0R0SqC1ulbaGd9PBqWaKGWKmEC/Qyj3BqB2Ia2Sj7
         k3f9SfMNcXaUIc9m4JDyVhUotBInZ7xqescpnhpsDotSaJDxYFvKgM1z3OQ0hDb+1sJQ
         oYCcymvv+IoH/SE87GGMVrQH5ZqA7rAZBPgqWxCxObCYUj4PBs3f0Hjp4KeYtHFidq2u
         MJEQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796376864; x=1796981664;
        h=content-transfer-encoding:content-type: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:content-type;
        bh=kZJbnZC/Ab41ryJ2GgqcQ8syooMKb39xaqrYEIFS+BU=;
        b=WS+mE0i+w8vYYkX/JRq4L82oYVVKcmCA7vOlrfTvvmtkgaifUIwnGWywIWp2+iwFWF
         fPrwz7z7HRmGmKwWsR2hMHBpxbGpOuxcgIbCPphbyuH3kgfJmyS5ePcMdxHKzeu3B1Jm
         RRZGoJWig5xOJkoqaqyDTZfZ0MbkD90MlHzv2I1lcpAopdN6r/Qh9Tcjr9UeT2S9pDru
         YkMrREOSFDceueI+C4Aw3H7bpGQ+9bnlL7t/+z6qsO5fT/Q8Yw+dXG6amxJDoWw8Lkdd
         IyxAi4bDQHPBEdXLaBVsvlW7bChADeyLGrxt+HzwbEdXnMU7d9a/cxV87XGwCdsZBje1
         oqow==
X-Gm-Message-State: APuU4Z9pnH70ay1orVgMqQDvBQSPQ20Dwiqse+8vzQ1XeVYSzhatg5UI
	Q3JHu8pT4x600/PUg5cbr9b2SKZ2sP2tlHqAEP1Bx+Lm6/IzULzR+V2p
X-Gm-Gg: AZFdTZcmbsy3TcDQE5hxy/IYFBcfbKbJkxN+N/OYDyRdudnIJrWMKD+3fdg7FRE9+yQ
	i4n1JubXakpGR5k2AYhOFHZ62i5yO2f+ee6cW9NvLpinI8jVh6BT8ha00HcfVAoNpiG9czJJ9Km
	gb+d/WTK3rRXhXt0UpJI69S1wHdPnC+XsxEbYbNfQEjVYNCemk0M9ARkJvkig3MvV8QSAFTyZqd
	VE6uucaa8BAOgSKI8TBVWHPt/Imc667+g+Y3m1AsJ/if1Zo0v87CvrM0pj7scne2w/K9FeI0BTC
	sFOj6Fk6XJ73DyYCKl4hJ8dPRm48+rk2NHFJ9nszeeX0Lb5aTR45yLHlBtMnwulYZdlRcch4eQl
	dZVsu8un+6zbIkiwjq/IJUIcFF3WMOmh8wOh6OKFDBbZKxuGPsapvqmtkQ9aXgTJAjM0+QmFeID
	i6yxRBNUVgctnr0mC+wv03Zs2rUSVRtQkwlGkeoGOa0kpg5gh7Ne4IMzWIhZnxOhIJP+PLEbvqA
	9TOqBI/pu6FW3Dm4VDFB4aHbWM9Tpf62ufv9B6JI0gOxV2hANPutyW4jQhqk78YCAvS9AKEI4JT
	ghABEAqYex4egT/gqwXSwsJcKLTfyri19JUiGNEwP+9k+vv6kO3nGGOtvHVwudIQ5HNiCTpv61+
	6V7ICG1KzCrXMKUoQykpKxJLSuZT3d8QIvTXuOHk4NQ8Mpwwoag0t
X-Received: by 2002:a05:6402:2744:b0:6bc:79c6:1ad5 with SMTP id 4fb4d7f45d1cf-6bcbee53323mr756866a12.0.1796376863834;
        Fri, 04 Dec 2026 01:34:23 -0800 (PST)
X-Received: from dpawlik-thinkpadp1gen7.rmtpl.csb ([46.205.218.157])
        by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6bcbbeb3f85sm707507a12.4.2026.12.04.01.34.22
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Fri, 04 Dec 2026 01:34:23 -0800 (PST)
X-Cc: netdev@vger.kernel.org,
	willemb@google.com,
	andrew+netdev@lunn.ch,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	petr.wozniak@gmail.com,
	maxime.chevallier@bootlin.com,
	olek2@wp.pl,
	szymon.datko@gmail.com,
	Daniel Pawlik <pawlik.dan@gmail.com>
X-Mailer: git-send-email 2.56.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list