[J/K/Unstable/OEM-5.17/OEM-6.0] [PATCH 10/10] UBUNTU: SAUCE: PCI/PM: Simplify pci_pm_suspend_noirq()

Kai-Heng Feng kai.heng.feng at canonical.com
Thu Sep 15 12:09:33 UTC 2022


From: Rajvi Jingar <rajvi.jingar at linux.intel.com>

BugLink: https://bugs.launchpad.net/bugs/1988797

We always want to save the device state unless the driver has already done
it.  Rearrange the checking in pci_pm_suspend_noirq() to make this more
clear.  No functional change intended.

[bhelgaas: commit log, rewrap comment]
Link: https://lore.kernel.org/r/20220830104913.1620539-1-rajvi.jingar@linux.intel.com
Signed-off-by: Rajvi Jingar <rajvi.jingar at linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas at google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki at intel.com>
(cherry picked from commit 4c00cba122f3f3ae54aa5a3a1aec3afc7a2e6f94 git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git pci/pm)
Signed-off-by: Kai-Heng Feng <kai.heng.feng at canonical.com>
---
 drivers/pci/pci-driver.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 5d8c37c3e15a2..107d77f3c8467 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -873,20 +873,15 @@ static int pci_pm_suspend_noirq(struct device *dev)
 		}
 	}
 
-	if (pci_dev->skip_bus_pm) {
+	if (!pci_dev->state_saved) {
+		pci_save_state(pci_dev);
+
 		/*
-		 * Either the device is a bridge with a child in D0 below it, or
-		 * the function is running for the second time in a row without
-		 * going through full resume, which is possible only during
-		 * suspend-to-idle in a spurious wakeup case.  The device should
-		 * be in D0 at this point, but if it is a bridge, it may be
-		 * necessary to save its state.
+		 * If the device is a bridge with a child in D0 below it,
+		 * it needs to stay in D0, so check skip_bus_pm to avoid
+		 * putting it into a low-power state in that case.
 		 */
-		if (!pci_dev->state_saved)
-			pci_save_state(pci_dev);
-	} else if (!pci_dev->state_saved) {
-		pci_save_state(pci_dev);
-		if (pci_power_manageable(pci_dev))
+		if (!pci_dev->skip_bus_pm && pci_power_manageable(pci_dev))
 			pci_prepare_to_sleep(pci_dev);
 	}
 
-- 
2.37.2




More information about the kernel-team mailing list