From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.5 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796289156; b=xV2RG2xME/CwmEP3ik3zkEuPRm3CY+Y0H5hCiUzlVUU2IpuFstSbaUV4nF6p6nhvTIXB pztwYhwx7ZYqQ6TUD0W0PHf9XNhvfn6QcN0VP+uyVMRvsMcRZxZW5KvcCiIU1mS8McqTb 5XrvSENtMMS4B8WAO2ox9gS0rREzHG+xU4TqyFNBEb3dPjHfNkfEJcGZMKTaQWDc/8Q8e mR6KvG/aNY2429z4W5ugUSsaswySy+bUdID5n0D9pDVbI2EAQkCWSfpVMQcnA+O6zDM7q tK84PfXmMUNO1uksR+YiGYqmEs3e5+r8LbkbtxHPzZAVwcZ24sSdxoulHD3WIQI3qQg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796289156; 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=u4rGscN/FD/7Y1lQBwXNORFOe2gGL88pRdp1Gw8+XV8=; b=ocBUwcJ0o+a6c+cjcsBm8thnv6qyIOIKKnfPvJIz2tIgqkhIGBhXtoz96eGbADBb8iae UVr/kTwDrpTBct4YiszZjh/Tbg6VaZ8qx3b/8mrVHZOqrtnUmPYpLLzOZX5zPu6eJO9f5 pynQa7evF0ukrW/+fLuSjD4lB9eWoHns7orMV8KKyBh7WDIIFACXQ+6lUTglYI5GAN+U1 dm3cLH8LnsZvEInjdc0oEJX1b5ecjclIvLgkVSNtsexjASFsOO24K68Ysws9EeWCmR+2O 1wnGqPy1JBOkbnkKEcXW4RP49N21GLwGWuQ4TDHCJv3uGtE4a0o/wXk/n/H6TRXmnCQ== 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=nOkt1UCS; arc=none smtp.remote-ip=220.197.31.5 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 49668606A322; Thu, 3 Dec 2026 09:12:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 49668606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com 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=nOkt1UCS 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=u4rGscN/FD/7Y1lQBwXNORFOe2gGL88pRdp1Gw8+XV8=; b=nOkt1UCSKsEUfXYYb+tSilIRsA8Z7ZhifNcNxuHawOY97pR6uICUtGWxsJoP2v /ZTxY3GaAzFX7evHHRR7CCX9rTaHCBmfLoEcP9wGL4tNbTqZUs4HY7OtuBM6Et1b O4dKQ4zcvTvKOAHY2MxsUVmQCo5ytdGy+yFp2YhI9h35Y= Message-ID: <31e7f688-fa8d-4aad-b7ed-d03a06758ac1@163.com> Date: Thu, 3 Dec 2026 17:11:12 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] PCI: dw-rockchip: Enable async probe by default To: Robin Murphy , Danilo Krummrich Cc: Manivannan Sadhasivam , Manivannan Sadhasivam , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Heiko Stuebner , Niklas Cassel , Shawn Lin , Nicolas Frattaroli , Wilfred Mallawa , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Anand Moon , Grimmauld , Greg Kroah-Hartman , "Rafael J. Wysocki" , driver-core@lists.linux.dev, Lukas Wunner , Andrew Lunn , dmitry.torokhov@gmail.com References: <20260226101032.1042-1-linux.amoon@gmail.com> <177260693908.10259.13055467642416391434.b4-ty@kernel.org> <87bc37ee-234c-4568-b72e-955c130a6838@arm.com> <5d88fb5b-e771-4ea6-8d2c-c5cfd21e5860@arm.com> <55c28218-1638-4b90-a9cd-a177fb5abcb6@arm.com> <6cfe4bda-036f-4bb9-8a08-ed75f61cae24@arm.com> <4f9fdfc9-f2ad-49b1-a6b9-ae64aaa47cfd@arm.com> Content-Language: en-US From: Hans Zhang <18255117159@163.com> In-Reply-To: <4f9fdfc9-f2ad-49b1-a6b9-ae64aaa47cfd@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:QCgvCgDHjJgwMhFrDOB1Jg--.21591S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxKrWkGw43KF1fZFW7WrW7urg_yoWxGFWxpF W5JayYvFZ8JrWxZr17tF4SvFyFyw4xAr45Wrn5JryUZas0yFnavrWxtay5uFyDur18Ga4j vr1jga43uFyjyaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UZ0eLUUUUU= X-CM-SenderInfo: rpryjkyvrrlimvzbiqqrwthudrp/xtbC7BK3W2sRMjLG8gAA3c 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