diff options
author | Glauber Costa <gcosta@redhat.com> | 2008-03-03 12:13:07 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-17 11:40:56 -0400 |
commit | 69c18c15d39c4622c6e2f97e5db4d8c9c43adaaa (patch) | |
tree | cf04add1e7b3544056eecb3b511bf4d6177120bc /arch/x86/kernel/smpboot.c | |
parent | e9a6cb96fafa4d4df2033ab6cf9c817f6f47e052 (diff) |
x86: merge __cpu_disable and cpu_die
They are now equal, and are moved to a common file
Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/smpboot.c')
-rw-r--r-- | arch/x86/kernel/smpboot.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 644e60969f90..c35cd319d1ed 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -2,6 +2,13 @@ | |||
2 | #include <linux/smp.h> | 2 | #include <linux/smp.h> |
3 | #include <linux/module.h> | 3 | #include <linux/module.h> |
4 | #include <linux/sched.h> | 4 | #include <linux/sched.h> |
5 | #include <linux/percpu.h> | ||
6 | |||
7 | #include <asm/nmi.h> | ||
8 | #include <asm/irq.h> | ||
9 | #include <asm/smp.h> | ||
10 | #include <asm/cpu.h> | ||
11 | #include <asm/numa.h> | ||
5 | 12 | ||
6 | /* Number of siblings per CPU package */ | 13 | /* Number of siblings per CPU package */ |
7 | int smp_num_siblings = 1; | 14 | int smp_num_siblings = 1; |
@@ -181,5 +188,83 @@ __init void prefill_possible_map(void) | |||
181 | for (i = 0; i < possible; i++) | 188 | for (i = 0; i < possible; i++) |
182 | cpu_set(i, cpu_possible_map); | 189 | cpu_set(i, cpu_possible_map); |
183 | } | 190 | } |
191 | |||
192 | static void __ref remove_cpu_from_maps(int cpu) | ||
193 | { | ||
194 | cpu_clear(cpu, cpu_online_map); | ||
195 | #ifdef CONFIG_X86_64 | ||
196 | cpu_clear(cpu, cpu_callout_map); | ||
197 | cpu_clear(cpu, cpu_callin_map); | ||
198 | /* was set by cpu_init() */ | ||
199 | clear_bit(cpu, (unsigned long *)&cpu_initialized); | ||
200 | clear_node_cpumask(cpu); | ||
201 | #endif | ||
202 | } | ||
203 | |||
204 | int __cpu_disable(void) | ||
205 | { | ||
206 | int cpu = smp_processor_id(); | ||
207 | |||
208 | /* | ||
209 | * Perhaps use cpufreq to drop frequency, but that could go | ||
210 | * into generic code. | ||
211 | * | ||
212 | * We won't take down the boot processor on i386 due to some | ||
213 | * interrupts only being able to be serviced by the BSP. | ||
214 | * Especially so if we're not using an IOAPIC -zwane | ||
215 | */ | ||
216 | if (cpu == 0) | ||
217 | return -EBUSY; | ||
218 | |||
219 | if (nmi_watchdog == NMI_LOCAL_APIC) | ||
220 | stop_apic_nmi_watchdog(NULL); | ||
221 | clear_local_APIC(); | ||
222 | |||
223 | /* | ||
224 | * HACK: | ||
225 | * Allow any queued timer interrupts to get serviced | ||
226 | * This is only a temporary solution until we cleanup | ||
227 | * fixup_irqs as we do for IA64. | ||
228 | */ | ||
229 | local_irq_enable(); | ||
230 | mdelay(1); | ||
231 | |||
232 | local_irq_disable(); | ||
233 | remove_siblinginfo(cpu); | ||
234 | |||
235 | /* It's now safe to remove this processor from the online map */ | ||
236 | remove_cpu_from_maps(cpu); | ||
237 | fixup_irqs(cpu_online_map); | ||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | void __cpu_die(unsigned int cpu) | ||
242 | { | ||
243 | /* We don't do anything here: idle task is faking death itself. */ | ||
244 | unsigned int i; | ||
245 | |||
246 | for (i = 0; i < 10; i++) { | ||
247 | /* They ack this in play_dead by setting CPU_DEAD */ | ||
248 | if (per_cpu(cpu_state, cpu) == CPU_DEAD) { | ||
249 | printk(KERN_INFO "CPU %d is now offline\n", cpu); | ||
250 | if (1 == num_online_cpus()) | ||
251 | alternatives_smp_switch(0); | ||
252 | return; | ||
253 | } | ||
254 | msleep(100); | ||
255 | } | ||
256 | printk(KERN_ERR "CPU %u didn't die...\n", cpu); | ||
257 | } | ||
258 | #else /* ... !CONFIG_HOTPLUG_CPU */ | ||
259 | int __cpu_disable(void) | ||
260 | { | ||
261 | return -ENOSYS; | ||
262 | } | ||
263 | |||
264 | void __cpu_die(unsigned int cpu) | ||
265 | { | ||
266 | /* We said "no" in __cpu_disable */ | ||
267 | BUG(); | ||
268 | } | ||
184 | #endif | 269 | #endif |
185 | 270 | ||