Netdev List
 help / color / mirror / Atom feed
From: Hans Zhang <18255117159@163.com>
To: Andrew Lunn <andrew@lunn.ch>
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
Subject: Re: [PATCH] net: phy: avoid synchronous module request in async probe context
Date: Sun, 29 Nov 2026 15:16:34 +0800	[thread overview]
Message-ID: <c0834daa-176e-454b-8408-3818ead9c688@163.com> (raw)
In-Reply-To: <04208d88-5611-4b08-b4a3-4030d75fa946@lunn.ch>



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




  reply	other threads:[~2026-11-29  7:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  7:07 [PATCH] net: phy: avoid synchronous module request in async probe context Hans Zhang
2026-11-25  7:37 ` netdev-bot+sashiko
2026-11-25  7:55   ` Hans Zhang
2026-11-25 13:58     ` Andrew Lunn
2026-11-26  3:52       ` Hans Zhang
2026-11-26 14:35         ` Andrew Lunn
2026-11-29  7:16           ` Hans Zhang [this message]
2026-11-29  7:46             ` 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=c0834daa-176e-454b-8408-3818ead9c688@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