From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796566051; b=TKPVRI8lUrQUnOjVLI6WvDe2RDnNukVEzrTqMh5wWSJbRww5IFChwrG2FzfgKjw/7E2/ RIoNmVZnZ0ttwZXGq9eMdVJXR/dWYM8BMbom+rdbB5DjhG53jZhI8uw7qvNo4+F2qYK2y XWpwpbRhnGxmvkiduyfEn0jYGY8G8YrpwF1i3KQCa3JXuHlVPoXbjHWRXWxgpxjDHfhr3 0HI1z8921KChzqC8dYJdbOSiybzhYre2wY5DXMQ4+qaGazhsU+2FXEoTZOPPWa5u0CIeF XsJhpJnBbj3SkYBGJS/vO+EbvvEqvc/k0JYPSbViTi3Gc2CwA6fm7l2aP/LYJGkcbTA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796566051; 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=w0KO6t8qMbelUppWskK1lJv2CL1BPjhuSa0JQMjUYOA=; b=ptj77vFv9gZfLKYeV1H4DeO3ASJSoPOd3mjgWDAnwgfqJi8ZKenASz6EYscQsqhe1LUh uBrrYGEqUjYrQPJhXWVEEF7Qnqmzu8BiJS54HsZpn5snwlKRpIV6j3t+1Lv1KFMwCMXEB uM7AppTIOfdz22gCALZVjZj3/R3lSVzxxGZ/qXesdHYSTP2iLmG4HeJZZudmCgXXLrOjA fO03ypl8nqpEt4Yn9ZCEEJpN6jvNk8PcKIc5xeH+4LLdhkFaVm8Rt2wr6lIq1SGrCBls0 FOwyt6+OaQwzMdHjVhzJb8pw2KEwKrxa5P4d5Nf6EqxYf+Iud08LsLX29Qppc8961Rg== 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="xs5WYPY/"; arc=none smtp.remote-ip=209.85.128.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 0E9BC606A322 for ; Sun, 6 Dec 2026 14:07:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0E9BC606A322 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.a=rsa-sha256 header.s=20260707 header.b=xs5WYPY/ Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso28420475e9.1 for ; Sun, 06 Dec 2026 06:07:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796566048; x=1797170848; 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=w0KO6t8qMbelUppWskK1lJv2CL1BPjhuSa0JQMjUYOA=; b=xs5WYPY/f/T2BH7dW2VrsyjG3KK8Z8msFaBLpVJrEgavh8e1fgrRGSPZzMhwEOzcHW U+ij+yWYicxtnGk9GwWhJ8KVc7gXf9l7DPCWh966scgpVSpJ994/QcoP/tXTO9LDMIo/ lcaFc7CIyPnzQtbpwvJNsrpE2bG32jg+mfk6+peRX1clOVCM+xgGjDuw1E8uYH1CIo5T 3QtqBKWlVizgQ4P729J28mIKfhJml4NPpa4RsKsbuhY3XPInbjh+vRY67tju5WJVJZtd T5OzCoS2anxmWl2smnxuuefsJMHUmJK6M4x/yW25g23yuDJkgivNNiHp10gW8WreR4TL h9Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796566048; x=1797170848; 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=w0KO6t8qMbelUppWskK1lJv2CL1BPjhuSa0JQMjUYOA=; b=oiv+VPkep4kQgslunDNbAsHC3UBcxevQ9FuwUTuCGm3jsUFPWHOCBikAGbaxnCmohT nUNatLq6KHup7JP+Qj9txtSJHQ55kOd9NGMGZ8FHL5bauwcQgPOsLdl3h59qlEpRaass GE93iLhr3e59nBpbNdH/g1axBIIb7dpow+Nz0Jbby+E2ZWDpnOs5sJSW7NG/UlLG+iqB /ueJkU+KaVrMCpS7xu2v+N35SrlGbCQZlnmbgTcQ4P75MSsqpCxv54ddETm3AJUh60Az BqRTydv/ECX6yFC5I4hbyu9CXfhIsr4RTX1Xok7w2cBNUby8yY3ZuPmTRLm9qvOQ90Pk wmUQ== X-Gm-Message-State: APuU4Z/Y/ZCYjICUiQSb6NpN5nZLjb5sz9Y4VlGO18+oE0k+DQJNi9NY F5x30K5WMEp5mv8gBJIxX8wFWto1uehXhWi3CIvGQQFGAC7UAPyJ8oAB X-Gm-Gg: AZFdTZeMiW+BRs8CbWPoFwVWkYvid+xl5vXeytM3+QWyIuAXLwbNPOMbddLA2Bl0TIs XAGhejEeG3+Q/Njhko+koXYYeRG7ttr76lUu3MvMQu9ZSKH7dCEsL9BQ0SxFn3WeWSiqkIkiBEz cabPKQiFHrGcxlOTELDieD+ovPN5kBBIg32fVqJhnQGLDvKOY8hgINjveIAlh3WLTeW24MyzM0j wrTY7867AIwtB5Uz3MImWJH2Nnyc6dM/sj/SHrEUNRj+m0PVuvhHp4zWXW8zJ11taD5P3D5LG5a thL6YzFbGNIGJFg6k9yjlAidRnmiFFH/vAcfyUZICPjA1AdePHMJf3VkmDMVPBEWc5MFnNLPHeo 8lga+f0/eMFrivIvBw+HzNIucecngmjuluFuvX9RFOaSrG5U+cAkEoGkFGK4zW2Y9ixZlGliit8 MpdBfqIZM1nA9Ri9nlTGNM5ujrfGQpjvNmNzj32Q+er+z+/132/sxsvan44DUpqlkRto12QEZ4Q a9YL4F3Ri+h/9XopTQ7eUB5mfxWSrIw1+bcXhRAQYUN7ilGMDHpm9aUQEs63dUT7a6MrOMoZtGN /Aym6FSxu3qEC9Bo/pb+ecSX48SkKyi69WVU/Uz2gjc7e+XaJETzOVfjx6jGT+SYPAmIZbxSJK0 GndRXGRrQ0IRh7e0RURDW/HJbRSIS+JXl3O+k5Jlf2eyI3d+jEX9Bou7WeklU56GaeOrTIMqwFw == X-Received: by 2002:a05:600c:3544:b0:4b7:6942:39bf with SMTP id 5b1f17b1804b1-4bbeb8bf627mr152496165e9.28.1796566048235; Sun, 06 Dec 2026 06:07:28 -0800 (PST) Received: from dpawlik-thinkpadp1gen7.rmtpl.csb ([46.205.218.238]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbea285924sm223802215e9.6.2026.12.06.06.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 06:07:27 -0800 (PST) From: Daniel Pawlik To: kabel@kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk 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 Subject: [PATCH net-next v7] net: sfp: probe RollBall bridge with one MDIO read before the PHY probe Date: Sun, 6 Dec 2026 15:07:11 +0100 Message-ID: <20261206140711.2753350-1-pawlik.dan@gmail.com> X-Mailer: git-send-email 2.56.1 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Read errors are handled like the first read in get_phy_c45_devs_in_pkg(): -EIO and -ENODEV mean that nothing answered and are retried, any other error fails the probe and is logged. 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 Signed-off-by: Daniel Pawlik Reviewed-by: Andrew Lunn Link: https://lore.kernel.org/netdev/20260624084814.20972-1-petr.wozniak@gmail.com/ --- Changes in v7: - Treat -EIO and -ENODEV from the read like 0xffff and retry, as get_phy_c45_devs_in_pkg() does since commit f333eb1ccd33 ("net: phy: Map C45 probe read errors to -ENODEV during bus scan"); fail only on other errors. Returning -EIO for every error, as v6 did, would move the module to SFP_S_FAIL on a transient error (Sashiko AI review). - Keep Andrew's Reviewed-by from v6: the change is limited to which read errors are retried. 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. v6: https://lore.kernel.org/netdev/20261204093408.1391147-1-pawlik.dan@gmail.com/ 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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 915156743701..0018e92d0663 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,23 @@ 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. + * Like get_phy_c45_devs_in_pkg(), treat -EIO and -ENODEV as + * nothing answering. + */ + ret = mdiobus_c45_read(sfp->i2c_mii, SFP_PHY_ADDR_ROLLBALL, + MDIO_MMD_PMAPMD, MII_PHYSID1); + if (ret == 0xffff || ret == -EIO || ret == -ENODEV) + 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