lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <PAXPR04MB85106B63AF43DE0830B4C362889FA@PAXPR04MB8510.eurprd04.prod.outlook.com>
Date: Fri, 30 Jan 2026 03:41:19 +0000
From: Wei Fang <wei.fang@....com>
To: Russell King <linux@...linux.org.uk>, Jakub Kicinski <kuba@...nel.org>
CC: "andrew@...n.ch" <andrew@...n.ch>, "hkallweit1@...il.com"
	<hkallweit1@...il.com>, "florian.fainelli@...adcom.com"
	<florian.fainelli@...adcom.com>, xiaolei.wang <xiaolei.wang@...driver.com>,
	"davem@...emloft.net" <davem@...emloft.net>, "edumazet@...gle.com"
	<edumazet@...gle.com>, "pabeni@...hat.com" <pabeni@...hat.com>,
	"maxime.chevallier@...tlin.com" <maxime.chevallier@...tlin.com>,
	"quic_abchauha@...cinc.com" <quic_abchauha@...cinc.com>,
	"quic_sarohasa@...cinc.com" <quic_sarohasa@...cinc.com>,
	"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH net] net: phy: add device link between MAC device and MDIO
 device

> On Wed, Jan 28, 2026 at 08:15:01PM -0800, Jakub Kicinski wrote:
> > On Mon, 26 Jan 2026 18:44:09 +0800 Wei Fang wrote:
> > > The commit bc66fa87d4fd ("net: phy: Add link between phy dev and mac
> > > dev") has created a device link between the MAC and the PHY if the
> > > MAC uses a shared MDIO bus (The MDIO and the MAC are two separate
> devices).
> > > Sarosh Hasan tried to change the DL_FLAG_STATELESS flag to
> > > DL_FLAG_AUTOREMOVE_SUPPLIER to fix the issue [1]. However, the
> > > solution does not take into account the hot-swappable PHY devices (such as
> SFP).
> > > so when the PHY device is unplugged, the MAC driver will
> > > automatically be removed, which is not the expected behavior.
> > >
> > > Therefore, to solve this issue of the shared MDIO bus, we create the
> > > device link between the MAC device and the MDIO device, rather than
> > > between the MAC device and the PHY device. And when the shared MDIO
> > > bus is removed, all MAC drivers that depend on it will also be removed.
> >
> > Anyone willing to venture a review tag?
> 
> No, I don't agrew with the patch.
> 

Is it because of SFP? If so, would the following modification be more
reasonable, while SFP still follows the previous logic? I'm not sure if
phydev->sfp_bus_attached can be used to distinguish between SFP
PHYs and non-SFP PHYs.

Anyway, this problem has existed for a long time, and I think we should
find a way to solve it in upstream. If there's a better approach, I can help
verify it.

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 81984d4ebb7c..c48335bfc7b6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1771,9 +1771,17 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
         * another mac interface, so we should create a device link between
         * phy dev and mac dev.
         */
-       if (dev && phydev->mdio.bus->parent && dev->dev.parent != phydev->mdio.bus->parent)
-               phydev->devlink = device_link_add(dev->dev.parent, &phydev->mdio.dev,
-                                                 DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
+       if (dev && bus->parent && dev->dev.parent != bus->parent) {
+               if (phydev->sfp_bus_attached)
+                       phydev->devlink = device_link_add(dev->dev.parent,
+                                                         bus->parent,
+                                                         DL_FLAG_PM_RUNTIME |
+                                                         DL_FLAG_STATELESS);
+               else
+                       device_link_add(dev->dev.parent, bus->parent,
+                                       DL_FLAG_PM_RUNTIME |
+                                       DL_FLAG_AUTOREMOVE_SUPPLIER);
+       }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