Skip to content

Commit a0dce2e

Browse files
dcuirtg-canonical
authored andcommitted
PCI: hv: Use async probing to reduce boot time
BugLink: https://bugs.launchpad.net/bugs/2023071 BugLink: https://bugs.launchpad.net/bugs/2023594 Commit 414428c ("PCI: hv: Lock PCI bus on device eject") added pci_lock_rescan_remove() and pci_unlock_rescan_remove() in create_root_hv_pci_bus() and in hv_eject_device_work() to address the race between create_root_hv_pci_bus() and hv_eject_device_work(), but it turns that grabing the pci_rescan_remove_lock mutex is not enough: refer to the earlier fix "PCI: hv: Add a per-bus mutex state_lock". Now with hbus->state_lock and other fixes, the race is resolved, so remove pci_{lock,unlock}_rescan_remove() in create_root_hv_pci_bus(): this removes the serialization in hv_pci_probe() and hence allows async-probing (PROBE_PREFER_ASYNCHRONOUS) to work. Add the async-probing flag to hv_pci_drv. pci_{lock,unlock}_rescan_remove() in hv_eject_device_work() and in hv_pci_remove() are still kept: according to the comment before drivers/pci/probe.c: static DEFINE_MUTEX(pci_rescan_remove_lock), "PCI device removal routines should always be executed under this mutex". Signed-off-by: Dexuan Cui <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Reviewed-by: Long Li <[email protected]> Cc: [email protected] (backported from commit 08a9019ea35582f310946d193e5daab53931fd04 https://github.com/dcui/tdx.git) [rtg - context adjustments] Signed-off-by: Tim Gardner <[email protected]> Acked-by: Philip Cox <[email protected]> Acked-by: John Cabaj <[email protected]> Signed-off-by: Tim Gardner <[email protected]>
1 parent 1f4b32b commit a0dce2e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/pci/controller/pci-hyperv.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,12 +2288,16 @@ static int create_root_hv_pci_bus(struct hv_pcibus_device *hbus)
22882288
if (error)
22892289
return error;
22902290

2291-
pci_lock_rescan_remove();
22922291
hv_pci_assign_properties(hbus);
2292+
/*
2293+
* pci_lock_rescan_remove() and pci_unlock_rescan_remove() are
2294+
* unnecessary here, because we hold the hbus->state_lock, meaning
2295+
* hv_eject_device_work() and pci_devices_present_work() can't race
2296+
* with create_root_hv_pci_bus().
2297+
*/
22932298
pci_bus_assign_resources(bridge->bus);
22942299
hv_pci_assign_slots(hbus);
22952300
pci_bus_add_devices(bridge->bus);
2296-
pci_unlock_rescan_remove();
22972301
hbus->state = hv_pcibus_installed;
22982302
return 0;
22992303
}
@@ -3969,6 +3973,9 @@ static struct hv_driver hv_pci_drv = {
39693973
.remove = hv_pci_remove,
39703974
.suspend = hv_pci_suspend,
39713975
.resume = hv_pci_resume,
3976+
.driver = {
3977+
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
3978+
},
39723979
};
39733980

39743981
static void __exit exit_hv_pci_drv(void)

0 commit comments

Comments
 (0)