From nobody Mon Jun 8 08:30:34 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 D141E3C09E1 for ; Thu, 4 Jun 2026 18:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780596733; cv=none; b=tlp2XU3+djbqbbrfVmsApvdF6Drvwp3Iu8Or49pTVOT8xBfQC8OYVkmvouQQYtYi3v8uqhcnMsBLc8EIEsetn3Wcgp/F4RpFkpOoOnbmTgxiOqIBtIeeemBhgPIkp7KMqUJ1MYzFiYNwsPkzmktAXUAD+nGSJ4LIt+tpYkF0WBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780596733; c=relaxed/simple; bh=N1D5ItiD4ohqTNcYJwbRlDdv4O8t+O3dJ2OVB84yHyk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=QqFaD0PLCBix5qPwLgIpNq/3he9MPiZqUP+FPt1U8ysSHf1IQFdZ1ocWFyjOToCELT4x0QAVU4g/0IlwMmVj+a3nD7gqOT8UzIV3pGui+huWN28St/2m1Pl+SODiwUy1mCg3lXN2hhQDVz9OWgKbuJ7GpbdyjZG5jZKgdkcpot8= 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=PZ4WuWpw; arc=none smtp.client-ip=209.85.128.46 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="PZ4WuWpw" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-490b4a8e28bso9225275e9.1 for ; Thu, 04 Jun 2026 11:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780596730; x=1781201530; 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=MBV5F5ZFXu3LplEpSL9jXQmyH1fcjls/VQKnmrV9OCk=; b=PZ4WuWpwxLP3K5VoSZS44JtZc9g+i5+cL9kOoiWuDORAZTfKKhUkty5gwT8CqBQGAb 4iqq5pKknPw35if5iJEufsU2VP3ITbKI4jo+fN6pTeFfkEOpLMkvEWfO5lFBCC4RjHEo dRnfod3QWX7M32KO7hVlz0EXWRZZPxeYUyovscn/M8RMqiWZWXjOLR8lhunCedCIm9aF y3/rWJaNaEFYFH6I2UJOhohqJuVqcr76p8zI2OEb8B7sk1G30Dzc1ltBySMx98xJSyVO vONr4t3TZkhnxpBRdewnJvODDlen1n+Ef7xv990Brg4+mt8neWLHDzaa9bRDPnS9huI2 jlWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780596730; x=1781201530; 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=MBV5F5ZFXu3LplEpSL9jXQmyH1fcjls/VQKnmrV9OCk=; b=a6vEn7dVzbNSOX7x0CAdzUND1SofE7BKYr1aCOC90Rd4eq/uCfzrIkayZe4UeoMAej 7ha5Hj73XGRDNNi9pBhn5zuolOOPUnf/Cs/FVVxLrYZHEJJb7XuNXGhiWDB1t6f3q3Nr Njn9qIGHYRZC7I928KXuJdWgINzhSL3TPF+nZrrh3N9iFFPA9HNHayCd0bWrb1y7mxPh x+ldWFfvYpurQmirI5STVVKBbbIs38llY1TdAhfP5bAF4nKiWEV/ShV2h/9MWwQ3hSIN 4DRQj8Vg6VcuuUJEDbYVNPRs/SwWyZBKhT4IeO90WDMUo20HmeI98LZPjUI4tN6rCs9M aa/Q== X-Forwarded-Encrypted: i=1; AFNElJ+ps1xZLjLiljZ93fReIzJT/cdZ0nNRLXLKLJkM7YAWExH94sgJWX8wk7TwM0iS6n6fHTXuMeMmJOYOvtE=@vger.kernel.org X-Gm-Message-State: AOJu0YzBYLPsUdUzmwRmAV2d/8G4JFIwfjAGYw3hqxgYj0zK2GDHH2ii SuDOACnwo0Rrx4xmp6swoX7eWw+aFeNa8hqdcmRiXrBc22iqBYpXDyQJ X-Gm-Gg: Acq92OHezJE3hNJbieyQ5LfkaJQn6Sz3d4Ht7fcMXi1SVkAPULFn2wVxs+Oz0HMbYRf BAF9SBGR7scb7wqKLxsSs1NTU8M8Ih0E872kmF6xEx4zZImZxBfndwoM89a6TSy4+GFRV7Qxs7C TG2BDkj+CB4xNA92UNl22+H13aPGNL/RRX65d0P1omw7jqLsmATSmp8kmJ1X6L4iH1z87BqDIZB 2eOezM5kh9M85iLQZ5oIjLPQ+9uCiYFmFv15VPx3k30zxbTrz6hvAlTuH54geVdnI3TioTnvG9D awxK1/LiM2CT5SZ3qHdevOR+ObMdKw3NPsOCXe+R6EF05zQsIqmgqQ4MdVc9+XbQuPuNwg5oG5R p7vZd9XyC4+9GDY9mxniCH8HJYpoyGf0SLb0OH8xXYoZpbLIYX8Yk+oxzxo86WyPfpog1jo7+Ov YI8AGG7Z2/EvlLaAv0LMF7sS6ypyx3bsBtpz8Y+m/rf36LiyHEklyTlM5hCvkbrqFD5VvkpFVPb 9yonVPcLJUZiIon5e5A5CFSwen4 X-Received: by 2002:a05:600c:8b38:b0:48f:d5b8:5b07 with SMTP id 5b1f17b1804b1-490b5e51b8amr147464915e9.20.1780596729771; Thu, 04 Jun 2026 11:12:09 -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-490c159f51asm4304115e9.1.2026.06.04.11.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 11:12:09 -0700 (PDT) From: Petr Wozniak To: netdev@vger.kernel.org Cc: kuba@kernel.org, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, maxime.chevallier@bootlin.com, bjorn@mork.no, olek2@wp.pl, Petr Wozniak Subject: [PATCH net-next] net: phy: mdio-i2c: defer RollBall bridge probe to PHY discovery Date: Thu, 4 Jun 2026 20:12:06 +0200 Message-ID: <20260604181207.17468-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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable commit 8fe125892f40 ("net: phy: sfp: probe for RollBall I2C-to-MDIO bridge in mdio-i2c") introduced a regression: for SFP modules inserted before system boot, the RollBall I2C-to-MDIO bridge is not yet ready to respond to CMD_READ/CMD_DONE cycles when sfp_sm_add_mdio_bus() runs. The 200 ms probe times out, i2c_mii_probe_rollball() returns -ENODEV, and sfp_sm_add_mdio_bus() sets mdio_protocol =3D MDIO_I2C_NONE. By the time sfp_sm_probe_for_phy() runs (up to ~17 s later on affected hardware), the bridge is fully initialized =E2=80=94 but PHY probing is ski= pped because the protocol has already been changed to NONE. Move the probe from i2c_mii_init_rollball() =E2=80=94 called at bus-creation time =E2=80=94 to sfp_sm_probe_for_phy() in sfp.c, where it runs after the = SFP state machine's module initialization delays. Export the probe function as mdio_i2c_probe_rollball() so sfp.c can call it. For RTL8261BE-based modules: the probe correctly returns -ENODEV at PHY discovery time, causing sfp_sm_probe_for_phy() to destroy the MDIO bus and set MDIO_I2C_NONE =E2=80=94 eliminating the 5+ minute PHY probe retry l= oop. For genuine RollBall modules inserted before boot (e.g. FLYPRO SFP-10GT-CS-30M with Aquantia AQR113C): the probe now runs after initialization is complete and correctly returns 0 =E2=80=94 PHY detection proceeds normally. Reported-by: Aleksander Bajkowski Fixes: 8fe125892f40 ("net: phy: sfp: probe for RollBall I2C-to-MDIO bridge = in mdio-i2c") Signed-off-by: Petr Wozniak --- drivers/net/mdio/mdio-i2c.c | 18 ++++-------------- drivers/net/phy/sfp.c | 18 ++++++++++++------ include/linux/mdio/mdio-i2c.h | 1 + 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/net/mdio/mdio-i2c.c b/drivers/net/mdio/mdio-i2c.c --- a/drivers/net/mdio/mdio-i2c.c +++ b/drivers/net/mdio/mdio-i2c.c @@ -352,7 +352,7 @@ return 0; } -static int i2c_mii_probe_rollball(struct i2c_adapter *i2c) +int mdio_i2c_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 }; @@ -397,9 +397,11 @@ return -ENODEV; } +EXPORT_SYMBOL_GPL(mdio_i2c_probe_rollball); static int i2c_mii_init_rollball(struct i2c_adapter *i2c) { + /* Send the RollBall unlock password; bridge presence is verified + * later, in sfp_sm_probe_for_phy(), after module initialization. */ struct i2c_msg msg; u8 pw[5]; int ret; @@ -419,7 +421,7 @@ if (ret !=3D 1) return -EIO; - return i2c_mii_probe_rollball(i2c); + return 0; } struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *= i2c, @@ -444,12 +446,8 @@ case MDIO_I2C_ROLLBALL: ret =3D i2c_mii_init_rollball(i2c); if (ret < 0) { - 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. */ + 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 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -2028,17 +2028,8 @@ static int sfp_sm_add_mdio_bus(struct sfp *sfp) dev_info(sfp->dev, "probing phy device through the [%s] protocol\n", mdio_i2c_proto_type(sfp->mdio_protocol)); - int ret; - 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; + return sfp_i2c_mdiobus_create(sfp); } /* Probe a SFP for a PHY device if the module supports copper - the PHY @@ -2058,8 +2049,23 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp) case MDIO_I2C_ROLLBALL: - err =3D sfp_sm_probe_phy(sfp, SFP_PHY_ADDR_ROLLBALL, true); + /* Probe here, after module initialization delays, so that + * genuine RollBall bridges have had time to start up. + * Modules without a bridge (e.g. RTL8261BE) return -ENODEV. */ + err =3D mdio_i2c_probe_rollball(sfp->i2c); + if (err =3D=3D -ENODEV) { + sfp_i2c_mdiobus_destroy(sfp); + sfp->mdio_protocol =3D MDIO_I2C_NONE; + break; + } + if (!err) + err =3D sfp_sm_probe_phy(sfp, SFP_PHY_ADDR_ROLLBALL, true); break; } diff --git a/include/linux/mdio/mdio-i2c.h b/include/linux/mdio/mdio-i2c.h --- a/include/linux/mdio/mdio-i2c.h +++ b/include/linux/mdio/mdio-i2c.h @@ -33,5 +33,6 @@ struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *= i2c, enum mdio_i2c_proto protocol); +int mdio_i2c_probe_rollball(struct i2c_adapter *i2c); #endif -- 2.51.0