Commit | Line | Data |
---|---|---|
1da177e4 LT |
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> | |
5a72e04d | 16 | #include <linux/cpu.h> |
1da177e4 LT |
17 | #include <asm/atomic.h> |
18 | #include <asm/tlbflush.h> | |
19 | ||
5a72e04d LS |
20 | /* This is protected by pm_sem semaphore */ |
21 | static cpumask_t frozen_cpus; | |
1da177e4 LT |
22 | |
23 | void disable_nonboot_cpus(void) | |
24 | { | |
5a72e04d | 25 | int cpu, error; |
1da177e4 | 26 | |
5a72e04d LS |
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); | |
1da177e4 | 40 | } |
bba0e467 | 41 | BUG_ON(raw_smp_processor_id() != 0); |
5a72e04d LS |
42 | if (error) |
43 | panic("cpus not sleeping"); | |
1da177e4 LT |
44 | } |
45 | ||
46 | void enable_nonboot_cpus(void) | |
47 | { | |
5a72e04d | 48 | int cpu, error; |
1da177e4 | 49 | |
5a72e04d LS |
50 | printk("Thawing cpus ...\n"); |
51 | for_each_cpu_mask(cpu, frozen_cpus) { | |
34f361ad | 52 | error = cpu_up(cpu); |
5a72e04d LS |
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); | |
1da177e4 LT |
61 | } |
62 |