Commit 0ce3fcaf authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PCI / PM: Restore PME Enable after config space restoration

Commit dc15e71e (PCI / PM: Restore PME Enable if skipping wakeup
setup) introduced a mechanism by which the PME Enable bit can be
restored by pci_enable_wake() if dev->wakeup_prepared is set in
case it has been overwritten by PCI config space restoration.

However, that commit overlooked the fact that on some systems (Dell
XPS13 9360 in particular) the AML handling wakeup events checks PME
Status and PME Enable and it won't trigger a Notify() for devices
where those bits are not set while it is running.

That happens during resume from suspend-to-idle when pci_restore_state()
invoked by pci_pm_default_resume_early() clears PME Enable before the
wakeup events are processed by AML, effectively causing those wakeup
events to be ignored.

Fix this issue by restoring the PME Enable configuration right after
pci_restore_state() has been called instead of doing that in
pci_enable_wake().

Fixes: dc15e71e (PCI / PM: Restore PME Enable if skipping wakeup setup)
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent de3ef1eb
...@@ -506,6 +506,7 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev) ...@@ -506,6 +506,7 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev)
} }
pci_restore_state(pci_dev); pci_restore_state(pci_dev);
pci_pme_restore(pci_dev);
return 0; return 0;
} }
...@@ -517,6 +518,7 @@ static void pci_pm_default_resume_early(struct pci_dev *pci_dev) ...@@ -517,6 +518,7 @@ static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
{ {
pci_power_up(pci_dev); pci_power_up(pci_dev);
pci_restore_state(pci_dev); pci_restore_state(pci_dev);
pci_pme_restore(pci_dev);
pci_fixup_device(pci_fixup_resume_early, pci_dev); pci_fixup_device(pci_fixup_resume_early, pci_dev);
} }
......
...@@ -1798,7 +1798,11 @@ static void __pci_pme_active(struct pci_dev *dev, bool enable) ...@@ -1798,7 +1798,11 @@ static void __pci_pme_active(struct pci_dev *dev, bool enable)
pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr);
} }
static void pci_pme_restore(struct pci_dev *dev) /**
* pci_pme_restore - Restore PME configuration after config space restore.
* @dev: PCI device to update.
*/
void pci_pme_restore(struct pci_dev *dev)
{ {
u16 pmcsr; u16 pmcsr;
...@@ -1808,6 +1812,7 @@ static void pci_pme_restore(struct pci_dev *dev) ...@@ -1808,6 +1812,7 @@ static void pci_pme_restore(struct pci_dev *dev)
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
if (dev->wakeup_prepared) { if (dev->wakeup_prepared) {
pmcsr |= PCI_PM_CTRL_PME_ENABLE; pmcsr |= PCI_PM_CTRL_PME_ENABLE;
pmcsr &= ~PCI_PM_CTRL_PME_STATUS;
} else { } else {
pmcsr &= ~PCI_PM_CTRL_PME_ENABLE; pmcsr &= ~PCI_PM_CTRL_PME_ENABLE;
pmcsr |= PCI_PM_CTRL_PME_STATUS; pmcsr |= PCI_PM_CTRL_PME_STATUS;
...@@ -1904,14 +1909,9 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) ...@@ -1904,14 +1909,9 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)
{ {
int ret = 0; int ret = 0;
/* /* Don't do the same thing twice in a row for one device. */
* Don't do the same thing twice in a row for one device, but restore if (!!enable == !!dev->wakeup_prepared)
* PME Enable in case it has been updated by config space restoration.
*/
if (!!enable == !!dev->wakeup_prepared) {
pci_pme_restore(dev);
return 0; return 0;
}
/* /*
* According to "PCI System Architecture" 4th ed. by Tom Shanley & Don * According to "PCI System Architecture" 4th ed. by Tom Shanley & Don
......
...@@ -71,6 +71,7 @@ void pci_power_up(struct pci_dev *dev); ...@@ -71,6 +71,7 @@ void pci_power_up(struct pci_dev *dev);
void pci_disable_enabled_device(struct pci_dev *dev); void pci_disable_enabled_device(struct pci_dev *dev);
int pci_finish_runtime_suspend(struct pci_dev *dev); int pci_finish_runtime_suspend(struct pci_dev *dev);
int __pci_pme_wakeup(struct pci_dev *dev, void *ign); int __pci_pme_wakeup(struct pci_dev *dev, void *ign);
void pci_pme_restore(struct pci_dev *dev);
bool pci_dev_keep_suspended(struct pci_dev *dev); bool pci_dev_keep_suspended(struct pci_dev *dev);
void pci_dev_complete_resume(struct pci_dev *pci_dev); void pci_dev_complete_resume(struct pci_dev *pci_dev);
void pci_config_pm_runtime_get(struct pci_dev *dev); void pci_config_pm_runtime_get(struct pci_dev *dev);
......
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