aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2012-07-12 05:51:48 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-07-16 22:25:49 -0400
commiteed5d2150752bd08b22333d739f3120151773d28 (patch)
treea9bcdd279da2e39951bb588e51f075aa271088c5 /drivers/base
parenteab072609e11a357181806ab5a5c309ef6eb76f5 (diff)
PM / Runtime: Do not increment device usage counts before probing
The pm_runtime_get_noresume() calls before really_probe() and before executing __device_attach() for each driver on the device's bus cause problems to happen if probing fails and if the driver has enabled runtime PM for the device in its .probe() callback. Namely, in that case, if the device has been resumed by the driver after enabling its runtime PM and if it turns out that .probe() should return an error, the driver is supposed to suspend the device and disable its runtime PM before exiting .probe(). However, because the device's runtime PM usage counter was incremented by the core before calling .probe(), the driver's attempt to suspend the device will not succeed and the device will remain in the full-power state after the failing .probe() has returned. To fix this issue, remove the pm_runtime_get_noresume() calls from driver_probe_device() and from device_attach() and replace the corresponding pm_runtime_put_sync() calls with pm_runtime_idle() to preserve the existing behavior (which is to check if the device is idle and to suspend it eventually in that case after probing). Reported-and-tested-by: Kevin Hilman <khilman@ti.com> Reviewed-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/dd.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 9b0aca479580..e3bbed8a617c 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -369,10 +369,9 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
369 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 369 pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
370 drv->bus->name, __func__, dev_name(dev), drv->name); 370 drv->bus->name, __func__, dev_name(dev), drv->name);
371 371
372 pm_runtime_get_noresume(dev);
373 pm_runtime_barrier(dev); 372 pm_runtime_barrier(dev);
374 ret = really_probe(dev, drv); 373 ret = really_probe(dev, drv);
375 pm_runtime_put_sync(dev); 374 pm_runtime_idle(dev);
376 375
377 return ret; 376 return ret;
378} 377}
@@ -419,9 +418,8 @@ int device_attach(struct device *dev)
419 ret = 0; 418 ret = 0;
420 } 419 }
421 } else { 420 } else {
422 pm_runtime_get_noresume(dev);
423 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); 421 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
424 pm_runtime_put_sync(dev); 422 pm_runtime_idle(dev);
425 } 423 }
426out_unlock: 424out_unlock:
427 device_unlock(dev); 425 device_unlock(dev);