mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Zhang <18255117159@163.com>
To: Robin Murphy <robin.murphy@arm.com>, Danilo Krummrich <dakr@kernel.org>
Cc: "Manivannan Sadhasivam" <mani@kernel.org>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@oss.qualcomm.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Niklas Cassel" <cassel@kernel.org>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	"Nicolas Frattaroli" <nicolas.frattaroli@collabora.com>,
	"Wilfred Mallawa" <wilfred.mallawa@wdc.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	"Anand Moon" <linux.amoon@gmail.com>,
	Grimmauld <grimmauld@grimmauld.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	driver-core@lists.linux.dev, "Lukas Wunner" <lukas@wunner.de>,
	"Andrew Lunn" <andrew@lunn.ch>,
	dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3] PCI: dw-rockchip: Enable async probe by default
Date: Thu, 3 Dec 2026 17:11:12 +0800	[thread overview]
Message-ID: <31e7f688-fa8d-4aad-b7ed-d03a06758ac1@163.com> (raw)
In-Reply-To: <4f9fdfc9-f2ad-49b1-a6b9-ae64aaa47cfd@arm.com>



On 3/14/26 01:36, Robin Murphy wrote:
> On 2026-03-13 2:39 pm, Danilo Krummrich wrote:
>> On Fri Mar 13, 2026 at 2:15 PM CET, Robin Murphy wrote:
>>> On 2026-03-12 12:59 pm, Danilo Krummrich wrote:
>>>> On Thu Mar 12, 2026 at 1:48 PM CET, Robin Murphy wrote:
>>>>> On 2026-03-11 9:09 pm, Danilo Krummrich wrote:
>>>>>>    From a driver-core perspective I think we're rather limited on 
>>>>>> what we can do;
>>>>>> we are already in async context at this point and can't magically 
>>>>>> go back to
>>>>>> initcall context.
>>>>>>
>>>>>> So, the only thing I can think of is to kick off work on a 
>>>>>> workqueue, which in
>>>>>> the end would be the same as the deferred probe handling.
>>>>>
>>>>> Hmm, in fact, isn't the deferred probe mechanism itself actually quite
>>>>> appropriate?
>>>>
>>>> Yes, I've also mentioned this in [1], including the fact that it 
>>>> technically
>>>> even complies with the guarantees given by PROBE_FORCE_SYNCHRONOUS. 
>>>> I.e. the
>>>> documentation says:
>>>>
>>>>     Use this to annotate drivers that need their probe routines to run
>>>>     synchronously with driver and device registration (with the 
>>>> exception of
>>>>     -EPROBE_DEFER handling - re-probing always ends up being done
>>>>     asynchronously).
>>>>
>>>> However, I'm still not sure how I feel about this, since I consider 
>>>> this to be
>>>> more like a workaround that just moves things to a "more approprite" 
>>>> async
>>>> context.
>>>
>>> I guess the underlying problem there is that there are at least 3
>>> different significant aspects to what "synchronous" can mean:
>>>
>>> - literally in the context or device/driver registration as documented.
>>> Off-hand I'm not really sure what useful property may be *specific* to
>>> those conditions that a driver might rely on, other than for
>>> super-special cases like platform_driver_probe().
>>
>> I'm not worried about this one, as it is already special by not being 
>> compatible
>> with deferred probe. I.e. the caller already has to promise that the
>> corresponding probe() call will never return -EPROBE_DEFER.
>>
>> This is a much more error prone requirement than just "don't call this 
>> from
>> async" already.
>>
>>> - serialised, i.e. probes of multiple devices won't happen concurrently
>>> on multiple threads. This is probably the one hiding the most driver
>>> bugs, e.g. internal shared/global state without sufficient
>>> synchronisation. I guess this falls out as a side-effect of the first
>>> condition, but AFAICS it *can* also still provided by deferred probe
>>> (given that it's a single work item iterating a list one-by-one)
>>>
>>> - in some regular thread context that isn't liable to have issues
>>> synchronising against other async_func workers (i.e. the request_module
>>> case). Again, deferred can't have a problem here, or it wouldn't have
>>> worked properly in general for the last decade.
>>>
>>> So it's not that we'd be relying on some dubious "deferred is always
>>> synchronous" assumption - AFAICS deferred *can* launch async if the
>>> driver permits it - more just ratifying that deferred is still able to
>>> effectively honour all the useful properties of PROBE_FORCE_SYNCHRONOUS
>>> other than "during registration of the thing".
>>
>> Yes, and as mentioned above, EPROBE_DEFER has always been a valid path 
>> for
>> PROBE_FORCE_SYNCHRONOUS, which is why I brought it up as a a 
>> workaround in the
>> first place.
>>
>> (The reason why I still say "workaround" is because nothing actually 
>> needs to be
>> deferred.)
>>
>> Anyways, as I mentioned...
>>
>>>> On the other hand, eventually we want everything to work with
>>>> PROBE_PREFER_ASYNCHRONOUS, so maybe it's also good enough for the 
>>>> time being.
>>
>> ...plus there are not a lot of PROBE_FORCE_SYNCHRONOUS left anyways.
>>
>> Do you want to send a patch?
> 
> Sure, I just wanted to check that you didn't see anything obviously 
> wrong with my reasoning-by-inspection - if you're sufficiently happy 
> then I'll write this up as a proper commit message and post the patch 
> (likely on Monday now) so we can all nit-pick the details :)
> 


