Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Rafael J. Wysocki and committed by
Jesse Barnes
f06fc0b6 eb9c39d0

+6 -3
+6 -3
drivers/pci/pci.c
··· 525 525 * pci_update_current_state - Read PCI power state of given device from its 526 526 * PCI PM registers and cache it 527 527 * @dev: PCI device to handle. 528 + * @state: State to cache in case the device doesn't have the PM capability 528 529 */ 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) 530 531 { 531 532 if (dev->pm_cap) { 532 533 u16 pmcsr; 533 534 534 535 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 535 536 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); 537 + } else { 538 + dev->current_state = state; 536 539 } 537 540 } 538 541 ··· 578 575 */ 579 576 int ret = platform_pci_set_power_state(dev, PCI_D0); 580 577 if (!ret) 581 - pci_update_current_state(dev); 578 + pci_update_current_state(dev, PCI_D0); 582 579 } 583 580 /* This device is quirked not to be put into D3, so 584 581 don't put it in D3 */ ··· 591 588 /* Allow the platform to finalize the transition */ 592 589 int ret = platform_pci_set_power_state(dev, state); 593 590 if (!ret) { 594 - pci_update_current_state(dev); 591 + pci_update_current_state(dev, state); 595 592 error = 0; 596 593 } 597 594 }