Skip to content

Commit

Permalink
PM: suspend: advanced pm_wakeup_clear() for normal suspend/hibernate
Browse files Browse the repository at this point in the history
pm_wakeup_clear() will clear the wakeup source, which can ensure that it
is not disturbed by useless wakeup signals when doing suspend/hibernate;

At the beginning of the suspend/hibernate process, the notifier
mechanism is used to notify other device drivers. This action is
time-consuming (second-level time-consuming). If the process fails due
to the received wakeup signal during the execution of these functions,
it can better improve the experience of failing suspend/hibernate
returns;

Therefore, it is recommended here that for the suspend/hibernate process
normally called from /sys/power/state, the pm_wakeup_clear() function
should be brought before the notifier call; for the freeze_process()
function called from other places, the original logic is kept;

The pm_suspend_target_state variable is used here to identify whether the
suspend process is going normally.

Signed-off-by: xiongxin <xiongxin@kylinos.cn>
  • Loading branch information
TGSP authored and intel-lab-lkp committed Jun 29, 2022
1 parent 09d1c5e commit 2e0bc44
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/power/process.c
Expand Up @@ -131,7 +131,10 @@ int freeze_processes(void)
if (!pm_freezing)
atomic_inc(&system_freezing_cnt);

pm_wakeup_clear(0);
if (pm_suspend_target_state != PM_SUSPEND_ON)
pm_wakeup_clear(1);
else
pm_wakeup_clear(0);
pr_info("Freezing user space processes ... ");
pm_freezing = true;
error = try_to_freeze_tasks(true);
Expand Down
6 changes: 6 additions & 0 deletions kernel/power/suspend.c
Expand Up @@ -569,6 +569,12 @@ static int enter_state(suspend_state_t state)
* performed from the /sys/power/state entry.
*/
pm_suspend_target_state = state;
/*
* Put pm_wakeup_clear() before the notifier notification chain to
* optimize in the suspend process, the wakeup signal can interrupt
* the suspend in advance and fail to return.
*/
pm_wakeup_clear(0);

if (sync_on_suspend_enabled) {
trace_suspend_resume(TPS("sync_filesystems"), 0, true);
Expand Down

0 comments on commit 2e0bc44

Please sign in to comment.