linux-stable/drivers/pci
Ilpo Järvinen fae0e055d0 PCI: Do not wait for disconnected devices when resuming
[ Upstream commit 6613443ffc ]

On runtime resume, pci_dev_wait() is called:

  pci_pm_runtime_resume()
    pci_pm_bridge_power_up_actions()
      pci_bridge_wait_for_secondary_bus()
        pci_dev_wait()

While a device is runtime suspended along with its PCI hierarchy, the
device could get disconnected. In such case, the link will not come up no
matter how long pci_dev_wait() waits for it.

Besides the above mentioned case, there could be other ways to get the
device disconnected while pci_dev_wait() is waiting for the link to come
up.

Make pci_dev_wait() exit if the device is already disconnected to avoid
unnecessary delay.

The use cases of pci_dev_wait() boil down to two:

  1. Waiting for the device after reset
  2. pci_bridge_wait_for_secondary_bus()

The callers in both cases seem to benefit from propagating the
disconnection as error even if device disconnection would be more
analoguous to the case where there is no device in the first place which
return 0 from pci_dev_wait(). In the case 2, it results in unnecessary
marking of the devices disconnected again but that is just harmless extra
work.

Also make sure compiler does not become too clever with dev->error_state
and use READ_ONCE() to force a fetch for the up-to-date value.

Link: https://lore.kernel.org/r/20240208132322.4811-1-ilpo.jarvinen@linux.intel.com
Reported-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-27 13:49:05 +02:00
..
controller PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id 2024-06-21 14:38:41 +02:00
endpoint NTB: fix possible name leak in ntb_register_device() 2024-03-26 18:19:48 -04:00
hotplug Revert "PCI: acpiphp: Reassign resources on bridge if necessary" 2023-12-20 17:01:53 +01:00
msi PCI/MSI: Prevent MSI hardware interrupt number truncation 2024-03-01 13:35:01 +01:00
pcie PCI/EDR: Align EDR_PORT_LOCATE_DSM with PCI Firmware r3.3 2024-06-12 11:12:27 +02:00
switch PCI: switchtec: Fix an error handling path in switchtec_pci_probe() 2024-03-26 18:19:46 -04:00
access.c PCI: Simplify pcie_capability_clear_and_set_word() control flow 2023-08-25 08:16:10 -05:00
ats.c
bus.c PCI/ASPM: Fix deadlock when enabling ASPM 2024-04-27 17:11:44 +02:00
doe.c PCI/DOE: Fix destroy_work_on_stack() race 2023-07-27 15:20:47 -05:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Use pci_dev_id() to simplify the code 2023-08-07 16:15:39 -05:00
irq.c
Kconfig PCI: Fix CONFIG_PCI_DYNAMIC_OF_NODES kconfig dependencies 2023-09-05 12:42:28 -05:00
Makefile PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
mmap.c
of.c PCI: of: Destroy changeset when adding PCI device node fails 2023-09-29 17:33:51 -05:00
of_property.c PCI: of_property: Return error for int_map allocation failure 2024-06-12 11:12:24 +02:00
p2pdma.c PCI/P2PDMA: Fix a sleeping issue in a RCU read section 2024-03-26 18:19:46 -04:00
pci-acpi.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 17:19:57 +00:00
pci-bridge-emul.c
pci-bridge-emul.h
pci-driver.c PCI/PM: Drain runtime-idle callbacks before driver removal 2024-04-03 15:28:26 +02:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c
pci-sysfs.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 17:19:57 +00:00
pci.c PCI: Do not wait for disconnected devices when resuming 2024-06-27 13:49:05 +02:00
pci.h PCI/ASPM: Fix deadlock when enabling ASPM 2024-04-27 17:11:44 +02:00
probe.c PCI: Do error check on own line to split long "if" conditions 2023-11-28 17:19:43 +00:00
proc.c
quirks.c PCI: Simplify pcie_capability_clear_and_set_word() to ..._clear_word() 2024-04-27 17:11:36 +02:00
remove.c PCI: Create device tree node for bridge 2023-08-22 14:56:09 -05:00
rom.c
search.c
setup-bus.c PCI: Fix typos in docs and comments 2023-08-25 08:15:38 -05:00
setup-irq.c
setup-res.c PCI: Fix printk field formatting 2023-08-25 08:15:08 -05:00
slot.c
syscall.c PCI: Use consistent put_user() pointer types 2023-08-25 08:15:13 -05:00
vc.c
vgaarb.c PCI/VGA: Fix typos 2023-08-24 13:27:47 -05:00
vpd.c PCI/VPD: Add runtime power management to sysfs interface 2023-08-11 14:19:16 -05:00
xen-pcifront.c x86: always initialize xen-swiotlb when xen-pcifront is enabling 2023-07-31 17:54:27 +02:00