From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 8B01A393DC0 for ; Wed, 24 Jun 2026 08:48:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782290903; cv=none; b=qe+scbMvOaIuzkGlQS5+izji6xPzP5ZqkWy0nrDlu7RPl71FQsWAomoLnBtUu49HEsN8HL7tUQqp9YTi/Ul1UKAwtULO/MGP0AUTP3qhXktcgYA2ZeilbfVEfDAtkwmaceGo9A5HBCKVsNmY702r0MQW0p7kfDmEGwEAWHd5bDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782290903; c=relaxed/simple; bh=+hoPTClDOAlZNJW9xpaeflSfBReQ8xVFXvz4c5aX2Hc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hPpuUzl+5/8MJbAlbcVieQFH8ef1DPcwbN3AP0EWHDohTIq7v7hRa39D0cwqzohiCudFMpobe51RoKDodcTDOi3V+WY+pWPFJS6wI/QnUB29+7zaSplmpBRrceYxC67GejmgVn/pgrWYO9yNibMd35Pk62Aw2pgBGitVEvAI4qk= 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=atCz2+Qs; arc=none smtp.client-ip=209.85.221.43 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="atCz2+Qs" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-464192ab2e1so558491f8f.0 for ; Wed, 24 Jun 2026 01:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782290900; x=1782895700; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SB90+YCUH0dV66aMdsIbPcNB77SkXK4CkRD/ocilleU=; b=atCz2+QsEVVT05ZxkH2od0pNzOmGvAEh60yow7kAluneXemZ2jGQUlUaPrV0mIZVJZ 0C3SZp9ouc7wpb+TQH+ggVAlD1LlLjzBk+v1gCu1HSvvtnYjp5qtDt8S0tgucBzdQQuo TVXxbJkghUNPDOKBj1Mf7K16JGkjMY34+fV+wjHzcbZB1mbVv8RzUKOzpzb3lvupPVpC HxWDXSlq9HA2KUnCO/nWRFpw/cBG8bLAoJ+e0oJh4NqdKtim+J3x6ehyFbfLd2+l7AEk LPYhKXjcx6nqqOYBfUC/jgExpS/PT4GGt9x9PcVsfKuSAJrSS1in0f8GZ1ILxIQwAIb6 htOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782290900; x=1782895700; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SB90+YCUH0dV66aMdsIbPcNB77SkXK4CkRD/ocilleU=; b=BXQdohgqoTTkdhWNc5keoaaAhqqvHbwklpqpvvuN1P8nEVaDU5qepVNxdlI4SjmJti s5Bg+L4I0SXUOUd3fGUb6afJO3eQaFPCYQABb0xIgJ96ltOyg+SI7EL8K0xKgnPxg1Cy muy0UHIH5zRnPtq7+WFB6GqsPtUW4oQZ6JG/N8HghEzeY5z/uC78KDhlX4OE6ZSlLPeE tEJw+JXUYC4ahDOeLKLFHyMJpILz96WZtjtTw5f+gUkkzlpLmzBqF1sqOXTnfNJKi5cM 3ztGWFLAN43v1rgKMTqx7iq2uKtob7LEdfhnyuyGVlfWVC6wOSzWEwE6pRDoOqZJpg4b eN0A== X-Forwarded-Encrypted: i=1; AHgh+RqOzPIO/LcZvsXGIdh3s4ws4/64ey01DE8KDzejyCLN9x0MEAd8nPZk0cqI2CzcXqIVuI7t2E4x563UHAQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwVRXKtGHY/ieHzpvGsyXnWCzDS/OkH/KRwbThqJ63oxKkklxSO jAdaYlPvNLSnilAV8PrLhCPRZYxQHjRn+TwNvWe9J4ksvT0r3dPjLh3d X-Gm-Gg: AfdE7cloidRi/Q5L8BQuK8oZUXhucPfL8JvnninaggQRf7H/hInkC9Fiq2lmrGkzZ9c oLf021Kpn1VckEi+MIWVG0S7ByIv81EQu+9Jocj8j4IZq/30zwHEyORxlOzHorKmpdW2VHgC5zn 3AHQuKxHakby6zkPeSUpdEy0QzB1gcfhScay9kFs+NRzX5wN9GMz0kEdmixl13djteOXBSLf0Iu elkMs186QL7gTmo+rZCOEMbRF1wn06BVmdaK3cethQNRuEpLwoLMuMLuzKm9jp9yQEf+/xRMJkW XfBnptzzdDOXrd/mpJOzZWq1w6VOzEox4EoeWygM9c9mTaBZVlBvvwKmqbMEi+9D4RJ1buX4J7W TtE/PxihSmd3lvSONUBZkctvlLosH6qJDa4ZWG8Pl8NFN7At77b3T8ny+o38k3v+A0Hh4ZD1rwJ RjTroVvMHLlLRXkOCkwjhzOqVrJsbxXOyuS9FKRH73h+1G5wMnXYg72hjfMKcOogU6TD1MlzfKF kf2Q2dfXCGzkAxWSw== X-Received: by 2002:a05:6000:2404:b0:465:81cb:bb20 with SMTP id ffacd0b85a97d-46c04a33d34mr4263361f8f.9.1782290899881; Wed, 24 Jun 2026 01:48:19 -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-46c221d9371sm5065849f8f.21.2026.06.24.01.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jun 2026 01:48:19 -0700 (PDT) From: Petr Wozniak To: Russell King , Andrew Lunn , Heiner Kallweit Cc: Jakub Kicinski , "David S . Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, Maxime Chevallier , Bjorn Mork , Aleksander Bajkowski , Marek Behun , Petr Wozniak Subject: [PATCH net v4 2/2] net: phy: mdio-i2c: defer RollBall bridge probe to PHY discovery Date: Wed, 24 Jun 2026 10:48:14 +0200 Message-ID: <20260624084814.20972-3-petr.wozniak@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260624084814.20972-1-petr.wozniak@gmail.com> References: <20260624084814.20972-1-petr.wozniak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit commit 8fe125892f40 ("net: phy: sfp: probe for RollBall I2C-to-MDIO bridge in mdio-i2c") introduced a regression: 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 in SFP_S_INIT. The 200 ms probe times out, i2c_mii_probe_rollball() returns -ENODEV, and sfp_sm_add_mdio_bus() sets mdio_protocol = 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 but PHY probing is skipped because the protocol has already been changed to NONE. This affects both modules inserted before boot and hotplugged modules on hardware where bridge initialization exceeds the 200 ms probe window (confirmed: FLYPRO SFP-10GT-CS-30M with Aquantia AQR113C, hotplugged). Move the probe from i2c_mii_init_rollball(), called at bus-creation time, to sfp_sm_probe_for_phy() in sfp.c, where it runs after the SFP state machine 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, eliminating the 5+ minute PHY probe retry loop. For genuine RollBall modules (e.g. FLYPRO SFP-10GT-CS-30M with Aquantia AQR113C) the probe now runs after initialization is complete and correctly returns 0, so 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 | 15 +++++++++------ drivers/net/phy/sfp.c | 22 ++++++++++++++-------- include/linux/mdio/mdio-i2c.h | 1 + 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/drivers/net/mdio/mdio-i2c.c b/drivers/net/mdio/mdio-i2c.c index b88f63234b4e..2a3a418c1369 100644 --- a/drivers/net/mdio/mdio-i2c.c +++ b/drivers/net/mdio/mdio-i2c.c @@ -419,7 +419,7 @@ static int i2c_mii_write_rollball(struct mii_bus *bus, int phy_id, int devad, return 0; } -static int i2c_mii_probe_rollball(struct i2c_adapter *i2c) +int mdio_i2c_probe_rollball(struct i2c_adapter *i2c) { u8 data_buf[] = { ROLLBALL_DATA_ADDR, 0x01, 0x00, 0x00 }; u8 cmd_buf[] = { ROLLBALL_CMD_ADDR, ROLLBALL_CMD_READ }; @@ -462,9 +462,13 @@ static int i2c_mii_probe_rollball(struct i2c_adapter *i2c) 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; @@ -486,7 +490,7 @@ static int i2c_mii_init_rollball(struct i2c_adapter *i2c) if (ret != 1) return -EIO; - return i2c_mii_probe_rollball(i2c); + return 0; } static bool mdio_i2c_check_functionality(struct i2c_adapter *i2c, @@ -531,10 +535,9 @@ struct mii_bus *mdio_i2c_alloc(struct device *parent, struct i2c_adapter *i2c, case MDIO_I2C_ROLLBALL: ret = i2c_mii_init_rollball(i2c); if (ret < 0) { - if (ret != -ENODEV) - dev_err(parent, - "Cannot initialize RollBall MDIO I2C protocol: %d\n", - ret); + 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 c4d274ab651e..01b941a38eed 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -2174,17 +2174,10 @@ static void sfp_sm_fault(struct sfp *sfp, unsigned int next_state, bool warn) static int sfp_sm_add_mdio_bus(struct sfp *sfp) { - int ret; - if (sfp->mdio_protocol == MDIO_I2C_NONE) return 0; - ret = sfp_i2c_mdiobus_create(sfp); - if (ret == -ENODEV) { - sfp->mdio_protocol = 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 @@ -2215,6 +2208,19 @@ static int sfp_sm_probe_for_phy(struct sfp *sfp) break; case MDIO_I2C_ROLLBALL: + /* 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 = mdio_i2c_probe_rollball(sfp->i2c); + if (err == -ENODEV) { + sfp_i2c_mdiobus_destroy(sfp); + sfp->mdio_protocol = MDIO_I2C_NONE; + err = 0; + break; + } + if (err) + break; err = 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 index 65b550a6fc32..5cf14f45c94b 100644 --- a/include/linux/mdio/mdio-i2c.h +++ b/include/linux/mdio/mdio-i2c.h @@ -20,5 +20,6 @@ enum mdio_i2c_proto { 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