blob: 35e7e1eb0188f58de9fe39ed50af1538b5802e69 [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>
Mike Frysinger6327a572011-04-15 03:06:59 -040028#include <asm/irq_handler.h>
Graf Yang6b3087c2009-01-07 23:14:39 +080029#include <asm/mmu_context.h>
30#include <asm/pgtable.h>
31#include <asm/pgalloc.h>
32#include <asm/processor.h>
33#include <asm/ptrace.h>
34#include <asm/cpu.h>
Graf Yang1fa9be72009-05-15 11:01:59 +000035#include <asm/time.h>
Graf Yang6b3087c2009-01-07 23:14:39 +080036#include <linux/err.h>
37
Graf Yang555487b2009-05-06 10:38:07 +000038/*
39 * Anomaly notes:
40 * 05000120 - we always define corelock as 32-bit integer in L2
41 */
Graf Yang6b3087c2009-01-07 23:14:39 +080042struct corelock_slot corelock __attribute__ ((__section__(".l2.bss")));
43
Sonic Zhangc6345ab2010-08-05 07:49:26 +000044#ifdef CONFIG_ICACHE_FLUSH_L1
45unsigned long blackfin_iflush_l1_entry[NR_CPUS];
46#endif
47
Graf Yang6b3087c2009-01-07 23:14:39 +080048void __cpuinitdata *init_retx_coreb, *init_saved_retx_coreb,
49 *init_saved_seqstat_coreb, *init_saved_icplb_fault_addr_coreb,
50 *init_saved_dcplb_fault_addr_coreb;
51
Graf Yang6b3087c2009-01-07 23:14:39 +080052#define BFIN_IPI_RESCHEDULE 0
53#define BFIN_IPI_CALL_FUNC 1
54#define BFIN_IPI_CPU_STOP 2
55
56struct blackfin_flush_data {
57 unsigned long start;
58 unsigned long end;
59};
60
61void *secondary_stack;
62
63
64struct smp_call_struct {
65 void (*func)(void *info);
66 void *info;
67 int wait;
Yi Li73a40062009-12-17 08:20:32 +000068 cpumask_t *waitmask;
Graf Yang6b3087c2009-01-07 23:14:39 +080069};
70
71static struct blackfin_flush_data smp_flush_data;
72
73static DEFINE_SPINLOCK(stop_lock);
74
75struct ipi_message {
Graf Yang6b3087c2009-01-07 23:14:39 +080076 unsigned long type;
77 struct smp_call_struct call_struct;
78};
79
Yi Li73a40062009-12-17 08:20:32 +000080/* A magic number - stress test shows this is safe for common cases */
81#define BFIN_IPI_MSGQ_LEN 5
82
83/* Simple FIFO buffer, overflow leads to panic */
Graf Yang6b3087c2009-01-07 23:14:39 +080084struct ipi_message_queue {
Graf Yang6b3087c2009-01-07 23:14:39 +080085 spinlock_t lock;
86 unsigned long count;
Yi Li73a40062009-12-17 08:20:32 +000087 unsigned long head; /* head of the queue */
88 struct ipi_message ipi_message[BFIN_IPI_MSGQ_LEN];
Graf Yang6b3087c2009-01-07 23:14:39 +080089};
90
91static DEFINE_PER_CPU(struct ipi_message_queue, ipi_msg_queue);
92
93static void ipi_cpu_stop(unsigned int cpu)
94{
95 spin_lock(&stop_lock);
96 printk(KERN_CRIT "CPU%u: stopping\n", cpu);
97 dump_stack();
98 spin_unlock(&stop_lock);
99
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900100 set_cpu_online(cpu, false);
Graf Yang6b3087c2009-01-07 23:14:39 +0800101
102 local_irq_disable();
103
104 while (1)
105 SSYNC();
106}
107
108static void ipi_flush_icache(void *info)
109{
110 struct blackfin_flush_data *fdata = info;
111
112 /* Invalidate the memory holding the bounds of the flushed region. */
Sonic Zhang8d50de92011-04-12 08:16:04 +0000113 blackfin_dcache_invalidate_range((unsigned long)fdata,
114 (unsigned long)fdata + sizeof(*fdata));
Graf Yang6b3087c2009-01-07 23:14:39 +0800115
Sonic Zhang8d50de92011-04-12 08:16:04 +0000116 /* Make sure all write buffers in the data side of the core
117 * are flushed before trying to invalidate the icache. This
118 * needs to be after the data flush and before the icache
119 * flush so that the SSYNC does the right thing in preventing
120 * the instruction prefetcher from hitting things in cached
121 * memory at the wrong time -- it runs much further ahead than
122 * the pipeline.
123 */
124 SSYNC();
125
126 /* ipi_flaush_icache is invoked by generic flush_icache_range,
127 * so call blackfin arch icache flush directly here.
128 */
129 blackfin_icache_flush_range(fdata->start, fdata->end);
Graf Yang6b3087c2009-01-07 23:14:39 +0800130}
131
132static void ipi_call_function(unsigned int cpu, struct ipi_message *msg)
133{
134 int wait;
135 void (*func)(void *info);
136 void *info;
137 func = msg->call_struct.func;
138 info = msg->call_struct.info;
139 wait = msg->call_struct.wait;
Graf Yang6b3087c2009-01-07 23:14:39 +0800140 func(info);
Yi Lic9784eb2009-12-04 06:56:21 +0000141 if (wait) {
142#ifdef __ARCH_SYNC_CORE_DCACHE
143 /*
144 * 'wait' usually means synchronization between CPUs.
145 * Invalidate D cache in case shared data was changed
146 * by func() to ensure cache coherence.
147 */
148 resync_core_dcache();
149#endif
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900150 cpumask_clear_cpu(cpu, msg->call_struct.waitmask);
Yi Li73a40062009-12-17 08:20:32 +0000151 }
Graf Yang6b3087c2009-01-07 23:14:39 +0800152}
153
Yi Li73a40062009-12-17 08:20:32 +0000154/* Use IRQ_SUPPLE_0 to request reschedule.
155 * When returning from interrupt to user space,
156 * there is chance to reschedule */
157static irqreturn_t ipi_handler_int0(int irq, void *dev_instance)
158{
159 unsigned int cpu = smp_processor_id();
160
161 platform_clear_ipi(cpu, IRQ_SUPPLE_0);
162 return IRQ_HANDLED;
163}
164
165static irqreturn_t ipi_handler_int1(int irq, void *dev_instance)
Graf Yang6b3087c2009-01-07 23:14:39 +0800166{
Sonic Zhang86f20082009-06-10 08:42:41 +0000167 struct ipi_message *msg;
Graf Yang6b3087c2009-01-07 23:14:39 +0800168 struct ipi_message_queue *msg_queue;
169 unsigned int cpu = smp_processor_id();
Yi Li73a40062009-12-17 08:20:32 +0000170 unsigned long flags;
Graf Yang6b3087c2009-01-07 23:14:39 +0800171
Yi Li73a40062009-12-17 08:20:32 +0000172 platform_clear_ipi(cpu, IRQ_SUPPLE_1);
Graf Yang6b3087c2009-01-07 23:14:39 +0800173
174 msg_queue = &__get_cpu_var(ipi_msg_queue);
Graf Yang6b3087c2009-01-07 23:14:39 +0800175
Yi Li73a40062009-12-17 08:20:32 +0000176 spin_lock_irqsave(&msg_queue->lock, flags);
177
178 while (msg_queue->count) {
179 msg = &msg_queue->ipi_message[msg_queue->head];
Graf Yang6b3087c2009-01-07 23:14:39 +0800180 switch (msg->type) {
Peter Zijlstra184748c2011-04-05 17:23:39 +0200181 case BFIN_IPI_RESCHEDULE:
182 scheduler_ipi();
183 break;
Graf Yang6b3087c2009-01-07 23:14:39 +0800184 case BFIN_IPI_CALL_FUNC:
Yi Li73a40062009-12-17 08:20:32 +0000185 spin_unlock_irqrestore(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800186 ipi_call_function(cpu, msg);
Yi Li73a40062009-12-17 08:20:32 +0000187 spin_lock_irqsave(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800188 break;
189 case BFIN_IPI_CPU_STOP:
Yi Li73a40062009-12-17 08:20:32 +0000190 spin_unlock_irqrestore(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800191 ipi_cpu_stop(cpu);
Yi Li73a40062009-12-17 08:20:32 +0000192 spin_lock_irqsave(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800193 break;
194 default:
Joe Perchesdb52ecc2010-03-26 19:27:51 -0700195 printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%lx\n",
196 cpu, msg->type);
Graf Yang6b3087c2009-01-07 23:14:39 +0800197 break;
198 }
Yi Li73a40062009-12-17 08:20:32 +0000199 msg_queue->head++;
200 msg_queue->head %= BFIN_IPI_MSGQ_LEN;
201 msg_queue->count--;
Graf Yang6b3087c2009-01-07 23:14:39 +0800202 }
Yi Li73a40062009-12-17 08:20:32 +0000203 spin_unlock_irqrestore(&msg_queue->lock, flags);
Graf Yang6b3087c2009-01-07 23:14:39 +0800204 return IRQ_HANDLED;
205}
206
207static void ipi_queue_init(void)
208{
209 unsigned int cpu;
210 struct ipi_message_queue *msg_queue;
211 for_each_possible_cpu(cpu) {
212 msg_queue = &per_cpu(ipi_msg_queue, cpu);
Graf Yang6b3087c2009-01-07 23:14:39 +0800213 spin_lock_init(&msg_queue->lock);
214 msg_queue->count = 0;
Yi Li73a40062009-12-17 08:20:32 +0000215 msg_queue->head = 0;
Graf Yang6b3087c2009-01-07 23:14:39 +0800216 }
217}
218
Yi Li73a40062009-12-17 08:20:32 +0000219static inline void smp_send_message(cpumask_t callmap, unsigned long type,
220 void (*func) (void *info), void *info, int wait)
Graf Yang6b3087c2009-01-07 23:14:39 +0800221{
222 unsigned int cpu;
Graf Yang6b3087c2009-01-07 23:14:39 +0800223 struct ipi_message_queue *msg_queue;
224 struct ipi_message *msg;
Yi Li73a40062009-12-17 08:20:32 +0000225 unsigned long flags, next_msg;
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900226 cpumask_t waitmask; /* waitmask is shared by all cpus */
Graf Yang6b3087c2009-01-07 23:14:39 +0800227
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900228 cpumask_copy(&waitmask, &callmap);
229 for_each_cpu(cpu, &callmap) {
Graf Yang6b3087c2009-01-07 23:14:39 +0800230 msg_queue = &per_cpu(ipi_msg_queue, cpu);
231 spin_lock_irqsave(&msg_queue->lock, flags);
Yi Li73a40062009-12-17 08:20:32 +0000232 if (msg_queue->count < BFIN_IPI_MSGQ_LEN) {
233 next_msg = (msg_queue->head + msg_queue->count)
234 % BFIN_IPI_MSGQ_LEN;
235 msg = &msg_queue->ipi_message[next_msg];
236 msg->type = type;
237 if (type == BFIN_IPI_CALL_FUNC) {
238 msg->call_struct.func = func;
239 msg->call_struct.info = info;
240 msg->call_struct.wait = wait;
241 msg->call_struct.waitmask = &waitmask;
242 }
243 msg_queue->count++;
244 } else
245 panic("IPI message queue overflow\n");
Graf Yang6b3087c2009-01-07 23:14:39 +0800246 spin_unlock_irqrestore(&msg_queue->lock, flags);
Yi Li73a40062009-12-17 08:20:32 +0000247 platform_send_ipi_cpu(cpu, IRQ_SUPPLE_1);
Graf Yang6b3087c2009-01-07 23:14:39 +0800248 }
Yi Li73a40062009-12-17 08:20:32 +0000249
Graf Yang6b3087c2009-01-07 23:14:39 +0800250 if (wait) {
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900251 while (!cpumask_empty(&waitmask))
Graf Yang6b3087c2009-01-07 23:14:39 +0800252 blackfin_dcache_invalidate_range(
Yi Li73a40062009-12-17 08:20:32 +0000253 (unsigned long)(&waitmask),
254 (unsigned long)(&waitmask));
Yi Lic9784eb2009-12-04 06:56:21 +0000255#ifdef __ARCH_SYNC_CORE_DCACHE
256 /*
257 * Invalidate D cache in case shared data was changed by
258 * other processors to ensure cache coherence.
259 */
260 resync_core_dcache();
261#endif
Graf Yang6b3087c2009-01-07 23:14:39 +0800262 }
Yi Li73a40062009-12-17 08:20:32 +0000263}
264
265int smp_call_function(void (*func)(void *info), void *info, int wait)
266{
267 cpumask_t callmap;
268
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000269 preempt_disable();
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900270 cpumask_copy(&callmap, cpu_online_mask);
271 cpumask_clear_cpu(smp_processor_id(), &callmap);
272 if (!cpumask_empty(&callmap))
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000273 smp_send_message(callmap, BFIN_IPI_CALL_FUNC, func, info, wait);
Yi Li73a40062009-12-17 08:20:32 +0000274
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000275 preempt_enable();
Yi Li73a40062009-12-17 08:20:32 +0000276
Graf Yang6b3087c2009-01-07 23:14:39 +0800277 return 0;
278}
279EXPORT_SYMBOL_GPL(smp_call_function);
280
281int smp_call_function_single(int cpuid, void (*func) (void *info), void *info,
282 int wait)
283{
284 unsigned int cpu = cpuid;
285 cpumask_t callmap;
Graf Yang6b3087c2009-01-07 23:14:39 +0800286
287 if (cpu_is_offline(cpu))
288 return 0;
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900289 cpumask_clear(&callmap);
290 cpumask_set_cpu(cpu, &callmap);
Graf Yang6b3087c2009-01-07 23:14:39 +0800291
Yi Li73a40062009-12-17 08:20:32 +0000292 smp_send_message(callmap, BFIN_IPI_CALL_FUNC, func, info, wait);
Graf Yang6b3087c2009-01-07 23:14:39 +0800293
Graf Yang6b3087c2009-01-07 23:14:39 +0800294 return 0;
295}
296EXPORT_SYMBOL_GPL(smp_call_function_single);
297
298void smp_send_reschedule(int cpu)
299{
Yi Li73a40062009-12-17 08:20:32 +0000300 /* simply trigger an ipi */
Graf Yang6b3087c2009-01-07 23:14:39 +0800301 if (cpu_is_offline(cpu))
302 return;
Yi Li73a40062009-12-17 08:20:32 +0000303 platform_send_ipi_cpu(cpu, IRQ_SUPPLE_0);
Graf Yang6b3087c2009-01-07 23:14:39 +0800304
305 return;
306}
307
308void smp_send_stop(void)
309{
Graf Yang6b3087c2009-01-07 23:14:39 +0800310 cpumask_t callmap;
Graf Yang6b3087c2009-01-07 23:14:39 +0800311
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000312 preempt_disable();
KOSAKI Motohirofecedc82011-04-26 10:57:27 +0900313 cpumask_copy(&callmap, cpu_online_mask);
314 cpumask_clear_cpu(smp_processor_id(), &callmap);
315 if (!cpumask_empty(&callmap))
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000316 smp_send_message(callmap, BFIN_IPI_CPU_STOP, NULL, NULL, 0);
Graf Yang6b3087c2009-01-07 23:14:39 +0800317
Sonic Zhang567ebfc2010-06-25 05:55:16 +0000318 preempt_enable();
Graf Yang6b3087c2009-01-07 23:14:39 +0800319
Graf Yang6b3087c2009-01-07 23:14:39 +0800320 return;
321}
322
323int __cpuinit __cpu_up(unsigned int cpu)
324{
Graf Yang6b3087c2009-01-07 23:14:39 +0800325 int ret;
Graf Yang0b39db22009-12-28 11:13:51 +0000326 static struct task_struct *idle;
327
328 if (idle)
329 free_task(idle);
Graf Yang6b3087c2009-01-07 23:14:39 +0800330
331 idle = fork_idle(cpu);
332 if (IS_ERR(idle)) {
333 printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
334 return PTR_ERR(idle);
335 }
336
337 secondary_stack = task_stack_page(idle) + THREAD_SIZE;
Graf Yang6b3087c2009-01-07 23:14:39 +0800338
339 ret = platform_boot_secondary(cpu, idle);
340
Graf Yang6b3087c2009-01-07 23:14:39 +0800341 secondary_stack = NULL;
342
343 return ret;
344}
345
346static void __cpuinit setup_secondary(unsigned int cpu)
347{
Graf Yang6b3087c2009-01-07 23:14:39 +0800348 unsigned long ilat;
349
350 bfin_write_IMASK(0);
351 CSYNC();
352 ilat = bfin_read_ILAT();
353 CSYNC();
354 bfin_write_ILAT(ilat);
355 CSYNC();
356
Graf Yang6b3087c2009-01-07 23:14:39 +0800357 /* Enable interrupt levels IVG7-15. IARs have been already
358 * programmed by the boot CPU. */
Mike Frysinger40059782008-11-18 17:48:22 +0800359 bfin_irq_flags |= IMASK_IVG15 |
Graf Yang6b3087c2009-01-07 23:14:39 +0800360 IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 |
361 IMASK_IVG10 | IMASK_IVG9 | IMASK_IVG8 | IMASK_IVG7 | IMASK_IVGHW;
Graf Yang6b3087c2009-01-07 23:14:39 +0800362}
363
364void __cpuinit secondary_start_kernel(void)
365{
366 unsigned int cpu = smp_processor_id();
367 struct mm_struct *mm = &init_mm;
368
369 if (_bfin_swrst & SWRST_DBL_FAULT_B) {
370 printk(KERN_EMERG "CoreB Recovering from DOUBLE FAULT event\n");
371#ifdef CONFIG_DEBUG_DOUBLEFAULT
372 printk(KERN_EMERG " While handling exception (EXCAUSE = 0x%x) at %pF\n",
373 (int)init_saved_seqstat_coreb & SEQSTAT_EXCAUSE, init_saved_retx_coreb);
374 printk(KERN_NOTICE " DCPLB_FAULT_ADDR: %pF\n", init_saved_dcplb_fault_addr_coreb);
375 printk(KERN_NOTICE " ICPLB_FAULT_ADDR: %pF\n", init_saved_icplb_fault_addr_coreb);
376#endif
377 printk(KERN_NOTICE " The instruction at %pF caused a double exception\n",
378 init_retx_coreb);
379 }
380
381 /*
382 * We want the D-cache to be enabled early, in case the atomic
383 * support code emulates cache coherence (see
384 * __ARCH_SYNC_CORE_DCACHE).
385 */
386 init_exception_vectors();
387
Graf Yang6b3087c2009-01-07 23:14:39 +0800388 local_irq_disable();
389
390 /* Attach the new idle task to the global mm. */
391 atomic_inc(&mm->mm_users);
392 atomic_inc(&mm->mm_count);
393 current->active_mm = mm;
Graf Yang6b3087c2009-01-07 23:14:39 +0800394
395 preempt_disable();
396
397 setup_secondary(cpu);
398
Yi Li578d36f2009-12-02 07:58:12 +0000399 platform_secondary_init(cpu);
400
Yi Li0d152c22009-12-28 10:21:49 +0000401 /* setup local core timer */
402 bfin_local_timer_setup();
403
Graf Yang6b3087c2009-01-07 23:14:39 +0800404 local_irq_enable();
405
steven miaoab61d2a2010-09-07 10:08:36 +0000406 bfin_setup_caches(cpu);
407
Yi Li578d36f2009-12-02 07:58:12 +0000408 /*
409 * Calibrate loops per jiffy value.
410 * IRQs need to be enabled here - D-cache can be invalidated
411 * in timer irq handler, so core B can read correct jiffies.
412 */
413 calibrate_delay();
Graf Yang6b3087c2009-01-07 23:14:39 +0800414
415 cpu_idle();
416}
417
418void __init smp_prepare_boot_cpu(void)
419{
420}
421
422void __init smp_prepare_cpus(unsigned int max_cpus)
423{
424 platform_prepare_cpus(max_cpus);
425 ipi_queue_init();
Yi Li73a40062009-12-17 08:20:32 +0000426 platform_request_ipi(IRQ_SUPPLE_0, ipi_handler_int0);
427 platform_request_ipi(IRQ_SUPPLE_1, ipi_handler_int1);
Graf Yang6b3087c2009-01-07 23:14:39 +0800428}
429
430void __init smp_cpus_done(unsigned int max_cpus)
431{
432 unsigned long bogosum = 0;
433 unsigned int cpu;
434
435 for_each_online_cpu(cpu)
Michael Hennerichc70c7542009-07-09 09:58:52 +0000436 bogosum += loops_per_jiffy;
Graf Yang6b3087c2009-01-07 23:14:39 +0800437
438 printk(KERN_INFO "SMP: Total of %d processors activated "
439 "(%lu.%02lu BogoMIPS).\n",
440 num_online_cpus(),
441 bogosum / (500000/HZ),
442 (bogosum / (5000/HZ)) % 100);
443}
444
445void smp_icache_flush_range_others(unsigned long start, unsigned long end)
446{
447 smp_flush_data.start = start;
448 smp_flush_data.end = end;
449
Sonic Zhang0bf3d932009-03-05 16:44:53 +0800450 if (smp_call_function(&ipi_flush_icache, &smp_flush_data, 0))
Graf Yang6b3087c2009-01-07 23:14:39 +0800451 printk(KERN_WARNING "SMP: failed to run I-cache flush request on other CPUs\n");
452}
453EXPORT_SYMBOL_GPL(smp_icache_flush_range_others);
454
Sonic Zhang47e9ded2009-06-10 08:57:08 +0000455#ifdef __ARCH_SYNC_CORE_ICACHE
Graf Yang718340f2010-02-01 06:07:50 +0000456unsigned long icache_invld_count[NR_CPUS];
Sonic Zhang47e9ded2009-06-10 08:57:08 +0000457void resync_core_icache(void)
458{
459 unsigned int cpu = get_cpu();
460 blackfin_invalidate_entire_icache();
Graf Yang718340f2010-02-01 06:07:50 +0000461 icache_invld_count[cpu]++;
Sonic Zhang47e9ded2009-06-10 08:57:08 +0000462 put_cpu();
463}
464EXPORT_SYMBOL(resync_core_icache);
465#endif
466
Graf Yang6b3087c2009-01-07 23:14:39 +0800467#ifdef __ARCH_SYNC_CORE_DCACHE
Graf Yang718340f2010-02-01 06:07:50 +0000468unsigned long dcache_invld_count[NR_CPUS];
Graf Yang6b3087c2009-01-07 23:14:39 +0800469unsigned long barrier_mask __attribute__ ((__section__(".l2.bss")));
470
471void resync_core_dcache(void)
472{
473 unsigned int cpu = get_cpu();
474 blackfin_invalidate_entire_dcache();
Graf Yang718340f2010-02-01 06:07:50 +0000475 dcache_invld_count[cpu]++;
Graf Yang6b3087c2009-01-07 23:14:39 +0800476 put_cpu();
477}
478EXPORT_SYMBOL(resync_core_dcache);
479#endif
Graf Yang0b39db22009-12-28 11:13:51 +0000480
481#ifdef CONFIG_HOTPLUG_CPU
482int __cpuexit __cpu_disable(void)
483{
484 unsigned int cpu = smp_processor_id();
485
486 if (cpu == 0)
487 return -EPERM;
488
489 set_cpu_online(cpu, false);
490 return 0;
491}
492
493static DECLARE_COMPLETION(cpu_killed);
494
495int __cpuexit __cpu_die(unsigned int cpu)
496{
497 return wait_for_completion_timeout(&cpu_killed, 5000);
498}
499
500void cpu_die(void)
501{
502 complete(&cpu_killed);
503
504 atomic_dec(&init_mm.mm_users);
505 atomic_dec(&init_mm.mm_count);
506
507 local_irq_disable();
508 platform_cpu_die();
509}
510#endif