diff options
authorRafael J. Wysocki <>2020-10-22 17:38:22 +0200
committerGreg Kroah-Hartman <>2020-11-10 12:37:34 +0100
commit258d01b1577e98feda9cb3d4f141aa318e59b715 (patch)
parent37f75c6aa8ddfea0bb9d6823c24b0da398a649d0 (diff)
PM: runtime: Resume the device earlier in __device_release_driver()
commit 9226c504e364158a17a68ff1fe9d67d266922f50 upstream. Since the device is resumed from runtime-suspend in __device_release_driver() anyway, it is better to do that before looking for busy managed device links from it to consumers, because if there are any, device_links_unbind_consumers() will be called and it will cause the consumer devices' drivers to unbind, so the consumer devices will be runtime-resumed. In turn, resuming each consumer device will cause the supplier to be resumed and when the runtime PM references from the given consumer to it are dropped, it may be suspended. Then, the runtime-resume of the next consumer will cause the supplier to resume again and so on. Update the code accordingly. Signed-off-by: Rafael J. Wysocki <> Fixes: 9ed9895370ae ("driver core: Functional dependencies tracking support") Cc: All applicable <> # All applicable Tested-by: Xiang Chen <> Reviewed-by: Greg Kroah-Hartman <> Signed-off-by: Greg Kroah-Hartman <>
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 85463c4f7653..32823f36cffd 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1105,6 +1105,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
drv = dev->driver;
if (drv) {
+ pm_runtime_get_sync(dev);
while (device_links_busy(dev)) {
__device_driver_unlock(dev, parent);
@@ -1116,12 +1118,12 @@ static void __device_release_driver(struct device *dev, struct device *parent)
* have released the driver successfully while this one
* was waiting, so check for that.
- if (dev->driver != drv)
+ if (dev->driver != drv) {
+ pm_runtime_put(dev);
+ }
- pm_runtime_get_sync(dev);
if (dev->bus)