summaryrefslogtreecommitdiff
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2009-02-04 01:56:14 +0100
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-02-04 17:20:09 -0800
commitddb7c9d29fac34626aef2af9f19787a888e4ca9c (patch)
tree9f56f777604d4ccc5395f93972e7a0d0618ba249 /drivers/pci/pci-driver.c
parent97c44836cdec1ea713a15d84098a1a908157e68f (diff)
PCI PM: Fix handling of devices without drivers
Suspend to RAM is reported to break on some machines as a result of attempting to put one of driverless PCI devices into a low power state. Avoid that by not attepmting to power manage driverless devices during suspend. Fix up pci_pm_poweroff() after a previous incomplete fix for the same thing during hibernation. This patch is reported to fix the regression from 2.6.28 tracked as http://bugzilla.kernel.org/show_bug.cgi?id=12605 Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Reported-and-tested-by: Eric Sesterhenn <snakebyte@gmx.de> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index ab1d615425a8..6613bef25bf2 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -445,11 +445,11 @@ static void pci_pm_default_suspend_generic(struct pci_dev *pci_dev)
pci_save_state(pci_dev);
}
-static void pci_pm_default_suspend(struct pci_dev *pci_dev)
+static void pci_pm_default_suspend(struct pci_dev *pci_dev, bool prepare)
{
pci_pm_default_suspend_generic(pci_dev);
- if (!pci_is_bridge(pci_dev))
+ if (prepare && !pci_is_bridge(pci_dev))
pci_prepare_to_sleep(pci_dev);
pci_fixup_device(pci_fixup_suspend, pci_dev);
@@ -497,19 +497,19 @@ static void pci_pm_complete(struct device *dev)
static int pci_pm_suspend(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
- struct device_driver *drv = dev->driver;
+ struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int error = 0;
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_SUSPEND);
- if (drv && drv->pm && drv->pm->suspend) {
- error = drv->pm->suspend(dev);
- suspend_report_result(drv->pm->suspend, error);
+ if (pm && pm->suspend) {
+ error = pm->suspend(dev);
+ suspend_report_result(pm->suspend, error);
}
if (!error)
- pci_pm_default_suspend(pci_dev);
+ pci_pm_default_suspend(pci_dev, !!pm);
return error;
}
@@ -663,22 +663,19 @@ static int pci_pm_thaw(struct device *dev)
static int pci_pm_poweroff(struct device *dev)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
- struct device_driver *drv = dev->driver;
+ struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int error = 0;
if (pci_has_legacy_pm_support(pci_dev))
return pci_legacy_suspend(dev, PMSG_HIBERNATE);
- if (!drv || !drv->pm)
- return 0;
-
- if (drv->pm->poweroff) {
- error = drv->pm->poweroff(dev);
- suspend_report_result(drv->pm->poweroff, error);
+ if (pm && pm->poweroff) {
+ error = pm->poweroff(dev);
+ suspend_report_result(pm->poweroff, error);
}
if (!error)
- pci_pm_default_suspend(pci_dev);
+ pci_pm_default_suspend(pci_dev, !!pm);
return error;
}