From 656088aa9b513907833ba091d0dcde87571fe05b Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Fri, 18 May 2018 10:17:42 +0200 Subject: PCI / PM: Do not clear state_saved for devices that remain suspended The state_saved flag should not be cleared in pci_pm_suspend() if the given device is going to remain suspended, or the device's config space will not be restored properly during the subsequent resume. Namely, if the device is going to stay in suspend, both the late and noirq callbacks return early for it, so if its state_saved flag is cleared in pci_pm_suspend(), it will remain unset throughout the remaining part of suspend and resume and pci_restore_state() called for the device going forward will return without doing anything. For this reason, change pci_pm_suspend() to only clear state_saved if the given device is not going to remain suspended. [This is analogous to what commit ae860a19f37c (PCI / PM: Do not clear state_saved in pci_pm_freeze() when smart suspend is set) did for hibernation.] Fixes: c4b65157aeef (PCI / PM: Take SMART_SUSPEND driver flag into account) Cc: 4.15+ # 4.15+ Signed-off-by: Rafael J. Wysocki Reviewed-by: Mika Westerberg Acked-by: Bjorn Helgaas --- drivers/pci/pci-driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/pci') diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index b9a131137e64..c816b0683a82 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -753,10 +753,11 @@ static int pci_pm_suspend(struct device *dev) * better to resume the device from runtime suspend here. */ if (!dev_pm_test_driver_flags(dev, DPM_FLAG_SMART_SUSPEND) || - !pci_dev_keep_suspended(pci_dev)) + !pci_dev_keep_suspended(pci_dev)) { pm_runtime_resume(dev); + pci_dev->state_saved = false; + } - pci_dev->state_saved = false; if (pm->suspend) { pci_power_t prev = pci_dev->current_state; int error; -- cgit From 60ee031aabbe602df01cb12f3098e99262832e62 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 21 May 2018 13:11:12 +0200 Subject: PCI / PM: Clean up outdated comments in pci_target_state() Two comments in pci_target_state() are outdated, as the function doesn't set the target power state for the device any more, only finds one for it, so fix them accordingly. Reported-by: Bjorn Helgaas Signed-off-by: Rafael J. Wysocki Acked-by: Bjorn Helgaas --- drivers/pci/pci.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/pci') diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index dbfe7c4f3776..e90cf5c32e14 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2025,8 +2025,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup) if (platform_pci_power_manageable(dev)) { /* - * Call the platform to choose the target state of the device - * and enable wake-up from this state if supported. + * Call the platform to find the target state for the device. */ pci_power_t state = platform_pci_choose_state(dev); @@ -2059,8 +2058,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup) if (wakeup) { /* * Find the deepest state from which the device can generate - * wake-up events, make it the target state and enable device - * to generate PME#. + * PME#. */ if (dev->pme_support) { while (target_state -- cgit