blob: ece658e773a6ff71075c63f40ec082439c0b4bf4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/kernel/smp.c
3 *
4 * Copyright (C) 2002 ARM Limited, All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
Russell Kingc97d4862006-10-25 13:59:16 +010010#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#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>
Alexey Dobriyan4e950f62007-07-30 02:36:13 +040020#include <linux/err.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/cpu.h>
22#include <linux/smp.h>
23#include <linux/seq_file.h>
Russell Kingc97d4862006-10-25 13:59:16 +010024#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include <asm/atomic.h>
27#include <asm/cacheflush.h>
28#include <asm/cpu.h>
Russell Kinge65f38e2005-06-18 09:33:31 +010029#include <asm/mmu_context.h>
30#include <asm/pgtable.h>
31#include <asm/pgalloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <asm/processor.h>
33#include <asm/tlbflush.h>
34#include <asm/ptrace.h>
Catalin Marinasfaa7bc52009-05-30 14:00:14 +010035#include <asm/cputype.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37/*
Russell Kinge65f38e2005-06-18 09:33:31 +010038 * as from 2.5, kernels no longer have an init_tasks structure
39 * so we need some other way of telling a new secondary core
40 * where to place its SVC stack
41 */
42struct secondary_data secondary_data;
43
44/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 * structures for inter-processor calls
46 * - A collection of single bit ipi messages.
47 */
48struct ipi_data {
49 spinlock_t lock;
50 unsigned long ipi_count;
51 unsigned long bits;
52};
53
54static DEFINE_PER_CPU(struct ipi_data, ipi_data) = {
55 .lock = SPIN_LOCK_UNLOCKED,
56};
57
58enum ipi_msg_type {
59 IPI_TIMER,
60 IPI_RESCHEDULE,
61 IPI_CALL_FUNC,
Jens Axboef6dd9fa52008-06-10 20:48:30 +020062 IPI_CALL_FUNC_SINGLE,
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 IPI_CPU_STOP,
64};
65
Russell Kingbd6f68a2005-07-17 21:35:41 +010066int __cpuinit __cpu_up(unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070067{
Russell King71f512e2005-11-02 21:51:40 +000068 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
69 struct task_struct *idle = ci->idle;
Russell Kinge65f38e2005-06-18 09:33:31 +010070 pgd_t *pgd;
71 pmd_t *pmd;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 int ret;
73
74 /*
Russell King71f512e2005-11-02 21:51:40 +000075 * Spawn a new process manually, if not already done.
76 * Grab a pointer to its task struct so we can mess with it
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 */
Russell King71f512e2005-11-02 21:51:40 +000078 if (!idle) {
79 idle = fork_idle(cpu);
80 if (IS_ERR(idle)) {
81 printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
82 return PTR_ERR(idle);
83 }
84 ci->idle = idle;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 }
86
87 /*
Russell Kinge65f38e2005-06-18 09:33:31 +010088 * Allocate initial page tables to allow the new CPU to
89 * enable the MMU safely. This essentially means a set
90 * of our "standard" page tables, with the addition of
91 * a 1:1 mapping for the physical address of the kernel.
92 */
93 pgd = pgd_alloc(&init_mm);
Russell King058ddee2008-08-07 22:36:59 +010094 pmd = pmd_offset(pgd + pgd_index(PHYS_OFFSET), PHYS_OFFSET);
Russell Kinge65f38e2005-06-18 09:33:31 +010095 *pmd = __pmd((PHYS_OFFSET & PGDIR_MASK) |
96 PMD_TYPE_SECT | PMD_SECT_AP_WRITE);
Catalin Marinase9fc7822009-02-11 13:14:57 +010097 flush_pmd_entry(pmd);
Russell Kinge65f38e2005-06-18 09:33:31 +010098
99 /*
100 * We need to tell the secondary core where to find
101 * its stack and the page tables.
102 */
Al Viro32d39a92006-01-12 01:05:58 -0800103 secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
Russell Kinge65f38e2005-06-18 09:33:31 +0100104 secondary_data.pgdir = virt_to_phys(pgd);
105 wmb();
106
107 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 * Now bring the CPU into our world.
109 */
110 ret = boot_secondary(cpu, idle);
Russell Kinge65f38e2005-06-18 09:33:31 +0100111 if (ret == 0) {
112 unsigned long timeout;
113
114 /*
115 * CPU was successfully started, wait for it
116 * to come online or time out.
117 */
118 timeout = jiffies + HZ;
119 while (time_before(jiffies, timeout)) {
120 if (cpu_online(cpu))
121 break;
122
123 udelay(10);
124 barrier();
125 }
126
127 if (!cpu_online(cpu))
128 ret = -EIO;
129 }
130
Russell King5d430452005-11-08 10:44:46 +0000131 secondary_data.stack = NULL;
Russell Kinge65f38e2005-06-18 09:33:31 +0100132 secondary_data.pgdir = 0;
133
Russell King058ddee2008-08-07 22:36:59 +0100134 *pmd = __pmd(0);
Catalin Marinase9fc7822009-02-11 13:14:57 +0100135 clean_pmd_entry(pmd);
Benjamin Herrenschmidt5e541972008-02-04 22:29:14 -0800136 pgd_free(&init_mm, pgd);
Russell Kinge65f38e2005-06-18 09:33:31 +0100137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 if (ret) {
Russell King0908db22005-06-19 19:48:16 +0100139 printk(KERN_CRIT "CPU%u: processor failed to boot\n", cpu);
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 /*
142 * FIXME: We need to clean up the new idle thread. --rmk
143 */
144 }
145
146 return ret;
147}
148
Russell Kinga054a812005-11-02 22:24:33 +0000149#ifdef CONFIG_HOTPLUG_CPU
150/*
151 * __cpu_disable runs on the processor to be shutdown.
152 */
153int __cpuexit __cpu_disable(void)
154{
155 unsigned int cpu = smp_processor_id();
156 struct task_struct *p;
157 int ret;
158
159 ret = mach_cpu_disable(cpu);
160 if (ret)
161 return ret;
162
163 /*
164 * Take this CPU offline. Once we clear this, we can't return,
165 * and we must not schedule until we're ready to give up the cpu.
166 */
167 cpu_clear(cpu, cpu_online_map);
168
169 /*
170 * OK - migrate IRQs away from this CPU
171 */
172 migrate_irqs();
173
174 /*
Russell King37ee16a2005-11-08 19:08:05 +0000175 * Stop the local timer for this CPU.
176 */
Catalin Marinasebac6542008-12-01 14:54:57 +0000177 local_timer_stop();
Russell King37ee16a2005-11-08 19:08:05 +0000178
179 /*
Russell Kinga054a812005-11-02 22:24:33 +0000180 * Flush user cache and TLB mappings, and then remove this CPU
181 * from the vm mask set of all processes.
182 */
183 flush_cache_all();
184 local_flush_tlb_all();
185
186 read_lock(&tasklist_lock);
187 for_each_process(p) {
188 if (p->mm)
189 cpu_clear(cpu, p->mm->cpu_vm_mask);
190 }
191 read_unlock(&tasklist_lock);
192
193 return 0;
194}
195
196/*
197 * called on the thread which is asking for a CPU to be shutdown -
198 * waits until shutdown has completed, or it is timed out.
199 */
200void __cpuexit __cpu_die(unsigned int cpu)
201{
202 if (!platform_cpu_kill(cpu))
203 printk("CPU%u: unable to kill\n", cpu);
204}
205
206/*
207 * Called from the idle thread for the CPU which has been shutdown.
208 *
209 * Note that we disable IRQs here, but do not re-enable them
210 * before returning to the caller. This is also the behaviour
211 * of the other hotplug-cpu capable cores, so presumably coming
212 * out of idle fixes this.
213 */
214void __cpuexit cpu_die(void)
215{
216 unsigned int cpu = smp_processor_id();
217
218 local_irq_disable();
219 idle_task_exit();
220
221 /*
222 * actual CPU shutdown procedure is at least platform (if not
223 * CPU) specific
224 */
225 platform_cpu_die(cpu);
226
227 /*
228 * Do not return to the idle loop - jump back to the secondary
229 * cpu initialisation. There's some initialisation which needs
230 * to be repeated to undo the effects of taking the CPU offline.
231 */
232 __asm__("mov sp, %0\n"
233 " b secondary_start_kernel"
234 :
Al Viro32d39a92006-01-12 01:05:58 -0800235 : "r" (task_stack_page(current) + THREAD_SIZE - 8));
Russell Kinga054a812005-11-02 22:24:33 +0000236}
237#endif /* CONFIG_HOTPLUG_CPU */
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239/*
Russell Kinge65f38e2005-06-18 09:33:31 +0100240 * This is the secondary CPU boot entry. We're using this CPUs
241 * idle thread stack, but a set of temporary page tables.
242 */
Russell Kingbd6f68a2005-07-17 21:35:41 +0100243asmlinkage void __cpuinit secondary_start_kernel(void)
Russell Kinge65f38e2005-06-18 09:33:31 +0100244{
245 struct mm_struct *mm = &init_mm;
Russell Kingda2660d2005-11-12 17:21:47 +0000246 unsigned int cpu = smp_processor_id();
Russell Kinge65f38e2005-06-18 09:33:31 +0100247
248 printk("CPU%u: Booted secondary processor\n", cpu);
249
250 /*
251 * All kernel threads share the same mm context; grab a
252 * reference and switch to it.
253 */
254 atomic_inc(&mm->mm_users);
255 atomic_inc(&mm->mm_count);
256 current->active_mm = mm;
257 cpu_set(cpu, mm->cpu_vm_mask);
258 cpu_switch_mm(mm->pgd, mm);
259 enter_lazy_tlb(mm, current);
Russell King505d7b12005-07-28 20:32:47 +0100260 local_flush_tlb_all();
Russell Kinge65f38e2005-06-18 09:33:31 +0100261
262 cpu_init();
Nick Piggin5bfb5d62005-11-08 21:39:01 -0800263 preempt_disable();
Russell Kinge65f38e2005-06-18 09:33:31 +0100264
265 /*
266 * Give the platform a chance to do its own initialisation.
267 */
268 platform_secondary_init(cpu);
269
270 /*
271 * Enable local interrupts.
272 */
Manfred Spraule545a612008-09-07 16:57:22 +0200273 notify_cpu_starting(cpu);
Russell Kinge65f38e2005-06-18 09:33:31 +0100274 local_irq_enable();
275 local_fiq_enable();
276
Catalin Marinasa8655e82008-02-04 17:30:57 +0100277 /*
278 * Setup local timer for this CPU.
279 */
Catalin Marinasebac6542008-12-01 14:54:57 +0000280 local_timer_setup();
Catalin Marinasa8655e82008-02-04 17:30:57 +0100281
Russell Kinge65f38e2005-06-18 09:33:31 +0100282 calibrate_delay();
283
284 smp_store_cpu_info(cpu);
285
286 /*
287 * OK, now it's safe to let the boot CPU continue
288 */
289 cpu_set(cpu, cpu_online_map);
290
291 /*
292 * OK, it's off to the idle thread for us
293 */
294 cpu_idle();
295}
296
297/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 * Called by both boot and secondaries to move global data into
299 * per-processor storage.
300 */
Russell Kingbd6f68a2005-07-17 21:35:41 +0100301void __cpuinit smp_store_cpu_info(unsigned int cpuid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302{
303 struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
304
305 cpu_info->loops_per_jiffy = loops_per_jiffy;
306}
307
308void __init smp_cpus_done(unsigned int max_cpus)
309{
310 int cpu;
311 unsigned long bogosum = 0;
312
313 for_each_online_cpu(cpu)
314 bogosum += per_cpu(cpu_data, cpu).loops_per_jiffy;
315
316 printk(KERN_INFO "SMP: Total of %d processors activated "
317 "(%lu.%02lu BogoMIPS).\n",
318 num_online_cpus(),
319 bogosum / (500000/HZ),
320 (bogosum / (5000/HZ)) % 100);
321}
322
323void __init smp_prepare_boot_cpu(void)
324{
325 unsigned int cpu = smp_processor_id();
326
Russell King71f512e2005-11-02 21:51:40 +0000327 per_cpu(cpu_data, cpu).idle = current;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328}
329
Russell King82668102009-05-17 16:20:18 +0100330static void send_ipi_message(const struct cpumask *mask, enum ipi_msg_type msg)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
332 unsigned long flags;
333 unsigned int cpu;
334
335 local_irq_save(flags);
336
Russell King82668102009-05-17 16:20:18 +0100337 for_each_cpu(cpu, mask) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
339
340 spin_lock(&ipi->lock);
341 ipi->bits |= 1 << msg;
342 spin_unlock(&ipi->lock);
343 }
344
345 /*
346 * Call the platform specific cross-CPU call function.
347 */
Russell King82668102009-05-17 16:20:18 +0100348 smp_cross_call(mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349
350 local_irq_restore(flags);
351}
352
Russell King82668102009-05-17 16:20:18 +0100353void arch_send_call_function_ipi_mask(const struct cpumask *mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354{
Jens Axboef6dd9fa52008-06-10 20:48:30 +0200355 send_ipi_message(mask, IPI_CALL_FUNC);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356}
357
Jens Axboef6dd9fa52008-06-10 20:48:30 +0200358void arch_send_call_function_single_ipi(int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359{
Russell King82668102009-05-17 16:20:18 +0100360 send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361}
Catalin Marinas3e459992008-02-04 17:28:56 +0100362
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363void show_ipi_list(struct seq_file *p)
364{
365 unsigned int cpu;
366
367 seq_puts(p, "IPI:");
368
Russell Kinge11b2232005-07-11 19:26:31 +0100369 for_each_present_cpu(cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 seq_printf(p, " %10lu", per_cpu(ipi_data, cpu).ipi_count);
371
372 seq_putc(p, '\n');
373}
374
Russell King37ee16a2005-11-08 19:08:05 +0000375void show_local_irqs(struct seq_file *p)
376{
377 unsigned int cpu;
378
379 seq_printf(p, "LOC: ");
380
381 for_each_present_cpu(cpu)
382 seq_printf(p, "%10u ", irq_stat[cpu].local_timer_irqs);
383
384 seq_putc(p, '\n');
385}
386
Russell Kingc97d4862006-10-25 13:59:16 +0100387static void ipi_timer(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 irq_enter();
Catalin Marinas3e459992008-02-04 17:28:56 +0100390 local_timer_interrupt();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 irq_exit();
392}
393
Russell King37ee16a2005-11-08 19:08:05 +0000394#ifdef CONFIG_LOCAL_TIMERS
Russell Kingb9811d72007-05-08 11:31:07 +0100395asmlinkage void __exception do_local_timer(struct pt_regs *regs)
Russell King37ee16a2005-11-08 19:08:05 +0000396{
Russell Kingc97d4862006-10-25 13:59:16 +0100397 struct pt_regs *old_regs = set_irq_regs(regs);
Russell King37ee16a2005-11-08 19:08:05 +0000398 int cpu = smp_processor_id();
399
400 if (local_timer_ack()) {
401 irq_stat[cpu].local_timer_irqs++;
Russell Kingc97d4862006-10-25 13:59:16 +0100402 ipi_timer();
Russell King37ee16a2005-11-08 19:08:05 +0000403 }
Russell Kingc97d4862006-10-25 13:59:16 +0100404
405 set_irq_regs(old_regs);
Russell King37ee16a2005-11-08 19:08:05 +0000406}
407#endif
408
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409static DEFINE_SPINLOCK(stop_lock);
410
411/*
412 * ipi_cpu_stop - handle IPI from smp_send_stop()
413 */
414static void ipi_cpu_stop(unsigned int cpu)
415{
416 spin_lock(&stop_lock);
417 printk(KERN_CRIT "CPU%u: stopping\n", cpu);
418 dump_stack();
419 spin_unlock(&stop_lock);
420
421 cpu_clear(cpu, cpu_online_map);
422
423 local_fiq_disable();
424 local_irq_disable();
425
426 while (1)
427 cpu_relax();
428}
429
430/*
431 * Main handler for inter-processor interrupts
432 *
433 * For ARM, the ipimask now only identifies a single
434 * category of IPI (Bit 1 IPIs have been replaced by a
435 * different mechanism):
436 *
437 * Bit 0 - Inter-processor function call
438 */
Russell Kingb9811d72007-05-08 11:31:07 +0100439asmlinkage void __exception do_IPI(struct pt_regs *regs)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440{
441 unsigned int cpu = smp_processor_id();
442 struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
Russell Kingc97d4862006-10-25 13:59:16 +0100443 struct pt_regs *old_regs = set_irq_regs(regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444
445 ipi->ipi_count++;
446
447 for (;;) {
448 unsigned long msgs;
449
450 spin_lock(&ipi->lock);
451 msgs = ipi->bits;
452 ipi->bits = 0;
453 spin_unlock(&ipi->lock);
454
455 if (!msgs)
456 break;
457
458 do {
459 unsigned nextmsg;
460
461 nextmsg = msgs & -msgs;
462 msgs &= ~nextmsg;
463 nextmsg = ffz(~nextmsg);
464
465 switch (nextmsg) {
466 case IPI_TIMER:
Russell Kingc97d4862006-10-25 13:59:16 +0100467 ipi_timer();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 break;
469
470 case IPI_RESCHEDULE:
471 /*
472 * nothing more to do - eveything is
473 * done on the interrupt return path
474 */
475 break;
476
477 case IPI_CALL_FUNC:
Jens Axboef6dd9fa52008-06-10 20:48:30 +0200478 generic_smp_call_function_interrupt();
479 break;
480
481 case IPI_CALL_FUNC_SINGLE:
482 generic_smp_call_function_single_interrupt();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 break;
484
485 case IPI_CPU_STOP:
486 ipi_cpu_stop(cpu);
487 break;
488
489 default:
490 printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%x\n",
491 cpu, nextmsg);
492 break;
493 }
494 } while (msgs);
495 }
Russell Kingc97d4862006-10-25 13:59:16 +0100496
497 set_irq_regs(old_regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498}
499
500void smp_send_reschedule(int cpu)
501{
Russell King82668102009-05-17 16:20:18 +0100502 send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503}
504
Russell King82668102009-05-17 16:20:18 +0100505void smp_timer_broadcast(const struct cpumask *mask)
Catalin Marinas3e459992008-02-04 17:28:56 +0100506{
507 send_ipi_message(mask, IPI_TIMER);
508}
509
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510void smp_send_stop(void)
511{
512 cpumask_t mask = cpu_online_map;
513 cpu_clear(smp_processor_id(), mask);
Russell King82668102009-05-17 16:20:18 +0100514 send_ipi_message(&mask, IPI_CPU_STOP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515}
516
517/*
518 * not supported here
519 */
Russell King5048bcb2007-07-23 12:59:46 +0100520int setup_profiling_timer(unsigned int multiplier)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521{
522 return -EINVAL;
523}
Russell King4b0ef3b2005-06-28 13:49:16 +0100524
Russell King82668102009-05-17 16:20:18 +0100525static void
526on_each_cpu_mask(void (*func)(void *), void *info, int wait,
527 const struct cpumask *mask)
Russell King4b0ef3b2005-06-28 13:49:16 +0100528{
Russell King4b0ef3b2005-06-28 13:49:16 +0100529 preempt_disable();
530
Russell King82668102009-05-17 16:20:18 +0100531 smp_call_function_many(mask, func, info, wait);
532 if (cpumask_test_cpu(smp_processor_id(), mask))
Russell King4b0ef3b2005-06-28 13:49:16 +0100533 func(info);
534
535 preempt_enable();
Russell King4b0ef3b2005-06-28 13:49:16 +0100536}
537
538/**********************************************************************/
539
540/*
541 * TLB operations
542 */
543struct tlb_args {
544 struct vm_area_struct *ta_vma;
545 unsigned long ta_start;
546 unsigned long ta_end;
547};
548
Catalin Marinasfaa7bc52009-05-30 14:00:14 +0100549/* all SMP configurations have the extended CPUID registers */
550static inline int tlb_ops_need_broadcast(void)
551{
552 return ((read_cpuid_ext(CPUID_EXT_MMFR3) >> 12) & 0xf) < 2;
553}
554
Russell King4b0ef3b2005-06-28 13:49:16 +0100555static inline void ipi_flush_tlb_all(void *ignored)
556{
557 local_flush_tlb_all();
558}
559
560static inline void ipi_flush_tlb_mm(void *arg)
561{
562 struct mm_struct *mm = (struct mm_struct *)arg;
563
564 local_flush_tlb_mm(mm);
565}
566
567static inline void ipi_flush_tlb_page(void *arg)
568{
569 struct tlb_args *ta = (struct tlb_args *)arg;
570
571 local_flush_tlb_page(ta->ta_vma, ta->ta_start);
572}
573
574static inline void ipi_flush_tlb_kernel_page(void *arg)
575{
576 struct tlb_args *ta = (struct tlb_args *)arg;
577
578 local_flush_tlb_kernel_page(ta->ta_start);
579}
580
581static inline void ipi_flush_tlb_range(void *arg)
582{
583 struct tlb_args *ta = (struct tlb_args *)arg;
584
585 local_flush_tlb_range(ta->ta_vma, ta->ta_start, ta->ta_end);
586}
587
588static inline void ipi_flush_tlb_kernel_range(void *arg)
589{
590 struct tlb_args *ta = (struct tlb_args *)arg;
591
592 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
593}
594
595void flush_tlb_all(void)
596{
Catalin Marinasfaa7bc52009-05-30 14:00:14 +0100597 if (tlb_ops_need_broadcast())
598 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
599 else
600 local_flush_tlb_all();
Russell King4b0ef3b2005-06-28 13:49:16 +0100601}
602
603void flush_tlb_mm(struct mm_struct *mm)
604{
Catalin Marinasfaa7bc52009-05-30 14:00:14 +0100605 if (tlb_ops_need_broadcast())
606 on_each_cpu_mask(ipi_flush_tlb_mm, mm, 1, &mm->cpu_vm_mask);
607 else
608 local_flush_tlb_mm(mm);
Russell King4b0ef3b2005-06-28 13:49:16 +0100609}
610
611void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
612{
Catalin Marinasfaa7bc52009-05-30 14:00:14 +0100613 if (tlb_ops_need_broadcast()) {
614 struct tlb_args ta;
615 ta.ta_vma = vma;
616 ta.ta_start = uaddr;
617 on_each_cpu_mask(ipi_flush_tlb_page, &ta, 1, &vma->vm_mm->cpu_vm_mask);
618 } else
619 local_flush_tlb_page(vma, uaddr);
Russell King4b0ef3b2005-06-28 13:49:16 +0100620}
621
622void flush_tlb_kernel_page(unsigned long kaddr)
623{
Catalin Marinasfaa7bc52009-05-30 14:00:14 +0100624 if (tlb_ops_need_broadcast()) {
625 struct tlb_args ta;
626 ta.ta_start = kaddr;
627 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
628 } else
629 local_flush_tlb_kernel_page(kaddr);
Russell King4b0ef3b2005-06-28 13:49:16 +0100630}
631
632void flush_tlb_range(struct vm_area_struct *vma,
633 unsigned long start, unsigned long end)
634{
Catalin Marinasfaa7bc52009-05-30 14:00:14 +0100635 if (tlb_ops_need_broadcast()) {
636 struct tlb_args ta;
637 ta.ta_vma = vma;
638 ta.ta_start = start;
639 ta.ta_end = end;
640 on_each_cpu_mask(ipi_flush_tlb_range, &ta, 1, &vma->vm_mm->cpu_vm_mask);
641 } else
642 local_flush_tlb_range(vma, start, end);
Russell King4b0ef3b2005-06-28 13:49:16 +0100643}
644
645void flush_tlb_kernel_range(unsigned long start, unsigned long end)
646{
Catalin Marinasfaa7bc52009-05-30 14:00:14 +0100647 if (tlb_ops_need_broadcast()) {
648 struct tlb_args ta;
649 ta.ta_start = start;
650 ta.ta_end = end;
651 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
652 } else
653 local_flush_tlb_kernel_range(start, end);
Russell King4b0ef3b2005-06-28 13:49:16 +0100654}