Skip to content

Commit

Permalink
suspend: Prevent might sleep splats
Browse files Browse the repository at this point in the history
timekeeping suspend/resume calls read_persistant_clock() which takes
rtc_lock. That results in might sleep warnings because at that point
we run with interrupts disabled.

We cannot convert rtc_lock to a raw spinlock as that would trigger
other might sleep warnings.

As a temporary workaround we disable the might sleep warnings by
setting system_state to SYSTEM_SUSPEND before calling sysdev_suspend()
and restoring it to SYSTEM_RUNNING afer sysdev_resume().

Needs to be revisited.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
KAGA-KOKO authored and Tiejun Chen committed Feb 24, 2018
1 parent c0dd906 commit eecf471
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ extern enum system_states {
SYSTEM_HALT,
SYSTEM_POWER_OFF,
SYSTEM_RESTART,
SYSTEM_SUSPEND,
} system_state;

#define TAINT_PROPRIETARY_MODULE 0
Expand Down
7 changes: 7 additions & 0 deletions kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ static int create_image(int platform_mode)

local_irq_disable();

system_state = SYSTEM_SUSPEND;

error = syscore_suspend();
if (error) {
pr_err("Some system devices failed to power down, aborting hibernation\n");
Expand Down Expand Up @@ -317,6 +319,7 @@ static int create_image(int platform_mode)
syscore_resume();

Enable_irqs:
system_state = SYSTEM_RUNNING;
local_irq_enable();

Enable_cpus:
Expand Down Expand Up @@ -445,6 +448,7 @@ static int resume_target_kernel(bool platform_mode)
goto Enable_cpus;

local_irq_disable();
system_state = SYSTEM_SUSPEND;

error = syscore_suspend();
if (error)
Expand Down Expand Up @@ -478,6 +482,7 @@ static int resume_target_kernel(bool platform_mode)
syscore_resume();

Enable_irqs:
system_state = SYSTEM_RUNNING;
local_irq_enable();

Enable_cpus:
Expand Down Expand Up @@ -563,6 +568,7 @@ int hibernation_platform_enter(void)
goto Enable_cpus;

local_irq_disable();
system_state = SYSTEM_SUSPEND;
syscore_suspend();
if (pm_wakeup_pending()) {
error = -EAGAIN;
Expand All @@ -575,6 +581,7 @@ int hibernation_platform_enter(void)

Power_up:
syscore_resume();
system_state = SYSTEM_RUNNING;
local_irq_enable();

Enable_cpus:
Expand Down
4 changes: 4 additions & 0 deletions kernel/power/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
arch_suspend_disable_irqs();
BUG_ON(!irqs_disabled());

system_state = SYSTEM_SUSPEND;

error = syscore_suspend();
if (!error) {
*wakeup = pm_wakeup_pending();
Expand All @@ -443,6 +445,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup)
syscore_resume();
}

system_state = SYSTEM_RUNNING;

arch_suspend_enable_irqs();
BUG_ON(irqs_disabled());

Expand Down

0 comments on commit eecf471

Please sign in to comment.