On 12/2/26 23:09, Hans Zhang wrote:
>
>
> 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/55c28218-1638-4b90-a9cd- a177…@arm.com/
>
Hello Andrew,
Follow-up on the direction question from my last mail: I've now tested
Robin Murphy's driver-core patch from the dw-rockchip thread [1] on the
Sky1 board — two RTL8126A NICs behind a PCIe controller that sets
PROBE_PREFER_ASYNCHRONOUS, i.e. the exact async + request_module() case.
Robin's patch as posted doesn't actually work: the child device is
silently dropped — never probed and never queued. driver_deferred_probe_add() returns early when dev_can_match() is false, and in this path that flag is only set later in __driver_probe_device(), which the early return in __device_attach_driver() never reaches. So the device ends up neither
bound nor on the deferred list.
Setting the flag first fixes it:
if (!async_allowed && current_is_async()) {
dev_set_can_match(dev);
driver_deferred_probe_add(dev);
return 0;
}
With that one line, on Sky1 both RTL8126A NICs bind (eth0/eth1 up, link
running), the __request_module() WARN_ON_ONCE() is gone, and boot time is unchanged (the NICs probe slightly faster than the splatting baseline).
So the driver-core defer is the right fix: it makes the driver core honor a synchronous child even when the parent probes asynchronously, rather than teaching phylib to detect async. I'll take the results and the one-line dev_set_can_match() delta back to the dw-rockchip thread, and see whether Robin wants to post it himself or would like me to — happy to add my Tested-by either way.
[1] https://lore.kernel.org/driver-core/55c2…@arm.com/
Best regards,
Hans