mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
[ACPI] fix reboot upon suspend-to-disk
http://bugzilla.kernel.org/show_bug.cgi?id=4320 Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> Acked-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
7116317dc9
commit
729b4d4ce1
@ -33,9 +33,7 @@ int acpi_sleep_prepare(u32 acpi_state)
|
||||
ACPI_FLUSH_CPU_CACHE();
|
||||
acpi_enable_wakeup_device_prep(acpi_state);
|
||||
#endif
|
||||
if (acpi_state == ACPI_STATE_S5) {
|
||||
acpi_wakeup_gpe_poweroff_prepare();
|
||||
}
|
||||
acpi_gpe_sleep_prepare(acpi_state);
|
||||
acpi_enter_sleep_state_prep(acpi_state);
|
||||
return 0;
|
||||
}
|
||||
@ -53,11 +51,16 @@ void acpi_power_off(void)
|
||||
|
||||
static int acpi_shutdown(struct sys_device *x)
|
||||
{
|
||||
if (system_state == SYSTEM_POWER_OFF) {
|
||||
/* Prepare if we are going to power off the system */
|
||||
switch (system_state) {
|
||||
case SYSTEM_POWER_OFF:
|
||||
/* Prepare to power off the system */
|
||||
return acpi_sleep_prepare(ACPI_STATE_S5);
|
||||
case SYSTEM_SUSPEND_DISK:
|
||||
/* Prepare to suspend the system to disk */
|
||||
return acpi_sleep_prepare(ACPI_STATE_S4);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct sysdev_class acpi_sysclass = {
|
||||
|
@ -5,4 +5,4 @@ extern int acpi_suspend (u32 state);
|
||||
extern void acpi_enable_wakeup_device_prep(u8 sleep_state);
|
||||
extern void acpi_enable_wakeup_device(u8 sleep_state);
|
||||
extern void acpi_disable_wakeup_device(u8 sleep_state);
|
||||
extern void acpi_wakeup_gpe_poweroff_prepare(void);
|
||||
extern void acpi_gpe_sleep_prepare(u32 sleep_state);
|
||||
|
@ -192,7 +192,7 @@ late_initcall(acpi_wakeup_device_init);
|
||||
* RUNTIME GPEs, we simply mark all GPES that
|
||||
* are not enabled for wakeup from S5 as RUNTIME.
|
||||
*/
|
||||
void acpi_wakeup_gpe_poweroff_prepare(void)
|
||||
void acpi_gpe_sleep_prepare(u32 sleep_state)
|
||||
{
|
||||
struct list_head *node, *next;
|
||||
|
||||
@ -201,8 +201,8 @@ void acpi_wakeup_gpe_poweroff_prepare(void)
|
||||
struct acpi_device,
|
||||
wakeup_list);
|
||||
|
||||
/* The GPE can wakeup system from S5, don't touch it */
|
||||
if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5)
|
||||
/* The GPE can wakeup system from this state, don't touch it */
|
||||
if ((u32) dev->wakeup.sleep_state >= sleep_state)
|
||||
continue;
|
||||
/* acpi_set_gpe_type will automatically disable GPE */
|
||||
acpi_set_gpe_type(dev->wakeup.gpe_device,
|
||||
|
@ -181,6 +181,7 @@ extern enum system_states {
|
||||
SYSTEM_HALT,
|
||||
SYSTEM_POWER_OFF,
|
||||
SYSTEM_RESTART,
|
||||
SYSTEM_SUSPEND_DISK,
|
||||
} system_state;
|
||||
|
||||
#define TAINT_PROPRIETARY_MODULE (1<<0)
|
||||
|
@ -60,8 +60,7 @@ extern void machine_crash_shutdown(struct pt_regs *);
|
||||
*/
|
||||
|
||||
extern void kernel_restart_prepare(char *cmd);
|
||||
extern void kernel_halt_prepare(void);
|
||||
extern void kernel_power_off_prepare(void);
|
||||
extern void kernel_shutdown_prepare(enum system_states state);
|
||||
|
||||
extern void kernel_restart(char *cmd);
|
||||
extern void kernel_halt(void);
|
||||
|
@ -52,7 +52,7 @@ static void power_down(suspend_disk_method_t mode)
|
||||
|
||||
switch(mode) {
|
||||
case PM_DISK_PLATFORM:
|
||||
kernel_power_off_prepare();
|
||||
kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
|
||||
error = pm_ops->enter(PM_SUSPEND_DISK);
|
||||
break;
|
||||
case PM_DISK_SHUTDOWN:
|
||||
@ -119,13 +119,6 @@ static int prepare_processes(void)
|
||||
goto thaw;
|
||||
}
|
||||
|
||||
if (pm_disk_mode == PM_DISK_PLATFORM) {
|
||||
if (pm_ops && pm_ops->prepare) {
|
||||
if ((error = pm_ops->prepare(PM_SUSPEND_DISK)))
|
||||
goto thaw;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free memory before shutting down devices. */
|
||||
free_some_memory();
|
||||
return 0;
|
||||
|
25
kernel/sys.c
25
kernel/sys.c
@ -427,23 +427,25 @@ void kernel_kexec(void)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kernel_kexec);
|
||||
|
||||
void kernel_shutdown_prepare(enum system_states state)
|
||||
{
|
||||
notifier_call_chain(&reboot_notifier_list,
|
||||
(state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);
|
||||
system_state = state;
|
||||
device_shutdown();
|
||||
}
|
||||
/**
|
||||
* kernel_halt - halt the system
|
||||
*
|
||||
* Shutdown everything and perform a clean system halt.
|
||||
*/
|
||||
void kernel_halt_prepare(void)
|
||||
{
|
||||
notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
|
||||
system_state = SYSTEM_HALT;
|
||||
device_shutdown();
|
||||
}
|
||||
void kernel_halt(void)
|
||||
{
|
||||
kernel_halt_prepare();
|
||||
kernel_shutdown_prepare(SYSTEM_HALT);
|
||||
printk(KERN_EMERG "System halted.\n");
|
||||
machine_halt();
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL_GPL(kernel_halt);
|
||||
|
||||
/**
|
||||
@ -451,20 +453,13 @@ EXPORT_SYMBOL_GPL(kernel_halt);
|
||||
*
|
||||
* Shutdown everything and perform a clean system power_off.
|
||||
*/
|
||||
void kernel_power_off_prepare(void)
|
||||
{
|
||||
notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
|
||||
system_state = SYSTEM_POWER_OFF;
|
||||
device_shutdown();
|
||||
}
|
||||
void kernel_power_off(void)
|
||||
{
|
||||
kernel_power_off_prepare();
|
||||
kernel_shutdown_prepare(SYSTEM_POWER_OFF);
|
||||
printk(KERN_EMERG "Power down.\n");
|
||||
machine_power_off();
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kernel_power_off);
|
||||
|
||||
/*
|
||||
* Reboot system call: for obvious reasons only root may call it,
|
||||
* and even root needs to set up some magic numbers in the registers
|
||||
|
Loading…
Reference in New Issue
Block a user