From: Hans Zhang <18255117159@163.com>
To: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net,
edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com
Cc: linux@armlinux.org.uk, netdev@vger.kernel.org,
Hans Zhang <18255117159@163.com>
Subject: [PATCH] net: phy: avoid synchronous module request in async probe context
Date: Tue, 24 Nov 2026 15:07:53 +0800 [thread overview]
Message-ID: <20261124070753.25972-1-18255117159@163.com> (raw)
phy_request_driver_module() calls request_module() with wait=true to
load a PHY driver. When the PHY device is probed from an async worker,
such as a PCIe host controller driver that sets PROBE_PREFER_ASYNCHRONOUS,
this triggers:
WARN_ON_ONCE(wait && current_is_async());
in __request_module(). On an arm64 board whose PCIe controller uses
PROBE_PREFER_ASYNCHRONOUS, probing an RTL8126A behind it produced:
WARNING: kernel/module/kmod.c:145 at __request_module+0x198/0x200, CPU#5: kworker/u49:0/77
Workqueue: async async_run_entry_fn
Call trace:
__request_module+0x198/0x200 (P)
phy_request_driver_module+0x11c/0x17c
phy_device_create+0x234/0x260
get_phy_device+0x74/0x150
mdiobus_scan+0x34/0x114
__mdiobus_register+0x1ec/0x450
__devm_mdiobus_register+0x70/0xe8
rtl_init_one+0x1350/0x16b0
local_pci_probe+0x40/0xa8
pci_call_probe+0x64/0x174
pci_device_probe+0xb4/0x144
really_probe+0xbc/0x298
__driver_probe_device+0x16c/0x19c
driver_probe_device+0x3c/0x114
__device_attach_driver+0xb8/0x118
bus_for_each_drv+0x84/0xe0
__device_attach+0x9c/0x194
device_initial_probe+0x50/0x68
pci_bus_add_device+0x6c/0xf8
pci_bus_add_devices+0x3c/0x88
pci_bus_add_devices+0x68/0x88
pci_host_probe+0x90/0x108
cdns_pcie_hpa_host_setup+0x300/0x684
sky1_pcie_probe+0x230/0x360
platform_probe+0x5c/0x9c
really_probe+0xbc/0x298
__driver_probe_device+0x16c/0x19c
driver_probe_device+0x3c/0x114
__driver_attach_async_helper+0x58/0xcc
async_run_entry_fn+0x34/0xe0
process_one_work+0x180/0x2dc
worker_thread+0x188/0x304
kthread+0x110/0x124
ret_from_fork+0x10/0x20
---[ end trace 0000000000000000 ]---
Use request_module_nowait() when current_is_async() is true so that the
PHY driver module load is requested without blocking the async worker.
The PHY driver will still bind later, when it registers and the driver
core attaches it to the already-created PHY device.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/net/phy/phy_device.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index b39e945cebd7..a634b8b0c5b2 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -10,6 +10,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/acpi.h>
+#include <linux/async.h>
#include <linux/bitmap.h>
#include <linux/delay.h>
#include <linux/errno.h>
@@ -639,8 +640,12 @@ static int phy_request_driver_module(struct phy_device *dev, u32 phy_id)
{
int ret;
- ret = request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
- MDIO_ID_ARGS(phy_id));
+ if (current_is_async())
+ ret = request_module_nowait(MDIO_MODULE_PREFIX MDIO_ID_FMT,
+ MDIO_ID_ARGS(phy_id));
+ else
+ ret = request_module(MDIO_MODULE_PREFIX MDIO_ID_FMT,
+ MDIO_ID_ARGS(phy_id));
/* We only check for failures in executing the usermode binary,
* not whether a PHY driver module exists for the PHY ID.
* Accept -ENOENT because this may occur in case no initramfs exists,
--
2.43.0
next reply other threads:[~2026-11-24 7:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:07 Hans Zhang [this message]
2026-11-25 7:37 ` [PATCH] net: phy: avoid synchronous module request in async probe context netdev-bot+sashiko
2026-11-25 7:55 ` 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=20261124070753.25972-1-18255117159@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@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