From nobody Mon Jun 8 06:36:47 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 8C1E93976BA for ; Thu, 4 Jun 2026 09:28:28 +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=1780565310; cv=none; b=oatZxumLMqIR0TwA3XwLFr5jN8YhEjXlYdc9D/2J4DnMj6/GGN5GlH01wrjrQxjumlqNXDVmtwJH9SS9dGEBzRRSykrj3FvzOMRBJ7grrUmlS8/KXeQ39K3Ydyux9dIAtXJTU7h3RGJ3SX51GdwZOHeDq76J7QGiXBYdLkk8V4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780565310; c=relaxed/simple; bh=BY1wSl9pkqttpFP/BkW6RWoeWfy8riR7HCU3xX210HU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HSBYTb0x7NBTdthCNQiUCJJBqv5PBI/mhagiybE/ZI4YdZwri5UqRKo7SJuyuJuvBRSepNbt1JbOfuNYHEL8HsSeZH8jUiWS2A6eBlqd83ajDnjj3TNKHLuYpnarl2j2xzLzqgaOfIqkIk7nyOlDfQhmXdPq5KR9pqgqSBPV0YE= 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=xQ/ITLu5; 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="xQ/ITLu5" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 5D0FE1A06E3; Thu, 4 Jun 2026 09:28:27 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2B5115FEF7; Thu, 4 Jun 2026 09:28:27 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 51CF7106A1703; Thu, 4 Jun 2026 11:28:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780565306; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=s5Hv3nkaKIJM7GUZb3G5hBDjKGl2UIsIV6beBbWFt/A=; b=xQ/ITLu5Yi4hFQTs2gMQpDwXHx3/PieKrp5hulaP5GU1jfGP3Homj3++5RshXObTmtUojS ivePVXGlFXKbu82cK1G1TDg5ctIvKVBGAmIpzkkAEHslbJ2/u1gWckc1TZakE0nI8IqSl2 0LEGRruDdD/X5J3OsRHz++nPYzydG0LS2ZbaWVXhuoip3reI99D4hPExoF0XOvFUkTzpj6 +HhNnv0Xj8PiFfxMRUTJ85qjruo1EKPdFklx/JQYl6oe6fZ+IpRGI5C+TMEkFHxbxS0Z42 LR6t9HdHgD1N0TAUkqxTPryUVGPbWQdkqU6nx7WSvVVuETWsVxACXaaEa3KKPA== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net v3 1/4] net: phy: clean the sfp upstream if phy probing fails Date: Thu, 4 Jun 2026 11:28:15 +0200 Message-ID: <20260604092819.723505-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604092819.723505-1-maxime.chevallier@bootlin.com> References: <20260604092819.723505-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. Reviewed-by: Nicolai Buchwitz Fixes: 298e54fa810e ("net: phy: add core phylib sfp support") Signed-off-by: Maxime Chevallier --- 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:47 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 6BD1F3FE641 for ; Thu, 4 Jun 2026 09:28:30 +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=1780565312; cv=none; b=EHP61VdM8myjozAIPs7f1jfcl4X43bGdNJHz8ckTRqA07HmaLlCO62wORlck0vyO8xr78kE3HwiNOzwlTac/LkBMyeN9bCFv3zLHW7hiRYdSECQUc138jBNPlrgg2ZwVpwGhxyVCxyuOFQZy2lRuXWgWimlaAbONYh/ltWbGs1I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780565312; c=relaxed/simple; bh=e4v07/+zK1P244AKQ4xDCa0GcImTQfulqMIpVfkGvXQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kZGMgl1EFrA85EsN7ApFq1wt7I7/Yxq3JoydD0TuwV9vff+RBfRoXQpxnFTemu2CDq73R7pthiXhN/AITa1MvNtRuo3ER0Ykd1+WXFmRbCLqm2ZJausr+yJ7IOgYZQ3D1PW34Aq4HJ7sA+K8c8LGEZXmtGHhMZ+kjt+L6q6cOvA= 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=I+8GSkcP; 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="I+8GSkcP" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 36C4B1A06FB; Thu, 4 Jun 2026 09:28:29 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 0526C5FEF7; Thu, 4 Jun 2026 09:28:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1A7E3106A184A; Thu, 4 Jun 2026 11:28:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780565308; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=eQqrERDHTXSlGADmEjsJ09WzmFs2+YERQbgnmZ/C04s=; b=I+8GSkcPWofuZ24aPWmHVBaR64djyAiavPYkiDBicBrhZXOgyhrdi1YiPXiLmfrLJ/VFmt G1VWupTXhyCWANjkRf/TVU/2xhsfvGDC5oqhPxbPZmkyAF20Xh8FKg4NHjayB0FLgjnCQQ O+pgfu0FnVFrdc838x6bg3s3rEYZlBoDLsu3oTtNseF2O5jTBtuf91GTTijiOTC9cpaLMf a8t9yTgbTGaYmOXj/mg0jNrbTvGrChIqnbmJ48LhKGpYbsUNOkzzHux7DqyzaqWBbtxEFa 0dCwTmL7Dqb++qPTpa07UO8y6A3mzbordztPHeUcueYgI+uLMcX+w39NG6PSyw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net v3 2/4] net: phy: remove phy ports upon probe failure Date: Thu, 4 Jun 2026 11:28:16 +0200 Message-ID: <20260604092819.723505-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604092819.723505-1-maxime.chevallier@bootlin.com> References: <20260604092819.723505-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 Reviewed-by: Nicolai Buchwitz Fixes: 589e934d2735 ("net: phy: Introduce PHY ports representation") Signed-off-by: Maxime Chevallier --- 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..4ba880446896 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3781,6 +3781,8 @@ static int phy_probe(struct device *dev) sfp_bus_del_upstream(phydev->sfp_bus); phydev->sfp_bus =3D NULL; =20 + phy_cleanup_ports(phydev); + if (!phydev->is_on_sfp_module) phy_led_triggers_unregister(phydev); =20 --=20 2.54.0 From nobody Mon Jun 8 06:36:47 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 3FCBB3F44CB; Thu, 4 Jun 2026 09:28:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780565313; cv=none; b=t5Zyo4G+T9/HFORaadhVCFzATYeSxNONzND7On7/NlMpFQIR/jtVi0+zKHk9dHx1Bi3m7QdgPQjrWl1jVn6Lm6kxLgsg91emKdrJz/gya2kmWwZ/jQXdJdc/Rg8e1LisyvG7YqHr4SK+lk4KGZa+O7gymhRA9gqsXfUrMh5uklI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780565313; c=relaxed/simple; bh=WW6JgxeMBErUtGgr/0vA+ffViSgDw6LQlXiiXxfyoDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DnHgtG0VjLWQq6VmuoM4+5uFN1wU8qfRjRGdIkYAmrJNYEkE2GH1h2dWLRg87Fb5J/EWjv6BcG3NiPPcoB0astOvBIRSPD/rdTAGvoik344bJq+3kDvYoUllayLatsfVqjbbKPFwZhOnSMbVPbZBIfjOhY6L8zwRoLPsLNgCwoM= 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=07lJXG45; arc=none smtp.client-ip=185.246.85.4 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="07lJXG45" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id AADE84E405EF; Thu, 4 Jun 2026 09:28:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7F4585FEF7; Thu, 4 Jun 2026 09:28:30 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7C669106A1867; Thu, 4 Jun 2026 11:28:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780565309; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=mw+r8i3yM/UEbAoWm4ZLrQzfHj7n/cBFxgGHZ6EACQE=; b=07lJXG45jRow/WvmQqwGSKNvhExW6fcIGvK9pydACJZwyJ8Roy2ngE51vHckBzxiwPtuIj BjdLvvRjGhw6tQnQ8R/XVUIoiswY3PoSbPbMV5Epdsfefl7WdisHr23E4Izp/wzFPYRfaf STm2m20MIWrFRdnqh3ajl3aSXxfX5l+nkz/+zymLTbQSiWEkg1bykH6f7uyETj+rKLil1x r4bPk9lh/EwMDZR9LvvNqWXXQJqLNOc8pOok5i4lOV4mswJTiLeR0IsqEepe8buoesYLPA g1tj9kylPUEwIwVWQharOS8+ipIQI6ptCJDmSifmYIOdb9/Vy+xjXW+ZzIxIfw== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net v3 3/4] net: phy: Clean the phy_ports after unregistering the downstream SFP bus Date: Thu, 4 Jun 2026 11:28:17 +0200 Message-ID: <20260604092819.723505-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604092819.723505-1-maxime.chevallier@bootlin.com> References: <20260604092819.723505-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" As reported by sashiko when looking a other patches, we need to ensure that the downstream SFP bus gets unregistered prior to destroying the phy_ports attached to a phy_device, as the SFP code may reference these ports. Let's make sure we follow that ordering in phy_remove(). Fixes: 589e934d2735 ("net: phy: Introduce PHY ports representation") Signed-off-by: Maxime Chevallier --- drivers/net/phy/phy_device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 4ba880446896..b48722589f40 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3806,11 +3806,11 @@ static int phy_remove(struct device *dev) =20 phydev->state =3D PHY_DOWN; =20 - phy_cleanup_ports(phydev); - sfp_bus_del_upstream(phydev->sfp_bus); phydev->sfp_bus =3D NULL; =20 + phy_cleanup_ports(phydev); + if (phydev->drv && phydev->drv->remove) phydev->drv->remove(phydev); =20 --=20 2.54.0 From nobody Mon Jun 8 06:36:47 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 BE4A8400DF5 for ; Thu, 4 Jun 2026 09:28:32 +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=1780565314; cv=none; b=jskjY3A16TlDRBwpsavuKjPJA8+g3hMhzx2pUSolgfWJyhxrJWHsuZNNz6C3J7aD/3Wqax3hv4T3ue8mXMVqvLYnw87sPHI1rtmpAlYxUF8PL9nJaaQgvQ4ZppuqfDobCoOyltS8mdIquvjcncbhfnVNe0IaPCoMhT6XDSXVLvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780565314; c=relaxed/simple; bh=jskCFflmxToUINjJmLffODvvm6DVOanoQ5eEaEd+aVI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MZToobUf7jcn1K3W7ReCYOLBPPei2FXtfD8yWldgSvGQBMr/GcDJcCUEHWxnIFvny7uGuBDnK8Uz3r+woZXHIOc1B5BEi//dlPWYPu8tcm4XBy9X9k5KgAVrCXWW/x+7qujwPSEF3nRVd11O/iCUNN9Mg0mWVFyfRjqazJz6k1g= 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=jFOlI3bO; 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="jFOlI3bO" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id B7877C63451; Thu, 4 Jun 2026 09:28:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8CFEA5FEF7; Thu, 4 Jun 2026 09:28:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DDC09106A17C0; Thu, 4 Jun 2026 11:28:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1780565310; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=YsRgl1lRAk6jP9fJqYly+oGLmo/o8RaokN6f/Q0aPJY=; b=jFOlI3bOuPoe+KcopbAWXAHlKCLBJmjGsmlFd1z/oFxMWlwk/ulCgkDc9k5b6QAUSesoOR Cl5zLQnY8kip0261+ZGGzyW2VZHX0Zx5vpAdslTPk2yhVvYkS+/PMgDyozG30i48uJiU3t FtmcoExh+YdIOuO8XwWTXW+8/Dp9afLQJptpNybULvSTX4SxtCc2/hlWtzrfrwNABYnBnt 5h86l7ww7MR2kCTCvSYDdzKvyZFJnISTImhq1P69uMLASQFLKBs223cxb+8CJDltF2odlg tp4RgfZn7/1Yfy8+wFB17pEIF1Xre10shK0TpXtjclEM9vyN7QnUsUI0hyYmCQ== From: Maxime Chevallier To: Andrew Lunn , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , Heiner Kallweit , Nicolai Buchwitz Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com Subject: [PATCH net v3 4/4] net: phy: don't try to setup PHY-driven SFP cages when using genphy Date: Thu, 4 Jun 2026 11:28:18 +0200 Message-ID: <20260604092819.723505-5-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260604092819.723505-1-maxime.chevallier@bootlin.com> References: <20260604092819.723505-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. Reviewed-by: Nicolai Buchwitz Fixes: bad869b5e41a ("net: phy: Only rely on phy_port for PHY-driven SFP") Signed-off-by: Maxime Chevallier --- drivers/net/phy/phy_device.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index b48722589f40..1511385b9b36 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3512,9 +3512,15 @@ 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, which will deadlock the call to + * 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