smp.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /*
  2. * SMP support for ppc.
  3. *
  4. * Written by Cort Dougan (cort@cs.nmt.edu) borrowing a great
  5. * deal of code from the sparc and intel versions.
  6. *
  7. * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
  8. *
  9. * PowerPC-64 Support added by Dave Engebretsen, Peter Bergner, and
  10. * Mike Corrigan {engebret|bergner|mikec}@us.ibm.com
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * as published by the Free Software Foundation; either version
  15. * 2 of the License, or (at your option) any later version.
  16. */
  17. #undef DEBUG
  18. #include <linux/kernel.h>
  19. #include <linux/export.h>
  20. #include <linux/sched.h>
  21. #include <linux/smp.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/delay.h>
  24. #include <linux/init.h>
  25. #include <linux/spinlock.h>
  26. #include <linux/cache.h>
  27. #include <linux/err.h>
  28. #include <linux/device.h>
  29. #include <linux/cpu.h>
  30. #include <linux/notifier.h>
  31. #include <linux/topology.h>
  32. #include <asm/ptrace.h>
  33. #include <linux/atomic.h>
  34. #include <asm/irq.h>
  35. #include <asm/page.h>
  36. #include <asm/pgtable.h>
  37. #include <asm/prom.h>
  38. #include <asm/smp.h>
  39. #include <asm/time.h>
  40. #include <asm/machdep.h>
  41. #include <asm/cputhreads.h>
  42. #include <asm/cputable.h>
  43. #include <asm/mpic.h>
  44. #include <asm/vdso_datapage.h>
  45. #ifdef CONFIG_PPC64
  46. #include <asm/paca.h>
  47. #endif
  48. #include <asm/debug.h>
  49. #ifdef DEBUG
  50. #include <asm/udbg.h>
  51. #define DBG(fmt...) udbg_printf(fmt)
  52. #else
  53. #define DBG(fmt...)
  54. #endif
  55. #ifdef CONFIG_HOTPLUG_CPU
  56. /* State of each CPU during hotplug phases */
  57. static DEFINE_PER_CPU(int, cpu_state) = { 0 };
  58. #endif
  59. struct thread_info *secondary_ti;
  60. DEFINE_PER_CPU(cpumask_var_t, cpu_sibling_map);
  61. DEFINE_PER_CPU(cpumask_var_t, cpu_core_map);
  62. EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
  63. EXPORT_PER_CPU_SYMBOL(cpu_core_map);
  64. /* SMP operations for this machine */
  65. struct smp_ops_t *smp_ops;
  66. /* Can't be static due to PowerMac hackery */
  67. volatile unsigned int cpu_callin_map[NR_CPUS];
  68. int smt_enabled_at_boot = 1;
  69. static void (*crash_ipi_function_ptr)(struct pt_regs *) = NULL;
  70. #ifdef CONFIG_PPC64
  71. int __devinit smp_generic_kick_cpu(int nr)
  72. {
  73. BUG_ON(nr < 0 || nr >= NR_CPUS);
  74. /*
  75. * The processor is currently spinning, waiting for the
  76. * cpu_start field to become non-zero After we set cpu_start,
  77. * the processor will continue on to secondary_start
  78. */
  79. if (!paca[nr].cpu_start) {
  80. paca[nr].cpu_start = 1;
  81. smp_mb();
  82. return 0;
  83. }
  84. #ifdef CONFIG_HOTPLUG_CPU
  85. /*
  86. * Ok it's not there, so it might be soft-unplugged, let's
  87. * try to bring it back
  88. */
  89. per_cpu(cpu_state, nr) = CPU_UP_PREPARE;
  90. smp_wmb();
  91. smp_send_reschedule(nr);
  92. #endif /* CONFIG_HOTPLUG_CPU */
  93. return 0;
  94. }
  95. #endif /* CONFIG_PPC64 */
  96. static irqreturn_t call_function_action(int irq, void *data)
  97. {
  98. generic_smp_call_function_interrupt();
  99. return IRQ_HANDLED;
  100. }
  101. static irqreturn_t reschedule_action(int irq, void *data)
  102. {
  103. scheduler_ipi();
  104. return IRQ_HANDLED;
  105. }
  106. static irqreturn_t call_function_single_action(int irq, void *data)
  107. {
  108. generic_smp_call_function_single_interrupt();
  109. return IRQ_HANDLED;
  110. }
  111. static irqreturn_t debug_ipi_action(int irq, void *data)
  112. {
  113. if (crash_ipi_function_ptr) {
  114. crash_ipi_function_ptr(get_irq_regs());
  115. return IRQ_HANDLED;
  116. }
  117. #ifdef CONFIG_DEBUGGER
  118. debugger_ipi(get_irq_regs());
  119. #endif /* CONFIG_DEBUGGER */
  120. return IRQ_HANDLED;
  121. }
  122. static irq_handler_t smp_ipi_action[] = {
  123. [PPC_MSG_CALL_FUNCTION] = call_function_action,
  124. [PPC_MSG_RESCHEDULE] = reschedule_action,
  125. [PPC_MSG_CALL_FUNC_SINGLE] = call_function_single_action,
  126. [PPC_MSG_DEBUGGER_BREAK] = debug_ipi_action,
  127. };
  128. const char *smp_ipi_name[] = {
  129. [PPC_MSG_CALL_FUNCTION] = "ipi call function",
  130. [PPC_MSG_RESCHEDULE] = "ipi reschedule",
  131. [PPC_MSG_CALL_FUNC_SINGLE] = "ipi call function single",
  132. [PPC_MSG_DEBUGGER_BREAK] = "ipi debugger",
  133. };
  134. /* optional function to request ipi, for controllers with >= 4 ipis */
  135. int smp_request_message_ipi(int virq, int msg)
  136. {
  137. int err;
  138. if (msg < 0 || msg > PPC_MSG_DEBUGGER_BREAK) {
  139. return -EINVAL;
  140. }
  141. #if !defined(CONFIG_DEBUGGER) && !defined(CONFIG_KEXEC)
  142. if (msg == PPC_MSG_DEBUGGER_BREAK) {
  143. return 1;
  144. }
  145. #endif
  146. err = request_irq(virq, smp_ipi_action[msg],
  147. IRQF_PERCPU | IRQF_NO_THREAD,
  148. smp_ipi_name[msg], 0);
  149. WARN(err < 0, "unable to request_irq %d for %s (rc %d)\n",
  150. virq, smp_ipi_name[msg], err);
  151. return err;
  152. }
  153. #ifdef CONFIG_PPC_SMP_MUXED_IPI
  154. struct cpu_messages {
  155. int messages; /* current messages */
  156. unsigned long data; /* data for cause ipi */
  157. };
  158. static DEFINE_PER_CPU_SHARED_ALIGNED(struct cpu_messages, ipi_message);
  159. void smp_muxed_ipi_set_data(int cpu, unsigned long data)
  160. {
  161. struct cpu_messages *info = &per_cpu(ipi_message, cpu);
  162. info->data = data;
  163. }
  164. void smp_muxed_ipi_message_pass(int cpu, int msg)
  165. {
  166. struct cpu_messages *info = &per_cpu(ipi_message, cpu);
  167. char *message = (char *)&info->messages;
  168. message[msg] = 1;
  169. mb();
  170. smp_ops->cause_ipi(cpu, info->data);
  171. }
  172. irqreturn_t smp_ipi_demux(void)
  173. {
  174. struct cpu_messages *info = &__get_cpu_var(ipi_message);
  175. unsigned int all;
  176. mb(); /* order any irq clear */
  177. do {
  178. all = xchg_local(&info->messages, 0);
  179. #ifdef __BIG_ENDIAN
  180. if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNCTION)))
  181. generic_smp_call_function_interrupt();
  182. if (all & (1 << (24 - 8 * PPC_MSG_RESCHEDULE)))
  183. scheduler_ipi();
  184. if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNC_SINGLE)))
  185. generic_smp_call_function_single_interrupt();
  186. if (all & (1 << (24 - 8 * PPC_MSG_DEBUGGER_BREAK)))
  187. debug_ipi_action(0, NULL);
  188. #else
  189. #error Unsupported ENDIAN
  190. #endif
  191. } while (info->messages);
  192. return IRQ_HANDLED;
  193. }
  194. #endif /* CONFIG_PPC_SMP_MUXED_IPI */
  195. static inline void do_message_pass(int cpu, int msg)
  196. {
  197. if (smp_ops->message_pass)
  198. smp_ops->message_pass(cpu, msg);
  199. #ifdef CONFIG_PPC_SMP_MUXED_IPI
  200. else
  201. smp_muxed_ipi_message_pass(cpu, msg);
  202. #endif
  203. }
  204. void smp_send_reschedule(int cpu)
  205. {
  206. if (likely(smp_ops))
  207. do_message_pass(cpu, PPC_MSG_RESCHEDULE);
  208. }
  209. EXPORT_SYMBOL_GPL(smp_send_reschedule);
  210. void arch_send_call_function_single_ipi(int cpu)
  211. {
  212. do_message_pass(cpu, PPC_MSG_CALL_FUNC_SINGLE);
  213. }
  214. void arch_send_call_function_ipi_mask(const struct cpumask *mask)
  215. {
  216. unsigned int cpu;
  217. for_each_cpu(cpu, mask)
  218. do_message_pass(cpu, PPC_MSG_CALL_FUNCTION);
  219. }
  220. #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
  221. void smp_send_debugger_break(void)
  222. {
  223. int cpu;
  224. int me = raw_smp_processor_id();
  225. if (unlikely(!smp_ops))
  226. return;
  227. for_each_online_cpu(cpu)
  228. if (cpu != me)
  229. do_message_pass(cpu, PPC_MSG_DEBUGGER_BREAK);
  230. }
  231. #endif
  232. #ifdef CONFIG_KEXEC
  233. void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *))
  234. {
  235. crash_ipi_function_ptr = crash_ipi_callback;
  236. if (crash_ipi_callback) {
  237. mb();
  238. smp_send_debugger_break();
  239. }
  240. }
  241. #endif
  242. static void stop_this_cpu(void *dummy)
  243. {
  244. /* Remove this CPU */
  245. set_cpu_online(smp_processor_id(), false);
  246. local_irq_disable();
  247. while (1)
  248. ;
  249. }
  250. void smp_send_stop(void)
  251. {
  252. smp_call_function(stop_this_cpu, NULL, 0);
  253. }
  254. struct thread_info *current_set[NR_CPUS];
  255. static void __devinit smp_store_cpu_info(int id)
  256. {
  257. per_cpu(cpu_pvr, id) = mfspr(SPRN_PVR);
  258. #ifdef CONFIG_PPC_FSL_BOOK3E
  259. per_cpu(next_tlbcam_idx, id)
  260. = (mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY) - 1;
  261. #endif
  262. }
  263. void __init smp_prepare_cpus(unsigned int max_cpus)
  264. {
  265. unsigned int cpu;
  266. DBG("smp_prepare_cpus\n");
  267. /*
  268. * setup_cpu may need to be called on the boot cpu. We havent
  269. * spun any cpus up but lets be paranoid.
  270. */
  271. BUG_ON(boot_cpuid != smp_processor_id());
  272. /* Fixup boot cpu */
  273. smp_store_cpu_info(boot_cpuid);
  274. cpu_callin_map[boot_cpuid] = 1;
  275. for_each_possible_cpu(cpu) {
  276. zalloc_cpumask_var_node(&per_cpu(cpu_sibling_map, cpu),
  277. GFP_KERNEL, cpu_to_node(cpu));
  278. zalloc_cpumask_var_node(&per_cpu(cpu_core_map, cpu),
  279. GFP_KERNEL, cpu_to_node(cpu));
  280. }
  281. cpumask_set_cpu(boot_cpuid, cpu_sibling_mask(boot_cpuid));
  282. cpumask_set_cpu(boot_cpuid, cpu_core_mask(boot_cpuid));
  283. if (smp_ops)
  284. if (smp_ops->probe)
  285. max_cpus = smp_ops->probe();
  286. else
  287. max_cpus = NR_CPUS;
  288. else
  289. max_cpus = 1;
  290. }
  291. void __devinit smp_prepare_boot_cpu(void)
  292. {
  293. BUG_ON(smp_processor_id() != boot_cpuid);
  294. #ifdef CONFIG_PPC64
  295. paca[boot_cpuid].__current = current;
  296. #endif
  297. current_set[boot_cpuid] = task_thread_info(current);
  298. }
  299. #ifdef CONFIG_HOTPLUG_CPU
  300. int generic_cpu_disable(void)
  301. {
  302. unsigned int cpu = smp_processor_id();
  303. if (cpu == boot_cpuid)
  304. return -EBUSY;
  305. set_cpu_online(cpu, false);
  306. #ifdef CONFIG_PPC64
  307. vdso_data->processorCount--;
  308. #endif
  309. migrate_irqs();
  310. return 0;
  311. }
  312. void generic_cpu_die(unsigned int cpu)
  313. {
  314. int i;
  315. for (i = 0; i < 100; i++) {
  316. smp_rmb();
  317. if (per_cpu(cpu_state, cpu) == CPU_DEAD)
  318. return;
  319. msleep(100);
  320. }
  321. printk(KERN_ERR "CPU%d didn't die...\n", cpu);
  322. }
  323. void generic_mach_cpu_die(void)
  324. {
  325. unsigned int cpu;
  326. local_irq_disable();
  327. idle_task_exit();
  328. cpu = smp_processor_id();
  329. printk(KERN_DEBUG "CPU%d offline\n", cpu);
  330. __get_cpu_var(cpu_state) = CPU_DEAD;
  331. smp_wmb();
  332. while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE)
  333. cpu_relax();
  334. }
  335. void generic_set_cpu_dead(unsigned int cpu)
  336. {
  337. per_cpu(cpu_state, cpu) = CPU_DEAD;
  338. }
  339. int generic_check_cpu_restart(unsigned int cpu)
  340. {
  341. return per_cpu(cpu_state, cpu) == CPU_UP_PREPARE;
  342. }
  343. #endif
  344. static void cpu_idle_thread_init(unsigned int cpu, struct task_struct *idle)
  345. {
  346. struct thread_info *ti = task_thread_info(idle);
  347. #ifdef CONFIG_PPC64
  348. paca[cpu].__current = idle;
  349. paca[cpu].kstack = (unsigned long)ti + THREAD_SIZE - STACK_FRAME_OVERHEAD;
  350. #endif
  351. ti->cpu = cpu;
  352. secondary_ti = current_set[cpu] = ti;
  353. }
  354. int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
  355. {
  356. int rc, c;
  357. if (smp_ops == NULL ||
  358. (smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu)))
  359. return -EINVAL;
  360. cpu_idle_thread_init(cpu, tidle);
  361. /* Make sure callin-map entry is 0 (can be leftover a CPU
  362. * hotplug
  363. */
  364. cpu_callin_map[cpu] = 0;
  365. /* The information for processor bringup must
  366. * be written out to main store before we release
  367. * the processor.
  368. */
  369. smp_mb();
  370. /* wake up cpus */
  371. DBG("smp: kicking cpu %d\n", cpu);
  372. rc = smp_ops->kick_cpu(cpu);
  373. if (rc) {
  374. pr_err("smp: failed starting cpu %d (rc %d)\n", cpu, rc);
  375. return rc;
  376. }
  377. /*
  378. * wait to see if the cpu made a callin (is actually up).
  379. * use this value that I found through experimentation.
  380. * -- Cort
  381. */
  382. if (system_state < SYSTEM_RUNNING)
  383. for (c = 50000; c && !cpu_callin_map[cpu]; c--)
  384. udelay(100);
  385. #ifdef CONFIG_HOTPLUG_CPU
  386. else
  387. /*
  388. * CPUs can take much longer to come up in the
  389. * hotplug case. Wait five seconds.
  390. */
  391. for (c = 5000; c && !cpu_callin_map[cpu]; c--)
  392. msleep(1);
  393. #endif
  394. if (!cpu_callin_map[cpu]) {
  395. printk(KERN_ERR "Processor %u is stuck.\n", cpu);
  396. return -ENOENT;
  397. }
  398. DBG("Processor %u found.\n", cpu);
  399. if (smp_ops->give_timebase)
  400. smp_ops->give_timebase();
  401. /* Wait until cpu puts itself in the online map */
  402. while (!cpu_online(cpu))
  403. cpu_relax();
  404. return 0;
  405. }
  406. /* Return the value of the reg property corresponding to the given
  407. * logical cpu.
  408. */
  409. int cpu_to_core_id(int cpu)
  410. {
  411. struct device_node *np;
  412. const int *reg;
  413. int id = -1;
  414. np = of_get_cpu_node(cpu, NULL);
  415. if (!np)
  416. goto out;
  417. reg = of_get_property(np, "reg", NULL);
  418. if (!reg)
  419. goto out;
  420. id = *reg;
  421. out:
  422. of_node_put(np);
  423. return id;
  424. }
  425. /* Helper routines for cpu to core mapping */
  426. int cpu_core_index_of_thread(int cpu)
  427. {
  428. return cpu >> threads_shift;
  429. }
  430. EXPORT_SYMBOL_GPL(cpu_core_index_of_thread);
  431. int cpu_first_thread_of_core(int core)
  432. {
  433. return core << threads_shift;
  434. }
  435. EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
  436. /* Must be called when no change can occur to cpu_present_mask,
  437. * i.e. during cpu online or offline.
  438. */
  439. static struct device_node *cpu_to_l2cache(int cpu)
  440. {
  441. struct device_node *np;
  442. struct device_node *cache;
  443. if (!cpu_present(cpu))
  444. return NULL;
  445. np = of_get_cpu_node(cpu, NULL);
  446. if (np == NULL)
  447. return NULL;
  448. cache = of_find_next_cache_node(np);
  449. of_node_put(np);
  450. return cache;
  451. }
  452. /* Activate a secondary processor. */
  453. void __devinit start_secondary(void *unused)
  454. {
  455. unsigned int cpu = smp_processor_id();
  456. struct device_node *l2_cache;
  457. int i, base;
  458. atomic_inc(&init_mm.mm_count);
  459. current->active_mm = &init_mm;
  460. smp_store_cpu_info(cpu);
  461. set_dec(tb_ticks_per_jiffy);
  462. preempt_disable();
  463. cpu_callin_map[cpu] = 1;
  464. if (smp_ops->setup_cpu)
  465. smp_ops->setup_cpu(cpu);
  466. if (smp_ops->take_timebase)
  467. smp_ops->take_timebase();
  468. secondary_cpu_time_init();
  469. #ifdef CONFIG_PPC64
  470. if (system_state == SYSTEM_RUNNING)
  471. vdso_data->processorCount++;
  472. #endif
  473. ipi_call_lock();
  474. notify_cpu_starting(cpu);
  475. set_cpu_online(cpu, true);
  476. /* Update sibling maps */
  477. base = cpu_first_thread_sibling(cpu);
  478. for (i = 0; i < threads_per_core; i++) {
  479. if (cpu_is_offline(base + i))
  480. continue;
  481. cpumask_set_cpu(cpu, cpu_sibling_mask(base + i));
  482. cpumask_set_cpu(base + i, cpu_sibling_mask(cpu));
  483. /* cpu_core_map should be a superset of
  484. * cpu_sibling_map even if we don't have cache
  485. * information, so update the former here, too.
  486. */
  487. cpumask_set_cpu(cpu, cpu_core_mask(base + i));
  488. cpumask_set_cpu(base + i, cpu_core_mask(cpu));
  489. }
  490. l2_cache = cpu_to_l2cache(cpu);
  491. for_each_online_cpu(i) {
  492. struct device_node *np = cpu_to_l2cache(i);
  493. if (!np)
  494. continue;
  495. if (np == l2_cache) {
  496. cpumask_set_cpu(cpu, cpu_core_mask(i));
  497. cpumask_set_cpu(i, cpu_core_mask(cpu));
  498. }
  499. of_node_put(np);
  500. }
  501. of_node_put(l2_cache);
  502. ipi_call_unlock();
  503. local_irq_enable();
  504. cpu_idle();
  505. BUG();
  506. }
  507. int setup_profiling_timer(unsigned int multiplier)
  508. {
  509. return 0;
  510. }
  511. void __init smp_cpus_done(unsigned int max_cpus)
  512. {
  513. cpumask_var_t old_mask;
  514. /* We want the setup_cpu() here to be called from CPU 0, but our
  515. * init thread may have been "borrowed" by another CPU in the meantime
  516. * se we pin us down to CPU 0 for a short while
  517. */
  518. alloc_cpumask_var(&old_mask, GFP_NOWAIT);
  519. cpumask_copy(old_mask, tsk_cpus_allowed(current));
  520. set_cpus_allowed_ptr(current, cpumask_of(boot_cpuid));
  521. if (smp_ops && smp_ops->setup_cpu)
  522. smp_ops->setup_cpu(boot_cpuid);
  523. set_cpus_allowed_ptr(current, old_mask);
  524. free_cpumask_var(old_mask);
  525. if (smp_ops && smp_ops->bringup_done)
  526. smp_ops->bringup_done();
  527. dump_numa_cpu_topology();
  528. }
  529. int arch_sd_sibling_asym_packing(void)
  530. {
  531. if (cpu_has_feature(CPU_FTR_ASYM_SMT)) {
  532. printk_once(KERN_INFO "Enabling Asymmetric SMT scheduling\n");
  533. return SD_ASYM_PACKING;
  534. }
  535. return 0;
  536. }
  537. #ifdef CONFIG_HOTPLUG_CPU
  538. int __cpu_disable(void)
  539. {
  540. struct device_node *l2_cache;
  541. int cpu = smp_processor_id();
  542. int base, i;
  543. int err;
  544. if (!smp_ops->cpu_disable)
  545. return -ENOSYS;
  546. err = smp_ops->cpu_disable();
  547. if (err)
  548. return err;
  549. /* Update sibling maps */
  550. base = cpu_first_thread_sibling(cpu);
  551. for (i = 0; i < threads_per_core; i++) {
  552. cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i));
  553. cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu));
  554. cpumask_clear_cpu(cpu, cpu_core_mask(base + i));
  555. cpumask_clear_cpu(base + i, cpu_core_mask(cpu));
  556. }
  557. l2_cache = cpu_to_l2cache(cpu);
  558. for_each_present_cpu(i) {
  559. struct device_node *np = cpu_to_l2cache(i);
  560. if (!np)
  561. continue;
  562. if (np == l2_cache) {
  563. cpumask_clear_cpu(cpu, cpu_core_mask(i));
  564. cpumask_clear_cpu(i, cpu_core_mask(cpu));
  565. }
  566. of_node_put(np);
  567. }
  568. of_node_put(l2_cache);
  569. return 0;
  570. }
  571. void __cpu_die(unsigned int cpu)
  572. {
  573. if (smp_ops->cpu_die)
  574. smp_ops->cpu_die(cpu);
  575. }
  576. static DEFINE_MUTEX(powerpc_cpu_hotplug_driver_mutex);
  577. void cpu_hotplug_driver_lock()
  578. {
  579. mutex_lock(&powerpc_cpu_hotplug_driver_mutex);
  580. }
  581. void cpu_hotplug_driver_unlock()
  582. {
  583. mutex_unlock(&powerpc_cpu_hotplug_driver_mutex);
  584. }
  585. void cpu_die(void)
  586. {
  587. if (ppc_md.cpu_die)
  588. ppc_md.cpu_die();
  589. /* If we return, we re-enter start_secondary */
  590. start_secondary_resume();
  591. }
  592. #endif