From a946e18c1510b2ca6836eef5675da898e18de766 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Thu, 23 Mar 2006 03:00:07 -0800 Subject: [PATCH] --- yaml --- r: 23023 b: refs/heads/master c: ff4da2e262d2509fe1bacff70dd00934be569c66 h: refs/heads/master i: 23021: e6fe66c276a5b0b31363ff713484e3ba28751f7c 23019: b3ee3208f854872af8d51d7dc13c66de23397bd0 23015: b54417be3d1abd845a49424924ac67ffb7fd789f 23007: 5b74a81b77fd4d2c9270bd48174e6bfbeb83cf28 v: v3 --- [refs] | 2 +- trunk/drivers/base/power/suspend.c | 5 ++++- trunk/drivers/char/vt.c | 8 ++++++++ trunk/include/linux/vt_kern.h | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 5cb571cb24da..296f1982ebb6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e4e4d665560c75afb6060cb43bb6738777648ca1 +refs/heads/master: ff4da2e262d2509fe1bacff70dd00934be569c66 diff --git a/trunk/drivers/base/power/suspend.c b/trunk/drivers/base/power/suspend.c index 8660779fb288..bdb60663f2ef 100644 --- a/trunk/drivers/base/power/suspend.c +++ b/trunk/drivers/base/power/suspend.c @@ -8,6 +8,7 @@ * */ +#include #include #include "../base.h" #include "power.h" @@ -62,7 +63,6 @@ int suspend_device(struct device * dev, pm_message_t state) return error; } - /** * device_suspend - Save state and stop all devices in system. * @state: Power state to put each device in. @@ -82,6 +82,9 @@ int device_suspend(pm_message_t state) { int error = 0; + if (!is_console_suspend_safe()) + return -EINVAL; + down(&dpm_sem); down(&dpm_list_sem); while (!list_empty(&dpm_active) && error == 0) { diff --git a/trunk/drivers/char/vt.c b/trunk/drivers/char/vt.c index 0900d1dbee59..86b31b87eb85 100644 --- a/trunk/drivers/char/vt.c +++ b/trunk/drivers/char/vt.c @@ -3234,6 +3234,14 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org) } } +int is_console_suspend_safe(void) +{ + /* It is unsafe to suspend devices while X has control of the + * hardware. Make sure we are running on a kernel-controlled console. + */ + return vc_cons[fg_console].d->vc_mode == KD_TEXT; +} + /* * Visible symbols for modules */ diff --git a/trunk/include/linux/vt_kern.h b/trunk/include/linux/vt_kern.h index fab5aed8ca31..530ae3f4248c 100644 --- a/trunk/include/linux/vt_kern.h +++ b/trunk/include/linux/vt_kern.h @@ -73,6 +73,11 @@ int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc); int vt_waitactive(int vt); void change_console(struct vc_data *new_vc); void reset_vc(struct vc_data *vc); +#ifdef CONFIG_VT +int is_console_suspend_safe(void); +#else +static inline int is_console_suspend_safe(void) { return 1; } +#endif /* * vc_screen.c shares this temporary buffer with the console write code so that