aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2010-06-08 15:23:51 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2010-07-30 12:29:09 -0400
commitf3ec4f87d607f40497afdb5ac03f11e2ea253d52 (patch)
treeb485337aee10cb1c0fcb1593d8947b5370aa73ff /drivers/pci
parenta2dccdb2055abeb8a7ce8e45e5f83de9c980a00c (diff)
PCI: change device runtime PM settings for probe and remove
This patch (as1388) changes the way the PCI core handles runtime PM settings when probing or unbinding drivers. Now the core will make sure the device is enabled for runtime PM, with a usage count >= 1, when a driver is probed. It does the same when calling a driver's remove method. If the driver wants to use runtime PM, all it has to do is call pm_runtime_pu_noidle() near the end of its probe routine (to cancel the core's usage increment) and pm_runtime_get_noresume() near the start of its remove routine (to restore the usage count). It does not need to mess around with setting the runtime state to enabled, disabled, active, or suspended. The patch updates e1000e and r8169, the only PCI drivers that already use the existing runtime PM interface. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-driver.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index f9a0aec3abcf..8a6f797de8e5 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -289,8 +289,26 @@ struct drv_dev_and_id {
289static long local_pci_probe(void *_ddi) 289static long local_pci_probe(void *_ddi)
290{ 290{
291 struct drv_dev_and_id *ddi = _ddi; 291 struct drv_dev_and_id *ddi = _ddi;
292 292 struct device *dev = &ddi->dev->dev;
293 return ddi->drv->probe(ddi->dev, ddi->id); 293 int rc;
294
295 /* Unbound PCI devices are always set to disabled and suspended.
296 * During probe, the device is set to enabled and active and the
297 * usage count is incremented. If the driver supports runtime PM,
298 * it should call pm_runtime_put_noidle() in its probe routine and
299 * pm_runtime_get_noresume() in its remove routine.
300 */
301 pm_runtime_get_noresume(dev);
302 pm_runtime_set_active(dev);
303 pm_runtime_enable(dev);
304
305 rc = ddi->drv->probe(ddi->dev, ddi->id);
306 if (rc) {
307 pm_runtime_disable(dev);
308 pm_runtime_set_suspended(dev);
309 pm_runtime_put_noidle(dev);
310 }
311 return rc;
294} 312}
295 313
296static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev, 314static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
@@ -369,11 +387,19 @@ static int pci_device_remove(struct device * dev)
369 struct pci_driver * drv = pci_dev->driver; 387 struct pci_driver * drv = pci_dev->driver;
370 388
371 if (drv) { 389 if (drv) {
372 if (drv->remove) 390 if (drv->remove) {
391 pm_runtime_get_sync(dev);
373 drv->remove(pci_dev); 392 drv->remove(pci_dev);
393 pm_runtime_put_noidle(dev);
394 }
374 pci_dev->driver = NULL; 395 pci_dev->driver = NULL;
375 } 396 }
376 397
398 /* Undo the runtime PM settings in local_pci_probe() */
399 pm_runtime_disable(dev);
400 pm_runtime_set_suspended(dev);
401 pm_runtime_put_noidle(dev);
402
377 /* 403 /*
378 * If the device is still on, set the power state as "unknown", 404 * If the device is still on, set the power state as "unknown",
379 * since it might change by the next time we load the driver. 405 * since it might change by the next time we load the driver.