PCI: Don't show errors on inaccessible PCI devices
PATCH 1/4 PCI: Don't show errors on inaccessible PCI devices
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will remove 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.
As the device is already gone and the PCI core is cleaning up there isn't really any reason to show error messages to the user about failing to change power states. Detect the error state and skip the messaging.
--- drivers/pci/pci.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci.c +3 -2
@@ -1376,8 +1376,9 @@ int pci_power_up(struct pci_dev *dev)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" , -pci_power_name (dev->current_state)); +if (dev->error_state != pci_channel_io_perm_failure) +pci_err (dev,"Unable to change power state from %s to D0, device inaccessible\n" , +pci_power_name (dev->current_state)); dev->current_state = PCI_D3cold;return -EIO ; }
Signature · 1 line
2.43.0
PATCH 2/4 PCI: Fix runtime PM usage count underflow
From: Mario Limonciello <[email protected]>
When a USB4 dock is unplugged the PCIe bridge it's connected to will remove 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.
When PCI core gets to the point that the device is removed using pci_device_remove() the runtime count has already been decremented and so calling pm_runtime_put_sync() will cause an underflow.
Detect the device is in the error state and skip the call for this cleanup path.
--- drivers/pci/pci-driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci-driver.c +2 -1
@@ -479,7 +479,8 @@ static void pci_device_remove(struct device *dev)pci_iov_remove (pci_dev);/* Undo the runtime PM settings in local_pci_probe() */ -pm_runtime_put_sync (dev); +if (pci_dev->error_state != pci_channel_io_perm_failure) +pm_runtime_put_sync (dev);/* * If the device is still on, set the power state as "unknown",
Signature · 1 line
2.43.0