Skip to content

Commit f06fc0b

Browse files
rjwysockijbarnes993
authored andcommitted
PCI PM: Fix pci_update_current_state
Currently, PCI devices without the PM capability that are power manageable by the platform (eg. ACPI) are not handled correctly by pci_set_power_state(), because their current_state field is not updated to reflect the new power state of the device. Fix this by making pci_update_current_state() accept additional argument representing the power state of the device as set by the platform. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
1 parent eb9c39d commit f06fc0b

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎drivers/pci/pci.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,17 @@ pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
525525
* pci_update_current_state - Read PCI power state of given device from its
526526
* PCI PM registers and cache it
527527
* @dev: PCI device to handle.
528+
* @state: State to cache in case the device doesn't have the PM capability
528529
*/
529-
static void pci_update_current_state(struct pci_dev *dev)
530+
static void pci_update_current_state(struct pci_dev *dev, pci_power_t state)
530531
{
531532
if (dev->pm_cap) {
532533
u16 pmcsr;
533534

534535
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
535536
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
537+
} else {
538+
dev->current_state = state;
536539
}
537540
}
538541

@@ -575,7 +578,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
575578
*/
576579
int ret = platform_pci_set_power_state(dev, PCI_D0);
577580
if (!ret)
578-
pci_update_current_state(dev);
581+
pci_update_current_state(dev, PCI_D0);
579582
}
580583
/* This device is quirked not to be put into D3, so
581584
don't put it in D3 */
@@ -588,7 +591,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
588591
/* Allow the platform to finalize the transition */
589592
int ret = platform_pci_set_power_state(dev, state);
590593
if (!ret) {
591-
pci_update_current_state(dev);
594+
pci_update_current_state(dev, state);
592595
error = 0;
593596
}
594597
}

0 commit comments

Comments
 (0)