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: Wed, 2 Dec 2026 23:09:05 +0800 [thread overview]
Message-ID: <0ac68808-10b0-49fd-8057-2f9b0ce35319@163.com> (raw)
In-Reply-To: <8541a0f4-8f25-47ab-89ec-4e37a48358e8@lunn.ch>
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/
Best regards,
Hans
next prev parent reply other threads:[~2026-12-02 15:10 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 [this message]
2026-12-03 9:05 ` Hans Zhang
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=0ac68808-10b0-49fd-8057-2f9b0ce35319@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