diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2006-09-26 02:32:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:48:59 -0400 |
commit | e3920fb42c8ddfe63befb54d95c0e13eabacea9b (patch) | |
tree | 08371a71e58e6e9d3ec62dfa6a22b3b5e6ff0fd5 /kernel/power/smp.c | |
parent | e8eff5ac294e12531c4195e0c15a222d3c9015e5 (diff) |
[PATCH] Disable CPU hotplug during suspend
The current suspend code has to be run on one CPU, so we use the CPU
hotplug to take the non-boot CPUs offline on SMP machines. However, we
should also make sure that these CPUs will not be enabled by someone else
after we have disabled them.
The functions disable_nonboot_cpus() and enable_nonboot_cpus() are moved to
kernel/cpu.c, because they now refer to some stuff in there that should
better be static. Also it's better if disable_nonboot_cpus() returns an
error instead of panicking if something goes wrong, and
enable_nonboot_cpus() has no reason to panic(), because the CPUs may have
been enabled by the userland before it tries to take them online.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/power/smp.c')
-rw-r--r-- | kernel/power/smp.c | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/kernel/power/smp.c b/kernel/power/smp.c deleted file mode 100644 index 5957312b2d68..000000000000 --- a/kernel/power/smp.c +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | /* | ||
2 | * drivers/power/smp.c - Functions for stopping other CPUs. | ||
3 | * | ||
4 | * Copyright 2004 Pavel Machek <pavel@suse.cz> | ||
5 | * Copyright (C) 2002-2003 Nigel Cunningham <ncunningham@clear.net.nz> | ||
6 | * | ||
7 | * This file is released under the GPLv2. | ||
8 | */ | ||
9 | |||
10 | #undef DEBUG | ||
11 | |||
12 | #include <linux/smp_lock.h> | ||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/suspend.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/cpu.h> | ||
17 | #include <asm/atomic.h> | ||
18 | #include <asm/tlbflush.h> | ||
19 | |||
20 | /* This is protected by pm_sem semaphore */ | ||
21 | static cpumask_t frozen_cpus; | ||
22 | |||
23 | void disable_nonboot_cpus(void) | ||
24 | { | ||
25 | int cpu, error; | ||
26 | |||
27 | error = 0; | ||
28 | cpus_clear(frozen_cpus); | ||
29 | printk("Freezing cpus ...\n"); | ||
30 | for_each_online_cpu(cpu) { | ||
31 | if (cpu == 0) | ||
32 | continue; | ||
33 | error = cpu_down(cpu); | ||
34 | if (!error) { | ||
35 | cpu_set(cpu, frozen_cpus); | ||
36 | printk("CPU%d is down\n", cpu); | ||
37 | continue; | ||
38 | } | ||
39 | printk("Error taking cpu %d down: %d\n", cpu, error); | ||
40 | } | ||
41 | BUG_ON(raw_smp_processor_id() != 0); | ||
42 | if (error) | ||
43 | panic("cpus not sleeping"); | ||
44 | } | ||
45 | |||
46 | void enable_nonboot_cpus(void) | ||
47 | { | ||
48 | int cpu, error; | ||
49 | |||
50 | printk("Thawing cpus ...\n"); | ||
51 | for_each_cpu_mask(cpu, frozen_cpus) { | ||
52 | error = cpu_up(cpu); | ||
53 | if (!error) { | ||
54 | printk("CPU%d is up\n", cpu); | ||
55 | continue; | ||
56 | } | ||
57 | printk("Error taking cpu %d up: %d\n", cpu, error); | ||
58 | panic("Not enough cpus"); | ||
59 | } | ||
60 | cpus_clear(frozen_cpus); | ||
61 | } | ||
62 | |||