From: netdev-bot+sashiko@kernel.org
To: 18255117159@163.com
Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
linux@armlinux.org.uk, netdev@vger.kernel.org, 503536682@qq.com
Subject: Re: [PATCH v2] net: phy: defer PHY probe when running in async probe context
Date: Sun, 29 Nov 2026 08:40:01 +0000 [thread overview]
Message-ID: <179594160178.3146.13454099280646190968@kernel.org> (raw)
In-Reply-To: <20261125080939.176096-1-18255117159@163.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 2 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The commit message assumes the deferred retry runs synchronously
from the deferred probe workqueue.
- [High] get_phy_device(), and through it phy_device_create(), can now
return -EPROBE_DEFER.
- [Medium] The current_is_async() check in phy_request_driver_module()
(phy_device.c:643-644) runs before, and regardless of, the…
- [Low] The block comment in phy_device_create() (phy_device.c:720-729)
still says "Request the appropriate module unconditionally".
--
net: phy: defer PHY probe when running in async probe context
This commit makes phy_request_driver_module() return -EPROBE_DEFER when
it is called from an async worker, instead of calling request_module()
synchronously. The idea is that the parent device probe is retried later
from the deferred probe workqueue, where request_module() can run
synchronously.
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index b39e945cebd73..9f88da87df971 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
[ ... ]
> @@ -639,6 +640,9 @@ static int phy_request_driver_module(struct phy_device *dev, u32 phy_id)
> {
> int ret;
>
> + if (current_is_async())
> + return -EPROBE_DEFER;
> +
[Severity: High]
The commit message says the retry happens "from the deferred probe
workqueue, where request_module() can run synchronously". Does that hold
when the driver that registers the MDIO bus is itself allowed to probe
asynchronously?
The deferred retry path is:
deferred_probe_work_func()
bus_probe_device_deferred()
__bus_probe_device()
device_initial_probe()
__device_attach(dev, true)
In the synchronous pass, __device_attach_driver() skips drivers that
allow async probing:
drivers/base/dd.c:__device_attach_driver() {
...
if (async_allowed)
data->have_async = true;
if (data->check_async && async_allowed != data->want_async)
return 0;
...
}
__device_attach() then queues the probe through
async_schedule_dev_nocall(__device_attach_async_helper, dev). The retry
runs inside async_run_entry_fn again, so current_is_async() is true again
and -EPROBE_DEFER comes back again.
driver_allows_async_probing() returns true in several cases:
PROBE_PREFER_ASYNCHRONOUS
driver_async_probe=<name> or driver_async_probe=* on the command line
the per-module async_probe parameter, or module.async_probe=1
In any of these setups, could a driver like r8169 stay deferred forever
and never bind? It scans PHYs through
devm_mdiobus_register()->mdiobus_scan_bus_c22()->get_phy_device().
With module.async_probe=1, do_init_module() already skips the
synchronization:
kernel/module/main.c:do_init_module() {
...
if (!mod->async_probe_requested)
async_synchronize_full();
...
}
So the old code could not deadlock in that configuration. Before this
patch those systems got a WARN_ON_ONCE() and a working NIC. With this
patch, wouldn't the NIC stay stuck in deferred probe for good?
[Severity: High]
With this change, get_phy_device() and phy_device_create() can return
-EPROBE_DEFER. The get_phy_device() kernel-doc only lists -ENODEV and
-EIO. Do all callers pass the new error up?
fixed_phy_register() in drivers/net/phy/fixed_phy.c rewrites it:
phy = get_phy_device(fmb_mii_bus, phy_addr, false);
if (IS_ERR(phy)) {
fixed_phy_del(phy_addr);
return ERR_PTR(-EINVAL);
}
swphy_read_reg() returns 0 for MII_PHYSID1 and MII_PHYSID2. That makes
phy_id 0, so phy_device_create() always reaches
phy_request_driver_module(). In async context that now returns
-EPROBE_DEFER, and fixed_phy_register() turns it into -EINVAL.
Some MAC probes call of_phy_register_fixed_link() or fixed_phy_register()
from an async worker, for example fec, gianfar, bcmgenet, ravb, cpsw,
ftgmac100 and hibmcge. Wouldn't those now fail with -EINVAL and never be
retried?
Before this patch, __request_module() only did WARN_ON_ONCE(wait &&
current_is_async()), and the fixed PHY was still created.
Other callers collapse the error in a similar way:
xgbe_phy_find_phy_device() maps it to -ENODEV
hns_mac_register_phydev() maps it to -EIO
xgene_enet_phy_register() maps it to NULL
It hasn't been checked whether these three can run in async context.
> ret = request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
> MDIO_ID_ARGS(phy_id));
> /* We only check for failures in executing the usermode binary,
[Severity: Medium]
Should the new check apply only when a module load can actually happen?
With CONFIG_MODULES=n, include/linux/kmod.h has:
static inline int request_module(const char *name, ...) { return -ENOSYS; }
The existing IS_ENABLED(CONFIG_MODULES) && ret < 0 test then makes
phy_request_driver_module() return 0. In that configuration nothing is
loaded, there is no warning, and async_synchronize_full() can't deadlock.
current_is_async() is always built in. So non-modular kernels now also
defer every PHY creation in async context, and they hit the permanent
deferral and fixed_phy -EINVAL cases above. The same is true when the
PHY driver is built in or already loaded.
The commit message only covers the modular case.
[Severity: Low]
This isn't a bug, but the block comment in phy_device_create() still
says:
/* Request the appropriate module unconditionally; don't
* bother trying to do so only if it isn't already loaded,
...
* enough for the driver to get loaded. With MDIO, the NIC
* driver will get bored and give up as soon as it finds that
* there's no driver _already_ loaded.
*/
After this change the module request is skipped in async context, and
PHY creation returns -EPROBE_DEFER instead. Should the comment mention
the async restriction and the reliance on deferred probing?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125080939.176096-1-18255117159%40163.com
prev parent reply other threads:[~2026-11-29 8:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 8:09 [PATCH v2] net: phy: defer PHY probe when running in async probe context Hans Zhang
2026-11-29 8:40 ` netdev-bot+sashiko [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=179594160178.3146.13454099280646190968@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=18255117159@163.com \
--cc=503536682@qq.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@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