Skip to content

Commit 258d01b

Browse files
rafaeljwgregkh
authored andcommitted
PM: runtime: Resume the device earlier in __device_release_driver()
commit 9226c50 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 <rafael.j.wysocki@intel.com> Fixes: 9ed9895 ("driver core: Functional dependencies tracking support") Cc: All applicable <stable@vger.kernel.org> # All applicable Tested-by: Xiang Chen <chenxiang66@hisilicon.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 37f75c6 commit 258d01b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/base/dd.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
11051105

11061106
drv = dev->driver;
11071107
if (drv) {
1108+
pm_runtime_get_sync(dev);
1109+
11081110
while (device_links_busy(dev)) {
11091111
__device_driver_unlock(dev, parent);
11101112

@@ -1116,12 +1118,12 @@ static void __device_release_driver(struct device *dev, struct device *parent)
11161118
* have released the driver successfully while this one
11171119
* was waiting, so check for that.
11181120
*/
1119-
if (dev->driver != drv)
1121+
if (dev->driver != drv) {
1122+
pm_runtime_put(dev);
11201123
return;
1124+
}
11211125
}
11221126

1123-
pm_runtime_get_sync(dev);
1124-
11251127
driver_sysfs_remove(dev);
11261128

11271129
if (dev->bus)

0 commit comments

Comments
 (0)