Re: [PATCH net-next v6 0/5] net: pse-pd: decouple controller lookup from MDIO probe
From: Paolo Abeni <pabeni@redhat.com>
Date: 2026-09-10 09:07:01
Also in:
lkml
On 9/6/26 5:30 PM, Carlo Szelinsky wrote:
This is v6 of Corey's series [1]. It takes the PSE controller lookup out of the MDIO probe path, so a modular PSE driver no longer makes the PHY/DSA probe spin on -EPROBE_DEFER until the PSE module loads. Patches 1-3 are the same three notifier patches as v4 [4], unchanged, with Jonas's Tested-by. Patches 4 and 5 fix two problems the v4 review surfaced; v6 additionally fixes a build regression in v5 [7]'s patch 4. Patch 4: Aleksander reported [5] that v4 deadlocks on probe for an MDIO bus registered from ndo_init (lantiq_etop, sni_ave, netsec): those already hold rtnl via register_netdevice(), and v4's phy attach took rtnl again underneath. Patch 4 swaps that rtnl for a dedicated mutex, so the register path no longer recurses. The ethtool PSE paths take the same mutex, so the use-after-free that rtnl used to close stays closed. The mutex lives in pse_core rather than phylib: net/ethtool is always built into vmlinux but PHYLIB is tristate, so with CONFIG_PHYLIB=m or =n a phylib export is unresolved (v5 failed to link there [8]); PSE_CONTROLLER is bool, so pse_core is always reachable. Patch 5: Paolo's review [6] pointed out that patch 3 defers the pse_control_put() to phy_device_release(). A phy that is device_del()'d but still pinned (an attached netdev) is off the mdio_bus_type klist, so the PSE_UNREGISTERED notifier walk never clears its phydev->psec, and the deferred put later touches a pcdev->pi[] the controller has already freed. Patch 5 puts phydev->psec back in phy_device_remove(), which the mutex from patch 4 now makes safe (the rtnl recursion that motivated the deferral is gone), so the detach is synchronous and cannot outlive the controller. How it works: pse_core gets a notifier chain (REGISTERED / UNREGISTERED). The phy layer subscribes, owns phydev->psec, and attaches the PSE handle when the controller shows up instead of during probe. fwnode_mdio loses its PSE awareness, so no -EPROBE_DEFER leaves it and the probe-retry loop is gone. Tested on a Realtek rtl93xx PoE switch with two HS104 PSE controllers on i2c: - clean boot, no probe-retry loop, no watchdog reset - 10G SFP+ port: module hotplug works, no deadlock - ethtool --set-pse enable/disable cuts and restores power to a PD - i2c unbind -> rmmod -> modprobe: PSE detaches on unbind and re-attaches on reload with power restored, no reboot. No lockdep splats. Jonas confirmed the RTL8214FC deadlock he reported is gone. Aleksander confirmed the lantiq_etop probe deadlock is gone at boot. Tested-by: Carlo Szelinsky <redacted>
A bunch of 'high prio' sashiko reported issues are actually fixed by patch 5/5, so IMHO not very relevant. Still I think there are a few points to act upon. @Carlo: please have a look at commit c82ff94592fb68f529afe63ca7f5ddb7dae4ba83: you are supposed to reply to LLM's comments. /P