Skip to content

Commit e43f15e

Browse files
committed
PCI/PM: Decode D3cold power state correctly
Use pci_power_name() to print pci_power_t correctly. This changes: "state 0" or "D0" to "D0" "state 1" or "D1" to "D1" "state 2" or "D2" to "D2" "state 3" or "D3" to "D3hot" "state 4" or "D4" to "D3cold" Changes dmesg logging only, no other functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Mika Westerberg <[email protected]>
1 parent 9c77e63 commit e43f15e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/pci/pci.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,14 +834,16 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
834834
return -EINVAL;
835835

836836
/*
837-
* Validate current state:
838-
* Can enter D0 from any state, but if we can only go deeper
839-
* to sleep if we're already in a low power state
837+
* Validate transition: We can enter D0 from any state, but if
838+
* we're already in a low-power state, we can only go deeper. E.g.,
839+
* we can go from D1 to D3, but we can't go directly from D3 to D1;
840+
* we'd have to go from D3 to D0, then to D1.
840841
*/
841842
if (state != PCI_D0 && dev->current_state <= PCI_D3cold
842843
&& dev->current_state > state) {
843-
pci_err(dev, "invalid power transition (from state %d to %d)\n",
844-
dev->current_state, state);
844+
pci_err(dev, "invalid power transition (from %s to %s)\n",
845+
pci_power_name(dev->current_state),
846+
pci_power_name(state));
845847
return -EINVAL;
846848
}
847849

@@ -891,8 +893,9 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
891893
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
892894
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
893895
if (dev->current_state != state)
894-
pci_info_ratelimited(dev, "Refused to change power state, currently in D%d\n",
895-
dev->current_state);
896+
pci_info_ratelimited(dev, "refused to change power state from %s to %s\n",
897+
pci_power_name(dev->current_state),
898+
pci_power_name(state));
896899

897900
/*
898901
* According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT

0 commit comments

Comments
 (0)