Article View: linux.kernel.netdev
Article #24069Re: [PATCH] net: phy: avoid synchronous module request in async probe context
From: Hans Zhang
Date: Sun, 29 Nov 2026 07:16
Date: Sun, 29 Nov 2026 07:16
116 lines
12513 bytes
12513 bytes
On 11/26/26 22:35, Andrew Lunn wrote:
>> For v3 I'm considering moving the check to __mdiobus_register() itself,
>> returning -EPROBE_DEFER before the scan when current_is_async() is true.
>
> Maybe. This code is tricky. There are quiet a lot of comments
> explaining the issues, which the LLM quoted. You should look at the
> comments, and what the LLM said, and think about all the corner cases
> you can think of.
>
>> __mdiobus_register() already returns -EPROBE_DEFER for the reset-GPIO
>> case, and the deferred-probe retry runs on a normal workqueue where
>> current_is_async() is false, so the synchronous request_module() is safe
>> again. Direct get_phy_device() callers would not be affected.
>
> This does seem like it could work. However, i'm considering the risks.
> Are there MAC drivers which don't correctly handle EPROBE_DEFER from
> the mdiobus_register variants?
>
> Such a change would solve it for all MAC drives which probe
> async. However, i think there is a less risky option:
>
> .probe_type = PROBE_FORCE_SYNCHRONOUS,
>
> for this one MAC driver.
>
> That is also probably faster. The MAC driver has often done a lot of
> work setting stuff up before it calls mdiobus_register(), which it
> then needs to undo, and do again later. I assume
> PROBE_FORCE_SYNCHRONOUS will completely avoid that, the probe happens
> later in synchronous context, and avoids all this.
>
> If we see more MAC drivers having this problem, we can then consider
> your general solution.
>
> Andrew
Hi Andrew,
I tested PROBE_FORCE_SYNCHRONOUS on the r8169 MAC driver (and reverted
Sky1 back to PROBE_PREFER_ASYNCHRONOUS). The WARN still fires.
The trace still starts at async_run_entry_fn and goes through:
async_run_entry_fn
__driver_attach_async_helper
driver_probe_device
__driver_probe_device
really_probe
platform_probe
sky1_pcie_probe
cdns_pcie_hpa_host_setup
pci_host_probe
pci_bus_add_devices
pci_bus_add_device
device_initial_probe
__device_attach
__device_attach_driver
driver_probe_device
really_probe
pci_device_probe
local_pci_probe
rtl_init_one
__devm_mdiobus_register
__mdiobus_register
mdiobus_scan
get_phy_device
phy_device_create
phy_request_driver_module
__request_module
diff patch:
diff --git a/drivers/net/ethernet/realtek/r8169_main.c
b/drivers/net/ethernet/realtek/r8169_main.c
index f151ab681393..85746643afbb 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -7074,7 +7074,10 @@ static struct pci_driver rtl8169_pci_driver = {
.probe = rtl_init_one,
.remove = rtl_remove_one,
.shutdown = rtl_shutdown,
- .driver.pm = pm_ptr(&rtl8169_pm_ops),
+ .driver = {
+ .pm = pm_ptr(&rtl8169_pm_ops),
+ .probe_type = PROBE_FORCE_SYNCHRONOUS,
+ },
};
module_pci_driver(rtl8169_pci_driver);
So the r8169 probe still runs inside the async worker of the parent Sky1
controller. PROBE_FORCE_SYNCHRONOUS on the child PCI driver only prevents
scheduling a new async probe for it; it does not change the context when
the child is added during the parent's async probe.
Forcing the Sky1 controller probe synchronous is not an option on the PCI
side: those controllers use PROBE_PREFER_ASYNCHRONOUS specifically so
their multiple root complexes are enumerated in parallel, and serializing
them would hurt boot time and PCIe enumeration. So the fix needs to be in
the phylib/mdio path instead.
Could the phylib maintainers advise on the right way to avoid the
synchronous request_module() when the MDIO bus is scanned from async
context? I'm happy to implement and test whatever direction you suggest.
Best regards,
Hans
Technical Details
Message-ID:
<c0834daa-176e-454b-8408-3818ead9c688@163.com>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373393-linux-kernel-netdev=dewy.ruReferences:
<20261124070753.25972-1-18255117159@163.com> <179559227928.3135.10596298102368144827@kernel.org> <0437f8be-41ca-4fb8-b775-ed02413ea16d@163.com> <24787f0c-e90e-45f1-a9f3-d0772fbafeaf@lunn.ch> <c1ee530d-21bc-4b50-881f-3be9b2654b9d@163.com> <04208d88-5611-4b08-b4a3-4030d75fa946@lunn.ch>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373393-linux-kernel-netdev=dewy.ru From: 18255117159@163.com (Hans Zhang) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH] net: phy: avoid synchronous module request in async probe context Date: Sun, 29 Nov 2026 15:16:34 +0800 Organization: Usenet Network Message-ID: <c0834daa-176e-454b-8408-3818ead9c688@163.com> References: <20261124070753.25972-1-18255117159@163.com> <179559227928.3135.10596298102368144827@kernel.org> <0437f8be-41ca-4fb8-b775-ed02413ea16d@163.com> <24787f0c-e90e-45f1-a9f3-d0772fbafeaf@lunn.ch> <c1ee530d-21bc-4b50-881f-3be9b2654b9d@163.com> <04208d88-5611-4b08-b4a3-4030d75fa946@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="1124195"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:uSc/IOsHr83xA/IlF669sJkm4uI= sha256:f3y+24ZYvnrlSWIUeT5FEyfv1SRUUCZ+RluIBZ4NWQM= sha1:L1JTDO05iAtleHRTu23r8yiwoxA= sha256:bEDoDVyKy9A6po3kVAdHtegyNRtFpMKhRH7xkzqfL90= Content-Language: en-US List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id D920A125F95; Sun, 29 Nov 2026 10:17:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.717 X-Spam-Status: No, score=-2.717 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, FROM_LOCAL_DIGITS=0.001, FROM_LOCAL_HEX=0.331, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZjuRMaCr62FL; Sun, 29 Nov 2026 10:17:52 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373393-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 9D64F125F93; Sun, 29 Nov 2026 10:17:40 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 0554925BBF; Sun, 29 Nov 2026 07:17:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795936658; b=kyOl9kWBgrTymAoPDSFEqpza/MuIuqmCGZkcdqOfWAM33jWtx4zH4dHDEtJQXkfZCOq/ oDini3lHgjp6uVVBLiyzIgCwUTxHEJ5pCwATfgV5hRqbIk0CobVNwncKt+yBsIPAWtkzA lEwgCkiTgtL06n00dhNORKXmLrR17bq4kdpWj8pEIWaYphX+et5SOsjnkjYpsY/09NUUF PcM28l6Y6evZ69nWWeEZUPWuEDweNY2LFLEMtoFInCu/D7f71WKczOnbdNe/IvvLL1FLX yVioLePDfVhqIGDsBx2IiMGdkJbdWMmtF0YKSQry5qok8nXQBO554IYamg9Om/JdVPg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795936658; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=XviO2xoZ9/v+cUX9+9bb3Wsx91K2SQwfVrm4pibCLKk=; b=BADczfD4DlN8HRg3hNmAlMkw10P4/SKuJ2NPkunsGEQi/QtbrnppMhKe+lYwR1EmUZl3 YvJ87f17cHwQyjI1/9kxnRqZxY1f2W0EqG1u66Lqw5kKoR5PhiUrFFzbF1NIeG2ifqEOE VoazZNabYDU3X4L7ejCxDAKqrq47CVkiZAn6LHIcAzQBc2nxb2t4rD4aZWKITVzcTm6kW +g+Qrkis77OJwYUtWfnS93aGrd14BvbNbwfT2GPPd37Q5XdF/ePFx3jEVmz5A2gx5t4l5 5FUjnj6IrYpkNrAMm2CFx1Rv8dLJeIxCgdONrzGfPjMnsOggJkS4/IJwJp8sMOyBzOg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=aHA5f+PX; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADFE5606A32A; Sun, 29 Nov 2026 07:17:38 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=aHA5f+PX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.5 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795936657; b=L1iAAtQUX7q+9/xcelWRICZdfzCkZN/SUKy8MkaMC2vsBrLv6sahKnSmmzNu8ciDi0oH xvqorUfIUDFFjeVixTFfh2mOrLRZgBCNQ1cyqif8utNqvRB5zkompsDnF34p+pRaZDgj7 Y1XBSDyzPoyQgxVv89gTs9xI6SC5g793nMK3uKdhtsSBDKF40y9UMEnvDmtKzaQeETFzn FdGfS8Nui2uBdRbtsrjZjQU4b6tg+KpuUIQ+/hZhrt+ncVy8LqGY4qixl275LocEW0yxQ U9UO7Bvm5GcfihtoWPqsOa+l4bJIUQL98tGAnWdJdN8k+7m8eQZcR2UpjbC7NkKBuFw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795936657; h=DMARC-Filter:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=XviO2xoZ9/v+cUX9+9bb3Wsx91K2SQwfVrm4pibCLKk=; b=kPkxVQ7vl87cPC4rIgb9L1h7c+SsWGUeDbLLBCBPxZ/iPlrVLNNlSpNveIene9u8BJMh bkL1/THC1UG63X4zzV1kYpBqS/YrFrAdeA5kP834TWXgIzS3+OjusMeW+jMocdctWs5XC b0b2zKFDVI3HXJjS6iBW8fLuAl1pRrzu0WeNT9izevY8CCmoN8B3UTGn9R8ldKgxdG87K dc9dYB6IIUeIOAD1DHmhETX7nUH4/bjvLg917SfIYu5tVyqqamgb/DtwNJ/MyuKtcVVaI sP4TpasaA+u/g0lrAXTx/7mkuIQrWjgc6wWwdZJpBJfuWvxMjiekgDYmKHdCEFWmtoQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=aHA5f+PX; arc=none smtp.remote-ip=220.197.31.5 X-Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C07D7606A31C for <netdev@vger.kernel.org>; Sun, 29 Nov 2026 07:17:34 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C07D7606A31C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:To:From: Content-Type; bh=XviO2xoZ9/v+cUX9+9bb3Wsx91K2SQwfVrm4pibCLKk=; b=aHA5f+PX2YDCgrew/LWOA/hXwOwpPFUrDaJqbhLfwAH+FAfbLL+leavt4c2DSG 2S3eAJmG0oEWGde0Z4QHNT4ogXNU8bOXFZI0YPzSY0x/nDbxR5BVaxpl5eC5xty+ goaxgUDPvqjwFv27GSr7jwJkEO3QZ6xkUpXWXDamDzfKI= X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: netdev-bot+sashiko@kernel.org, hkallweit1@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, netdev@vger.kernel.org X-In-Reply-To: <04208d88-5611-4b08-b4a3-4030d75fa946@lunn.ch> X-CM-TRANSID: _____wD3t79S0QtriumZLw--.18235S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxXFyrKw13Kr18ZrWDJF47Arb_yoWrJw1DpF Z8Xa9IvF4vqr4Ivws7Cw40vFyrta1rAr9xWr1kG34a9rZ09r1qvryxKrWjvr1DXws3Ka12 qrnIyryrCa45AFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U5gA7UUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/xtbC6xMmyWsL0VNIdQAA3I