PM: make freezer optional for suspend
Subsystems (3)
PATCH v3 1/1 PM: make freezer optional for suspend
This patch makes the freezer optional for suspend to allow the system to work (or not work) like the original PMU suspend.
Signed-off-by Johannes Berg <[email protected]>
---
In a quick test, playing sound across suspend failed to work, it usually works when the freezer is enabled (unless you use gstreamer.)
arch/powerpc/Kconfig | 4 ++++ kernel/power/Kconfig | 11 +++++++++++ kernel/power/main.c | 6 +++--- kernel/power/power.h | 22 ++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-)
kernel/power/main.c +3 -3
@@ -79,7 +79,7 @@ static int suspend_prepare(void)pm_prepare_console (); -if (freeze_processes ()) { +if (suspend_freeze_processes ()) { error = -EAGAIN ; goto Thaw; }
@@ -97,7 +97,7 @@ static int suspend_prepare(void)return 0 ; Thaw: -thaw_processes (); +suspend_thaw_processes ();pm_restore_console (); Finish:pm_notifier_call_chain (PM_POST_SUSPEND );
@@ -191,7 +191,7 @@ int suspend_devices_and_enter(suspend_st*/ static void suspend_finish (void ) { -thaw_processes (); +suspend_thaw_processes ();pm_restore_console ();pm_notifier_call_chain (PM_POST_SUSPEND ); }
kernel/power/Kconfig +11 -0
@@ -97,6 +97,17 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (i.e. the ACPI S3 state). +config SUSPEND_FREEZER + bool "Enable freezer for suspend to RAM/standby" \ + if ARCH_WANTS_FREEZER_CONTROL || BROKEN + depends on SUSPEND + default y + help + This allows you to turn off the freezer for suspend. If this is + done, no tasks are frozen for suspend to RAM/standby. + + Turning OFF this setting is NOT recommended! If in doubt, say Y. + config HIBERNATION_UP_POSSIBLE bool depends on X86 || PPC64_SWSUSP || PPC32
arch/powerpc/Kconfig +4 -0
@@ -365,6 +365,10 @@ config CMDLINE most cases you will need to specify the root device here. if !44x || BROKEN +config ARCH_WANTS_FREEZER_CONTROL + def_bool y + depends on ADB_PMU + source kernel/power/Kconfig endif
kernel/power/power.h +22 -0
@@ -1,5 +1,6 @@#include <linux/suspend.h> #include <linux/utsname.h> +#include <linux/freezer.h> struct swsusp_info {struct new_utsname uts;
@@ -211,3 +212,24 @@ static inline int pm_notifier_call_chainreturn (blocking_notifier_call_chain (&pm_chain_head, val,NULL ) ==NOTIFY_BAD ) ? -EINVAL :0 ; } + +#ifdef CONFIG_SUSPEND_FREEZER +static inline int suspend_freeze_processes (void ) +{ +return freeze_processes (); +} + +static inline void suspend_thaw_processes (void ) +{ +thaw_processes (); +} +#else +static inline int suspend_freeze_processes (void ) +{ +return 0 ; +} + +static inline void suspend_thaw_processes (void ) +{ +} +#endif
Quoted 4 lines · Johannes Berg
This patch makes the freezer optional for suspend to allow the system to work (or not work) like the original PMU suspend.
Signed-off-by Johannes Berg <[email protected]>
Looks good.
I'm going to push this patch upstream, for 2.6.25.
Thanks,
Rafael
Quoted 111 lines
---
In a quick test, playing sound across suspend failed to work, it usually works when the freezer is enabled (unless you use gstreamer.)arch/powerpc/Kconfig | 4 ++++ kernel/power/Kconfig | 11 +++++++++++ kernel/power/main.c | 6 +++--- kernel/power/power.h | 22 ++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-)kernel/power/main.c +3
-3@@ -79,7 +79,7 @@ static int suspend_prepare(void)pm_prepare_console (); -if (freeze_processes ()) { +if (suspend_freeze_processes ()) { error = -EAGAIN ; goto Thaw; }@@ -97,7 +97,7 @@ static int suspend_prepare(void)return 0 ; Thaw: -thaw_processes (); +suspend_thaw_processes ();pm_restore_console (); Finish:pm_notifier_call_chain (PM_POST_SUSPEND );@@ -191,7 +191,7 @@ int suspend_devices_and_enter(suspend_st*/ static void suspend_finish (void ) { -thaw_processes (); +suspend_thaw_processes ();pm_restore_console ();pm_notifier_call_chain (PM_POST_SUSPEND ); }kernel/power/Kconfig +11
-0@@ -97,6 +97,17 @@ config SUSPEND powered and thus its contents are preserved, such as the suspend-to-RAM state (i.e. the ACPI S3 state). +config SUSPEND_FREEZER + bool "Enable freezer for suspend to RAM/standby" \ + if ARCH_WANTS_FREEZER_CONTROL || BROKEN + depends on SUSPEND + default y + help + This allows you to turn off the freezer for suspend. If this is + done, no tasks are frozen for suspend to RAM/standby. + + Turning OFF this setting is NOT recommended! If in doubt, say Y. + config HIBERNATION_UP_POSSIBLE bool depends on X86 || PPC64_SWSUSP || PPC32arch/powerpc/Kconfig +4
-0@@ -365,6 +365,10 @@ config CMDLINE most cases you will need to specify the root device here. if !44x || BROKEN +config ARCH_WANTS_FREEZER_CONTROL + def_bool y + depends on ADB_PMU + source kernel/power/Kconfig endifkernel/power/power.h +22
-0@@ -1,5 +1,6 @@#include <linux/suspend.h> #include <linux/utsname.h> +#include <linux/freezer.h> struct swsusp_info {struct new_utsname uts;@@ -211,3 +212,24 @@ static inline int pm_notifier_call_chainreturn (blocking_notifier_call_chain (&pm_chain_head, val,NULL ) ==NOTIFY_BAD ) ? -EINVAL :0 ; } + +#ifdef CONFIG_SUSPEND_FREEZER +static inline int suspend_freeze_processes (void ) +{ +return freeze_processes (); +} + +static inline void suspend_thaw_processes (void ) +{ +thaw_processes (); +} +#else +static inline int suspend_freeze_processes (void ) +{ +return 0 ; +} + +static inline void suspend_thaw_processes (void ) +{ +} +#endif
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth