Skip to content

Commit

Permalink
[ACPI] fix reboot upon suspend-to-disk
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexey Starikovskiy authored and Len Brown committed Dec 15, 2005
1 parent 7116317 commit 729b4d4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 35 deletions.
15 changes: 9 additions & 6 deletions drivers/acpi/sleep/poweroff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/sleep/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 3 additions & 3 deletions drivers/acpi/sleep/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions include/linux/reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 1 addition & 8 deletions kernel/power/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 10 additions & 15 deletions kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,44 +427,39 @@ 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);

/**
* kernel_power_off - power_off the system
*
* 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
Expand Down

0 comments on commit 729b4d4

Please sign in to comment.