Skip to content

Commit e5248a1

Browse files
Liu ShuoXrafaeljw
authored andcommitted
PM / Sleep: avoid 'autosleep' in shutdown progress
Prevent automatic system suspend from happening during system shutdown by making try_to_suspend() check system_state and return immediately if it is not SYSTEM_RUNNING. This prevents the following breakage from happening (scenario from Zhang Yanmin): Kernel starts shutdown and calls all device driver's shutdown callback. When a driver's shutdown is called, the last wakelock is released and suspend-to-ram starts. However, as some driver's shut down callbacks already shut down devices and disabled runtime pm, the suspend-to-ram calls driver's suspend callback without noticing that device is already off and causes crash. [rjw: Changelog] Signed-off-by: Liu ShuoX <[email protected]> Cc: 3.5+ <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent aae760e commit e5248a1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/power/autosleep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ static void try_to_suspend(struct work_struct *work)
3232

3333
mutex_lock(&autosleep_lock);
3434

35-
if (!pm_save_wakeup_count(initial_count)) {
35+
if (!pm_save_wakeup_count(initial_count) ||
36+
system_state != SYSTEM_RUNNING) {
3637
mutex_unlock(&autosleep_lock);
3738
goto out;
3839
}

0 commit comments

Comments
 (0)