From: "Rafael J. Wysocki" 1) Remove the console-switching code from the suspend part of the swsusp userland interface and let the userland tools switch the console. 2) It is unsafe to suspend devices if the hardware is controlled by X. Add an extra check to prevent this from happening. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Andrew Morton --- drivers/base/power/suspend.c | 9 +++++++++ kernel/power/user.c | 3 --- 2 files changed, 9 insertions(+), 3 deletions(-) diff -puN drivers/base/power/suspend.c~swsusp-pm-refuse-to-suspend-devices-if-wrong-console-is-active drivers/base/power/suspend.c --- devel/drivers/base/power/suspend.c~swsusp-pm-refuse-to-suspend-devices-if-wrong-console-is-active 2006-02-19 21:34:07.000000000 -0800 +++ devel-akpm/drivers/base/power/suspend.c 2006-02-19 21:34:07.000000000 -0800 @@ -8,6 +8,9 @@ * */ +#include +#include +#include #include #include "../base.h" #include "power.h" @@ -82,6 +85,12 @@ int device_suspend(pm_message_t state) { int error = 0; + /* It is unsafe to suspend devices while X has control of the + * hardware. Make sure we are running on a kernel-controlled console. + */ + if (vc_cons[fg_console].d->vc_mode != KD_TEXT) + return -EINVAL; + down(&dpm_sem); down(&dpm_list_sem); while (!list_empty(&dpm_active) && error == 0) { diff -puN kernel/power/user.c~swsusp-pm-refuse-to-suspend-devices-if-wrong-console-is-active kernel/power/user.c --- devel/kernel/power/user.c~swsusp-pm-refuse-to-suspend-devices-if-wrong-console-is-active 2006-02-19 21:34:07.000000000 -0800 +++ devel-akpm/kernel/power/user.c 2006-02-19 21:34:07.000000000 -0800 @@ -138,12 +138,10 @@ static int snapshot_ioctl(struct inode * if (data->frozen) break; down(&pm_sem); - pm_prepare_console(); disable_nonboot_cpus(); if (freeze_processes()) { thaw_processes(); enable_nonboot_cpus(); - pm_restore_console(); error = -EBUSY; } up(&pm_sem); @@ -157,7 +155,6 @@ static int snapshot_ioctl(struct inode * down(&pm_sem); thaw_processes(); enable_nonboot_cpus(); - pm_restore_console(); up(&pm_sem); data->frozen = 0; break; _