Hi Robin, Danilo, Dmitry,

I have the exact async-probe-vs-phylib case on the Cix Sky1 SoC: the 
PCIe controller (pci-sky1.c) sets PROBE_PREFER_ASYNCHRONOUS, and probing 
a Realtek RTL8126A NIC behind it hits WARN_ON_ONCE(wait && 
current_is_async()) in __request_module(), reached from 
phy_device_create() -> phy_request_driver_module().  So I tested the 
deferred-probe idea from [1].

As posted, it doesn't actually work: the child device is silently 
dropped — never probed and never queued.  driver_deferred_probe_add() 
bails out immediately when dev_can_match() is false, and in this path 
that flag is only set later in __driver_probe_device(), which the early 
return in __device_attach_driver() never reaches.  The device ends up 
neither bound nor on the deferred list.

The one-line fix is to set the flag first:

         if (!async_allowed && current_is_async()) {
                 dev_set_can_match(dev);
                 driver_deferred_probe_add(dev);
                 return 0;
         }

With that, on Sky1 (two RTL8126A NICs) both NICs bind and link up, the
__request_module() WARN is gone, and boot time is unchanged (both NICs 
up at 2.13s / 2.15s, vs 2.22s / 2.44s with the WARN in the baseline).

Dmitry, this respects the principle you raised: a driver's probe type is
its own property, not the parent's — the defer makes the driver core 
honor a synchronous child even when the parent probes asynchronously. 
Deferred reprobing is already the documented exception to 
PROBE_FORCE_SYNCHRONOUS's synchronous-registration guarantee.  The 
separate question of why PCI does initial probing differently from every 
other bus is a deeper issue, but this patch is the general driver-core 
fix for the child-context problem.

Robin, you mentioned [2] writing this up as a proper patch — do you 
still want to send it yourself, or would you like me to post it?  Either 
way I can provide a Tested-by (Sky1 / RTL8126A) and the 
dev_set_can_match() delta.

[1] 
https://lore.kernel.org/driver-core/55c28218-1638-4b90-a9cd-a177fb5abcb6@arm.com/
[2] 
https://lore.kernel.org/driver-core/4f9fdfc9-f2ad-49b1-a6b9-ae64aaa47cfd@arm.com/

Thanks,
Hans






  parent reply	other threads:[~2026-12-03  9:12 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 10:10 Anand Moon
2026-02-26 12:06 ` Niklas Cassel
2026-03-02 15:59 ` Hans Zhang
2026-03-03  1:01 ` Shawn Lin
2026-03-04  6:48 ` Manivannan Sadhasivam
2026-03-10 13:41   ` Robin Murphy
2026-03-10 15:30     ` Manivannan Sadhasivam
2026-03-10 21:03       ` Robin Murphy
2026-03-11  0:43         ` Danilo Krummrich
2026-03-25  3:44           ` Dmitry Torokhov
2026-03-25  6:36             ` Lukas Wunner
2026-03-11  5:24         ` Manivannan Sadhasivam
2026-03-11  7:56           ` Lukas Wunner
2026-03-11 11:46           ` Danilo Krummrich
2026-03-11 12:13             ` Niklas Cassel
2026-03-11 12:28             ` Manivannan Sadhasivam
2026-03-11 21:09               ` Danilo Krummrich
2026-03-12  1:33                 ` Shawn Lin
2026-03-12 11:40                   ` Anand Moon
2026-03-12 11:54                     ` Danilo Krummrich
2026-03-13  9:26                       ` Anand Moon
2026-03-12 12:48                 ` Robin Murphy
2026-03-12 12:59                   ` Danilo Krummrich
2026-03-13 13:15                     ` Robin Murphy
2026-03-13 14:39                       ` Danilo Krummrich
2026-03-13 17:36                         ` Robin Murphy
2026-03-14  5:12                           ` Anand Moon
2026-03-17  6:24                             ` Anand Moon
2026-12-03  9:11                           ` Hans Zhang [this message]
2026-03-13 14:05                     ` Manivannan Sadhasivam
2026-03-13  9:25                   ` Anand Moon
2026-03-25  4:13                   ` Dmitry Torokhov
2026-03-25 15:01                     ` Robin Murphy
2026-03-25 15:23                       ` Dmitry Torokhov
2026-03-25 15:13                     ` Danilo Krummrich
2026-03-25 15:26                       ` Dmitry Torokhov
2026-03-25 18:24                         ` Anand Moon
2026-03-11 12:32   ` Manivannan Sadhasivam

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=31e7f688-fa8d-4aad-b7ed-d03a06758ac1@163.com \
    --to=18255117159@163.com \
    --cc=andrew@lunn.ch \
    --cc=bhelgaas@google.com \
    --cc=cassel@kernel.org \
    --cc=dakr@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=grimmauld@grimmauld.de \
    --cc=heiko@sntech.de \
    --cc=kwilczynski@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux.amoon@gmail.com \
    --cc=lpieralisi@kernel.org \
    --cc=lukas@wunner.de \
    --cc=mani@kernel.org \
    --cc=manivannan.sadhasivam@oss.qualcomm.com \
    --cc=nicolas.frattaroli@collabora.com \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=shawn.lin@rock-chips.com \
    --cc=wilfred.mallawa@wdc.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

all inboxes | Powered by JetHome®