Skip to content

Commit a39bd85

Browse files
committed
PCI/PM: Clear PCIe PME Status bit in core, not PCIe port driver
fe31e69 ("PCI/PCIe: Clear Root PME Status bits early during system resume") added a .resume_noirq() callback to the PCIe port driver to clear the PME Status bit during resume to work around a BIOS issue. The BIOS evidently enabled PME interrupts for ACPI-based runtime wakeups but did not clear the PME Status bit during resume, which meant PMEs after resume did not trigger interrupts because PME Status did not transition from cleared to set. The fix was in the PCIe port driver, so it worked when CONFIG_PCIEPORTBUS was set. But I think we *always* want the fix because the platform may use PME interrupts even if Linux is built without the PCIe port driver. Move the fix from the port driver to the PCI core so we can work around this "PME doesn't work after waking from a sleep state" issue regardless of CONFIG_PCIEPORTBUS. [bhelgaas: folded in warning fix from Arnd Bergmann <arnd@arndb.de>: https://lkml.kernel.org/r/20180328134747.2062348-1-arnd@arndb.de] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent dcb0453 commit a39bd85

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

‎drivers/pci/pci-driver.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,17 @@ static void pci_pm_complete(struct device *dev)
714714
#endif /* !CONFIG_PM_SLEEP */
715715

716716
#ifdef CONFIG_SUSPEND
717+
static void pcie_pme_root_status_cleanup(struct pci_dev *pci_dev)
718+
{
719+
/*
720+
* Some BIOSes forget to clear Root PME Status bits after system
721+
* wakeup, which breaks ACPI-based runtime wakeup on PCI Express.
722+
* Clear those bits now just in case (shouldn't hurt).
723+
*/
724+
if (pci_is_pcie(pci_dev) &&
725+
pci_pcie_type(pci_dev) == PCI_EXP_TYPE_ROOT_PORT)
726+
pcie_clear_root_pme_status(pci_dev);
727+
}
717728

718729
static int pci_pm_suspend(struct device *dev)
719730
{
@@ -873,6 +884,8 @@ static int pci_pm_resume_noirq(struct device *dev)
873884
if (pci_has_legacy_pm_support(pci_dev))
874885
return pci_legacy_resume_early(dev);
875886

887+
pcie_pme_root_status_cleanup(pci_dev);
888+
876889
if (drv && drv->pm && drv->pm->resume_noirq)
877890
error = drv->pm->resume_noirq(dev);
878891

‎drivers/pci/pcie/portdrv_pci.c‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev)
6161
}
6262

6363
#ifdef CONFIG_PM
64-
static int pcie_port_resume_noirq(struct device *dev)
65-
{
66-
struct pci_dev *pdev = to_pci_dev(dev);
67-
68-
/*
69-
* Some BIOSes forget to clear Root PME Status bits after system wakeup
70-
* which breaks ACPI-based runtime wakeup on PCI Express, so clear those
71-
* bits now just in case (shouldn't hurt).
72-
*/
73-
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT)
74-
pcie_clear_root_pme_status(pdev);
75-
return 0;
76-
}
77-
7864
static int pcie_port_runtime_suspend(struct device *dev)
7965
{
8066
return to_pci_dev(dev)->bridge_d3 ? 0 : -EBUSY;
@@ -102,7 +88,6 @@ static const struct dev_pm_ops pcie_portdrv_pm_ops = {
10288
.thaw = pcie_port_device_resume,
10389
.poweroff = pcie_port_device_suspend,
10490
.restore = pcie_port_device_resume,
105-
.resume_noirq = pcie_port_resume_noirq,
10691
.runtime_suspend = pcie_port_runtime_suspend,
10792
.runtime_resume = pcie_port_runtime_resume,
10893
.runtime_idle = pcie_port_runtime_idle,

0 commit comments

Comments
 (0)