From nobody Mon Jun 8 06:36:27 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B507F389116; Mon, 1 Jun 2026 08:40:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303241; cv=none; b=pu5PCARj45FG2oXCvsVLU8Cj5vawwFd1H4mPIOY+gX7vvbdHLWTVvSfeF538ErIcnBViC47fPJXrQrNHwW4e2uIHEVXXjDoP1DQ7cqQgQQZWoyCrA1+BbiZbwOuBhcnlfzhazZ1RX9bb33qOxkolf4jCPPF7dqw+CqxM0aWUwTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303241; c=relaxed/simple; bh=0HdDkK/TOSL0phTZpiBrOQIZaoNT35M+ccOOAiuQQ1k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y3c0FqSPZC972s08pVChztKl+qDw27LPj8uzBExL9GWjkXUkKWQ+ejIluJoe4h4sLtyk9+fgB4NMgptSR/emwzUps3GNhqE7D5XY8m+2o+z7smkjq7tGPiKPwmcYwYa476xmwMjIg/bj/BVSw03NVNi4x16p3xS4ZNiCFm4Jq8k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=utpxjufA; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="utpxjufA" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id C39F3C62200; Mon, 1 Jun 2026 08:40:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D8904602AB; Mon, 1 Jun 2026 08:40:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B0AB0108881D6; Mon, 1 Jun 2026 10:40:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780303235; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=rAHF5SYcrtIeGSTN66k3V1ki0y/e4CSmPJwMqIdfps8=; b=utpxjufAbmgmP0CD2yYn1yWsvkUtqvx4/nPO79++0z7KOwj+DeeHv/9il26TFnw0RE5L2J o777R4xlvzWNQUbUyIqSYwPd1bvdBLGpMuIvPuKbEmUh+qJD3rmmBHqUIEMokQhgmdsQt5 NvJnQ61PYfNgc85XtbRtf+6cBys3fBPYsO3sZyrXWfYNz+62XzTDhTj5U1SB6vX1E9H1M2 FA2jr5E2dlx8WmApmJMLAGKn+vAW7mcGZVksuqkrJ5KAMxpvJaIlAM/tQg0HVBCTIAO2XO 4Jwdkn2OdeMzE3uv5Bclc9QX1i8hS2Aip2VmZeyNCWNxSm7Fp02QyVh9fccYqw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net v2 1/3] net: phy: clean the sfp upstream if phy probing fails Date: Mon, 1 Jun 2026 10:40:26 +0200 Message-ID: <20260601084029.815461-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601084029.815461-1-maxime.chevallier@bootlin.com> References: <20260601084029.815461-1-maxime.chevallier@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" Sashiko reported that we don't call sfp_bus_del_upstream() in the probe failure path, so let's add it, otherwise the sfp-bus is left with a dangling 'upstream' field, that may be used later on during SFP events. This issue existed before the generic phylib sfp support, back when drivers were calling phy_sfp_probe themselves. Fixes: 298e54fa810e ("net: phy: add core phylib sfp support") Signed-off-by: Maxime Chevallier Reviewed-by: Nicolai Buchwitz --- V2: Null-ify phydev->sfp_bus upon sfp_bus_add_upstream failure drivers/net/phy/phy_device.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 3370eb822017..6ccbfacf7d1d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1718,6 +1718,9 @@ static int phy_sfp_probe(struct phy_device *phydev) =20 ret =3D sfp_bus_add_upstream(bus, phydev, &sfp_phydev_ops); sfp_bus_put(bus); + + if (ret) + phydev->sfp_bus =3D NULL; } =20 if (!ret && phydev->sfp_bus) @@ -3775,6 +3778,9 @@ static int phy_probe(struct device *dev) return 0; =20 out: + sfp_bus_del_upstream(phydev->sfp_bus); + phydev->sfp_bus =3D NULL; + if (!phydev->is_on_sfp_module) phy_led_triggers_unregister(phydev); =20 --=20 2.54.0 From nobody Mon Jun 8 06:36:27 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C93C3876A7; Mon, 1 Jun 2026 08:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303242; cv=none; b=C+DZ4O7VVCPpXuBRlRZU+xQ/gQ21VqBBVIqg+Mmy0i86VZa8QTUiW08w0Rh3S7YMuEov9S+UKcuJSvE9PyxeJ7sY9Lb4pOfgL0y3BJdSYdOefuKEK0+UdHkUYmjUyIdTxUGtsfzUmZQEcLr+u84MvJ8KBUuoG9SR/degGKcI6YQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303242; c=relaxed/simple; bh=9SwFFhj8pwEev4ROzEm7v/IF6xzDumyvZ34YJZubTao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LWf7q3TaIZDvlIvlFtqiG3GBrEzHksjLP9yd7edD44bsvXjx97Dh9n03O4wP1ijq278s53krazHR9lrR0OQs3HKYg3TAftDayjspdXfzl3oYnIWi2ZjfIakPGGEcgkWzqY4rsqMkb5xgf+otWBlCo4kuAqAoXjoMj5ukExANHUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=SA7dJ88H; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="SA7dJ88H" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 9EABE1A3792; Mon, 1 Jun 2026 08:40:37 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6CA94602AB; Mon, 1 Jun 2026 08:40:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 741F110888598; Mon, 1 Jun 2026 10:40:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780303236; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=Uem2QYARB7RSbR4S39JbGy9eFJwE9WGo90FrLWo7T/E=; b=SA7dJ88HfWthrNHg1BF2brPyKSn6F20DFwu5kAjQeKgAUy5X3Hfc5Mzseb7S2IIR8vNKR2 mo1kxe6BsMrNU6JlCXpHHpc0PtVJZ3hYo+eLnt6isABpaXDtt/k3GeidhO0n43PKD9RfBu OJZZp1x6+gDhGkVCenwRvlo3RA0RStUSTlaRS+y1puCebA39nFdoDG75bLvHaQvMh5TNaB WvvbH9eQ7h0KocA8G8MqugO3aaanxJw2599KMN9TxB8lp31tx/J8s1SW16OPowsJsLfrAI FJC4hkdYaRsCfnuHah0jb0QJCiSqZcRj5HiCXcCzxbrvldIvf/kmcUvYcxzPdw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Nicolai Buchwitz Subject: [PATCH net v2 2/3] net: phy: remove phy ports upon probe failure Date: Mon, 1 Jun 2026 10:40:27 +0200 Message-ID: <20260601084029.815461-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601084029.815461-1-maxime.chevallier@bootlin.com> References: <20260601084029.815461-1-maxime.chevallier@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" When phy_probe fails, let's clean the phy_ports that were successfully added already. Suggested-by: Nicolai Buchwitz Fixes: 589e934d2735 ("net: phy: Introduce PHY ports representation") Signed-off-by: Maxime Chevallier Reviewed-by: Nicolai Buchwitz --- drivers/net/phy/phy_device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 6ccbfacf7d1d..a171cbe2a74a 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3778,6 +3778,8 @@ static int phy_probe(struct device *dev) return 0; =20 out: + phy_cleanup_ports(phydev); + sfp_bus_del_upstream(phydev->sfp_bus); phydev->sfp_bus =3D NULL; =20 --=20 2.54.0 From nobody Mon Jun 8 06:36:27 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59FBB33B6C9; Mon, 1 Jun 2026 08:40:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303243; cv=none; b=ZnhTFk7JBf8qqb7kjE8M/AdCmXQFD3x9+A7WRmzmsIAHe0485SDOOlZDYCcNxNaj88pqnq4B7e06JKj+gre+Fim+K8+FbDehxWBC0IGUSdvutWY5n48etZ8p9e/+JXYMkpnbX5ErMFmYTipbgJfs4u/mN6F5MgzDONmrqSPP6Mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780303243; c=relaxed/simple; bh=l85lD5VAUj656fnz9FNLxjJKX9/nAn5Zyt14JkcqemU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JMpMmH0qHf82G5QUp+deqjOF9ACHkBHGBu/GYEKnUDcbnc2sgl2n3TTjR6kyEjBXqvDXaph6xxUbtxmwOVhTQKywNwFCmG6ZkeKsV1MH+wejL47gAW2XxLvQxTy7YT+RRVoNJupdkMb/JAAXOIgU4mlT6KV0pJBbL1hxh/Y10ho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=tMWw4u6g; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="tMWw4u6g" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 0942F1A3796; Mon, 1 Jun 2026 08:40:39 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id CC67E602AB; Mon, 1 Jun 2026 08:40:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0D03310888076; Mon, 1 Jun 2026 10:40:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780303238; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=859Mw0cJmmb6gjd0ybDixiH+mwHlqm5Uah1fsB5XgEY=; b=tMWw4u6gbRlLKWDwk5CqBJnlToUfXS1qWiuUII2Bog3/VA+OGlHszGSGhNRTRFDkiK7i09 p6q9TvitJGu8Z/8YUYvA/CzSHCvWNNzD0d6t6oS5dtdla2m3+RuDXlGoMZH39BeaxYEN5d hu8vlzNUpKensIdZllvscsaw17v/7g9sHdn/39nvK/onBezEb4W9MTSaNcWkFwEufzAAc5 33J73fr1KU5p4OPrrckLLKrNNcGwCnZjhsBqm3cHSbbONQHjaGm1cPgkqZr631daqkxRwy 38aMtCXCHbkK/THQQi1l1BR7xCIyleqqaAsSHV2LsMOXpbwhPk9abPi7HppP+w== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net v2 3/3] net: phy: don't try to setup PHY-driven SFP cages when using genphy Date: Mon, 1 Jun 2026 10:40:28 +0200 Message-ID: <20260601084029.815461-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260601084029.815461-1-maxime.chevallier@bootlin.com> References: <20260601084029.815461-1-maxime.chevallier@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" We don't have support for PHY-driver SFP cages with the genphy code. On top of that, it was found by sashiko that running sfp_bus_add_upstream() for genphy deadlocks, as for genphy the PHY probing runs under RTNL, which isn't the case for non-genphy drivers. This problem was reproduced, and does lead to a deadlock on RTNL. Before the blamed commit, the phy_sfp_probe() call was made by individual PHY drivers, so there was no way to get to the SFP probing path when using genphy. Let's therefore only run phy_sfp_probe when not using genphy. Fixes: bad869b5e41a ("net: phy: Only rely on phy_port for PHY-driven SFP") Signed-off-by: Maxime Chevallier Reviewed-by: Nicolai Buchwitz --- drivers/net/phy/phy_device.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index a171cbe2a74a..8eace58e9f12 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3512,9 +3512,14 @@ static int phy_setup_ports(struct phy_device *phydev) if (ret) return ret; =20 - ret =3D phy_sfp_probe(phydev); - if (ret) - goto out; + /* We don't support SFP with genphy drivers. Also, genphy driver binding + * occurs with RTNL help, wich will deadlock the sfp_bus_add_upstream(). + */ + if (!phydev->is_genphy_driven) { + ret =3D phy_sfp_probe(phydev); + if (ret) + goto out; + } =20 if (phydev->n_ports < phydev->max_n_ports) { ret =3D phy_default_setup_single_port(phydev); --=20 2.54.0