From: netdev-bot+sashiko@kernel.org
To: maxime.chevallier@bootlin.com
Cc: davem@davemloft.net, andrew+netdev@lunn.ch, kuba@kernel.org,
edumazet@kernel.org, willemb@google.com, pabeni@redhat.com,
linux@armlinux.org.uk, kabel@kernel.org,
sebastian.hesselbarth@gmail.com, gregory.clement@bootlin.com,
hkallweit1@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
thomas.petazzoni@bootlin.com, devicetree@vger.kernel.org,
conor+dt@kernel.org, krzk+dt@kernel.org, robh@kernel.org,
christophe.leroy@csgroup.eu, herve.codina@bootlin.com,
f.fainelli@gmail.com, vladimir.oltean@nxp.com,
kory.maincent@bootlin.com, o.rempel@pengutronix.de,
nicveronese@gmail.com, horms@kernel.org,
marcin.s.wojtas@gmail.com, daniel@makrotopia.org,
dimitri.fedrau@liebherr.com, frank.wunderlich@linux.dev,
p.ameruoso@live.it, f@lex.la
Subject: Re: [PATCH net-next 03/12] net: phy: Don't create the sysfs links for PHYs behind a mux
Date: Sat, 05 Dec 2026 12:18:25 +0000 [thread overview]
Message-ID: <179647310509.3146.4826722371590579464@kernel.org> (raw)
In-Reply-To: <20261204110622.1106492-4-maxime.chevallier@bootlin.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] For a PHY behind a mux, phy_attach_direct()
(drivers/net/phy/phy_device.c:2022) now skips phy_sysfs_create_links()…
- [Low] The commit message says that two PHYs' sysfs links in the netdev
entry would 'overwrite one another'.
--
net: phy: Don't create the sysfs links for PHYs behind a mux
This commit adds a mux_port pointer to struct phy_device. When that
pointer is set, phy_attach_direct() no longer calls
phy_sysfs_create_links(). The reason given is that a mux can attach
several PHYs to one netdev, and their sysfs links would conflict.
> Attached phys create sysfs links in the netdev entry, pointing to the
> PHY. We can't have two of them (otherwise they'd overwrite one another),
> so let's just not create these.
[Severity: Low]
Is "overwrite one another" accurate here? Sysfs links aren't overwritten.
When the name already exists, sysfs_do_create_link_sd() returns -EEXIST
from kernfs_create_link().
For the netdev side "phydev" link, phy_sysfs_create_links() logs that
failure, treats it as non-fatal, and still sets sysfs_links:
err = sysfs_create_link_nowarn(&dev->dev.kobj,
&phydev->mdio.dev.kobj,
"phydev");
if (err) {
dev_err(...);
/* non-fatal - some net drivers can use one netdevice
* with more then one phy
*/
}
phydev->sysfs_links = true;
So the real problem looks different. An error is logged for each
additional PHY, and phy_detach_internal() removes the "phydev" link by
name:
if (phydev->sysfs_links) {
if (dev)
sysfs_remove_link(&dev->dev.kobj, "phydev");
sysfs_remove_link(&phydev->mdio.dev.kobj, "attached_dev");
}
Detaching one PHY could then remove a link that belongs to another PHY
that is still attached.
The same collision and remove-by-name behavior already exists for non-mux
drivers that use one netdev with several PHYs, as the in-tree comment
says.
Could the commit message describe the failure more precisely, and say
that only the netdev side link can collide?
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 60440b62e6c79..9630578a6a5c5 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -2019,7 +2019,8 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
> */
> phydev->sysfs_links = false;
>
> - phy_sysfs_create_links(phydev);
> + if (!phydev->mux_port)
> + phy_sysfs_create_links(phydev);
[Severity: Medium]
Does skipping the whole helper also drop the attached_dev link for mux
PHYs? phy_sysfs_create_links() creates two links:
err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj,
"attached_dev");
...
err = sysfs_create_link_nowarn(&dev->dev.kobj,
&phydev->mdio.dev.kobj,
"phydev");
The attached_dev link is created under each PHY's own mdio device kobject.
Several PHYs behind the same mux therefore can't collide on it. Only the
netdev side "phydev" link can conflict.
Later in the series, phy_mux_attach() calls phy_mux_port_bind_phy(), which
sets phydev->mux_port, and then calls phy_attach_direct():
ret = phy_mux_port_bind_phy(port);
...
ret = phy_attach_direct(dev, port->phydev, phy_flags,
port->interface);
phy_attach_direct() still sets phydev->attached_dev = dev and adds the PHY
to the link topology. Every mux PHY is attached to the netdev, but
/sys/class/mdio_bus/<bus>/<device>/attached_dev is never created for any
of them.
Documentation/ABI/testing/sysfs-class-net-phydev describes attached_dev as
a symbolic link to the network device this PHY device is attached to. It
makes no exception for muxes. The phydev entry in
Documentation/ABI/testing/sysfs-class-net doesn't mention the mux case
either.
Skipping the netdev side phydev link seems fine, because phy_mux_attach()
sets dev->phydev = NULL anyway.
Would it make sense to keep creating attached_dev for mux PHYs and only
skip the netdev side link? If not, could the exception be documented in
the ABI files?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204110622.1106492-1-maxime.chevallier%40bootlin.com
next prev parent reply other threads:[~2026-12-05 12:18 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 11:06 [PATCH net-next 00/12] net: phy: Introduce MII multiplexers Maxime Chevallier
2026-12-04 11:06 ` [PATCH net-next 01/12] dt-bindings: net: Add Ethernet " Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
2026-12-04 11:06 ` [PATCH net-next 02/12] net: phy: Introduce phy_mux, a MII multiplexer representation Maxime Chevallier
2026-12-04 11:06 ` [PATCH net-next 03/12] net: phy: Don't create the sysfs links for PHYs behind a mux Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko [this message]
2026-12-04 11:06 ` [PATCH net-next 04/12] net: phy: phy_mux: Allow attaching a mux to a net_device Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
2026-12-04 11:06 ` [PATCH net-next 05/12] net: phy: phy_mux: Add port selection logic Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
2026-12-04 11:06 ` [PATCH net-next 06/12] net: phy: phy_mux: Support SFP cage ports Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
2026-12-04 11:06 ` [PATCH net-next 07/12] net: phylink: Factor out phylink_clear_phydev() Maxime Chevallier
2026-12-04 11:06 ` [PATCH net-next 08/12] net: phy: phy_mux: Add phy_mux_set_mac_managed_pm() Maxime Chevallier
2026-12-04 11:06 ` [PATCH net-next 09/12] net: phylink: Support PHYs reached through a phy_mux Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
2026-12-04 11:06 ` [PATCH net-next 10/12] net: phylink: Support an SFP cage behind " Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
2026-12-04 11:06 ` [PATCH net-next 11/12] net: phy: mux: Add the mii-mux-auto driver Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
2026-12-04 11:06 ` [PATCH net-next 12/12] ARM: dts: turris-omnia: Describe the WAN port multiplexer Maxime Chevallier
2026-12-05 11:08 ` sashiko-bot
2026-12-05 12:18 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179647310509.3146.4826722371590579464@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=christophe.leroy@csgroup.eu \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dimitri.fedrau@liebherr.com \
--cc=edumazet@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=f@lex.la \
--cc=frank.wunderlich@linux.dev \
--cc=gregory.clement@bootlin.com \
--cc=herve.codina@bootlin.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kabel@kernel.org \
--cc=kory.maincent@bootlin.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=marcin.s.wojtas@gmail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=nicveronese@gmail.com \
--cc=o.rempel@pengutronix.de \
--cc=p.ameruoso@live.it \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.oltean@nxp.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox