PM / suspend: Prevent might sleep splats
timekeeping suspend/resume calls read_persistent_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 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(). There is no lock contention because hibernate / suspend to RAM is single-CPU at this point. In s2idle's case the system_state is set to SYSTEM_SUSPEND before timekeeping_suspend() which is invoked by the last CPU. In the resume case it set back to SYSTEM_RUNNING after timekeeping_resume() which is invoked by the first CPU in the resume case. The other CPUs will block on tick_freeze_lock. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> [bigeasy: cover s2idle in tick_freeze() / tick_unfreeze()] Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Родитель
771c577c23
Коммит
c1a957d170
|
@ -542,6 +542,7 @@ extern enum system_states {
|
|||
SYSTEM_HALT,
|
||||
SYSTEM_POWER_OFF,
|
||||
SYSTEM_RESTART,
|
||||
SYSTEM_SUSPEND,
|
||||
} system_state;
|
||||
|
||||
/* This cannot be an enum because some may be used in assembly source. */
|
||||
|
|
|
@ -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");
|
||||
|
@ -317,6 +319,7 @@ static int create_image(int platform_mode)
|
|||
syscore_resume();
|
||||
|
||||
Enable_irqs:
|
||||
system_state = SYSTEM_RUNNING;
|
||||
local_irq_enable();
|
||||
|
||||
Enable_cpus:
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
@ -575,6 +581,7 @@ int hibernation_platform_enter(void)
|
|||
|
||||
Power_up:
|
||||
syscore_resume();
|
||||
system_state = SYSTEM_RUNNING;
|
||||
local_irq_enable();
|
||||
|
||||
Enable_cpus:
|
||||
|
|
|
@ -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();
|
||||
|
@ -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());
|
||||
|
||||
|
|
|
@ -490,6 +490,7 @@ void tick_freeze(void)
|
|||
if (tick_freeze_depth == num_online_cpus()) {
|
||||
trace_suspend_resume(TPS("timekeeping_freeze"),
|
||||
smp_processor_id(), true);
|
||||
system_state = SYSTEM_SUSPEND;
|
||||
timekeeping_suspend();
|
||||
} else {
|
||||
tick_suspend_local();
|
||||
|
@ -513,6 +514,7 @@ void tick_unfreeze(void)
|
|||
|
||||
if (tick_freeze_depth == num_online_cpus()) {
|
||||
timekeeping_resume();
|
||||
system_state = SYSTEM_RUNNING;
|
||||
trace_suspend_resume(TPS("timekeeping_freeze"),
|
||||
smp_processor_id(), false);
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче