diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-11-05 16:59:53 -0700 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-11-05 16:59:53 -0700 |
commit | 3cba8eedb757590455b03dfeaba15a5b32610339 (patch) | |
tree | 9c035788cf5a2f5fcf897f3fe63c32064bdef255 /drivers/pci/pci.c | |
parent | 8f0d8163b50e01f398b14bcd4dc039ac5ab18d64 (diff) | |
parent | b3c32c4f9565f93407921c0d8a4458042eb8998e (diff) |
Merge branch 'pci/huang-d3cold-fixes' into for-linus
* pci/huang-d3cold-fixes:
PCI/PM: Fix proc config reg access for D3cold and bridge suspending
PCI/PM: Resume device before shutdown
PCI/PM: Fix deadlock when unbinding device if parent in D3cold
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 54858838f09..aabf64798bd 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1858,6 +1858,38 @@ bool pci_dev_run_wake(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_dev_run_wake); +void pci_config_pm_runtime_get(struct pci_dev *pdev) +{ + struct device *dev = &pdev->dev; + struct device *parent = dev->parent; + + if (parent) + pm_runtime_get_sync(parent); + pm_runtime_get_noresume(dev); + /* + * pdev->current_state is set to PCI_D3cold during suspending, + * so wait until suspending completes + */ + pm_runtime_barrier(dev); + /* + * Only need to resume devices in D3cold, because config + * registers are still accessible for devices suspended but + * not in D3cold. + */ + if (pdev->current_state == PCI_D3cold) + pm_runtime_resume(dev); +} + +void pci_config_pm_runtime_put(struct pci_dev *pdev) +{ + struct device *dev = &pdev->dev; + struct device *parent = dev->parent; + + pm_runtime_put(dev); + if (parent) + pm_runtime_put_sync(parent); +} + /** * pci_pm_init - Initialize PM functions of given PCI device * @dev: PCI device to handle. |