On 12/1/26 21:40, Andrew Lunn wrote:
> On Tue, Dec 01, 2026 at 12:19:54PM +0800, Hans Zhang wrote:
>> Hi sashiko,
>>
>>
>> Thank you for the review. The High issues are valid.
>>
>> v2 will:
>> - drop the smsc9420 change, since its mdiobus_register() call is in
>> ndo_open rather than a probe path, and the v1 version could return
>> success after a PHY probe failure;
>
> You need to be careful here. What context is open called in? Can you
> return EPROBE_DEFER here? Generally no.
>
> What makes this interesting is things like NFS root. You pass on the
> kernel command line all the parameters needed to connect to the NFS
> server. Deep within netdev_register(), generally called from probe, it
> can open the device, and start sending packets in order to connect to
> the NFS server. So the device is alive and running before
> netdev_register() even returns.
>
> If probe was called in async mode, can open be called in async mode,
> resulting in an EPROBE_DEFER from mdiobus_register? What happens then?
> Does it all correctly unwind and the probe is tried again later in
> sync mode?
>
Hello Andrew,
You're right to push on the open path. I traced it: smsc9420 registers its MDIO bus from smsc9420_open() via smsc9420_mii_init(), and open() folds any error into -ENODEV. __dev_open() just does ret = ops->ndo_open(dev); return ret; with no deferred-probe handling, and NFS root reaches ndo_open via ip_auto_config() -> dev_change_flags(IFF_UP) -> dev_open(). So returning -EPROBE_DEFER from open is wrong, and current_is_async() cannot distinguish probe from open in a leaf like mdiobus_register().
That confirms the defer-from-async approach in phylib does not hold. Combined with Sashiko's other findings (the deferred retry can be re-queued async and defer forever, and get_phy_device() callers fold -EPROBE_DEFER into -EINVAL / -ENODEV / -EIO), I'll drop the phylib core change.
For now I've sent v2 as a standalone cleanup: propagate the real mdiobus_register() errors, and convert the callers in a real probe context to dev_err_probe() so the existing reset-GPIO -EPROBE_DEFER path no longer prints a misleading message. Jijie Shao pointed out one hns3 hclge_mdio.c spot that should be return dev_err_probe(...) instead of the braces; I'll fold that into v3.
Since v2 only folds in Sashiko's review comments, I'll hold off on the next version until I've heard back from you and the other reviewers, rather than respinning quickly.
For the original deadlock, I found this exact problem was discussed in the dw-rockchip async-probe thread [1], where Robin Murphy proposed fixing it in the driver core: in __device_attach_driver(), defer a child device whose driver wants a synchronous probe while the parent probes asynchronously:
if (!async_allowed && current_is_async()) {
driver_deferred_probe_add(dev);
return 0;
}
That "fix the context" approach avoids the open-vs-probe and permanent-deferral problems, since it never lets a sync-request_module caller run in async context. I'm testing Robin's patch on my Sky1 board now and will report back with the results. Does that look like the right direction to pursue with the driver-core maintainers?
[1] https://lore.kernel.org/driver-core/55c2…@arm.com/
Best regards,
Hans