summaryrefslogtreecommitdiff
path: root/drivers/pci
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2009-01-07 13:05:05 +0100
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-01-07 11:15:18 -0800
commit571ff7584bb9e05fca0eb79752ae55a46faf3a98 (patch)
treea9439b1749154f2a7d4ed18c28a4d221235f2f3b /drivers/pci
parentfa58d305d9925b01830e535896a7227a868a9e15 (diff)
PCI PM: Power-manage devices without drivers during suspend-resume
PCI devices without drivers can be put into low power states during suspend with the help of pci_prepare_to_sleep() and prevented from generating wake-up events during resume with the help of pci_enable_wake(). However, it's better not to put bridges into low power states during suspend, because that might result in entire bus segments being powered off. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-driver.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 57cb0015a470..2617ebb34e14 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -435,6 +435,31 @@ static int pci_legacy_resume_early(struct device *dev)
return error;
}
+/* Auxiliary functions used by the new power management framework */
+
+static bool pci_is_bridge(struct pci_dev *pci_dev)
+{
+ return !!(pci_dev->subordinate);
+}
+
+static int pci_pm_default_resume(struct pci_dev *pci_dev)
+{
+ if (!pci_is_bridge(pci_dev))
+ pci_enable_wake(pci_dev, PCI_D0, false);
+
+ return pci_default_pm_resume_late(pci_dev);
+}
+
+static void pci_pm_default_suspend(struct pci_dev *pci_dev)
+{
+ pci_default_pm_suspend_early(pci_dev);
+
+ if (!pci_is_bridge(pci_dev))
+ pci_prepare_to_sleep(pci_dev);
+}
+
+/* New power management framework */
+
static int pci_pm_prepare(struct device *dev)
{
struct device_driver *drv = dev->driver;
@@ -470,7 +495,7 @@ static int pci_pm_suspend(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
error = pci_legacy_suspend(dev, PMSG_SUSPEND);
} else {
- pci_default_pm_suspend_early(pci_dev);
+ pci_pm_default_suspend(pci_dev);
}
pci_fixup_device(pci_fixup_suspend, pci_dev);
@@ -512,7 +537,7 @@ static int pci_pm_resume(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
error = pci_legacy_resume(dev);
} else {
- error = pci_default_pm_resume_late(pci_dev);
+ error = pci_pm_default_resume(pci_dev);
}
return error;
@@ -642,7 +667,7 @@ static int pci_pm_poweroff(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
error = pci_legacy_suspend(dev, PMSG_HIBERNATE);
} else {
- pci_default_pm_suspend_early(pci_dev);
+ pci_pm_default_suspend(pci_dev);
}
pci_fixup_device(pci_fixup_suspend, pci_dev);
@@ -681,7 +706,7 @@ static int pci_pm_restore(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
error = pci_legacy_resume(dev);
} else {
- error = pci_default_pm_resume_late(pci_dev);
+ error = pci_pm_default_resume(pci_dev);
}
return error;