From 0da8cf5597fe54ec4e580d08ca1573f60b3f1616 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Thu, 22 Sep 2022 20:04:40 +0200 Subject: [PATCH 3/6] UPSTREAM: PM: runtime: Return -EINPROGRESS from rpm_resume() in the RPM_NOWAIT case The prospective callers of rpm_resume() passing RPM_NOWAIT to it may be confused when it returns 0 without actually resuming the device which may happen if the device is suspending at the given time and it will only resume when the suspend in progress has completed. To avoid that confusion, return -EINPROGRESS from rpm_resume() in that case. Since none of the current callers passing RPM_NOWAIT to rpm_resume() check its return value, this change has no functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Alan Stern Reviewed-by: Douglas Anderson Reviewed-by: Ulf Hansson (cherry picked from commit e66332a4bc89e3219baaabc7bb549d17a2c42ce9) BUG=b:328070191 TEST=No more deadlocks Change-Id: I4460d67e92fc99d38fe185cbe5d7b093008a8648 Signed-off-by: Douglas Anderson --- drivers/base/power/runtime.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 6699096ff2fa..6bd54d3ae12f 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -800,10 +800,13 @@ static int rpm_resume(struct device *dev, int rpmflags) DEFINE_WAIT(wait); if (rpmflags & (RPM_ASYNC | RPM_NOWAIT)) { - if (dev->power.runtime_status == RPM_SUSPENDING) + if (dev->power.runtime_status == RPM_SUSPENDING) { dev->power.deferred_resume = true; - else + if (rpmflags & RPM_NOWAIT) + retval = -EINPROGRESS; + } else { retval = -EINPROGRESS; + } goto out; } -- 2.44.0.rc1.240.g4c46232300-goog