From: Bjorn Helgaas <helgaas@kernel.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
linux-pci@vger.kernel.org,
Yaron Avizrat <yaron.avizrat@intel.com>,
Koby Elbaz <koby.elbaz@intel.com>,
Konstantin Sinyuk <konstantin.sinyuk@intel.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Even Xu <even.xu@intel.com>, Xinpeng Sun <xinpeng.sun@intel.com>,
Jean Delvare <jdelvare@suse.com>,
Alexander Usyskin <alexander.usyskin@intel.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Alan Stern <stern@rowland.harvard.edu>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Stuart Hayes <stuart.w.hayes@gmail.com>,
David Jeffery <djeffery@redhat.com>,
Jeremy Allison <jallison@ciq.com>
Subject: Re: [PATCH] PCI: Allow drivers to opt in to async probing
Date: Tue, 8 Jul 2025 18:11:23 -0500 [thread overview]
Message-ID: <20250708231123.GA2169642@bhelgaas> (raw)
In-Reply-To: <53abe6f5ac7c631f95f5d061aa748b192eda0379.1751614426.git.lukas@wunner.de>
On Fri, Jul 04, 2025 at 09:38:33AM +0200, Lukas Wunner wrote:
> The PCI core has historically not allowed drivers to opt in to async
> probing: Even though drivers may set "PROBE_PREFER_ASYNCHRONOUS", initial
> probing always happens synchronously. That's because the PCI core uses
> device_attach() instead of device_initial_probe().
>
> Should a driver return -EPROBE_DEFER on initial probe, reprobing later on
> does honor the PROBE_PREFER_ASYNCHRONOUS setting, which is inconsistent.
>
> The choice of device_attach() is likely not deliberate: It was introduced
> in 2013 with commit 58d9a38f6fac ("PCI: Skip attaching driver in
> device_add()"), but asynchronous probing was added two years later with
> commit 765230b5f084 ("driver-core: add asynchronous probing support for
> drivers").
>
> According to the kernel-doc of "enum probe_type", "the end goal is to
> switch the kernel to use asynchronous probing by default". To this end,
> use device_initial_probe() to allow asynchronous probing. The function
> returns void, making the return value check unnecessary.
>
> Initial PCI probing often takes on the order of seconds even on laptops,
> so this may speed up booting significantly.
>
> Curiously, a small number of PCI drivers already opt in to asynchronous
> probing. Their maintainters (who are all cc'ed) should watch out for
> issues, now that asynchronous probing is not just allowed for deferred
> probing, but also initial probing:
>
> hl_pci_driver drivers/accel/habanalabs/common/habanalabs_drv.c
> cxl_pci_driver drivers/cxl/pci.c
> quicki2c_driver drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
> quickspi_driver drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
> i801_driver drivers/i2c/busses/i2c-i801.c
> mei_me_driver drivers/misc/mei/pci-me.c
> mei_vsc_drv drivers/misc/mei/platform-vsc.c
> sdhci_driver drivers/mmc/host/sdhci-pci-core.c
> nvme_driver drivers/nvme/host/pci.c
> ehci_pci_driver drivers/usb/host/ehci-pci.c
> hvfb_pci_stub_driver drivers/video/fbdev/hyperv_fb.c
>
> All other driver maintainers may test asynchronous probing by specifying
> the command line parameter "driver_async_probe=drv_name1,drv_name2,...",
> and on success setting "probe_type = PROBE_PREFER_ASYNCHRONOUS" in the
> pci_driver struct.
>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
Applied to pci/enumeration for v6.17, thanks!
> ---
> drivers/pci/bus.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
> index 69048869ef1c..b77fd30bbfd9 100644
> --- a/drivers/pci/bus.c
> +++ b/drivers/pci/bus.c
> @@ -341,7 +341,6 @@ void pci_bus_add_device(struct pci_dev *dev)
> {
> struct device_node *dn = dev->dev.of_node;
> struct platform_device *pdev;
> - int retval;
>
> /*
> * Can not put in pci_device_add yet because resources
> @@ -372,9 +371,7 @@ void pci_bus_add_device(struct pci_dev *dev)
> if (!dn || of_device_is_available(dn))
> pci_dev_allow_binding(dev);
>
> - retval = device_attach(&dev->dev);
> - if (retval < 0 && retval != -EPROBE_DEFER)
> - pci_warn(dev, "device attach failed (%d)\n", retval);
> + device_initial_probe(&dev->dev);
>
> pci_dev_assign_added(dev);
> }
> --
> 2.47.2
>
next prev parent reply other threads:[~2025-07-08 23:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 7:38 [PATCH] PCI: Allow drivers to opt in to async probing Lukas Wunner
2025-07-08 23:11 ` Bjorn Helgaas [this message]
2025-07-14 13:45 ` Christoph Hellwig
2025-07-14 14:20 ` Lukas Wunner
2025-07-15 6:13 ` Christoph Hellwig
2025-07-15 6:35 ` dan.j.williams
2025-07-15 8:42 ` Lukas Wunner
2025-07-15 16:26 ` Bjorn Helgaas
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=20250708231123.GA2169642@bhelgaas \
--to=helgaas@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.usyskin@intel.com \
--cc=alison.schofield@intel.com \
--cc=axboe@kernel.dk \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=decui@microsoft.com \
--cc=djeffery@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=even.xu@intel.com \
--cc=haiyangz@microsoft.com \
--cc=hch@lst.de \
--cc=ira.weiny@intel.com \
--cc=jallison@ciq.com \
--cc=jdelvare@suse.com \
--cc=jonathan.cameron@huawei.com \
--cc=kbusch@kernel.org \
--cc=koby.elbaz@intel.com \
--cc=konstantin.sinyuk@intel.com \
--cc=kys@microsoft.com \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=sagi@grimberg.me \
--cc=stern@rowland.harvard.edu \
--cc=stuart.w.hayes@gmail.com \
--cc=vishal.l.verma@intel.com \
--cc=wei.liu@kernel.org \
--cc=xinpeng.sun@intel.com \
--cc=yaron.avizrat@intel.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;
as well as URLs for NNTP newsgroup(s).