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/20190822200551.129039-3-helgaas@kernel.org
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
Bjorn Helgaas 2019-08-02 18:47:22 -05:00
parent 9c77e63bd8
commit e43f15ea2f
1 changed files with 10 additions and 7 deletions

View File

@ -834,14 +834,16 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
return -EINVAL; return -EINVAL;
/* /*
* Validate current state: * Validate transition: We can enter D0 from any state, but if
* Can enter D0 from any state, but if we can only go deeper * we're already in a low-power state, we can only go deeper. E.g.,
* to sleep if we're already in a low power state * we can go from D1 to D3, but we can't go directly from D3 to D1;
* we'd have to go from D3 to D0, then to D1.
*/ */
if (state != PCI_D0 && dev->current_state <= PCI_D3cold if (state != PCI_D0 && dev->current_state <= PCI_D3cold
&& dev->current_state > state) { && dev->current_state > state) {
pci_err(dev, "invalid power transition (from state %d to %d)\n", pci_err(dev, "invalid power transition (from %s to %s)\n",
dev->current_state, state); pci_power_name(dev->current_state),
pci_power_name(state));
return -EINVAL; return -EINVAL;
} }
@ -891,8 +893,9 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
if (dev->current_state != state) if (dev->current_state != state)
pci_info_ratelimited(dev, "Refused to change power state, currently in D%d\n", pci_info_ratelimited(dev, "refused to change power state from %s to %s\n",
dev->current_state); pci_power_name(dev->current_state),
pci_power_name(state));
/* /*
* According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT * According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT