Commit 5e69a33c authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Bjorn Helgaas

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/20220601074024.3481035-1-hch@lst.deSigned-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
parent f2906aa8
...@@ -55,9 +55,13 @@ static int report_error_detected(struct pci_dev *dev, ...@@ -55,9 +55,13 @@ static int report_error_detected(struct pci_dev *dev,
device_lock(&dev->dev); device_lock(&dev->dev);
pdrv = dev->driver; pdrv = dev->driver;
if (!pci_dev_set_io_state(dev, state) || if (pci_dev_is_disconnected(dev)) {
!pdrv || vote = PCI_ERS_RESULT_DISCONNECT;
!pdrv->err_handler || } else if (!pci_dev_set_io_state(dev, state)) {
pci_info(dev, "can't recover (state transition %u -> %u invalid)\n",
dev->error_state, state);
vote = PCI_ERS_RESULT_NONE;
} else if (!pdrv || !pdrv->err_handler ||
!pdrv->err_handler->error_detected) { !pdrv->err_handler->error_detected) {
/* /*
* If any device in the subtree does not have an error_detected * If any device in the subtree does not have an error_detected
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment