PCI/PM: refactor pci_pm_suspend_noirq()
A message that is not in the archive (sent off-list or not yet received): [email protected]
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 theskip_bus_pmflag value. Soskip_bus_pmcheck is removed before saving the device state.Signed-off-by Rajvi Jingar <[email protected]>Suggested-by David E. Box <[email protected]>--- drivers/pci/pci-driver.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)drivers/pci/pci-driver.c +0
-0@@ -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]
Rafael J. Wysocki
Reviewed-byRe: [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 ofpci_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.Signed-off-by Rajvi Jingar <[email protected]>Suggested-by David E. Box <[email protected]>
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@@ -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@@ -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);