smp.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. *
  4. * Copyright (C) 2000, 2001 Kanoj Sarcar
  5. * Copyright (C) 2000, 2001 Ralf Baechle
  6. * Copyright (C) 2000, 2001 Silicon Graphics, Inc.
  7. * Copyright (C) 2000, 2001, 2003 Broadcom Corporation
  8. */
  9. #include <linux/cache.h>
  10. #include <linux/delay.h>
  11. #include <linux/init.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/profile.h>
  14. #include <linux/smp.h>
  15. #include <linux/spinlock.h>
  16. #include <linux/threads.h>
  17. #include <linux/export.h>
  18. #include <linux/time.h>
  19. #include <linux/timex.h>
  20. #include <linux/sched/mm.h>
  21. #include <linux/cpumask.h>
  22. #include <linux/cpu.h>
  23. #include <linux/err.h>
  24. #include <linux/ftrace.h>
  25. #include <linux/irqdomain.h>
  26. #include <linux/of.h>
  27. #include <linux/of_irq.h>
  28. #include <linux/atomic.h>
  29. #include <asm/cpu.h>
  30. #include <asm/ginvt.h>
  31. #include <asm/processor.h>
  32. #include <asm/idle.h>
  33. #include <asm/r4k-timer.h>
  34. #include <asm/mips-cps.h>
  35. #include <asm/mmu_context.h>
  36. #include <asm/time.h>
  37. #include <asm/setup.h>
  38. #include <asm/maar.h>
  39. int __cpu_number_map[CONFIG_MIPS_NR_CPU_NR_MAP]; /* Map physical to logical */
  40. EXPORT_SYMBOL(__cpu_number_map);
  41. int __cpu_logical_map[NR_CPUS]; /* Map logical to physical */
  42. EXPORT_SYMBOL(__cpu_logical_map);
  43. /* Number of TCs (or siblings in Intel speak) per CPU core */
  44. int smp_num_siblings = 1;
  45. EXPORT_SYMBOL(smp_num_siblings);
  46. /* representing the TCs (or siblings in Intel speak) of each logical CPU */
  47. cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
  48. EXPORT_SYMBOL(cpu_sibling_map);
  49. /* representing the core map of multi-core chips of each logical CPU */
  50. cpumask_t cpu_core_map[NR_CPUS] __read_mostly;
  51. EXPORT_SYMBOL(cpu_core_map);
  52. static DECLARE_COMPLETION(cpu_starting);
  53. static DECLARE_COMPLETION(cpu_running);
  54. /*
  55. * A logical cpu mask containing only one VPE per core to
  56. * reduce the number of IPIs on large MT systems.
  57. */
  58. cpumask_t cpu_foreign_map[NR_CPUS] __read_mostly;
  59. EXPORT_SYMBOL(cpu_foreign_map);
  60. /* representing cpus for which sibling maps can be computed */
  61. static cpumask_t cpu_sibling_setup_map;
  62. /* representing cpus for which core maps can be computed */
  63. static cpumask_t cpu_core_setup_map;
  64. cpumask_t cpu_coherent_mask;
  65. unsigned int smp_max_threads __initdata = UINT_MAX;
  66. static int __init early_nosmt(char *s)
  67. {
  68. smp_max_threads = 1;
  69. return 0;
  70. }
  71. early_param("nosmt", early_nosmt);
  72. static int __init early_smt(char *s)
  73. {
  74. get_option(&s, &smp_max_threads);
  75. /* Ensure at least one thread is available */
  76. smp_max_threads = clamp_val(smp_max_threads, 1U, UINT_MAX);
  77. return 0;
  78. }
  79. early_param("smt", early_smt);
  80. #ifdef CONFIG_GENERIC_IRQ_IPI
  81. static struct irq_desc *call_desc;
  82. static struct irq_desc *sched_desc;
  83. #endif
  84. static inline void set_cpu_sibling_map(int cpu)
  85. {
  86. int i;
  87. cpumask_set_cpu(cpu, &cpu_sibling_setup_map);
  88. if (smp_num_siblings > 1) {
  89. for_each_cpu(i, &cpu_sibling_setup_map) {
  90. if (cpus_are_siblings(cpu, i)) {
  91. cpumask_set_cpu(i, &cpu_sibling_map[cpu]);
  92. cpumask_set_cpu(cpu, &cpu_sibling_map[i]);
  93. }
  94. }
  95. } else
  96. cpumask_set_cpu(cpu, &cpu_sibling_map[cpu]);
  97. }
  98. static inline void set_cpu_core_map(int cpu)
  99. {
  100. int i;
  101. cpumask_set_cpu(cpu, &cpu_core_setup_map);
  102. for_each_cpu(i, &cpu_core_setup_map) {
  103. if (cpu_data[cpu].package == cpu_data[i].package) {
  104. cpumask_set_cpu(i, &cpu_core_map[cpu]);
  105. cpumask_set_cpu(cpu, &cpu_core_map[i]);
  106. }
  107. }
  108. }
  109. /*
  110. * Calculate a new cpu_foreign_map mask whenever a
  111. * new cpu appears or disappears.
  112. */
  113. void calculate_cpu_foreign_map(void)
  114. {
  115. int i, k, core_present;
  116. cpumask_t temp_foreign_map;
  117. /* Re-calculate the mask */
  118. cpumask_clear(&temp_foreign_map);
  119. for_each_online_cpu(i) {
  120. core_present = 0;
  121. for_each_cpu(k, &temp_foreign_map)
  122. if (cpus_are_siblings(i, k))
  123. core_present = 1;
  124. if (!core_present)
  125. cpumask_set_cpu(i, &temp_foreign_map);
  126. }
  127. for_each_online_cpu(i)
  128. cpumask_andnot(&cpu_foreign_map[i],
  129. &temp_foreign_map, &cpu_sibling_map[i]);
  130. }
  131. const struct plat_smp_ops *mp_ops;
  132. EXPORT_SYMBOL(mp_ops);
  133. void register_smp_ops(const struct plat_smp_ops *ops)
  134. {
  135. if (mp_ops)
  136. printk(KERN_WARNING "Overriding previously set SMP ops\n");
  137. mp_ops = ops;
  138. }
  139. #ifdef CONFIG_GENERIC_IRQ_IPI
  140. void mips_smp_send_ipi_single(int cpu, unsigned int action)
  141. {
  142. mips_smp_send_ipi_mask(cpumask_of(cpu), action);
  143. }
  144. void mips_smp_send_ipi_mask(const struct cpumask *mask, unsigned int action)
  145. {
  146. unsigned long flags;
  147. unsigned int core;
  148. int cpu;
  149. local_irq_save(flags);
  150. switch (action) {
  151. case SMP_CALL_FUNCTION:
  152. __ipi_send_mask(call_desc, mask);
  153. break;
  154. case SMP_RESCHEDULE_YOURSELF:
  155. __ipi_send_mask(sched_desc, mask);
  156. break;
  157. default:
  158. BUG();
  159. }
  160. if (mips_cpc_present()) {
  161. for_each_cpu(cpu, mask) {
  162. if (cpus_are_siblings(cpu, smp_processor_id()))
  163. continue;
  164. core = cpu_core(&cpu_data[cpu]);
  165. while (!cpumask_test_cpu(cpu, &cpu_coherent_mask)) {
  166. mips_cm_lock_other_cpu(cpu, CM_GCR_Cx_OTHER_BLOCK_LOCAL);
  167. mips_cpc_lock_other(core);
  168. write_cpc_co_cmd(CPC_Cx_CMD_PWRUP);
  169. mips_cpc_unlock_other();
  170. mips_cm_unlock_other();
  171. }
  172. }
  173. }
  174. local_irq_restore(flags);
  175. }
  176. static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id)
  177. {
  178. scheduler_ipi();
  179. return IRQ_HANDLED;
  180. }
  181. static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
  182. {
  183. generic_smp_call_function_interrupt();
  184. return IRQ_HANDLED;
  185. }
  186. static void smp_ipi_init_one(unsigned int virq, const char *name,
  187. irq_handler_t handler)
  188. {
  189. int ret;
  190. irq_set_handler(virq, handle_percpu_irq);
  191. ret = request_irq(virq, handler, IRQF_PERCPU, name, NULL);
  192. BUG_ON(ret);
  193. }
  194. static unsigned int call_virq, sched_virq;
  195. int mips_smp_ipi_allocate(const struct cpumask *mask)
  196. {
  197. int virq;
  198. struct irq_domain *ipidomain;
  199. struct device_node *node;
  200. node = of_irq_find_parent(of_root);
  201. ipidomain = irq_find_matching_host(node, DOMAIN_BUS_IPI);
  202. /*
  203. * Some platforms have half DT setup. So if we found irq node but
  204. * didn't find an ipidomain, try to search for one that is not in the
  205. * DT.
  206. */
  207. if (node && !ipidomain)
  208. ipidomain = irq_find_matching_host(NULL, DOMAIN_BUS_IPI);
  209. /*
  210. * There are systems which use IPI IRQ domains, but only have one
  211. * registered when some runtime condition is met. For example a Malta
  212. * kernel may include support for GIC & CPU interrupt controller IPI
  213. * IRQ domains, but if run on a system with no GIC & no MT ASE then
  214. * neither will be supported or registered.
  215. *
  216. * We only have a problem if we're actually using multiple CPUs so fail
  217. * loudly if that is the case. Otherwise simply return, skipping IPI
  218. * setup, if we're running with only a single CPU.
  219. */
  220. if (!ipidomain) {
  221. BUG_ON(num_present_cpus() > 1);
  222. return 0;
  223. }
  224. virq = irq_reserve_ipi(ipidomain, mask);
  225. BUG_ON(!virq);
  226. if (!call_virq)
  227. call_virq = virq;
  228. virq = irq_reserve_ipi(ipidomain, mask);
  229. BUG_ON(!virq);
  230. if (!sched_virq)
  231. sched_virq = virq;
  232. if (irq_domain_is_ipi_per_cpu(ipidomain)) {
  233. int cpu;
  234. for_each_cpu(cpu, mask) {
  235. smp_ipi_init_one(call_virq + cpu, "IPI call",
  236. ipi_call_interrupt);
  237. smp_ipi_init_one(sched_virq + cpu, "IPI resched",
  238. ipi_resched_interrupt);
  239. }
  240. } else {
  241. smp_ipi_init_one(call_virq, "IPI call", ipi_call_interrupt);
  242. smp_ipi_init_one(sched_virq, "IPI resched",
  243. ipi_resched_interrupt);
  244. }
  245. return 0;
  246. }
  247. int mips_smp_ipi_free(const struct cpumask *mask)
  248. {
  249. struct irq_domain *ipidomain;
  250. struct device_node *node;
  251. node = of_irq_find_parent(of_root);
  252. ipidomain = irq_find_matching_host(node, DOMAIN_BUS_IPI);
  253. /*
  254. * Some platforms have half DT setup. So if we found irq node but
  255. * didn't find an ipidomain, try to search for one that is not in the
  256. * DT.
  257. */
  258. if (node && !ipidomain)
  259. ipidomain = irq_find_matching_host(NULL, DOMAIN_BUS_IPI);
  260. BUG_ON(!ipidomain);
  261. if (irq_domain_is_ipi_per_cpu(ipidomain)) {
  262. int cpu;
  263. for_each_cpu(cpu, mask) {
  264. free_irq(call_virq + cpu, NULL);
  265. free_irq(sched_virq + cpu, NULL);
  266. }
  267. }
  268. irq_destroy_ipi(call_virq, mask);
  269. irq_destroy_ipi(sched_virq, mask);
  270. return 0;
  271. }
  272. static int __init mips_smp_ipi_init(void)
  273. {
  274. if (num_possible_cpus() == 1)
  275. return 0;
  276. mips_smp_ipi_allocate(cpu_possible_mask);
  277. call_desc = irq_to_desc(call_virq);
  278. sched_desc = irq_to_desc(sched_virq);
  279. return 0;
  280. }
  281. early_initcall(mips_smp_ipi_init);
  282. #endif
  283. /*
  284. * First C code run on the secondary CPUs after being started up by
  285. * the master.
  286. */
  287. asmlinkage void start_secondary(void)
  288. {
  289. unsigned int cpu = raw_smp_processor_id();
  290. cpu_probe();
  291. per_cpu_trap_init(false);
  292. rcutree_report_cpu_starting(cpu);
  293. mips_clockevent_init();
  294. mp_ops->init_secondary();
  295. cpu_report();
  296. maar_init();
  297. /*
  298. * XXX parity protection should be folded in here when it's converted
  299. * to an option instead of something based on .cputype
  300. */
  301. calibrate_delay();
  302. cpu_data[cpu].udelay_val = loops_per_jiffy;
  303. set_cpu_sibling_map(cpu);
  304. set_cpu_core_map(cpu);
  305. cpumask_set_cpu(cpu, &cpu_coherent_mask);
  306. notify_cpu_starting(cpu);
  307. /* Notify boot CPU that we're starting & ready to sync counters */
  308. complete(&cpu_starting);
  309. synchronise_count_slave(cpu);
  310. /* The CPU is running and counters synchronised, now mark it online */
  311. set_cpu_online(cpu, true);
  312. calculate_cpu_foreign_map();
  313. /*
  314. * Notify boot CPU that we're up & online and it can safely return
  315. * from __cpu_up
  316. */
  317. complete(&cpu_running);
  318. /*
  319. * irq will be enabled in ->smp_finish(), enabling it too early
  320. * is dangerous.
  321. */
  322. WARN_ON_ONCE(!irqs_disabled());
  323. mp_ops->smp_finish();
  324. cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
  325. }
  326. static void stop_this_cpu(void *dummy)
  327. {
  328. /*
  329. * Remove this CPU:
  330. */
  331. set_cpu_online(smp_processor_id(), false);
  332. calculate_cpu_foreign_map();
  333. local_irq_disable();
  334. while (1);
  335. }
  336. void smp_send_stop(void)
  337. {
  338. smp_call_function(stop_this_cpu, NULL, 0);
  339. }
  340. void __init smp_cpus_done(unsigned int max_cpus)
  341. {
  342. }
  343. /* called from main before smp_init() */
  344. void __init smp_prepare_cpus(unsigned int max_cpus)
  345. {
  346. init_new_context(current, &init_mm);
  347. current_thread_info()->cpu = 0;
  348. mp_ops->prepare_cpus(max_cpus);
  349. set_cpu_sibling_map(0);
  350. set_cpu_core_map(0);
  351. calculate_cpu_foreign_map();
  352. #ifndef CONFIG_HOTPLUG_CPU
  353. init_cpu_present(cpu_possible_mask);
  354. #endif
  355. cpumask_copy(&cpu_coherent_mask, cpu_possible_mask);
  356. }
  357. /* preload SMP state for boot cpu */
  358. void __init smp_prepare_boot_cpu(void)
  359. {
  360. if (mp_ops->prepare_boot_cpu)
  361. mp_ops->prepare_boot_cpu();
  362. set_cpu_possible(0, true);
  363. set_cpu_online(0, true);
  364. }
  365. int __cpu_up(unsigned int cpu, struct task_struct *tidle)
  366. {
  367. int err;
  368. err = mp_ops->boot_secondary(cpu, tidle);
  369. if (err)
  370. return err;
  371. /* Wait for CPU to start and be ready to sync counters */
  372. if (!wait_for_completion_timeout(&cpu_starting,
  373. msecs_to_jiffies(1000))) {
  374. pr_crit("CPU%u: failed to start\n", cpu);
  375. return -EIO;
  376. }
  377. /* Wait for CPU to finish startup & mark itself online before return */
  378. wait_for_completion(&cpu_running);
  379. return 0;
  380. }
  381. #ifdef CONFIG_PROFILING
  382. /* Not really SMP stuff ... */
  383. int setup_profiling_timer(unsigned int multiplier)
  384. {
  385. return 0;
  386. }
  387. #endif
  388. static void flush_tlb_all_ipi(void *info)
  389. {
  390. local_flush_tlb_all();
  391. }
  392. void flush_tlb_all(void)
  393. {
  394. if (cpu_has_mmid) {
  395. htw_stop();
  396. ginvt_full();
  397. sync_ginv();
  398. instruction_hazard();
  399. htw_start();
  400. return;
  401. }
  402. on_each_cpu(flush_tlb_all_ipi, NULL, 1);
  403. }
  404. static void flush_tlb_mm_ipi(void *mm)
  405. {
  406. drop_mmu_context((struct mm_struct *)mm);
  407. }
  408. /*
  409. * Special Variant of smp_call_function for use by TLB functions:
  410. *
  411. * o No return value
  412. * o collapses to normal function call on UP kernels
  413. * o collapses to normal function call on systems with a single shared
  414. * primary cache.
  415. */
  416. static inline void smp_on_other_tlbs(void (*func) (void *info), void *info)
  417. {
  418. smp_call_function(func, info, 1);
  419. }
  420. static inline void smp_on_each_tlb(void (*func) (void *info), void *info)
  421. {
  422. preempt_disable();
  423. smp_on_other_tlbs(func, info);
  424. func(info);
  425. preempt_enable();
  426. }
  427. /*
  428. * The following tlb flush calls are invoked when old translations are
  429. * being torn down, or pte attributes are changing. For single threaded
  430. * address spaces, a new context is obtained on the current cpu, and tlb
  431. * context on other cpus are invalidated to force a new context allocation
  432. * at switch_mm time, should the mm ever be used on other cpus. For
  433. * multithreaded address spaces, inter-CPU interrupts have to be sent.
  434. * Another case where inter-CPU interrupts are required is when the target
  435. * mm might be active on another cpu (eg debuggers doing the flushes on
  436. * behalf of debugees, kswapd stealing pages from another process etc).
  437. * Kanoj 07/00.
  438. */
  439. void flush_tlb_mm(struct mm_struct *mm)
  440. {
  441. if (!mm)
  442. return;
  443. if (atomic_read(&mm->mm_users) == 0)
  444. return; /* happens as a result of exit_mmap() */
  445. preempt_disable();
  446. if (cpu_has_mmid) {
  447. /*
  448. * No need to worry about other CPUs - the ginvt in
  449. * drop_mmu_context() will be globalized.
  450. */
  451. } else if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) {
  452. smp_on_other_tlbs(flush_tlb_mm_ipi, mm);
  453. } else {
  454. unsigned int cpu;
  455. for_each_online_cpu(cpu) {
  456. if (cpu != smp_processor_id() && cpu_context(cpu, mm))
  457. set_cpu_context(cpu, mm, 0);
  458. }
  459. }
  460. drop_mmu_context(mm);
  461. preempt_enable();
  462. }
  463. struct flush_tlb_data {
  464. struct vm_area_struct *vma;
  465. unsigned long addr1;
  466. unsigned long addr2;
  467. };
  468. static void flush_tlb_range_ipi(void *info)
  469. {
  470. struct flush_tlb_data *fd = info;
  471. local_flush_tlb_range(fd->vma, fd->addr1, fd->addr2);
  472. }
  473. void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end)
  474. {
  475. struct mm_struct *mm = vma->vm_mm;
  476. unsigned long addr;
  477. u32 old_mmid;
  478. preempt_disable();
  479. if (cpu_has_mmid) {
  480. htw_stop();
  481. old_mmid = read_c0_memorymapid();
  482. write_c0_memorymapid(cpu_asid(0, mm));
  483. mtc0_tlbw_hazard();
  484. addr = round_down(start, PAGE_SIZE * 2);
  485. end = round_up(end, PAGE_SIZE * 2);
  486. do {
  487. ginvt_va_mmid(addr);
  488. sync_ginv();
  489. addr += PAGE_SIZE * 2;
  490. } while (addr < end);
  491. write_c0_memorymapid(old_mmid);
  492. instruction_hazard();
  493. htw_start();
  494. } else if ((atomic_read(&mm->mm_users) != 1) || (current->mm != mm)) {
  495. struct flush_tlb_data fd = {
  496. .vma = vma,
  497. .addr1 = start,
  498. .addr2 = end,
  499. };
  500. smp_on_other_tlbs(flush_tlb_range_ipi, &fd);
  501. local_flush_tlb_range(vma, start, end);
  502. } else {
  503. unsigned int cpu;
  504. int exec = vma->vm_flags & VM_EXEC;
  505. for_each_online_cpu(cpu) {
  506. /*
  507. * flush_cache_range() will only fully flush icache if
  508. * the VMA is executable, otherwise we must invalidate
  509. * ASID without it appearing to has_valid_asid() as if
  510. * mm has been completely unused by that CPU.
  511. */
  512. if (cpu != smp_processor_id() && cpu_context(cpu, mm))
  513. set_cpu_context(cpu, mm, !exec);
  514. }
  515. local_flush_tlb_range(vma, start, end);
  516. }
  517. preempt_enable();
  518. }
  519. static void flush_tlb_kernel_range_ipi(void *info)
  520. {
  521. struct flush_tlb_data *fd = info;
  522. local_flush_tlb_kernel_range(fd->addr1, fd->addr2);
  523. }
  524. void flush_tlb_kernel_range(unsigned long start, unsigned long end)
  525. {
  526. struct flush_tlb_data fd = {
  527. .addr1 = start,
  528. .addr2 = end,
  529. };
  530. on_each_cpu(flush_tlb_kernel_range_ipi, &fd, 1);
  531. }
  532. static void flush_tlb_page_ipi(void *info)
  533. {
  534. struct flush_tlb_data *fd = info;
  535. local_flush_tlb_page(fd->vma, fd->addr1);
  536. }
  537. void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
  538. {
  539. u32 old_mmid;
  540. preempt_disable();
  541. if (cpu_has_mmid) {
  542. htw_stop();
  543. old_mmid = read_c0_memorymapid();
  544. write_c0_memorymapid(cpu_asid(0, vma->vm_mm));
  545. mtc0_tlbw_hazard();
  546. ginvt_va_mmid(page);
  547. sync_ginv();
  548. write_c0_memorymapid(old_mmid);
  549. instruction_hazard();
  550. htw_start();
  551. } else if ((atomic_read(&vma->vm_mm->mm_users) != 1) ||
  552. (current->mm != vma->vm_mm)) {
  553. struct flush_tlb_data fd = {
  554. .vma = vma,
  555. .addr1 = page,
  556. };
  557. smp_on_other_tlbs(flush_tlb_page_ipi, &fd);
  558. local_flush_tlb_page(vma, page);
  559. } else {
  560. unsigned int cpu;
  561. for_each_online_cpu(cpu) {
  562. /*
  563. * flush_cache_page() only does partial flushes, so
  564. * invalidate ASID without it appearing to
  565. * has_valid_asid() as if mm has been completely unused
  566. * by that CPU.
  567. */
  568. if (cpu != smp_processor_id() && cpu_context(cpu, vma->vm_mm))
  569. set_cpu_context(cpu, vma->vm_mm, 1);
  570. }
  571. local_flush_tlb_page(vma, page);
  572. }
  573. preempt_enable();
  574. }
  575. static void flush_tlb_one_ipi(void *info)
  576. {
  577. unsigned long vaddr = (unsigned long) info;
  578. local_flush_tlb_one(vaddr);
  579. }
  580. void flush_tlb_one(unsigned long vaddr)
  581. {
  582. smp_on_each_tlb(flush_tlb_one_ipi, (void *) vaddr);
  583. }
  584. EXPORT_SYMBOL(flush_tlb_page);
  585. EXPORT_SYMBOL(flush_tlb_one);
  586. #ifdef CONFIG_HOTPLUG_CORE_SYNC_DEAD
  587. void arch_cpuhp_cleanup_dead_cpu(unsigned int cpu)
  588. {
  589. if (mp_ops->cleanup_dead_cpu)
  590. mp_ops->cleanup_dead_cpu(cpu);
  591. }
  592. #endif
  593. #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
  594. static void tick_broadcast_callee(void *info)
  595. {
  596. tick_receive_broadcast();
  597. }
  598. static DEFINE_PER_CPU(call_single_data_t, tick_broadcast_csd) =
  599. CSD_INIT(tick_broadcast_callee, NULL);
  600. void tick_broadcast(const struct cpumask *mask)
  601. {
  602. call_single_data_t *csd;
  603. int cpu;
  604. for_each_cpu(cpu, mask) {
  605. csd = &per_cpu(tick_broadcast_csd, cpu);
  606. smp_call_function_single_async(cpu, csd);
  607. }
  608. }
  609. #endif /* CONFIG_GENERIC_CLOCKEVENTS_BROADCAST */