Skip to content

Commit 002bf2f

Browse files
sgruszkabjorn-helgaas
authored andcommitted
PCI/AER: Block runtime suspend when handling errors
PM runtime can be done simultaneously with AER error handling. Avoid that by using pm_runtime_get_sync() before and pm_runtime_put() after reset in pcie_do_recovery() for all recovering devices. pm_runtime_get_sync() will increase dev->power.usage_count counter to prevent any possible future request to runtime suspend a device. It will also resume a device, if it was previously in D3hot state. I tested with igc device by doing simultaneous aer_inject and rpm suspend/resume via /sys/bus/pci/devices/PCI_ID/power/control and can reproduce: igc 0000:02:00.0: not ready 65535ms after bus reset; giving up pcieport 0000:00:1c.2: AER: Root Port link has been reset (-25) pcieport 0000:00:1c.2: AER: subordinate device reset failed pcieport 0000:00:1c.2: AER: device recovery failed igc 0000:02:00.0: Unable to change power state from D3hot to D0, device inaccessible The problem disappears when this patch is applied. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stanislaw Gruszka <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Cc: <[email protected]>
1 parent 96ed797 commit 002bf2f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/pci/pcie/err.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define dev_fmt(fmt) "AER: " fmt
1414

1515
#include <linux/pci.h>
16+
#include <linux/pm_runtime.h>
1617
#include <linux/module.h>
1718
#include <linux/kernel.h>
1819
#include <linux/errno.h>
@@ -85,6 +86,18 @@ static int report_error_detected(struct pci_dev *dev,
8586
return 0;
8687
}
8788

89+
static int pci_pm_runtime_get_sync(struct pci_dev *pdev, void *data)
90+
{
91+
pm_runtime_get_sync(&pdev->dev);
92+
return 0;
93+
}
94+
95+
static int pci_pm_runtime_put(struct pci_dev *pdev, void *data)
96+
{
97+
pm_runtime_put(&pdev->dev);
98+
return 0;
99+
}
100+
88101
static int report_frozen_detected(struct pci_dev *dev, void *data)
89102
{
90103
return report_error_detected(dev, pci_channel_io_frozen, data);
@@ -207,6 +220,8 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
207220
else
208221
bridge = pci_upstream_bridge(dev);
209222

223+
pci_walk_bridge(bridge, pci_pm_runtime_get_sync, NULL);
224+
210225
pci_dbg(bridge, "broadcast error_detected message\n");
211226
if (state == pci_channel_io_frozen) {
212227
pci_walk_bridge(bridge, report_frozen_detected, &status);
@@ -251,10 +266,15 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
251266
pcie_clear_device_status(dev);
252267
pci_aer_clear_nonfatal_status(dev);
253268
}
269+
270+
pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
271+
254272
pci_info(bridge, "device recovery successful\n");
255273
return status;
256274

257275
failed:
276+
pci_walk_bridge(bridge, pci_pm_runtime_put, NULL);
277+
258278
pci_uevent_ers(bridge, PCI_ERS_RESULT_DISCONNECT);
259279

260280
/* TODO: Should kernel panic here? */

0 commit comments

Comments
 (0)