diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2012-07-05 17:20:00 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-07-05 17:20:00 -0400 |
commit | db288c9c5f9db45610dab3940377625132b4af41 (patch) | |
tree | ef859024757b4b468eb33aa5d9f879aa28fdd754 /drivers/pci/pci.c | |
parent | 448bd857d48e69b33ef323739dc6d8ca20d4cda7 (diff) |
PCI / PM: restore the original behavior of pci_set_power_state()
Commit cc2893b6 (PCI: Ensure we re-enable devices on resume)
addressed the problem with USB not being powered after resume on
recent Lenovo machines, but it did that in a suboptimal way.
Namely, it should have changed the relevant code paths only,
which are pci_pm_resume_noirq() and pci_pm_restore_noirq() supposed
to restore the device's power and standard configuration registers
after system resume from suspend or hibernation. Instead, however,
it modified pci_set_power_state() which is executed in several
other situations too. That resulted in some undesirable effects,
like attempting to change a device's power state in the same way
multiple times in a row (up to as many as 4 times in a row in the
snd_hda_intel driver).
Fix the bug addressed by commit cc2893b6 in an alternative way,
by forcibly powering up all devices in pci_pm_default_resume_early(),
which is called by pci_pm_resume_noirq() and pci_pm_restore_noirq()
to restore the device's power and standard configuration registers,
and modifying pci_pm_runtime_resume() to avoid the forcible power-up
if not necessary. Then, revert the changes made by commit cc2893b6
to make the confusion introduced by it go away.
Acked-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8effb9b23eec..acae2705e7f6 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -673,6 +673,19 @@ void pci_update_current_state(struct pci_dev *dev, pci_power_t state) | |||
673 | } | 673 | } |
674 | 674 | ||
675 | /** | 675 | /** |
676 | * pci_power_up - Put the given device into D0 forcibly | ||
677 | * @dev: PCI device to power up | ||
678 | */ | ||
679 | void pci_power_up(struct pci_dev *dev) | ||
680 | { | ||
681 | if (platform_pci_power_manageable(dev)) | ||
682 | platform_pci_set_power_state(dev, PCI_D0); | ||
683 | |||
684 | pci_raw_set_power_state(dev, PCI_D0); | ||
685 | pci_update_current_state(dev, PCI_D0); | ||
686 | } | ||
687 | |||
688 | /** | ||
676 | * pci_platform_power_transition - Use platform to change device power state | 689 | * pci_platform_power_transition - Use platform to change device power state |
677 | * @dev: PCI device to handle. | 690 | * @dev: PCI device to handle. |
678 | * @state: State to put the device into. | 691 | * @state: State to put the device into. |
@@ -762,7 +775,7 @@ int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state) | |||
762 | { | 775 | { |
763 | int ret; | 776 | int ret; |
764 | 777 | ||
765 | if (state < PCI_D0) | 778 | if (state <= PCI_D0) |
766 | return -EINVAL; | 779 | return -EINVAL; |
767 | ret = pci_platform_power_transition(dev, state); | 780 | ret = pci_platform_power_transition(dev, state); |
768 | /* Power off the bridge may power off the whole hierarchy */ | 781 | /* Power off the bridge may power off the whole hierarchy */ |
@@ -804,6 +817,10 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
804 | */ | 817 | */ |
805 | return 0; | 818 | return 0; |
806 | 819 | ||
820 | /* Check if we're already there */ | ||
821 | if (dev->current_state == state) | ||
822 | return 0; | ||
823 | |||
807 | __pci_start_power_transition(dev, state); | 824 | __pci_start_power_transition(dev, state); |
808 | 825 | ||
809 | /* This device is quirked not to be put into D3, so | 826 | /* This device is quirked not to be put into D3, so |