From c28edb536bfc898846b33c2903a26325132bca2f Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Wed, 4 May 2022 09:28:34 -0700 Subject: [PATCH] PM / freezer: Abort suspend when there's a wakeup while freezing Although try_to_freeze_tasks() stops when there's a wakeup, it doesn't return an error when it successfully freezes everything it wants to freeze. As a result, the suspend attempt can continue even after a wakeup is issued. Although the wakeup will be eventually caught later in the suspend process, kicking the can down the road is suboptimal; when there's a wakeup detected, suspend should be immediately aborted by returning an error instead. Make try_to_freeze_tasks() do just that, and also move the wakeup check above the `todo` check so that we don't miss a wakeup from a process that successfully froze. Signed-off-by: Sultan Alsawaf Change-Id: I6d0ff54b1e1e143df2679d3848019590725c6351 --- kernel/power/process.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/power/process.c b/kernel/power/process.c index 879c15a16d34..c52bdd41b5b3 100755 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -65,14 +65,14 @@ static int try_to_freeze_tasks(bool user_only) todo += wq_busy; } - if (!todo || time_after(jiffies, end_time)) - break; - if (pm_wakeup_pending()) { wakeup = true; break; } + if (!todo || time_after(jiffies, end_time)) + break; + /* * We need to retry, but first give the freezing tasks some * time to enter the refrigerator. Start with an initial @@ -113,7 +113,7 @@ static int try_to_freeze_tasks(bool user_only) elapsed_msecs % 1000); } - return todo ? -EBUSY : 0; + return todo || wakeup ? -EBUSY : 0; } /**