Skip to contentSkip to conversation

PCI/PM: Skip resuming to D0 if disconnected

PATCH Superseded Mario Limonciello 1 participant 1 message Jul 9, 2025 PCI

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 PCI/PM: Skip resuming to D0 if disconnected

From: Mario Limonciello <[email protected]>

When a USB4 dock is unplugged the PCIe bridge it's connected to will issue a "Link Down" and "Card not detected event". The PCI core will treat this as a surprise hotplug event and unconfigure all downstream devices. This involves setting the device error state to pci_channel_io_perm_failure which pci_dev_is_disconnected() will check.

It doesn't make sense to runtime resume disconnected devices to D0 and report the (expected) error, so bail early.

---
v5:
* Pick up tags, rebase on linux-next

---
 drivers/pci/pci.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/pci/pci.c +5 -0
index 9e42090fb1089..160a9a482c732 100644
@@ -1374,6 +1374,11 @@ int pci_power_up(struct pci_dev *dev)
 		return -EIO;
 	}
 
+	if (pci_dev_is_disconnected(dev)) {
+		dev->current_state = PCI_D3cold;
+		return -EIO;
+	}
+
 	pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
 	if (PCI_POSSIBLE_ERROR(pmcsr)) {
 		pci_err(dev, "Unable to change power state from %s to D0, device inaccessible\n",
Signature · 1 line
2.43.0