Skip to content
/ linux Public

Commit f9b2f54

Browse files
computersforpeaceSasha Levin
authored andcommitted
PCI/PM: Avoid redundant delays on D3hot->D3cold
[ Upstream commit 4d98208 ] When transitioning to D3cold, __pci_set_power_state() first transitions to D3hot. If the device was already in D3hot, this adds excess work: (a) read/modify/write PMCSR; and (b) excess delay (pci_dev_d3_sleep()). For (b), we already performed the necessary delay on the previous D3hot entry; this was extra noticeable when evaluating runtime PM transition latency. Check whether we're already in the target state before continuing. Note that __pci_set_power_state() already does this same check for other state transitions, but D3cold is special because __pci_set_power_state() converts it to D3hot for the purposes of PMCSR. This seems to be an oversight in commit 0aacdc9 ("PCI/PM: Clean up pci_set_low_power_state()"). Fixes: 0aacdc9 ("PCI/PM: Clean up pci_set_low_power_state()") Signed-off-by: Brian Norris <briannorris@google.com> Signed-off-by: Brian Norris <briannorris@chromium.org> [bhelgaas: reverse test to match other "dev->current_state == state" cases] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://patch.msgid.link/20251003154008.1.I7a21c240b30062c66471329567a96dceb6274358@changeid Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d2bfee6 commit f9b2f54

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/pci/pci.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,9 @@ static int pci_set_low_power_state(struct pci_dev *dev, pci_power_t state, bool
13971397
|| (state == PCI_D2 && !dev->d2_support))
13981398
return -EIO;
13991399

1400+
if (dev->current_state == state)
1401+
return 0;
1402+
14001403
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
14011404
if (PCI_POSSIBLE_ERROR(pmcsr)) {
14021405
pci_err(dev, "Unable to change power state from %s to %s, device inaccessible\n",

0 commit comments

Comments
 (0)