When a PSE controller driver is built as a module, it may not be probed
yet when PHYs are registered on the MDIO bus. This causes
fwnode_find_pse_control() -> of_pse_control_get() to return
-EPROBE_DEFER, which currently propagates up and destroys the PHY
device.
Treat -EPROBE_DEFER as non-fatal, allowing the PHY to register
successfully with psec=NULL. The PSE control can be resolved lazily
when first needed.
Signed-off-by: Carlo Szelinsky <github@szelinsky.de>
Acked-by: Kory Maincent <kory.maincent@bootlin.com>
---
drivers/net/mdio/fwnode_mdio.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index ba7091518265..2a03b3fc41e6 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -161,8 +161,12 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
psec = fwnode_find_pse_control(child, phy);
if (IS_ERR(psec)) {
- rc = PTR_ERR(psec);
- goto unregister_phy;
+ if (PTR_ERR(psec) == -EPROBE_DEFER) {
+ psec = NULL;
+ } else {
+ rc = PTR_ERR(psec);
+ goto unregister_phy;
+ }
}
phy->psec = psec;
--
2.43.0
> Treat -EPROBE_DEFER as non-fatal, allowing the PHY to register > successfully with psec=NULL. The PSE control can be resolved lazily > when first needed. Is there a reason not to do lazily resolution all the time? Andrew
Hi Andrew, Thx for helping me! I thought of keeping the eager path so we still catch broken DT bindings early at boot instead of silently failing later on first ethtool access. But you're right, dropping it would simplify things quite a bit. Do you think that trade-off is worth it? I will follow your lead. cheers Carlo
On Fri, Apr 03, 2026 at 03:31:11PM +0200, Carlo Szelinsky wrote: > Hi Andrew, > > Thx for helping me! > I thought of keeping the eager path so we still catch broken DT bindings > early at boot instead of silently failing later on first ethtool access. > But you're right, dropping it would simplify things quite a bit. Do you > think that trade-off is worth it? I will follow your lead. I suppose, the real question is, are we fixing the correct thing? As a general principal in Linux, you don't register a device with the core until it has all the resources it needs. This is what EPROBE_DEFFER is about. If it is not registered with the core, the uAPI is not available, making user space simpler. As i understand the problem, by deferring the probe, the regulator gets turned off, cutting the power? So is the real problem with the regulator code? Do we need a way to indicate a regulator should not be turned off if it is unused? Or can we change when the regulator code turns off unused regulators? I don't remember all the details for deferred probing, but i thought the driver core had a timer and would keep running the deferred probes until that timer expires. When does the regulator code turn off unused regulators relative to this timer? Andrew
Hi Andrew, So I went and looked at whether we can just let EPROBE_DEFER do its thing here, like you suggested. From what I can tell, the issue is where it happens. fwnode_mdiobus_register_phy() gets called during the MDIO bus scan in __of_mdiobus_parse_phys(), and if any PHY returns -EPROBE_DEFER there, the whole scan bails out - none of the PHYs on that bus get registered. So you'd lose all networking on that bus just because one PHY's PSE controller isn't ready yet. I also dug into the timing question you raised. Correct me if I'm wrong, but from what I see the deferred probe timeout is 10s and regulator_late_cleanup fires at 30s, so the ordering would actually work out - the consumer would get to claim the regulator before cleanup kills it. It's more the bus level collateral damage that seemed like the real problem to me. That's basically why I ended up treating EPROBE_DEFER as non-fatal for PSE during PHY registration and doing lazy resolution instead. The admin_state_synced flag then covers the window between PSE controller probe and whenever the lazy resolution actually happens. But I might be looking at this the wrong way - would you rather we defer the whole bus and accept that trade-off? Or does the lazy approach seem reasonable for this case? Happy to hear if you have a different idea entirely. Cheers, Carlo
On Fri, 3 Apr 2026 15:31:11 +0200 Carlo Szelinsky <github@szelinsky.de> wrote: > Hi Andrew, > > Thx for helping me! > I thought of keeping the eager path so we still catch broken DT bindings > early at boot instead of silently failing later on first ethtool access. > But you're right, dropping it would simplify things quite a bit. Do you > think that trade-off is worth it? I will follow your lead. On my side I thinks that's a good idea, and I don't see any issue with that for now. Oleksij you introduced it here in the first place, is it ok for you? Regards, -- Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Hi, On Fri, Apr 03, 2026 at 03:38:49PM +0200, Kory Maincent wrote: > On Fri, 3 Apr 2026 15:31:11 +0200 > Carlo Szelinsky <github@szelinsky.de> wrote: > > > Hi Andrew, > > > > Thx for helping me! > > I thought of keeping the eager path so we still catch broken DT bindings > > early at boot instead of silently failing later on first ethtool access. > > But you're right, dropping it would simplify things quite a bit. Do you > > think that trade-off is worth it? I will follow your lead. > > On my side I thinks that's a good idea, and I don't see any issue with that for > now. Oleksij you introduced it here in the first place, is it ok for you? If I see it correctly - this patch kills all notifications originated from the PSE core to the users space, until some one calls get/set path from user space. Means, kernel update may break UAPI behavior of existing devices. On other hand, I agree that PSE is not a strickt requirement for PHY functionality in most cases. At the early stage, as initial PSE support was introduced, PHYs was kind of representation of the port and related ethernet interface (needed for LLDP). Are there better methods to solve it now? Best Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
© 2016 - 2026 Red Hat, Inc.