[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2532996.Lt9SDvczpP@kreacher>
Date: Thu, 14 Apr 2022 15:19:19 +0200
From: "Rafael J. Wysocki" <rjw@...ysocki.net>
To: Linux PCI <linux-pci@...r.kernel.org>
Cc: Linux PM <linux-pm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Bjorn Helgaas <helgaas@...nel.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>
Subject: [PATCH v3 9/9] PCI/PM: Replace pci_set_power_state() in pci_pm_thaw_noirq()
From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
Calling pci_set_power_state() to put the given device into D0 in
pci_pm_thaw_noirq() may cause it to restore the device's BARs, which
is redundant before calling pci_restore_state(), so replace it with
a direct pci_power_up() call followed by pci_update_current_state()
if it returns a nonzeor value, in analogy with
pci_pm_default_resume_early().
Avoid code duplication by introducing a wrapper function to contain
the repeating pattern and calling it in both places.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
Reviewed-by: Mika Westerberg <mika.westerberg@...ux.intel.com>
---
v2 -> v3:
* Added R-by from Mika.
---
drivers/pci/pci-driver.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: linux-pm/drivers/pci/pci-driver.c
===================================================================
--- linux-pm.orig/drivers/pci/pci-driver.c
+++ linux-pm/drivers/pci/pci-driver.c
@@ -551,11 +551,15 @@ static void pci_pm_default_resume(struct
pci_enable_wake(pci_dev, PCI_D0, false);
}
-static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
+static void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev)
{
if (pci_power_up(pci_dev))
pci_update_current_state(pci_dev, PCI_D0);
+}
+static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
+{
+ pci_pm_power_up_and_verify_state(pci_dev);
pci_restore_state(pci_dev);
pci_pme_restore(pci_dev);
}
@@ -1080,7 +1084,7 @@ static int pci_pm_thaw_noirq(struct devi
* in case the driver's "freeze" callbacks put it into a low-power
* state.
*/
- pci_set_power_state(pci_dev, PCI_D0);
+ pci_pm_power_up_and_verify_state(pci_dev);
pci_restore_state(pci_dev);
if (pci_has_legacy_pm_support(pci_dev))
Powered by blists - more mailing lists