Skip to contentSkip to conversation

PCI/PM: refactor pci_pm_suspend_noirq()

PATCH Rafael J. Wysocki 1 participant 2 messages Mar 11, 2022 2 messages not in the archive PCI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 17 lines · Rajvi Jingar

The state of the device is saved during pci_pm_suspend_noirq(), if it has not already been saved, regardless of the skip_bus_pm flag value. So skip_bus_pm check is removed before saving the device state.

---
  drivers/pci/pci-driver.c | 15 ++-------------
  1 file changed, 2 insertions(+), 13 deletions(-)
drivers/pci/pci-driver.c +0 -0
index 588588cfda48..ac3f7e1676a9 100644
@@ -834,20 +834,9 @@ static int pci_pm_suspend_noirq(struct device *dev)
  		}
  	}

drivers/pci/pci-driver.c static int pci_pm_suspend_noirq(struct device *dev) · line 845

Quoted 10 lines
drivers/pci/pci-driver.c +0 -9
 
-	if (pci_dev->skip_bus_pm) {
-		/*
-		 * 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.
-		 */

The comment is outdated, but the role of skip_bus_pm needs to be explained.  It only applies to the bridge with a child in D0 case now, because the other one has gone away, so I would put a new comment before the reworked check below.

drivers/pci/pci-driver.c static int pci_pm_suspend_noirq(struct device *dev) · line 850

Quoted 6 lines
drivers/pci/pci-driver.c +1 -4
-		if (!pci_dev->state_saved)
-			pci_save_state(pci_dev);
-	} else if (!pci_dev->state_saved) {
+	if (!pci_dev->state_saved) {
  		pci_save_state(pci_dev);
-		if (pci_power_manageable(pci_dev))

For example:

/*

 * 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.

 */

Quoted 4 lines
drivers/pci/pci-driver.c +1 -0
+		if (!pci_dev->skip_bus_pm && pci_power_manageable(pci_dev))
  			pci_prepare_to_sleep(pci_dev);
  	}
 

A message that is not in the archive (sent off-list or not yet received): [email protected]

author Reviewed-by
#3 lore raw

Re: [PATCH 2/2] PCI/PM: Fix pci_pm_suspend_noirq() to disable PTM

Quoted 10 lines · Rajvi Jingar

For the PCIe devices (like nvme) that do not go into D3 state still need to disable PTM on PCIe root ports to allow the port to enter a lower-power PM state and the SoC to reach a lower-power idle state as a whole. Move the pci_disable_ptm() out of pci_prepare_to_sleep() as this code path is not followed for devices that do not go into D3. This patch fixes the issue seen on Dell XPS 9300 with Ice Lake CPU and Dell Precision 5530 with Coffee Lake CPU platforms to get improved residency in low power idle states.

I would add a Fixes tag pointing to the commit that introduced pci_disable_ptm().

Otherwise I agree with this change:

Quoted 48 lines
---
  drivers/pci/pci-driver.c | 11 +++++++++++
  drivers/pci/pci.c        | 10 ----------
  2 files changed, 11 insertions(+), 10 deletions(-)
drivers/pci/pci-driver.c +11 -0
index ac3f7e1676a9..8be3f81afdf6 100644
@@ -836,6 +836,17 @@ static int pci_pm_suspend_noirq(struct device *dev)
 
  	if (!pci_dev->state_saved) {
  		pci_save_state(pci_dev);
+
+		/*
+		 * There are systems (for example, Intel mobile chips since Coffee
+		 * Lake) where the power drawn while suspended can be significantly
+		 * reduced by disabling PTM on PCIe root ports as this allows the
+		 * port to enter a lower-power PM state and the SoC to reach a
+		 * lower-power idle state as a whole.
+		 */
+		if (pci_pcie_type(pci_dev) == PCI_EXP_TYPE_ROOT_PORT)
+			pci_disable_ptm(pci_dev);
+
  		if (!pci_dev->skip_bus_pm && pci_power_manageable(pci_dev))
  			pci_prepare_to_sleep(pci_dev);
  	}
drivers/pci/pci.c +0 -10
index 9ecce435fb3f..f8768672c064 100644
@@ -2660,16 +2660,6 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
  	if (target_state == PCI_POWER_ERROR)
  		return -EIO;
 
-	/*
-	 * There are systems (for example, Intel mobile chips since Coffee
-	 * Lake) where the power drawn while suspended can be significantly
-	 * reduced by disabling PTM on PCIe root ports as this allows the
-	 * port to enter a lower-power PM state and the SoC to reach a
-	 * lower-power idle state as a whole.
-	 */
-	if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT)
-		pci_disable_ptm(dev);
-
  	pci_enable_wake(dev, target_state, wakeup);
 
  	error = pci_set_power_state(dev, target_state);