Re: [PATCH net-next v2 3/3] net: mdio: treat PSE EPROBE_DEFER as non-fatal during PHY registration

From: Andrew Lunn

Date: Wed Apr 08 2026 - 17:57:32 EST


On Wed, Apr 08, 2026 at 11:07:11PM +0200, Carlo Szelinsky wrote:
> So I went ahead and tested the phy_probe() approach on my setup (RTL930x
> DSA switch with an I2C Hasivo HS104 PSE controller as module).
>
> PoE itself works fine, but phydev->psec never gets set - ethtool just
> says "No PSE is attached" on all ports.
>
> Took me a while to figure out what's going on. The problem is how DSA
> handles PHYs: when phy_probe() returns -EPROBE_DEFER because the PSE
> controller hasn't probed yet, the PHY device is registered but sits
> there unprobed. Then the DSA switch comes along, sets up its ports, and
> phy_attach_direct() force-binds the generic PHY driver with
> device_bind_driver().

Yes, this is a known issue with phylib.

> What I'm seeing timing-wise:
> - MDIO scan registers PHYs, phy_probe() defers (no PSE yet)
> - DSA probes, phy_attach_direct() binds genphy
> - t=17s: HS104 finally probes

That is a long time. Does it actually start probing much earlier, but
it is busy download firmware, and the probe completes after 17
seconds.

> - deferred retry: nope, driver already bound
> - t=35s: regulator_late_cleanup (caught by admin_state_synced)
>
> Not sure what the best path forward is here. Should we look at fixing
> phy_attach_direct() to handle this case.

It is not easy to fix, because generally drivers call
phy_attach_direct() in their open() function, not probe(). It is too
late to return EPROBE_DEFFER, you can only do that in probe. phylib
knows the device exists, but it sees there is no driver, so it does
not have much choice. It can either use genphy, or it can error out
phy_attach_direct().

DSA is however atypical, and does phylink_connect() early. So there
might be a way out. In dsa_user_phy_connect() once you have the
phydev, you could look at phydev->drv and return EPROBE_DEFFER if it
is NULL. Ugly. And a bit of a layering violation. Maybe a helper in
phylib, phy_is_driver_bound() ?

Andrew