smp.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. /*
  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. */
  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/err.h>
  21. #include <linux/cpu.h>
  22. #include <linux/seq_file.h>
  23. #include <linux/irq.h>
  24. #include <linux/percpu.h>
  25. #include <linux/clockchips.h>
  26. #include <linux/completion.h>
  27. #include <linux/atomic.h>
  28. #include <asm/smp.h>
  29. #include <asm/cacheflush.h>
  30. #include <asm/cpu.h>
  31. #include <asm/cputype.h>
  32. #include <asm/exception.h>
  33. #include <asm/idmap.h>
  34. #include <asm/topology.h>
  35. #include <asm/mmu_context.h>
  36. #include <asm/pgtable.h>
  37. #include <asm/pgalloc.h>
  38. #include <asm/processor.h>
  39. #include <asm/sections.h>
  40. #include <asm/tlbflush.h>
  41. #include <asm/ptrace.h>
  42. #include <asm/localtimer.h>
  43. #include <asm/smp_plat.h>
  44. #include <asm/mach/arch.h>
  45. #ifdef CONFIG_SEC_DEBUG
  46. #include <mach/sec_debug.h>
  47. #endif
  48. /*
  49. * as from 2.5, kernels no longer have an init_tasks structure
  50. * so we need some other way of telling a new secondary core
  51. * where to place its SVC stack
  52. */
  53. struct secondary_data secondary_data;
  54. enum ipi_msg_type {
  55. IPI_CPU_START = 1,
  56. IPI_TIMER = 2,
  57. IPI_RESCHEDULE,
  58. IPI_CALL_FUNC,
  59. IPI_CALL_FUNC_SINGLE,
  60. IPI_CPU_STOP,
  61. IPI_CPU_BACKTRACE,
  62. };
  63. static DECLARE_COMPLETION(cpu_running);
  64. static struct smp_operations smp_ops;
  65. void __init smp_set_ops(struct smp_operations *ops)
  66. {
  67. if (ops)
  68. smp_ops = *ops;
  69. };
  70. int __cpuinit __cpu_up(unsigned int cpu)
  71. {
  72. struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
  73. struct task_struct *idle = ci->idle;
  74. int ret;
  75. /*
  76. * Spawn a new process manually, if not already done.
  77. * Grab a pointer to its task struct so we can mess with it
  78. */
  79. if (!idle) {
  80. idle = fork_idle(cpu);
  81. if (IS_ERR(idle)) {
  82. printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
  83. return PTR_ERR(idle);
  84. }
  85. ci->idle = idle;
  86. } else {
  87. /*
  88. * Since this idle thread is being re-used, call
  89. * init_idle() to reinitialize the thread structure.
  90. */
  91. init_idle(idle, cpu);
  92. }
  93. /*
  94. * We need to tell the secondary core where to find
  95. * its stack and the page tables.
  96. */
  97. secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
  98. secondary_data.pgdir = virt_to_phys(idmap_pgd);
  99. secondary_data.swapper_pg_dir = virt_to_phys(swapper_pg_dir);
  100. __cpuc_flush_dcache_area(&secondary_data, sizeof(secondary_data));
  101. outer_clean_range(__pa(&secondary_data), __pa(&secondary_data + 1));
  102. /*
  103. * Now bring the CPU into our world.
  104. */
  105. ret = boot_secondary(cpu, idle);
  106. if (ret == 0) {
  107. /*
  108. * CPU was successfully started, wait for it
  109. * to come online or time out.
  110. */
  111. wait_for_completion_timeout(&cpu_running,
  112. msecs_to_jiffies(1000));
  113. if (!cpu_online(cpu)) {
  114. pr_crit("CPU%u: failed to come online\n", cpu);
  115. ret = -EIO;
  116. }
  117. } else {
  118. pr_err("CPU%u: failed to boot: %d\n", cpu, ret);
  119. }
  120. secondary_data.stack = NULL;
  121. secondary_data.pgdir = 0;
  122. return ret;
  123. }
  124. /* platform specific SMP operations */
  125. void __attribute__((weak)) __init smp_init_cpus(void)
  126. {
  127. if (smp_ops.smp_init_cpus)
  128. smp_ops.smp_init_cpus();
  129. }
  130. void __attribute__((weak)) __init platform_smp_prepare_cpus(unsigned int max_cpus)
  131. {
  132. if (smp_ops.smp_prepare_cpus)
  133. smp_ops.smp_prepare_cpus(max_cpus);
  134. }
  135. void __attribute__((weak)) __cpuinit platform_secondary_init(unsigned int cpu)
  136. {
  137. if (smp_ops.smp_secondary_init)
  138. smp_ops.smp_secondary_init(cpu);
  139. }
  140. int __attribute__((weak)) __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  141. {
  142. if (smp_ops.smp_boot_secondary)
  143. return smp_ops.smp_boot_secondary(cpu, idle);
  144. return -ENOSYS;
  145. }
  146. #ifdef CONFIG_HOTPLUG_CPU
  147. static void percpu_timer_stop(void);
  148. int __attribute__((weak)) platform_cpu_kill(unsigned int cpu)
  149. {
  150. if (smp_ops.cpu_kill)
  151. return smp_ops.cpu_kill(cpu);
  152. return 1;
  153. }
  154. void __attribute__((weak)) platform_cpu_die(unsigned int cpu)
  155. {
  156. if (smp_ops.cpu_die)
  157. smp_ops.cpu_die(cpu);
  158. }
  159. int __attribute__((weak)) platform_cpu_disable(unsigned int cpu)
  160. {
  161. if (smp_ops.cpu_disable)
  162. return smp_ops.cpu_disable(cpu);
  163. /*
  164. * By default, allow disabling all CPUs except the first one,
  165. * since this is special on a lot of platforms, e.g. because
  166. * of clock tick interrupts.
  167. */
  168. return cpu == 0 ? -EPERM : 0;
  169. }
  170. /*
  171. * __cpu_disable runs on the processor to be shutdown.
  172. */
  173. int __cpu_disable(void)
  174. {
  175. unsigned int cpu = smp_processor_id();
  176. struct task_struct *p;
  177. int ret;
  178. ret = platform_cpu_disable(cpu);
  179. if (ret)
  180. return ret;
  181. /*
  182. * Take this CPU offline. Once we clear this, we can't return,
  183. * and we must not schedule until we're ready to give up the cpu.
  184. */
  185. set_cpu_online(cpu, false);
  186. /*
  187. * OK - migrate IRQs away from this CPU
  188. */
  189. migrate_irqs();
  190. /*
  191. * Stop the local timer for this CPU.
  192. */
  193. percpu_timer_stop();
  194. /*
  195. * Flush user cache and TLB mappings, and then remove this CPU
  196. * from the vm mask set of all processes.
  197. */
  198. flush_cache_all();
  199. local_flush_tlb_all();
  200. read_lock(&tasklist_lock);
  201. for_each_process(p) {
  202. if (p->mm)
  203. cpumask_clear_cpu(cpu, mm_cpumask(p->mm));
  204. }
  205. read_unlock(&tasklist_lock);
  206. return 0;
  207. }
  208. static DECLARE_COMPLETION(cpu_died);
  209. /*
  210. * called on the thread which is asking for a CPU to be shutdown -
  211. * waits until shutdown has completed, or it is timed out.
  212. */
  213. void __cpu_die(unsigned int cpu)
  214. {
  215. if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) {
  216. pr_err("CPU%u: cpu didn't die\n", cpu);
  217. return;
  218. }
  219. pr_debug("CPU%u: shutdown\n", cpu);
  220. if (!platform_cpu_kill(cpu))
  221. printk("CPU%u: unable to kill\n", cpu);
  222. }
  223. /*
  224. * Called from the idle thread for the CPU which has been shutdown.
  225. *
  226. * Note that we disable IRQs here, but do not re-enable them
  227. * before returning to the caller. This is also the behaviour
  228. * of the other hotplug-cpu capable cores, so presumably coming
  229. * out of idle fixes this.
  230. */
  231. void __ref cpu_die(void)
  232. {
  233. unsigned int cpu = smp_processor_id();
  234. idle_task_exit();
  235. local_irq_disable();
  236. mb();
  237. /* Tell __cpu_die() that this CPU is now safe to dispose of */
  238. complete(&cpu_died);
  239. /*
  240. * actual CPU shutdown procedure is at least platform (if not
  241. * CPU) specific.
  242. */
  243. platform_cpu_die(cpu);
  244. /*
  245. * Do not return to the idle loop - jump back to the secondary
  246. * cpu initialisation. There's some initialisation which needs
  247. * to be repeated to undo the effects of taking the CPU offline.
  248. */
  249. __asm__("mov sp, %0\n"
  250. " mov fp, #0\n"
  251. " b secondary_start_kernel"
  252. :
  253. : "r" (task_stack_page(current) + THREAD_SIZE - 8));
  254. }
  255. #endif /* CONFIG_HOTPLUG_CPU */
  256. /*
  257. * Called by both boot and secondaries to move global data into
  258. * per-processor storage.
  259. */
  260. static void __cpuinit smp_store_cpu_info(unsigned int cpuid)
  261. {
  262. struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
  263. cpu_info->loops_per_jiffy = loops_per_jiffy;
  264. store_cpu_topology(cpuid);
  265. }
  266. /*
  267. * This is the secondary CPU boot entry. We're using this CPUs
  268. * idle thread stack, but a set of temporary page tables.
  269. */
  270. asmlinkage void __cpuinit secondary_start_kernel(void)
  271. {
  272. struct mm_struct *mm = &init_mm;
  273. unsigned int cpu;
  274. /*
  275. * The identity mapping is uncached (strongly ordered), so
  276. * switch away from it before attempting any exclusive accesses.
  277. */
  278. cpu_switch_mm(mm->pgd, mm);
  279. enter_lazy_tlb(mm, current);
  280. local_flush_tlb_all();
  281. /*
  282. * All kernel threads share the same mm context; grab a
  283. * reference and switch to it.
  284. */
  285. cpu = smp_processor_id();
  286. atomic_inc(&mm->mm_count);
  287. current->active_mm = mm;
  288. cpumask_set_cpu(cpu, mm_cpumask(mm));
  289. pr_debug("CPU%u: Booted secondary processor\n", cpu);
  290. cpu_init();
  291. preempt_disable();
  292. trace_hardirqs_off();
  293. /*
  294. * Give the platform a chance to do its own initialisation.
  295. */
  296. platform_secondary_init(cpu);
  297. notify_cpu_starting(cpu);
  298. calibrate_delay();
  299. smp_store_cpu_info(cpu);
  300. /*
  301. * OK, now it's safe to let the boot CPU continue. Wait for
  302. * the CPU migration code to notice that the CPU is online
  303. * before we continue - which happens after __cpu_up returns.
  304. */
  305. set_cpu_online(cpu, true);
  306. complete(&cpu_running);
  307. /*
  308. * Setup the percpu timer for this CPU.
  309. */
  310. percpu_timer_setup();
  311. local_irq_enable();
  312. local_fiq_enable();
  313. /*
  314. * OK, it's off to the idle thread for us
  315. */
  316. cpu_idle();
  317. }
  318. void __init smp_cpus_done(unsigned int max_cpus)
  319. {
  320. int cpu;
  321. unsigned long bogosum = 0;
  322. for_each_online_cpu(cpu)
  323. bogosum += per_cpu(cpu_data, cpu).loops_per_jiffy;
  324. printk(KERN_INFO "SMP: Total of %d processors activated "
  325. "(%lu.%02lu BogoMIPS).\n",
  326. num_online_cpus(),
  327. bogosum / (500000/HZ),
  328. (bogosum / (5000/HZ)) % 100);
  329. }
  330. void __init smp_prepare_boot_cpu(void)
  331. {
  332. unsigned int cpu = smp_processor_id();
  333. per_cpu(cpu_data, cpu).idle = current;
  334. }
  335. void __init smp_prepare_cpus(unsigned int max_cpus)
  336. {
  337. unsigned int ncores = num_possible_cpus();
  338. init_cpu_topology();
  339. smp_store_cpu_info(smp_processor_id());
  340. /*
  341. * are we trying to boot more cores than exist?
  342. */
  343. if (max_cpus > ncores)
  344. max_cpus = ncores;
  345. if (ncores > 1 && max_cpus) {
  346. /*
  347. * Enable the local timer or broadcast device for the
  348. * boot CPU, but only if we have more than one CPU.
  349. */
  350. percpu_timer_setup();
  351. /*
  352. * Initialise the present map, which describes the set of CPUs
  353. * actually populated at the present time. A platform should
  354. * re-initialize the map in platform_smp_prepare_cpus() if
  355. * present != possible (e.g. physical hotplug).
  356. */
  357. init_cpu_present(cpu_possible_mask);
  358. /*
  359. * Initialise the SCU if there are more than one CPU
  360. * and let them know where to start.
  361. */
  362. platform_smp_prepare_cpus(max_cpus);
  363. }
  364. }
  365. static void (*smp_cross_call)(const struct cpumask *, unsigned int);
  366. void __init set_smp_cross_call(void (*fn)(const struct cpumask *, unsigned int))
  367. {
  368. smp_cross_call = fn;
  369. }
  370. void arch_send_call_function_ipi_mask(const struct cpumask *mask)
  371. {
  372. smp_cross_call(mask, IPI_CALL_FUNC);
  373. }
  374. void arch_send_call_function_single_ipi(int cpu)
  375. {
  376. smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE);
  377. }
  378. static const char *ipi_types[NR_IPI] = {
  379. #define S(x,s) [x - IPI_CPU_START] = s
  380. S(IPI_CPU_START, "CPU start interrupts"),
  381. S(IPI_TIMER, "Timer broadcast interrupts"),
  382. S(IPI_RESCHEDULE, "Rescheduling interrupts"),
  383. S(IPI_CALL_FUNC, "Function call interrupts"),
  384. S(IPI_CALL_FUNC_SINGLE, "Single function call interrupts"),
  385. S(IPI_CPU_STOP, "CPU stop interrupts"),
  386. S(IPI_CPU_BACKTRACE, "CPU backtrace"),
  387. };
  388. void show_ipi_list(struct seq_file *p, int prec)
  389. {
  390. unsigned int cpu, i;
  391. for (i = 0; i < NR_IPI; i++) {
  392. seq_printf(p, "%*s%u: ", prec - 1, "IPI", i);
  393. for_each_present_cpu(cpu)
  394. seq_printf(p, "%10u ",
  395. __get_irq_stat(cpu, ipi_irqs[i]));
  396. seq_printf(p, " %s\n", ipi_types[i]);
  397. }
  398. }
  399. u64 smp_irq_stat_cpu(unsigned int cpu)
  400. {
  401. u64 sum = 0;
  402. int i;
  403. for (i = 0; i < NR_IPI; i++)
  404. sum += __get_irq_stat(cpu, ipi_irqs[i]);
  405. return sum;
  406. }
  407. /*
  408. * Timer (local or broadcast) support
  409. */
  410. static DEFINE_PER_CPU(struct clock_event_device, percpu_clockevent);
  411. static void ipi_timer(void)
  412. {
  413. struct clock_event_device *evt = &__get_cpu_var(percpu_clockevent);
  414. evt->event_handler(evt);
  415. }
  416. #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
  417. static void smp_timer_broadcast(const struct cpumask *mask)
  418. {
  419. smp_cross_call(mask, IPI_TIMER);
  420. }
  421. #else
  422. #define smp_timer_broadcast NULL
  423. #endif
  424. static void broadcast_timer_set_mode(enum clock_event_mode mode,
  425. struct clock_event_device *evt)
  426. {
  427. }
  428. static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt)
  429. {
  430. evt->name = "dummy_timer";
  431. evt->features = CLOCK_EVT_FEAT_ONESHOT |
  432. CLOCK_EVT_FEAT_PERIODIC |
  433. CLOCK_EVT_FEAT_DUMMY;
  434. evt->rating = 400;
  435. evt->mult = 1;
  436. evt->set_mode = broadcast_timer_set_mode;
  437. clockevents_register_device(evt);
  438. }
  439. static struct local_timer_ops *lt_ops;
  440. #ifdef CONFIG_LOCAL_TIMERS
  441. int local_timer_register(struct local_timer_ops *ops)
  442. {
  443. if (lt_ops)
  444. return -EBUSY;
  445. lt_ops = ops;
  446. return 0;
  447. }
  448. #endif
  449. void __cpuinit percpu_timer_setup(void)
  450. {
  451. unsigned int cpu = smp_processor_id();
  452. struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
  453. evt->cpumask = cpumask_of(cpu);
  454. evt->broadcast = smp_timer_broadcast;
  455. if (!lt_ops || lt_ops->setup(evt))
  456. broadcast_timer_setup(evt);
  457. }
  458. #ifdef CONFIG_HOTPLUG_CPU
  459. /*
  460. * The generic clock events code purposely does not stop the local timer
  461. * on CPU_DEAD/CPU_DEAD_FROZEN hotplug events, so we have to do it
  462. * manually here.
  463. */
  464. static void percpu_timer_stop(void)
  465. {
  466. unsigned int cpu = smp_processor_id();
  467. struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
  468. if (lt_ops)
  469. lt_ops->stop(evt);
  470. }
  471. #endif
  472. static DEFINE_RAW_SPINLOCK(stop_lock);
  473. DEFINE_PER_CPU(struct pt_regs, regs_before_stop);
  474. /*
  475. * ipi_cpu_stop - handle IPI from smp_send_stop()
  476. */
  477. static void ipi_cpu_stop(unsigned int cpu, struct pt_regs *regs)
  478. {
  479. if (system_state == SYSTEM_BOOTING ||
  480. system_state == SYSTEM_RUNNING) {
  481. per_cpu(regs_before_stop, cpu) = *regs;
  482. raw_spin_lock(&stop_lock);
  483. printk(KERN_CRIT "CPU%u: stopping\n", cpu);
  484. dump_stack();
  485. #ifdef CONFIG_SEC_DEBUG
  486. sec_debug_dump_stack();
  487. #endif
  488. raw_spin_unlock(&stop_lock);
  489. }
  490. set_cpu_active(cpu, false);
  491. local_fiq_disable();
  492. local_irq_disable();
  493. flush_cache_all();
  494. while (1)
  495. cpu_relax();
  496. }
  497. static cpumask_t backtrace_mask;
  498. static DEFINE_RAW_SPINLOCK(backtrace_lock);
  499. /* "in progress" flag of arch_trigger_all_cpu_backtrace */
  500. static unsigned long backtrace_flag;
  501. void smp_send_all_cpu_backtrace(void)
  502. {
  503. unsigned int this_cpu = smp_processor_id();
  504. int i;
  505. if (test_and_set_bit(0, &backtrace_flag))
  506. /*
  507. * If there is already a trigger_all_cpu_backtrace() in progress
  508. * (backtrace_flag == 1), don't output double cpu dump infos.
  509. */
  510. return;
  511. cpumask_copy(&backtrace_mask, cpu_online_mask);
  512. cpu_clear(this_cpu, backtrace_mask);
  513. pr_info("Backtrace for cpu %d (current):\n", this_cpu);
  514. dump_stack();
  515. pr_info("\nsending IPI to all other CPUs:\n");
  516. if (!cpus_empty(backtrace_mask))
  517. smp_cross_call(&backtrace_mask, IPI_CPU_BACKTRACE);
  518. /* Wait for up to 10 seconds for all other CPUs to do the backtrace */
  519. for (i = 0; i < 10 * 1000; i++) {
  520. if (cpumask_empty(&backtrace_mask))
  521. break;
  522. mdelay(1);
  523. }
  524. clear_bit(0, &backtrace_flag);
  525. smp_mb__after_clear_bit();
  526. }
  527. /*
  528. * ipi_cpu_backtrace - handle IPI from smp_send_all_cpu_backtrace()
  529. */
  530. static void ipi_cpu_backtrace(unsigned int cpu, struct pt_regs *regs)
  531. {
  532. if (cpu_isset(cpu, backtrace_mask)) {
  533. raw_spin_lock(&backtrace_lock);
  534. pr_warning("IPI backtrace for cpu %d\n", cpu);
  535. show_regs(regs);
  536. raw_spin_unlock(&backtrace_lock);
  537. cpu_clear(cpu, backtrace_mask);
  538. }
  539. }
  540. /*
  541. * Main handler for inter-processor interrupts
  542. */
  543. asmlinkage void __exception_irq_entry do_IPI(int ipinr, struct pt_regs *regs)
  544. {
  545. handle_IPI(ipinr, regs);
  546. }
  547. void handle_IPI(int ipinr, struct pt_regs *regs)
  548. {
  549. unsigned int cpu = smp_processor_id();
  550. struct pt_regs *old_regs = set_irq_regs(regs);
  551. if (ipinr >= IPI_CPU_START && ipinr < IPI_CPU_START + NR_IPI)
  552. __inc_irq_stat(cpu, ipi_irqs[ipinr - IPI_CPU_START]);
  553. switch (ipinr) {
  554. case IPI_CPU_START:
  555. /* Wake up from WFI/WFE using SGI */
  556. break;
  557. case IPI_TIMER:
  558. irq_enter();
  559. ipi_timer();
  560. irq_exit();
  561. break;
  562. case IPI_RESCHEDULE:
  563. scheduler_ipi();
  564. break;
  565. case IPI_CALL_FUNC:
  566. irq_enter();
  567. generic_smp_call_function_interrupt();
  568. irq_exit();
  569. break;
  570. case IPI_CALL_FUNC_SINGLE:
  571. irq_enter();
  572. generic_smp_call_function_single_interrupt();
  573. irq_exit();
  574. break;
  575. case IPI_CPU_STOP:
  576. irq_enter();
  577. ipi_cpu_stop(cpu, regs);
  578. irq_exit();
  579. break;
  580. case IPI_CPU_BACKTRACE:
  581. ipi_cpu_backtrace(cpu, regs);
  582. break;
  583. default:
  584. printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%x\n",
  585. cpu, ipinr);
  586. break;
  587. }
  588. set_irq_regs(old_regs);
  589. }
  590. void smp_send_reschedule(int cpu)
  591. {
  592. #if defined(CONFIG_ARCH_MSM8974) || defined(CONFIG_ARCH_MSM8974PRO)
  593. WARN_ON(cpu_is_offline(cpu));
  594. #endif
  595. smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
  596. }
  597. #ifdef CONFIG_HOTPLUG_CPU
  598. static void smp_kill_cpus(cpumask_t *mask)
  599. {
  600. unsigned int cpu;
  601. for_each_cpu(cpu, mask)
  602. platform_cpu_kill(cpu);
  603. }
  604. #else
  605. static void smp_kill_cpus(cpumask_t *mask) { }
  606. #endif
  607. void smp_send_stop(void)
  608. {
  609. unsigned long timeout;
  610. struct cpumask mask;
  611. cpumask_copy(&mask, cpu_online_mask);
  612. cpumask_clear_cpu(smp_processor_id(), &mask);
  613. if (!cpumask_empty(&mask))
  614. smp_cross_call(&mask, IPI_CPU_STOP);
  615. /* Wait up to one second for other CPUs to stop */
  616. timeout = USEC_PER_SEC;
  617. while (num_active_cpus() > 1 && timeout--)
  618. udelay(1);
  619. if (num_active_cpus() > 1)
  620. pr_warning("SMP: failed to stop secondary CPUs\n");
  621. smp_kill_cpus(&mask);
  622. }
  623. /*
  624. * not supported here
  625. */
  626. int setup_profiling_timer(unsigned int multiplier)
  627. {
  628. return -EINVAL;
  629. }