blob: 8bce5ed031e448ed0a51d9e77c947864eed2e2bf [file] [log] [blame]
Graf Yang6b3087c2009-01-07 23:14:39 +08001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * IPI management based on arch/arm/kernel/smp.c (Copyright 2002 ARM Limited)
Graf Yang6b3087c2009-01-07 23:14:39 +08003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Copyright 2007-2009 Analog Devices Inc.
5 * Philippe Gerum <rpm@xenomai.org>
Graf Yang6b3087c2009-01-07 23:14:39 +08006 *
Robin Getz96f10502009-09-24 14:11:24 +00007 * Licensed under the GPL-2.
Graf Yang6b3087c2009-01-07 23:14:39 +08008 */
9
10#include <linux/module.h>
11#include <linux/delay.h>
12#include <linux/init.h>
13#include <linux/spinlock.h>
14#include <linux/sched.h>
15#include <linux/interrupt.h>
16#include <linux/cache.h>
17#include <linux/profile.h>
18#include <linux/errno.h>
19#include <linux/mm.h>
20#include <linux/cpu.h>
21#include <linux/smp.h>
Graf Yang9c199b52009-09-21 11:51:31 +000022#include <linux/cpumask.h>
Graf Yang6b3087c2009-01-07 23:14:39 +080023#include <linux/seq_file.h>
24#include <linux/irq.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090025#include <linux/slab.h>
Graf Yang6b3087c2009-01-07 23:14:39 +080026#include <asm/atomic.h>
27#include <asm/cacheflush.h>
28#include <asm/mmu_context.h>
29#include <asm/pgtable.h>
30#include <asm/pgalloc.h>
31#include <asm/processor.h>
32#include <asm/ptrace.h>
33#include <asm/cpu.h>
Graf Yang1fa9be72009-05-15 11:01:59 +000034#include <asm/time.h>
Graf Yang6b3087c2009-01-07 23:14:39 +080035#include <linux/err.h>
36
Graf Yang555487b2009-05-06 10:38:07 +000037/*
38 * Anomaly notes:
39 * 05000120 - we always define corelock as 32-bit integer in L2
40 */
Graf Yang6b3087c2009-01-07 23:14:39 +080041struct corelock_slot corelock __attribute__ ((__section__(".l2.bss")));
42
Sonic Zhangc6345ab2010-08-05 07:49:26 +000043#ifdef CONFIG_ICACHE_FLUSH_L1
44unsigned long blackfin_iflush_l1_entry[NR_CPUS];
45#endif
46
Graf Yang6b3087c2009-01-07 23:14:39 +080047void __cpuinitdata *init_retx_coreb, *init_saved_retx_coreb,
48 *init_saved_seqstat_coreb, *init_saved_icplb_fault_addr_coreb,
49 *init_saved_dcplb_fault_addr_coreb;
50
Graf Yang6b3087c2009-01-07 23:14:39 +080051#define BFIN_IPI_RESCHEDULE 0
52#define BFIN_IPI_CALL_FUNC 1
53#define BFIN_IPI_CPU_STOP 2
54
55struct blackfin_flush_data {
56 unsigned long start;
57 unsigned long end;
58};
59
60void *secondary_stack;
61
62
63struct smp_call_struct {
64 void (*func)(void *info);
65 void *info;
66 int wait;
Yi Li73a40062009-12-17 08:20:32 +000067 cpumask_t *waitmask;
Graf Yang6b3087c2009-01-07 23:14:39 +080068};
69
70static struct blackfin_flush_data smp_flush_data;
71
72static DEFINE_SPINLOCK(stop_lock);
73
74struct ipi_message {
Graf Yang6b3087c2009-01-07 23:14:39 +080075 unsigned long type;
76 struct smp_call_struct call_struct;
77};
78
Yi Li73a40062009-12-17 08:20:32 +000079/* A magic number - stress test shows this is safe for common cases */
80#define BFIN_IPI_MSGQ_LEN 5
81
82/* Simple FIFO buffer, overflow leads to panic */
Graf Yang6b3087c2009-01-07 23:14:39 +080083struct ipi_message_queue {
Graf Yang6b3087c2009-01-07 23:14:39 +080084 spinlock_t lock;
85 unsigned long count;
Yi Li73a40062009-12-17 08:20:32 +000086 unsigned long head; /* head of the queue */
87 struct ipi_message ipi_message[BFIN_IPI_MSGQ_LEN];
Graf Yang6b3087c2009-01-07 23:14:39 +080088};
89
90static DEFINE_PER_CPU(struct ipi_message_queue, ipi_msg_queue);
91
92static void ipi_cpu_stop(unsigned int cpu)
93{
94 spin_lock(&stop_lock);
95 printk(KERN_CRIT "CPU%u: stopping\n", cpu);
96 dump_stack();
97 spin_unlock(&stop_lock);
98
99 cpu_clear(cpu, cpu_online_map);
100
101 local_irq_disable();
102
103 while (1)
104 SSYNC();
105}
106
107static void ipi_flush_icache(void *info)
108{
109 struct blackfin_flush_data *fdata = info;
110
111 /* Invalidate the memory holding the bounds of the flushed region. */
Sonic Zhang8d50de92011-04-12 08:16:04 +0000112 blackfin_dcache_invalidate_range((unsigned long)fdata,
113 (unsigned long)fdata + sizeof(*fdata));
Graf Yang6b3087c2009-01-07 23:14:39 +0800114
Sonic Zhang8d50de92011-04-12 08:16:04 +0000115 /* Make sure all write buffers in the data side of the core
116 * are flushed before trying to invalidate the icache. This
117 * needs to be after the data flush and before the icache
118 * flush so that the SSYNC does the right thing in preventing
119 * the instruction prefetcher from hitting things in cached
120 * memory at the wrong time -- it runs much further ahead than
121 * the pipeline.
122 */
123 SSYNC();
124
125 /* ipi_flaush_icache is invoked by generic flush_icache_range,
126 * so call blackfin arch icache flush directly here.
127 */
128 blackfin_icache_flush_range(fdata->start, fdata->end);
Graf Yang6b3087c2009-01-07 23:14:39 +0800129}
130
131static void ipi_call_function(unsigned int cpu, struct ipi_message *msg)
132{
133 int wait;
134 void (*func)(void *info);
135 void *info;
136 func = msg->call_struct.func;
137 info = msg->call_struct.info;
138 wait = msg->call_struct.wait;
Graf Yang6b3087c2009-01-07 23:14:39 +0800139 func(info);
Yi Lic9784eb2009-12-04 06:56:21 +0000140 if (wait) {
141#ifdef __ARCH_SYNC_CORE_DCACHE
142 /*
143 * 'wait' usually means synchronization between CPUs.
144 * Invalidate D cache in case shared data was changed
145 * by func() to ensure cache coherence.
146 */
147 resync_core_dcache();
148#endif
Yi Li73a40062009-12-17 08:20:32 +0000149 cpu_clear(cpu, *msg->call_struct.waitmask);
150 }
Graf Yang6b3087c2009-01-07 23:14:39 +0800151}
152
Yi Li73a40062009-12-17 08:20:32 +0000153/* Use IRQ_SUPPLE_0 to request reschedule.
154 * When returning from interrupt to user space,
155 * there is chance to reschedule */
156static irqreturn_t ipi_handler_int0(int irq, void *dev_instance)
157{
158 unsigned int cpu = smp_processor_id();
159
160 platform_clear_ipi(cpu, IRQ_SUPPLE_0);
161 return IRQ_HANDLED;
162}
163
164static irqreturn_t ipi_handler_int1(int irq, void *dev_instance)
Graf Yang6b3087c2009-01-07 23:14:39 +0800165{
Sonic Zhang86f20082009-06-10 08:42:41 +0000166 struct ipi_message *msg;
Graf Yang6b3087c2009-01-07 23:14:39 +0800167 struct ipi_message_queue *msg_queue;
168 unsigned int cpu = smp_processor_id();
Yi Li73a40062009-12-17 08:20:32 +0000169 unsigned long flags;
Graf Yang6b3087c2009-01-07 23:14:39 +0800170
Yi Li73a40062009-12-17 08:20:32 +0000171 platform_clear_ipi(cpu, IRQ_SUPPLE_1);
Graf Yang6b3087c2009-01-07 23:14:39 +0800172
173 msg_queue = &__get_cpu_var(ipi_msg_queue);
Graf Yang6b3087c2009-01-07 23:14:39 +0800174
Yi Li73a40062009-12-17 08:20:32 +0000175 spin_lock_irqsave(&msg_queue->lock, flags);
176
177 while (msg_queue->count) {
178 msg = &msg_queue->ipi_message[msg_queue->head];
Graf Yang6b3087c2009-01-07 23:14:39 +0800179 switch (msg->type) {
Graf Yang6b3087c2009-01-07 23:14:39 +0800180 case BFIN_IPI_CALL_FUNC:
Yi Li73a40062009-12-17 08:20:32 +0000181 spin_unlock_irqrestore(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800182 ipi_call_function(cpu, msg);
Yi Li73a40062009-12-17 08:20:32 +0000183 spin_lock_irqsave(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800184 break;
185 case BFIN_IPI_CPU_STOP:
Yi Li73a40062009-12-17 08:20:32 +0000186 spin_unlock_irqrestore(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800187 ipi_cpu_stop(cpu);
Yi Li73a40062009-12-17 08:20:32 +0000188 spin_lock_irqsave(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800189 break;
190 default:
Joe Perchesdb52ecc2010-03-26 19:27:51 -0700191 printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%lx\n",
192 cpu, msg->type);
Graf Yang6b3087c2009-01-07 23:14:39 +0800193 break;
194 }
Yi Li73a40062009-12-17 08:20:32 +0000195 msg_queue->head++;
196 msg_queue->head %= BFIN_IPI_MSGQ_LEN;
197 msg_queue->count--;
Graf Yang6b3087c2009-01-07 23:14:39 +0800198 }
Yi Li73a40062009-12-17 08:20:32 +0000199 spin_unlock_irqrestore(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800200 return IRQ_HANDLED;
201}
202
203static void ipi_queue_init(void)
204{
205 unsigned int cpu;
206 struct ipi_message_queue *msg_queue;
207 for_each_possible_cpu(cpu) {
208 msg_queue = &per_cpu(ipi_msg_queue, cpu);
Graf Yang6b3087c2009-01-07 23:14:39 +0800209 spin_lock_init(&msg_queue->lock);
210 msg_queue->count = 0;
Yi Li73a40062009-12-17 08:20:32 +0000211 msg_queue->head = 0;
Graf Yang6b3087c2009-01-07 23:14:39 +0800212 }
213}
214
Yi Li73a40062009-12-17 08:20:32 +0000215static inline void smp_send_message(cpumask_t callmap, unsigned long type,
216 void (*func) (void *info), void *info, int wait)
Graf Yang6b3087c2009-01-07 23:14:39 +0800217{
218 unsigned int cpu;
Graf Yang6b3087c2009-01-07 23:14:39 +0800219 struct ipi_message_queue *msg_queue;
220 struct ipi_message *msg;
Yi Li73a40062009-12-17 08:20:32 +0000221 unsigned long flags, next_msg;
222 cpumask_t waitmask = callmap; /* waitmask is shared by all cpus */
Graf Yang6b3087c2009-01-07 23:14:39 +0800223
224 for_each_cpu_mask(cpu, callmap) {
225 msg_queue = &per_cpu(ipi_msg_queue, cpu);
226 spin_lock_irqsave(&msg_queue->lock, flags);
Yi Li73a40062009-12-17 08:20:32 +0000227 if (msg_queue->count < BFIN_IPI_MSGQ_LEN) {
228 next_msg = (msg_queue->head + msg_queue->count)
229 % BFIN_IPI_MSGQ_LEN;
230 msg = &msg_queue->ipi_message[next_msg];
231 msg->type = type;
232 if (type == BFIN_IPI_CALL_FUNC) {
233 msg->call_struct.func = func;
234 msg->call_struct.info = info;
235 msg->call_struct.wait = wait;
236 msg->call_struct.waitmask = &waitmask;
237 }
238 msg_queue->count++;
239 } else
240 panic("IPI message queue overflow\n");
Graf Yang6b3087c2009-01-07 23:14:39 +0800241 spin_unlock_irqrestore(&msg_queue->lock, flags);
Yi Li73a40062009-12-17 08:20:32 +0000242 platform_send_ipi_cpu(cpu, IRQ_SUPPLE_1);
Graf Yang6b3087c2009-01-07 23:14:39 +0800243 }
Yi Li73a40062009-12-17 08:20:32 +0000244
Graf Yang6b3087c2009-01-07 23:14:39 +0800245 if (wait) {
Yi Li73a40062009-12-17 08:20:32 +0000246 while (!cpus_empty(waitmask))
Graf Yang6b3087c2009-01-07 23:14:39 +0800247 blackfin_dcache_invalidate_range(
Yi Li73a40062009-12-17 08:20:32 +0000248 (unsigned long)(&waitmask),
249 (unsigned long)(&waitmask));
Yi Lic9784eb2009-12-04 06:56:21 +0000250#ifdef __ARCH_SYNC_CORE_DCACHE
251 /*
252 * Invalidate D cache in case shared data was changed by
253 * other processors to ensure cache coherence.
254 */
255 resync_core_dcache();
256#endif
Graf Yang6b3087c2009-01-07 23:14:39 +0800257 }
Yi Li73a40062009-12-17 08:20:32 +0000258}
259
260int smp_call_function(void (*func)(void *info), void *info, int wait)
261{
262 cpumask_t callmap;
263
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000264 preempt_disable();
Yi Li73a40062009-12-17 08:20:32 +0000265 callmap = cpu_online_map;
266 cpu_clear(smp_processor_id(), callmap);
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000267 if (!cpus_empty(callmap))
268 smp_send_message(callmap, BFIN_IPI_CALL_FUNC, func, info, wait);
Yi Li73a40062009-12-17 08:20:32 +0000269
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000270 preempt_enable();
Yi Li73a40062009-12-17 08:20:32 +0000271
Graf Yang6b3087c2009-01-07 23:14:39 +0800272 return 0;
273}
274EXPORT_SYMBOL_GPL(smp_call_function);
275
276int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
277 int wait)
278{
279 unsigned int cpu = cpuid;
280 cpumask_t callmap;
Graf Yang6b3087c2009-01-07 23:14:39 +0800281
282 if (cpu_is_offline(cpu))
283 return 0;
284 cpus_clear(callmap);
285 cpu_set(cpu, callmap);
286
Yi Li73a40062009-12-17 08:20:32 +0000287 smp_send_message(callmap, BFIN_IPI_CALL_FUNC, func, info, wait);
Graf Yang6b3087c2009-01-07 23:14:39 +0800288
Graf Yang6b3087c2009-01-07 23:14:39 +0800289 return 0;
290}
291EXPORT_SYMBOL_GPL(smp_call_function_single);
292
293void smp_send_reschedule(int cpu)
294{
Yi Li73a40062009-12-17 08:20:32 +0000295 /* simply trigger an ipi */
Graf Yang6b3087c2009-01-07 23:14:39 +0800296 if (cpu_is_offline(cpu))
297 return;
Yi Li73a40062009-12-17 08:20:32 +0000298 platform_send_ipi_cpu(cpu, IRQ_SUPPLE_0);
Graf Yang6b3087c2009-01-07 23:14:39 +0800299
300 return;
301}
302
303void smp_send_stop(void)
304{
Graf Yang6b3087c2009-01-07 23:14:39 +0800305 cpumask_t callmap;
Graf Yang6b3087c2009-01-07 23:14:39 +0800306
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000307 preempt_disable();
Graf Yang6b3087c2009-01-07 23:14:39 +0800308 callmap = cpu_online_map;
309 cpu_clear(smp_processor_id(), callmap);
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000310 if (!cpus_empty(callmap))
311 smp_send_message(callmap, BFIN_IPI_CPU_STOP, NULL, NULL, 0);
Graf Yang6b3087c2009-01-07 23:14:39 +0800312
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000313 preempt_enable();
Graf Yang6b3087c2009-01-07 23:14:39 +0800314
Graf Yang6b3087c2009-01-07 23:14:39 +0800315 return;
316}
317
318int __cpuinit __cpu_up(unsigned int cpu)
319{
Graf Yang6b3087c2009-01-07 23:14:39 +0800320 int ret;
Graf Yang0b39db22009-12-28 11:13:51 +0000321 static struct task_struct *idle;
322
323 if (idle)
324 free_task(idle);
Graf Yang6b3087c2009-01-07 23:14:39 +0800325
326 idle = fork_idle(cpu);
327 if (IS_ERR(idle)) {
328 printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
329 return PTR_ERR(idle);
330 }
331
332 secondary_stack = task_stack_page(idle) + THREAD_SIZE;
Graf Yang6b3087c2009-01-07 23:14:39 +0800333
334 ret = platform_boot_secondary(cpu, idle);
335
Graf Yang6b3087c2009-01-07 23:14:39 +0800336 secondary_stack = NULL;
337
338 return ret;
339}
340
341static void __cpuinit setup_secondary(unsigned int cpu)
342{
Graf Yang6b3087c2009-01-07 23:14:39 +0800343 unsigned long ilat;
344
345 bfin_write_IMASK(0);
346 CSYNC();
347 ilat = bfin_read_ILAT();
348 CSYNC();
349 bfin_write_ILAT(ilat);
350 CSYNC();
351
Graf Yang6b3087c2009-01-07 23:14:39 +0800352 /* Enable interrupt levels IVG7-15. IARs have been already
353 * programmed by the boot CPU. */
Mike Frysinger40059782008-11-18 17:48:22 +0800354 bfin_irq_flags |= IMASK_IVG15 |
Graf Yang6b3087c2009-01-07 23:14:39 +0800355 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
356 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
Graf Yang6b3087c2009-01-07 23:14:39 +0800357}
358
359void __cpuinit secondary_start_kernel(void)
360{
361 unsigned int cpu = smp_processor_id();
362 struct mm_struct *mm = &init_mm;
363
364 if (_bfin_swrst & SWRST_DBL_FAULT_B) {
365 printk(KERN_EMERG "CoreB Recovering from DOUBLE FAULT event\n");
366#ifdef CONFIG_DEBUG_DOUBLEFAULT
367 printk(KERN_EMERG " While handling exception (EXCAUSE = 0x%x) at %pF\n",
368 (int)init_saved_seqstat_coreb & SEQSTAT_EXCAUSE, init_saved_retx_coreb);
369 printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %pF\n", init_saved_dcplb_fault_addr_coreb);
370 printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %pF\n", init_saved_icplb_fault_addr_coreb);
371#endif
372 printk(KERN_NOTICE " The instruction at %pF caused a double exception\n",
373 init_retx_coreb);
374 }
375
376 /*
377 * We want the D-cache to be enabled early, in case the atomic
378 * support code emulates cache coherence (see
379 * __ARCH_SYNC_CORE_DCACHE).
380 */
381 init_exception_vectors();
382
Graf Yang6b3087c2009-01-07 23:14:39 +0800383 local_irq_disable();
384
385 /* Attach the new idle task to the global mm. */
386 atomic_inc(&mm->mm_users);
387 atomic_inc(&mm->mm_count);
388 current->active_mm = mm;
Graf Yang6b3087c2009-01-07 23:14:39 +0800389
390 preempt_disable();
391
392 setup_secondary(cpu);
393
Yi Li578d36f2009-12-02 07:58:12 +0000394 platform_secondary_init(cpu);
395
Yi Li0d152c22009-12-28 10:21:49 +0000396 /* setup local core timer */
397 bfin_local_timer_setup();
398
Graf Yang6b3087c2009-01-07 23:14:39 +0800399 local_irq_enable();
400
steven miaoab61d2a2010-09-07 10:08:36 +0000401 bfin_setup_caches(cpu);
402
Yi Li578d36f2009-12-02 07:58:12 +0000403 /*
404 * Calibrate loops per jiffy value.
405 * IRQs need to be enabled here - D-cache can be invalidated
406 * in timer irq handler, so core B can read correct jiffies.
407 */
408 calibrate_delay();
Graf Yang6b3087c2009-01-07 23:14:39 +0800409
410 cpu_idle();
411}
412
413void __init smp_prepare_boot_cpu(void)
414{
415}
416
417void __init smp_prepare_cpus(unsigned int max_cpus)
418{
419 platform_prepare_cpus(max_cpus);
420 ipi_queue_init();
Yi Li73a40062009-12-17 08:20:32 +0000421 platform_request_ipi(IRQ_SUPPLE_0, ipi_handler_int0);
422 platform_request_ipi(IRQ_SUPPLE_1, ipi_handler_int1);
Graf Yang6b3087c2009-01-07 23:14:39 +0800423}
424
425void __init smp_cpus_done(unsigned int max_cpus)
426{
427 unsigned long bogosum = 0;
428 unsigned int cpu;
429
430 for_each_online_cpu(cpu)
Michael Hennerichc70c7542009-07-09 09:58:52 +0000431 bogosum += loops_per_jiffy;
Graf Yang6b3087c2009-01-07 23:14:39 +0800432
433 printk(KERN_INFO "SMP: Total of %d processors activated "
434 "(%lu.%02lu BogoMIPS).\n",
435 num_online_cpus(),
436 bogosum / (500000/HZ),
437 (bogosum / (5000/HZ)) % 100);
438}
439
440void smp_icache_flush_range_others(unsigned long start, unsigned long end)
441{
442 smp_flush_data.start = start;
443 smp_flush_data.end = end;
444
Sonic Zhang0bf3d932009-03-05 16:44:53 +0800445 if (smp_call_function(&ipi_flush_icache, &smp_flush_data, 0))
Graf Yang6b3087c2009-01-07 23:14:39 +0800446 printk(KERN_WARNING "SMP: failed to run I-cache flush request on other CPUs\n");
447}
448EXPORT_SYMBOL_GPL(smp_icache_flush_range_others);
449
Sonic Zhang47e9ded2009-06-10 08:57:08 +0000450#ifdef __ARCH_SYNC_CORE_ICACHE
Graf Yang718340f2010-02-01 06:07:50 +0000451unsigned long icache_invld_count[NR_CPUS];
Sonic Zhang47e9ded2009-06-10 08:57:08 +0000452void resync_core_icache(void)
453{
454 unsigned int cpu = get_cpu();
455 blackfin_invalidate_entire_icache();
Graf Yang718340f2010-02-01 06:07:50 +0000456 icache_invld_count[cpu]++;
Sonic Zhang47e9ded2009-06-10 08:57:08 +0000457 put_cpu();
458}
459EXPORT_SYMBOL(resync_core_icache);
460#endif
461
Graf Yang6b3087c2009-01-07 23:14:39 +0800462#ifdef __ARCH_SYNC_CORE_DCACHE
Graf Yang718340f2010-02-01 06:07:50 +0000463unsigned long dcache_invld_count[NR_CPUS];
Graf Yang6b3087c2009-01-07 23:14:39 +0800464unsigned long barrier_mask __attribute__ ((__section__(".l2.bss")));
465
466void resync_core_dcache(void)
467{
468 unsigned int cpu = get_cpu();
469 blackfin_invalidate_entire_dcache();
Graf Yang718340f2010-02-01 06:07:50 +0000470 dcache_invld_count[cpu]++;
Graf Yang6b3087c2009-01-07 23:14:39 +0800471 put_cpu();
472}
473EXPORT_SYMBOL(resync_core_dcache);
474#endif
Graf Yang0b39db22009-12-28 11:13:51 +0000475
476#ifdef CONFIG_HOTPLUG_CPU
477int __cpuexit __cpu_disable(void)
478{
479 unsigned int cpu = smp_processor_id();
480
481 if (cpu == 0)
482 return -EPERM;
483
484 set_cpu_online(cpu, false);
485 return 0;
486}
487
488static DECLARE_COMPLETION(cpu_killed);
489
490int __cpuexit __cpu_die(unsigned int cpu)
491{
492 return wait_for_completion_timeout(&cpu_killed, 5000);
493}
494
495void cpu_die(void)
496{
497 complete(&cpu_killed);
498
499 atomic_dec(&init_mm.mm_users);
500 atomic_dec(&init_mm.mm_count);
501
502 local_irq_disable();
503 platform_cpu_die();
504}
505#endif