From 8baabde66c60a84781c718c28fe283ed411a7bd0 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 21 Nov 2007 02:50:17 +0100 Subject: [PATCH 1/5] Freezer: Fix s2disk resume from initrd Add appropriate freezer annotations to handle_initrd(), so that it's possible to resume from disk from an initrd. http://bugzilla.kernel.org/show_bug.cgi?id=9345 Signed-off-by: Rafael J. Wysocki Cc: Pavel Machek Cc: Nigel Cunningham Cc: Ingo Molnar Cc: Chris Friedhoff Signed-off-by: Len Brown --- init/do_mounts_initrd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index fd4fc12d2624..614241b5200c 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c @@ -55,12 +55,18 @@ static void __init handle_initrd(void) sys_mount(".", "/", NULL, MS_MOVE, NULL); sys_chroot("."); + /* + * In case that a resume from disk is carried out by linuxrc or one of + * its children, we need to tell the freezer not to wait for us. + */ + current->flags |= PF_FREEZER_SKIP; + pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD); if (pid > 0) - while (pid != sys_wait4(-1, NULL, 0, NULL)) { - try_to_freeze(); + while (pid != sys_wait4(-1, NULL, 0, NULL)) yield(); - } + + current->flags &= ~PF_FREEZER_SKIP; /* move initrd to rootfs' /old */ sys_fchdir(old_fd); From cb43c54ca05c01533c45e4d3abfe8f99b7acf624 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 21 Nov 2007 02:53:14 +0100 Subject: [PATCH 2/5] Freezer: Fix APM emulation breakage The APM emulation is currently broken as a result of commit 831441862956fffa17b9801db37e6ea1650b0f69 "Freezer: make kernel threads nonfreezable by default" that removed the PF_NOFREEZE annotations from apm_ioctl() without adding the appropriate freezer hooks. Fix it and remove the unnecessary variable flags from apm_ioctl(). Special thanks to Franck Bui-Huu for pointing out the problem. Signed-off-by: Rafael J. Wysocki Cc: Pavel Machek Cc: Franck Bui-Huu Cc: Nigel Cunningham Signed-off-by: Len Brown --- drivers/char/apm-emulation.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index c99e43b837f5..17d54315e146 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c @@ -295,7 +295,6 @@ static int apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) { struct apm_user *as = filp->private_data; - unsigned long flags; int err = -EINVAL; if (!as->suser || !as->writer) @@ -331,10 +330,16 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) * Wait for the suspend/resume to complete. If there * are pending acknowledges, we wait here for them. */ - flags = current->flags; + freezer_do_not_count(); wait_event(apm_suspend_waitqueue, as->suspend_state == SUSPEND_DONE); + + /* + * Since we are waiting until the suspend is done, the + * try_to_freeze() in freezer_count() will not trigger + */ + freezer_count(); } else { as->suspend_state = SUSPEND_WAIT; mutex_unlock(&state_lock); @@ -362,14 +367,10 @@ apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg) * Wait for the suspend/resume to complete. If there * are pending acknowledges, we wait here for them. */ - flags = current->flags; - - wait_event_interruptible(apm_suspend_waitqueue, + wait_event_freezable(apm_suspend_waitqueue, as->suspend_state == SUSPEND_DONE); } - current->flags = flags; - mutex_lock(&state_lock); err = as->suspend_result; as->suspend_state = SUSPEND_NONE; From 561d9a969455cb009bb15b63e1d925dc527e7a9d Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Mon, 3 Dec 2007 18:01:50 +0100 Subject: [PATCH 3/5] HWMON: coretemp, suspend fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not permitted to unregister a device after devices have been suspended. It causes deadlocks to appear on systems with coretemp hwmon loaded.  To avoid this, we can make coretemp_cpu_callback() do nothing if the _FROZEN bit is set in action.   Also, in other cases it's generally too late to unregister the coretemp device if the CPU is already dead, so it should be unregistered on CPU_DOWN_PREPARE.   Signed-off-by: Rafael J. Wysocki Acked-by: Mark M. Hoffman Cc: Jiri Slaby Cc: Andrew Morton Signed-off-by: Len Brown --- drivers/hwmon/coretemp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 5c82ec7f8bbd..3ee60d26e3a2 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c @@ -337,11 +337,10 @@ static int coretemp_cpu_callback(struct notifier_block *nfb, switch (action) { case CPU_ONLINE: - case CPU_ONLINE_FROZEN: + case CPU_DOWN_FAILED: coretemp_device_add(cpu); break; - case CPU_DEAD: - case CPU_DEAD_FROZEN: + case CPU_DOWN_PREPARE: coretemp_device_remove(cpu); break; } From e136e769d471e7f3d24a8f6bf9c91dcb372bd0ab Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Tue, 4 Dec 2007 01:11:09 +0100 Subject: [PATCH 4/5] Freezer: Fix JFFS2 garbage collector freezing issue (rev. 2) Fix breakage caused by commit d5d8c5976d6adeddb8208c240460411e2198b393 "freezer: do not send signals to kernel threads" in jffs2_garbage_collect_thread() that assumed it would be sent signals by the freezer. Signed-off-by: Rafael J. Wysocki Cc: David Woodhouse Cc: Pete MacKay Signed-off-by: Len Brown --- fs/jffs2/background.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index d568ae846741..8adebd3e43c6 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c @@ -105,7 +105,7 @@ static int jffs2_garbage_collect_thread(void *_c) /* Put_super will send a SIGKILL and then wait on the sem. */ - while (signal_pending(current)) { + while (signal_pending(current) || freezing(current)) { siginfo_t info; unsigned long signr; From 74d0f3338fbb3c69894968df1fedaf10c88cd0e4 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Thu, 6 Dec 2007 09:50:40 +0100 Subject: [PATCH 5/5] ACPI: suspend: old debugging hacks sneaked back Old debugging hack sneaked back during x86 merge, this removes it. Signed-off-by: Pavel Machek Acked-by: Rafael J. Wysocki Signed-off-by: Len Brown --- arch/x86/kernel/acpi/wakeup_32.S | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S index a97313b1270e..1e931aaf2ef6 100644 --- a/arch/x86/kernel/acpi/wakeup_32.S +++ b/arch/x86/kernel/acpi/wakeup_32.S @@ -35,10 +35,6 @@ wakeup_code: wakeup_code_start = . .code16 - movw $0xb800, %ax - movw %ax,%fs - movw $0x0e00 + 'L', %fs:(0x10) - cli cld