summaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-driver.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2009-01-07 13:03:42 +0100
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-01-07 11:14:40 -0800
commitfa58d305d9925b01830e535896a7227a868a9e15 (patch)
tree6b0509663958c9fc6c3b201e6a3b061af784ffa9 /drivers/pci/pci-driver.c
parentc9b9972b3c88272be02d971346285d1c67fbb95f (diff)
downloadop-kernel-dev-fa58d305d9925b01830e535896a7227a868a9e15.zip
op-kernel-dev-fa58d305d9925b01830e535896a7227a868a9e15.tar.gz
PCI PM: Add suspend counterpart of pci_reenable_device
PCI devices without drivers are not disabled during suspend and hibernation, but they are enabled during resume, with the help of pci_reenable_device(), so there is an unbalanced execution of pcibios_enable_device() in the resume code path. To correct this introduce function pci_disable_enabled_device() that will disable the argument device, if it is enabled when the function is being run, without updating the device's pci_dev structure and use it in the suspend code path to balance the pci_reenable_device() executed during resume. 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/pci-driver.c')
-rw-r--r--drivers/pci/pci-driver.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 23bdf64..57cb001 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -324,9 +324,19 @@ static bool pci_has_legacy_pm_support(struct pci_dev *pci_dev)
/*
* Default "suspend" method for devices that have no driver provided suspend,
- * or not even a driver at all.
+ * or not even a driver at all (first part).
+ */
+static void pci_default_pm_suspend_early(struct pci_dev *pci_dev)
+{
+ /* If device is enabled at this point, disable it */
+ pci_disable_enabled_device(pci_dev);
+}
+
+/*
+ * Default "suspend" method for devices that have no driver provided suspend,
+ * or not even a driver at all (second part).
*/
-static void pci_default_pm_suspend(struct pci_dev *pci_dev)
+static void pci_default_pm_suspend_late(struct pci_dev *pci_dev)
{
pci_save_state(pci_dev);
/*
@@ -377,7 +387,11 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
i = drv->suspend(pci_dev, state);
suspend_report_result(drv->suspend, i);
} else {
- pci_default_pm_suspend(pci_dev);
+ /*
+ * For compatibility with existing code with legacy PM support
+ * don't call pci_default_pm_suspend_early() here.
+ */
+ pci_default_pm_suspend_late(pci_dev);
}
return i;
}
@@ -455,7 +469,10 @@ 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_fixup_device(pci_fixup_suspend, pci_dev);
return error;
@@ -475,7 +492,7 @@ static int pci_pm_suspend_noirq(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
error = pci_legacy_suspend_late(dev, PMSG_SUSPEND);
} else {
- pci_default_pm_suspend(pci_dev);
+ pci_default_pm_suspend_late(pci_dev);
}
return error;
@@ -546,6 +563,8 @@ static int pci_pm_freeze(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
error = pci_legacy_suspend(dev, PMSG_FREEZE);
pci_fixup_device(pci_fixup_suspend, pci_dev);
+ } else {
+ pci_default_pm_suspend_early(pci_dev);
}
return error;
@@ -565,7 +584,7 @@ static int pci_pm_freeze_noirq(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
error = pci_legacy_suspend_late(dev, PMSG_FREEZE);
} else {
- pci_default_pm_suspend(pci_dev);
+ pci_default_pm_suspend_late(pci_dev);
}
return error;
@@ -583,6 +602,8 @@ static int pci_pm_thaw(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
pci_fixup_device(pci_fixup_resume, pci_dev);
error = pci_legacy_resume(dev);
+ } else {
+ pci_default_pm_resume_late(pci_dev);
}
return error;
@@ -600,6 +621,8 @@ static int pci_pm_thaw_noirq(struct device *dev)
} else if (pci_has_legacy_pm_support(pci_dev)) {
pci_fixup_device(pci_fixup_resume_early, to_pci_dev(dev));
error = pci_legacy_resume_early(dev);
+ } else {
+ pci_default_pm_resume_early(pci_dev);
}
return error;
@@ -618,6 +641,8 @@ 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_fixup_device(pci_fixup_suspend, pci_dev);
OpenPOWER on IntegriCloud