Skip to content

Commit 5e69a33

Browse files
Christoph Hellwigbjorn-helgaas
authored andcommitted
PCI/ERR: Recognize disconnected devices in report_error_detected()
When a device is already unplugged by pciehp by the time the AER handler is invoked, the PCIe device will already be in the pci_channel_io_perm_failure state. In that case simply return PCI_ERS_RESULT_DISCONNECT instead of trying to do a state transition that will fail. Also untangle the state transition failure from the lack of methods to improve the debugging output in case it happens again. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
1 parent f2906aa commit 5e69a33

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/pci/pcie/err.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ static int report_error_detected(struct pci_dev *dev,
5555

5656
device_lock(&dev->dev);
5757
pdrv = dev->driver;
58-
if (!pci_dev_set_io_state(dev, state) ||
59-
!pdrv ||
60-
!pdrv->err_handler ||
61-
!pdrv->err_handler->error_detected) {
58+
if (pci_dev_is_disconnected(dev)) {
59+
vote = PCI_ERS_RESULT_DISCONNECT;
60+
} else if (!pci_dev_set_io_state(dev, state)) {
61+
pci_info(dev, "can't recover (state transition %u -> %u invalid)\n",
62+
dev->error_state, state);
63+
vote = PCI_ERS_RESULT_NONE;
64+
} else if (!pdrv || !pdrv->err_handler ||
65+
!pdrv->err_handler->error_detected) {
6266
/*
6367
* If any device in the subtree does not have an error_detected
6468
* callback, PCI_ERS_RESULT_NO_AER_DRIVER prevents subsequent

0 commit comments

Comments
 (0)