Skip to content

Commit de3fed0

Browse files
author
Myron Stowe
committed
PCI: Allow built-in drivers to use async initial probing
JIRA: https://issues.redhat.com/browse/RHEL-107898 Upstream Status: 9170304 commit 9170304 Author: Lukas Wunner <lukas@wunner.de> Date: Fri Jul 4 09:38:33 2025 +0200 PCI: Allow built-in drivers to use async initial probing The PCI core has historically not allowed built-in drivers to opt in to async initial probing: Drivers may set "PROBE_PREFER_ASYNCHRONOUS", but 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. Modular drivers are also allowed to probe asynchronously, which is inconsistent. The choice of device_attach() is likely not deliberate: It was introduced in 2013 with commit 58d9a38 ("PCI: Skip attaching driver in device_add()"), but asynchronous probing was added two years later with commit 765230b ("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 initial 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. A small number of PCI drivers already opt in to asynchronous probing. Their maintainers (who are all cc'ed) should watch out for issues, now that asynchronous probing is not just allowed for deferred and modular 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> [bhelgaas: updated commit log per https://lore.kernel.org/r/aHYUh7WoDlhHckxd@wunner.de] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/53abe6f5ac7c631f95f5d061aa748b192eda0379.1751614426.git.lukas@wunner.de Signed-off-by: Myron Stowe <mstowe@redhat.com>
1 parent 0f9f063 commit de3fed0

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/pci/bus.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ void pci_bus_add_device(struct pci_dev *dev)
382382
{
383383
struct device_node *dn = dev->dev.of_node;
384384
struct platform_device *pdev;
385-
int retval;
386385

387386
/*
388387
* Can not put in pci_device_add yet because resources
@@ -415,9 +414,7 @@ void pci_bus_add_device(struct pci_dev *dev)
415414
if (!dn || of_device_is_available(dn))
416415
pci_dev_allow_binding(dev);
417416

418-
retval = device_attach(&dev->dev);
419-
if (retval < 0 && retval != -EPROBE_DEFER)
420-
pci_warn(dev, "device attach failed (%d)\n", retval);
417+
device_initial_probe(&dev->dev);
421418

422419
pci_dev_assign_added(dev);
423420
}

0 commit comments

Comments
 (0)