diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-07-05 18:29:52 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-07-05 18:29:52 -0400 |
commit | a7711ba1090a5fa1caa6e07182ac4e8e1c0da695 (patch) | |
tree | f5682057d40e557e3816a977fbf9a4762d6716e2 | |
parent | 85a00dd391d2de1e177c5ad8db5672428934ac20 (diff) | |
parent | db288c9c5f9db45610dab3940377625132b4af41 (diff) |
Merge branch 'pci/rafael-pci_set_power_state-rebase' into next
* pci/rafael-pci_set_power_state-rebase:
PCI / PM: restore the original behavior of pci_set_power_state()
-rw-r--r-- | drivers/pci/pci-driver.c | 14 | ||||
-rw-r--r-- | drivers/pci/pci.c | 19 | ||||
-rw-r--r-- | drivers/pci/pci.h | 1 |
3 files changed, 27 insertions, 7 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index ca2e4c79a588..1dd1d9dfa173 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -459,16 +459,17 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev) | |||
459 | return 0; | 459 | return 0; |
460 | } | 460 | } |
461 | 461 | ||
462 | #endif | ||
463 | |||
464 | #ifdef CONFIG_PM_SLEEP | ||
465 | |||
462 | static void pci_pm_default_resume_early(struct pci_dev *pci_dev) | 466 | static void pci_pm_default_resume_early(struct pci_dev *pci_dev) |
463 | { | 467 | { |
464 | pci_restore_standard_config(pci_dev); | 468 | pci_power_up(pci_dev); |
469 | pci_restore_state(pci_dev); | ||
465 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | 470 | pci_fixup_device(pci_fixup_resume_early, pci_dev); |
466 | } | 471 | } |
467 | 472 | ||
468 | #endif | ||
469 | |||
470 | #ifdef CONFIG_PM_SLEEP | ||
471 | |||
472 | /* | 473 | /* |
473 | * Default "suspend" method for devices that have no driver provided suspend, | 474 | * Default "suspend" method for devices that have no driver provided suspend, |
474 | * or not even a driver at all (second part). | 475 | * or not even a driver at all (second part). |
@@ -1054,7 +1055,8 @@ static int pci_pm_runtime_resume(struct device *dev) | |||
1054 | if (!pm || !pm->runtime_resume) | 1055 | if (!pm || !pm->runtime_resume) |
1055 | return -ENOSYS; | 1056 | return -ENOSYS; |
1056 | 1057 | ||
1057 | pci_pm_default_resume_early(pci_dev); | 1058 | pci_restore_standard_config(pci_dev); |
1059 | pci_fixup_device(pci_fixup_resume_early, pci_dev); | ||
1058 | __pci_enable_wake(pci_dev, PCI_D0, true, false); | 1060 | __pci_enable_wake(pci_dev, PCI_D0, true, false); |
1059 | pci_fixup_device(pci_fixup_resume, pci_dev); | 1061 | pci_fixup_device(pci_fixup_resume, pci_dev); |
1060 | 1062 | ||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e091b0afdc8a..f3ea977a5b1b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -638,6 +638,19 @@ void pci_update_current_state(struct pci_dev *dev, pci_power_t state) | |||
638 | } | 638 | } |
639 | 639 | ||
640 | /** | 640 | /** |
641 | * pci_power_up - Put the given device into D0 forcibly | ||
642 | * @dev: PCI device to power up | ||
643 | */ | ||
644 | void pci_power_up(struct pci_dev *dev) | ||
645 | { | ||
646 | if (platform_pci_power_manageable(dev)) | ||
647 | platform_pci_set_power_state(dev, PCI_D0); | ||
648 | |||
649 | pci_raw_set_power_state(dev, PCI_D0); | ||
650 | pci_update_current_state(dev, PCI_D0); | ||
651 | } | ||
652 | |||
653 | /** | ||
641 | * pci_platform_power_transition - Use platform to change device power state | 654 | * pci_platform_power_transition - Use platform to change device power state |
642 | * @dev: PCI device to handle. | 655 | * @dev: PCI device to handle. |
643 | * @state: State to put the device into. | 656 | * @state: State to put the device into. |
@@ -727,7 +740,7 @@ int __pci_complete_power_transition(struct pci_dev *dev, pci_power_t state) | |||
727 | { | 740 | { |
728 | int ret; | 741 | int ret; |
729 | 742 | ||
730 | if (state < PCI_D0) | 743 | if (state <= PCI_D0) |
731 | return -EINVAL; | 744 | return -EINVAL; |
732 | ret = pci_platform_power_transition(dev, state); | 745 | ret = pci_platform_power_transition(dev, state); |
733 | /* Power off the bridge may power off the whole hierarchy */ | 746 | /* Power off the bridge may power off the whole hierarchy */ |
@@ -769,6 +782,10 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state) | |||
769 | */ | 782 | */ |
770 | return 0; | 783 | return 0; |
771 | 784 | ||
785 | /* Check if we're already there */ | ||
786 | if (dev->current_state == state) | ||
787 | return 0; | ||
788 | |||
772 | __pci_start_power_transition(dev, state); | 789 | __pci_start_power_transition(dev, state); |
773 | 790 | ||
774 | /* This device is quirked not to be put into D3, so | 791 | /* This device is quirked not to be put into D3, so |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index ec1512de4297..bacbcba69cf3 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -67,6 +67,7 @@ struct pci_platform_pm_ops { | |||
67 | 67 | ||
68 | extern int pci_set_platform_pm(struct pci_platform_pm_ops *ops); | 68 | extern int pci_set_platform_pm(struct pci_platform_pm_ops *ops); |
69 | extern void pci_update_current_state(struct pci_dev *dev, pci_power_t state); | 69 | extern void pci_update_current_state(struct pci_dev *dev, pci_power_t state); |
70 | extern void pci_power_up(struct pci_dev *dev); | ||
70 | extern void pci_disable_enabled_device(struct pci_dev *dev); | 71 | extern void pci_disable_enabled_device(struct pci_dev *dev); |
71 | extern int pci_finish_runtime_suspend(struct pci_dev *dev); | 72 | extern int pci_finish_runtime_suspend(struct pci_dev *dev); |
72 | extern int __pci_pme_wakeup(struct pci_dev *dev, void *ign); | 73 | extern int __pci_pme_wakeup(struct pci_dev *dev, void *ign); |