PM / Runtime: Do not increment device usage counts before probing
authorRafael J. Wysocki <rjw@sisk.pl>
Thu, 12 Jul 2012 09:51:48 +0000 (11:51 +0200)
committerMandar Padmawar <mpadmawar@nvidia.com>
Mon, 11 Mar 2013 14:52:01 +0000 (07:52 -0700)
commit12f5955b6c07c0e5d2e48add1f0b6a97a4a5ccd8
tree8236200ffe736ad81ad6011bfeb11933779697c7
parentfadbfaaded67190c09bf2cb079e0b50c0f6dfa22
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>
Signed-off-by: Eric Miao <emiao@nvidia.com>
Change-Id: Idde55471031f4d99275b11fa05ae9de6950a68ae
Reviewed-on: http://git-master/r/206657
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
drivers/base/dd.c