From: Hans Zhang <18255117159@163.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: hkallweit1@gmail.com, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk,
netdev@vger.kernel.org, netdev-bot+sashiko@kernel.org
Subject: Re: [PATCH 0/4] prepare MDIO callers for -EPROBE_DEFER from __mdiobus_register()
Date: Thu, 3 Dec 2026 17:05:11 +0800 [thread overview]
Message-ID: <e253cb94-2145-49d7-b13d-2fe3d5b9829e@163.com> (raw)
In-Reply-To: <0ac68808-10b0-49fd-8057-2f9b0ce35319@163.com>
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-
> a177fb5abcb6@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/55c28218-1638-4b90-a9cd-a177fb5abcb6@arm.com/
Best regards,
Hans
prev parent reply other threads:[~2026-12-03 9:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 2:37 [PATCH 0/4] prepare MDIO callers for -EPROBE_DEFER from __mdiobus_register() Hans Zhang
2026-11-30 2:37 ` [PATCH 1/4] net: ethernet: lantiq_etop: propagate mdiobus_register() errors Hans Zhang
2026-12-01 2:46 ` netdev-bot+sashiko
2026-11-30 2:37 ` [PATCH 2/4] net: ethernet: smsc911x: " Hans Zhang
2026-12-01 2:46 ` netdev-bot+sashiko
2026-11-30 2:37 ` [PATCH 3/4] net: ethernet: smsc9420: " Hans Zhang
2026-12-01 2:46 ` netdev-bot+sashiko
2026-11-30 2:37 ` [PATCH 4/4] net: use dev_err_probe() for MDIO bus registration errors Hans Zhang
2026-12-01 2:46 ` netdev-bot+sashiko
2026-12-01 4:19 ` [PATCH 0/4] prepare MDIO callers for -EPROBE_DEFER from __mdiobus_register() Hans Zhang
2026-12-01 13:40 ` Andrew Lunn
2026-12-02 15:09 ` Hans Zhang
2026-12-03 9:05 ` Hans Zhang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e253cb94-2145-49d7-b13d-2fe3d5b9829e@163.com \
--to=18255117159@163.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox