smp.c 15 KB

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