smpboot.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315
  1. /*
  2. * x86 SMP booting functions
  3. *
  4. * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk>
  5. * (c) 1998, 1999, 2000, 2009 Ingo Molnar <mingo@redhat.com>
  6. * Copyright 2001 Andi Kleen, SuSE Labs.
  7. *
  8. * Much of the core SMP work is based on previous work by Thomas Radke, to
  9. * whom a great many thanks are extended.
  10. *
  11. * Thanks to Intel for making available several different Pentium,
  12. * Pentium Pro and Pentium-II/Xeon MP machines.
  13. * Original development of Linux SMP code supported by Caldera.
  14. *
  15. * This code is released under the GNU General Public License version 2 or
  16. * later.
  17. *
  18. * Fixes
  19. * Felix Koop : NR_CPUS used properly
  20. * Jose Renau : Handle single CPU case.
  21. * Alan Cox : By repeated request 8) - Total BogoMIPS report.
  22. * Greg Wright : Fix for kernel stacks panic.
  23. * Erich Boleyn : MP v1.4 and additional changes.
  24. * Matthias Sattler : Changes for 2.1 kernel map.
  25. * Michel Lespinasse : Changes for 2.1 kernel map.
  26. * Michael Chastain : Change trampoline.S to gnu as.
  27. * Alan Cox : Dumb bug: 'B' step PPro's are fine
  28. * Ingo Molnar : Added APIC timers, based on code
  29. * from Jose Renau
  30. * Ingo Molnar : various cleanups and rewrites
  31. * Tigran Aivazian : fixed "0.00 in /proc/uptime on SMP" bug.
  32. * Maciej W. Rozycki : Bits for genuine 82489DX APICs
  33. * Andi Kleen : Changed for SMP boot into long mode.
  34. * Martin J. Bligh : Added support for multi-quad systems
  35. * Dave Jones : Report invalid combinations of Athlon CPUs.
  36. * Rusty Russell : Hacked into shape for new "hotplug" boot process.
  37. * Andi Kleen : Converted to new state machine.
  38. * Ashok Raj : CPU hotplug support
  39. * Glauber Costa : i386 and x86_64 integration
  40. */
  41. #include <linux/init.h>
  42. #include <linux/smp.h>
  43. #include <linux/module.h>
  44. #include <linux/sched.h>
  45. #include <linux/percpu.h>
  46. #include <linux/bootmem.h>
  47. #include <linux/err.h>
  48. #include <linux/nmi.h>
  49. #include <asm/acpi.h>
  50. #include <asm/desc.h>
  51. #include <asm/nmi.h>
  52. #include <asm/irq.h>
  53. #include <asm/idle.h>
  54. #include <asm/trampoline.h>
  55. #include <asm/cpu.h>
  56. #include <asm/numa.h>
  57. #include <asm/pgtable.h>
  58. #include <asm/tlbflush.h>
  59. #include <asm/mtrr.h>
  60. #include <asm/vmi.h>
  61. #include <asm/apic.h>
  62. #include <asm/setup.h>
  63. #include <asm/uv/uv.h>
  64. #include <linux/mc146818rtc.h>
  65. #include <asm/smpboot_hooks.h>
  66. #ifdef CONFIG_X86_32
  67. u8 apicid_2_node[MAX_APICID];
  68. static int low_mappings;
  69. #endif
  70. /* State of each CPU */
  71. DEFINE_PER_CPU(int, cpu_state) = { 0 };
  72. /* Store all idle threads, this can be reused instead of creating
  73. * a new thread. Also avoids complicated thread destroy functionality
  74. * for idle threads.
  75. */
  76. #ifdef CONFIG_HOTPLUG_CPU
  77. /*
  78. * Needed only for CONFIG_HOTPLUG_CPU because __cpuinitdata is
  79. * removed after init for !CONFIG_HOTPLUG_CPU.
  80. */
  81. static DEFINE_PER_CPU(struct task_struct *, idle_thread_array);
  82. #define get_idle_for_cpu(x) (per_cpu(idle_thread_array, x))
  83. #define set_idle_for_cpu(x, p) (per_cpu(idle_thread_array, x) = (p))
  84. #else
  85. static struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ;
  86. #define get_idle_for_cpu(x) (idle_thread_array[(x)])
  87. #define set_idle_for_cpu(x, p) (idle_thread_array[(x)] = (p))
  88. #endif
  89. /* Number of siblings per CPU package */
  90. int smp_num_siblings = 1;
  91. EXPORT_SYMBOL(smp_num_siblings);
  92. /* Last level cache ID of each logical CPU */
  93. DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID;
  94. /* representing HT siblings of each logical CPU */
  95. DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
  96. EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
  97. /* representing HT and core siblings of each logical CPU */
  98. DEFINE_PER_CPU(cpumask_t, cpu_core_map);
  99. EXPORT_PER_CPU_SYMBOL(cpu_core_map);
  100. /* Per CPU bogomips and other parameters */
  101. DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
  102. EXPORT_PER_CPU_SYMBOL(cpu_info);
  103. atomic_t init_deasserted;
  104. #if defined(CONFIG_NUMA) && defined(CONFIG_X86_32)
  105. /* which logical CPUs are on which nodes */
  106. cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly =
  107. { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };
  108. EXPORT_SYMBOL(node_to_cpumask_map);
  109. /* which node each logical CPU is on */
  110. int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 };
  111. EXPORT_SYMBOL(cpu_to_node_map);
  112. /* set up a mapping between cpu and node. */
  113. static void map_cpu_to_node(int cpu, int node)
  114. {
  115. printk(KERN_INFO "Mapping cpu %d to node %d\n", cpu, node);
  116. cpumask_set_cpu(cpu, &node_to_cpumask_map[node]);
  117. cpu_to_node_map[cpu] = node;
  118. }
  119. /* undo a mapping between cpu and node. */
  120. static void unmap_cpu_to_node(int cpu)
  121. {
  122. int node;
  123. printk(KERN_INFO "Unmapping cpu %d from all nodes\n", cpu);
  124. for (node = 0; node < MAX_NUMNODES; node++)
  125. cpumask_clear_cpu(cpu, &node_to_cpumask_map[node]);
  126. cpu_to_node_map[cpu] = 0;
  127. }
  128. #else /* !(CONFIG_NUMA && CONFIG_X86_32) */
  129. #define map_cpu_to_node(cpu, node) ({})
  130. #define unmap_cpu_to_node(cpu) ({})
  131. #endif
  132. #ifdef CONFIG_X86_32
  133. static int boot_cpu_logical_apicid;
  134. u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly =
  135. { [0 ... NR_CPUS-1] = BAD_APICID };
  136. static void map_cpu_to_logical_apicid(void)
  137. {
  138. int cpu = smp_processor_id();
  139. int apicid = logical_smp_processor_id();
  140. int node = apic->apicid_to_node(apicid);
  141. if (!node_online(node))
  142. node = first_online_node;
  143. cpu_2_logical_apicid[cpu] = apicid;
  144. map_cpu_to_node(cpu, node);
  145. }
  146. void numa_remove_cpu(int cpu)
  147. {
  148. cpu_2_logical_apicid[cpu] = BAD_APICID;
  149. unmap_cpu_to_node(cpu);
  150. }
  151. #else
  152. #define map_cpu_to_logical_apicid() do {} while (0)
  153. #endif
  154. /*
  155. * Report back to the Boot Processor.
  156. * Running on AP.
  157. */
  158. static void __cpuinit smp_callin(void)
  159. {
  160. int cpuid, phys_id;
  161. unsigned long timeout;
  162. /*
  163. * If waken up by an INIT in an 82489DX configuration
  164. * we may get here before an INIT-deassert IPI reaches
  165. * our local APIC. We have to wait for the IPI or we'll
  166. * lock up on an APIC access.
  167. */
  168. if (apic->wait_for_init_deassert)
  169. apic->wait_for_init_deassert(&init_deasserted);
  170. /*
  171. * (This works even if the APIC is not enabled.)
  172. */
  173. phys_id = read_apic_id();
  174. cpuid = smp_processor_id();
  175. if (cpumask_test_cpu(cpuid, cpu_callin_mask)) {
  176. panic("%s: phys CPU#%d, CPU#%d already present??\n", __func__,
  177. phys_id, cpuid);
  178. }
  179. pr_debug("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid, phys_id);
  180. /*
  181. * STARTUP IPIs are fragile beasts as they might sometimes
  182. * trigger some glue motherboard logic. Complete APIC bus
  183. * silence for 1 second, this overestimates the time the
  184. * boot CPU is spending to send the up to 2 STARTUP IPIs
  185. * by a factor of two. This should be enough.
  186. */
  187. /*
  188. * Waiting 2s total for startup (udelay is not yet working)
  189. */
  190. timeout = jiffies + 2*HZ;
  191. while (time_before(jiffies, timeout)) {
  192. /*
  193. * Has the boot CPU finished it's STARTUP sequence?
  194. */
  195. if (cpumask_test_cpu(cpuid, cpu_callout_mask))
  196. break;
  197. cpu_relax();
  198. }
  199. if (!time_before(jiffies, timeout)) {
  200. panic("%s: CPU%d started up but did not get a callout!\n",
  201. __func__, cpuid);
  202. }
  203. /*
  204. * the boot CPU has finished the init stage and is spinning
  205. * on callin_map until we finish. We are free to set up this
  206. * CPU, first the APIC. (this is probably redundant on most
  207. * boards)
  208. */
  209. pr_debug("CALLIN, before setup_local_APIC().\n");
  210. if (apic->smp_callin_clear_local_apic)
  211. apic->smp_callin_clear_local_apic();
  212. setup_local_APIC();
  213. end_local_APIC_setup();
  214. map_cpu_to_logical_apicid();
  215. notify_cpu_starting(cpuid);
  216. /*
  217. * Get our bogomips.
  218. *
  219. * Need to enable IRQs because it can take longer and then
  220. * the NMI watchdog might kill us.
  221. */
  222. local_irq_enable();
  223. calibrate_delay();
  224. local_irq_disable();
  225. pr_debug("Stack at about %p\n", &cpuid);
  226. /*
  227. * Save our processor parameters
  228. */
  229. smp_store_cpu_info(cpuid);
  230. /*
  231. * Allow the master to continue.
  232. */
  233. cpumask_set_cpu(cpuid, cpu_callin_mask);
  234. }
  235. /*
  236. * Activate a secondary processor.
  237. */
  238. notrace static void __cpuinit start_secondary(void *unused)
  239. {
  240. /*
  241. * Don't put *anything* before cpu_init(), SMP booting is too
  242. * fragile that we want to limit the things done here to the
  243. * most necessary things.
  244. */
  245. vmi_bringup();
  246. cpu_init();
  247. preempt_disable();
  248. smp_callin();
  249. /* otherwise gcc will move up smp_processor_id before the cpu_init */
  250. barrier();
  251. /*
  252. * Check TSC synchronization with the BP:
  253. */
  254. check_tsc_sync_target();
  255. if (nmi_watchdog == NMI_IO_APIC) {
  256. disable_8259A_irq(0);
  257. enable_NMI_through_LVT0();
  258. enable_8259A_irq(0);
  259. }
  260. #ifdef CONFIG_X86_32
  261. while (low_mappings)
  262. cpu_relax();
  263. __flush_tlb_all();
  264. #endif
  265. /* This must be done before setting cpu_online_map */
  266. set_cpu_sibling_map(raw_smp_processor_id());
  267. wmb();
  268. /*
  269. * We need to hold call_lock, so there is no inconsistency
  270. * between the time smp_call_function() determines number of
  271. * IPI recipients, and the time when the determination is made
  272. * for which cpus receive the IPI. Holding this
  273. * lock helps us to not include this cpu in a currently in progress
  274. * smp_call_function().
  275. *
  276. * We need to hold vector_lock so there the set of online cpus
  277. * does not change while we are assigning vectors to cpus. Holding
  278. * this lock ensures we don't half assign or remove an irq from a cpu.
  279. */
  280. ipi_call_lock();
  281. lock_vector_lock();
  282. __setup_vector_irq(smp_processor_id());
  283. set_cpu_online(smp_processor_id(), true);
  284. unlock_vector_lock();
  285. ipi_call_unlock();
  286. per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
  287. /* enable local interrupts */
  288. local_irq_enable();
  289. setup_secondary_clock();
  290. wmb();
  291. cpu_idle();
  292. }
  293. /*
  294. * The bootstrap kernel entry code has set these up. Save them for
  295. * a given CPU
  296. */
  297. void __cpuinit smp_store_cpu_info(int id)
  298. {
  299. struct cpuinfo_x86 *c = &cpu_data(id);
  300. *c = boot_cpu_data;
  301. c->cpu_index = id;
  302. if (id != 0)
  303. identify_secondary_cpu(c);
  304. }
  305. void __cpuinit set_cpu_sibling_map(int cpu)
  306. {
  307. int i;
  308. struct cpuinfo_x86 *c = &cpu_data(cpu);
  309. cpumask_set_cpu(cpu, cpu_sibling_setup_mask);
  310. if (smp_num_siblings > 1) {
  311. for_each_cpu(i, cpu_sibling_setup_mask) {
  312. struct cpuinfo_x86 *o = &cpu_data(i);
  313. if (c->phys_proc_id == o->phys_proc_id &&
  314. c->cpu_core_id == o->cpu_core_id) {
  315. cpumask_set_cpu(i, cpu_sibling_mask(cpu));
  316. cpumask_set_cpu(cpu, cpu_sibling_mask(i));
  317. cpumask_set_cpu(i, cpu_core_mask(cpu));
  318. cpumask_set_cpu(cpu, cpu_core_mask(i));
  319. cpumask_set_cpu(i, &c->llc_shared_map);
  320. cpumask_set_cpu(cpu, &o->llc_shared_map);
  321. }
  322. }
  323. } else {
  324. cpumask_set_cpu(cpu, cpu_sibling_mask(cpu));
  325. }
  326. cpumask_set_cpu(cpu, &c->llc_shared_map);
  327. if (current_cpu_data.x86_max_cores == 1) {
  328. cpumask_copy(cpu_core_mask(cpu), cpu_sibling_mask(cpu));
  329. c->booted_cores = 1;
  330. return;
  331. }
  332. for_each_cpu(i, cpu_sibling_setup_mask) {
  333. if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&
  334. per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {
  335. cpumask_set_cpu(i, &c->llc_shared_map);
  336. cpumask_set_cpu(cpu, &cpu_data(i).llc_shared_map);
  337. }
  338. if (c->phys_proc_id == cpu_data(i).phys_proc_id) {
  339. cpumask_set_cpu(i, cpu_core_mask(cpu));
  340. cpumask_set_cpu(cpu, cpu_core_mask(i));
  341. /*
  342. * Does this new cpu bringup a new core?
  343. */
  344. if (cpumask_weight(cpu_sibling_mask(cpu)) == 1) {
  345. /*
  346. * for each core in package, increment
  347. * the booted_cores for this new cpu
  348. */
  349. if (cpumask_first(cpu_sibling_mask(i)) == i)
  350. c->booted_cores++;
  351. /*
  352. * increment the core count for all
  353. * the other cpus in this package
  354. */
  355. if (i != cpu)
  356. cpu_data(i).booted_cores++;
  357. } else if (i != cpu && !c->booted_cores)
  358. c->booted_cores = cpu_data(i).booted_cores;
  359. }
  360. }
  361. }
  362. /* maps the cpu to the sched domain representing multi-core */
  363. const struct cpumask *cpu_coregroup_mask(int cpu)
  364. {
  365. struct cpuinfo_x86 *c = &cpu_data(cpu);
  366. /*
  367. * For perf, we return last level cache shared map.
  368. * And for power savings, we return cpu_core_map
  369. */
  370. if (sched_mc_power_savings || sched_smt_power_savings)
  371. return cpu_core_mask(cpu);
  372. else
  373. return &c->llc_shared_map;
  374. }
  375. static void impress_friends(void)
  376. {
  377. int cpu;
  378. unsigned long bogosum = 0;
  379. /*
  380. * Allow the user to impress friends.
  381. */
  382. pr_debug("Before bogomips.\n");
  383. for_each_possible_cpu(cpu)
  384. if (cpumask_test_cpu(cpu, cpu_callout_mask))
  385. bogosum += cpu_data(cpu).loops_per_jiffy;
  386. printk(KERN_INFO
  387. "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
  388. num_online_cpus(),
  389. bogosum/(500000/HZ),
  390. (bogosum/(5000/HZ))%100);
  391. pr_debug("Before bogocount - setting activated=1.\n");
  392. }
  393. void __inquire_remote_apic(int apicid)
  394. {
  395. unsigned i, regs[] = { APIC_ID >> 4, APIC_LVR >> 4, APIC_SPIV >> 4 };
  396. char *names[] = { "ID", "VERSION", "SPIV" };
  397. int timeout;
  398. u32 status;
  399. printk(KERN_INFO "Inquiring remote APIC 0x%x...\n", apicid);
  400. for (i = 0; i < ARRAY_SIZE(regs); i++) {
  401. printk(KERN_INFO "... APIC 0x%x %s: ", apicid, names[i]);
  402. /*
  403. * Wait for idle.
  404. */
  405. status = safe_apic_wait_icr_idle();
  406. if (status)
  407. printk(KERN_CONT
  408. "a previous APIC delivery may have failed\n");
  409. apic_icr_write(APIC_DM_REMRD | regs[i], apicid);
  410. timeout = 0;
  411. do {
  412. udelay(100);
  413. status = apic_read(APIC_ICR) & APIC_ICR_RR_MASK;
  414. } while (status == APIC_ICR_RR_INPROG && timeout++ < 1000);
  415. switch (status) {
  416. case APIC_ICR_RR_VALID:
  417. status = apic_read(APIC_RRR);
  418. printk(KERN_CONT "%08x\n", status);
  419. break;
  420. default:
  421. printk(KERN_CONT "failed\n");
  422. }
  423. }
  424. }
  425. /*
  426. * Poke the other CPU in the eye via NMI to wake it up. Remember that the normal
  427. * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this
  428. * won't ... remember to clear down the APIC, etc later.
  429. */
  430. int __devinit
  431. wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip)
  432. {
  433. unsigned long send_status, accept_status = 0;
  434. int maxlvt;
  435. /* Target chip */
  436. /* Boot on the stack */
  437. /* Kick the second */
  438. apic_icr_write(APIC_DM_NMI | apic->dest_logical, logical_apicid);
  439. pr_debug("Waiting for send to finish...\n");
  440. send_status = safe_apic_wait_icr_idle();
  441. /*
  442. * Give the other CPU some time to accept the IPI.
  443. */
  444. udelay(200);
  445. if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) {
  446. maxlvt = lapic_get_maxlvt();
  447. if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
  448. apic_write(APIC_ESR, 0);
  449. accept_status = (apic_read(APIC_ESR) & 0xEF);
  450. }
  451. pr_debug("NMI sent.\n");
  452. if (send_status)
  453. printk(KERN_ERR "APIC never delivered???\n");
  454. if (accept_status)
  455. printk(KERN_ERR "APIC delivery error (%lx).\n", accept_status);
  456. return (send_status | accept_status);
  457. }
  458. int __devinit
  459. wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
  460. {
  461. unsigned long send_status, accept_status = 0;
  462. int maxlvt, num_starts, j;
  463. maxlvt = lapic_get_maxlvt();
  464. /*
  465. * Be paranoid about clearing APIC errors.
  466. */
  467. if (APIC_INTEGRATED(apic_version[phys_apicid])) {
  468. if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
  469. apic_write(APIC_ESR, 0);
  470. apic_read(APIC_ESR);
  471. }
  472. pr_debug("Asserting INIT.\n");
  473. /*
  474. * Turn INIT on target chip
  475. */
  476. /*
  477. * Send IPI
  478. */
  479. apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT,
  480. phys_apicid);
  481. pr_debug("Waiting for send to finish...\n");
  482. send_status = safe_apic_wait_icr_idle();
  483. mdelay(10);
  484. pr_debug("Deasserting INIT.\n");
  485. /* Target chip */
  486. /* Send IPI */
  487. apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid);
  488. pr_debug("Waiting for send to finish...\n");
  489. send_status = safe_apic_wait_icr_idle();
  490. mb();
  491. atomic_set(&init_deasserted, 1);
  492. /*
  493. * Should we send STARTUP IPIs ?
  494. *
  495. * Determine this based on the APIC version.
  496. * If we don't have an integrated APIC, don't send the STARTUP IPIs.
  497. */
  498. if (APIC_INTEGRATED(apic_version[phys_apicid]))
  499. num_starts = 2;
  500. else
  501. num_starts = 0;
  502. /*
  503. * Paravirt / VMI wants a startup IPI hook here to set up the
  504. * target processor state.
  505. */
  506. startup_ipi_hook(phys_apicid, (unsigned long) start_secondary,
  507. (unsigned long)stack_start.sp);
  508. /*
  509. * Run STARTUP IPI loop.
  510. */
  511. pr_debug("#startup loops: %d.\n", num_starts);
  512. for (j = 1; j <= num_starts; j++) {
  513. pr_debug("Sending STARTUP #%d.\n", j);
  514. if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
  515. apic_write(APIC_ESR, 0);
  516. apic_read(APIC_ESR);
  517. pr_debug("After apic_write.\n");
  518. /*
  519. * STARTUP IPI
  520. */
  521. /* Target chip */
  522. /* Boot on the stack */
  523. /* Kick the second */
  524. apic_icr_write(APIC_DM_STARTUP | (start_eip >> 12),
  525. phys_apicid);
  526. /*
  527. * Give the other CPU some time to accept the IPI.
  528. */
  529. udelay(300);
  530. pr_debug("Startup point 1.\n");
  531. pr_debug("Waiting for send to finish...\n");
  532. send_status = safe_apic_wait_icr_idle();
  533. /*
  534. * Give the other CPU some time to accept the IPI.
  535. */
  536. udelay(200);
  537. if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
  538. apic_write(APIC_ESR, 0);
  539. accept_status = (apic_read(APIC_ESR) & 0xEF);
  540. if (send_status || accept_status)
  541. break;
  542. }
  543. pr_debug("After Startup.\n");
  544. if (send_status)
  545. printk(KERN_ERR "APIC never delivered???\n");
  546. if (accept_status)
  547. printk(KERN_ERR "APIC delivery error (%lx).\n", accept_status);
  548. return (send_status | accept_status);
  549. }
  550. struct create_idle {
  551. struct work_struct work;
  552. struct task_struct *idle;
  553. struct completion done;
  554. int cpu;
  555. };
  556. static void __cpuinit do_fork_idle(struct work_struct *work)
  557. {
  558. struct create_idle *c_idle =
  559. container_of(work, struct create_idle, work);
  560. c_idle->idle = fork_idle(c_idle->cpu);
  561. complete(&c_idle->done);
  562. }
  563. /*
  564. * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
  565. * (ie clustered apic addressing mode), this is a LOGICAL apic ID.
  566. * Returns zero if CPU booted OK, else error code from
  567. * ->wakeup_secondary_cpu.
  568. */
  569. static int __cpuinit do_boot_cpu(int apicid, int cpu)
  570. {
  571. unsigned long boot_error = 0;
  572. unsigned long start_ip;
  573. int timeout;
  574. struct create_idle c_idle = {
  575. .cpu = cpu,
  576. .done = COMPLETION_INITIALIZER_ONSTACK(c_idle.done),
  577. };
  578. INIT_WORK(&c_idle.work, do_fork_idle);
  579. alternatives_smp_switch(1);
  580. c_idle.idle = get_idle_for_cpu(cpu);
  581. /*
  582. * We can't use kernel_thread since we must avoid to
  583. * reschedule the child.
  584. */
  585. if (c_idle.idle) {
  586. c_idle.idle->thread.sp = (unsigned long) (((struct pt_regs *)
  587. (THREAD_SIZE + task_stack_page(c_idle.idle))) - 1);
  588. init_idle(c_idle.idle, cpu);
  589. goto do_rest;
  590. }
  591. if (!keventd_up() || current_is_keventd())
  592. c_idle.work.func(&c_idle.work);
  593. else {
  594. schedule_work(&c_idle.work);
  595. wait_for_completion(&c_idle.done);
  596. }
  597. if (IS_ERR(c_idle.idle)) {
  598. printk("failed fork for CPU %d\n", cpu);
  599. return PTR_ERR(c_idle.idle);
  600. }
  601. set_idle_for_cpu(cpu, c_idle.idle);
  602. do_rest:
  603. per_cpu(current_task, cpu) = c_idle.idle;
  604. #ifdef CONFIG_X86_32
  605. /* Stack for startup_32 can be just as for start_secondary onwards */
  606. irq_ctx_init(cpu);
  607. #else
  608. clear_tsk_thread_flag(c_idle.idle, TIF_FORK);
  609. initial_gs = per_cpu_offset(cpu);
  610. per_cpu(kernel_stack, cpu) =
  611. (unsigned long)task_stack_page(c_idle.idle) -
  612. KERNEL_STACK_OFFSET + THREAD_SIZE;
  613. #endif
  614. early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
  615. initial_code = (unsigned long)start_secondary;
  616. stack_start.sp = (void *) c_idle.idle->thread.sp;
  617. /* start_ip had better be page-aligned! */
  618. start_ip = setup_trampoline();
  619. /* So we see what's up */
  620. printk(KERN_INFO "Booting processor %d APIC 0x%x ip 0x%lx\n",
  621. cpu, apicid, start_ip);
  622. /*
  623. * This grunge runs the startup process for
  624. * the targeted processor.
  625. */
  626. atomic_set(&init_deasserted, 0);
  627. if (get_uv_system_type() != UV_NON_UNIQUE_APIC) {
  628. pr_debug("Setting warm reset code and vector.\n");
  629. smpboot_setup_warm_reset_vector(start_ip);
  630. /*
  631. * Be paranoid about clearing APIC errors.
  632. */
  633. if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) {
  634. apic_write(APIC_ESR, 0);
  635. apic_read(APIC_ESR);
  636. }
  637. }
  638. /*
  639. * Kick the secondary CPU. Use the method in the APIC driver
  640. * if it's defined - or use an INIT boot APIC message otherwise:
  641. */
  642. if (apic->wakeup_secondary_cpu)
  643. boot_error = apic->wakeup_secondary_cpu(apicid, start_ip);
  644. else
  645. boot_error = wakeup_secondary_cpu_via_init(apicid, start_ip);
  646. if (!boot_error) {
  647. /*
  648. * allow APs to start initializing.
  649. */
  650. pr_debug("Before Callout %d.\n", cpu);
  651. cpumask_set_cpu(cpu, cpu_callout_mask);
  652. pr_debug("After Callout %d.\n", cpu);
  653. /*
  654. * Wait 5s total for a response
  655. */
  656. for (timeout = 0; timeout < 50000; timeout++) {
  657. if (cpumask_test_cpu(cpu, cpu_callin_mask))
  658. break; /* It has booted */
  659. udelay(100);
  660. }
  661. if (cpumask_test_cpu(cpu, cpu_callin_mask)) {
  662. /* number CPUs logically, starting from 1 (BSP is 0) */
  663. pr_debug("OK.\n");
  664. printk(KERN_INFO "CPU%d: ", cpu);
  665. print_cpu_info(&cpu_data(cpu));
  666. pr_debug("CPU has booted.\n");
  667. } else {
  668. boot_error = 1;
  669. if (*((volatile unsigned char *)trampoline_base)
  670. == 0xA5)
  671. /* trampoline started but...? */
  672. printk(KERN_ERR "Stuck ??\n");
  673. else
  674. /* trampoline code not run */
  675. printk(KERN_ERR "Not responding.\n");
  676. if (apic->inquire_remote_apic)
  677. apic->inquire_remote_apic(apicid);
  678. }
  679. }
  680. if (boot_error) {
  681. /* Try to put things back the way they were before ... */
  682. numa_remove_cpu(cpu); /* was set by numa_add_cpu */
  683. /* was set by do_boot_cpu() */
  684. cpumask_clear_cpu(cpu, cpu_callout_mask);
  685. /* was set by cpu_init() */
  686. cpumask_clear_cpu(cpu, cpu_initialized_mask);
  687. set_cpu_present(cpu, false);
  688. per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID;
  689. }
  690. /* mark "stuck" area as not stuck */
  691. *((volatile unsigned long *)trampoline_base) = 0;
  692. /*
  693. * Cleanup possible dangling ends...
  694. */
  695. smpboot_restore_warm_reset_vector();
  696. return boot_error;
  697. }
  698. int __cpuinit native_cpu_up(unsigned int cpu)
  699. {
  700. int apicid = apic->cpu_present_to_apicid(cpu);
  701. unsigned long flags;
  702. int err;
  703. WARN_ON(irqs_disabled());
  704. pr_debug("++++++++++++++++++++=_---CPU UP %u\n", cpu);
  705. if (apicid == BAD_APICID || apicid == boot_cpu_physical_apicid ||
  706. !physid_isset(apicid, phys_cpu_present_map)) {
  707. printk(KERN_ERR "%s: bad cpu %d\n", __func__, cpu);
  708. return -EINVAL;
  709. }
  710. /*
  711. * Already booted CPU?
  712. */
  713. if (cpumask_test_cpu(cpu, cpu_callin_mask)) {
  714. pr_debug("do_boot_cpu %d Already started\n", cpu);
  715. return -ENOSYS;
  716. }
  717. /*
  718. * Save current MTRR state in case it was changed since early boot
  719. * (e.g. by the ACPI SMI) to initialize new CPUs with MTRRs in sync:
  720. */
  721. mtrr_save_state();
  722. per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  723. #ifdef CONFIG_X86_32
  724. /* init low mem mapping */
  725. clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
  726. min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
  727. flush_tlb_all();
  728. low_mappings = 1;
  729. err = do_boot_cpu(apicid, cpu);
  730. zap_low_mappings();
  731. low_mappings = 0;
  732. #else
  733. err = do_boot_cpu(apicid, cpu);
  734. #endif
  735. if (err) {
  736. pr_debug("do_boot_cpu failed %d\n", err);
  737. return -EIO;
  738. }
  739. /*
  740. * Check TSC synchronization with the AP (keep irqs disabled
  741. * while doing so):
  742. */
  743. local_irq_save(flags);
  744. check_tsc_sync_source(cpu);
  745. local_irq_restore(flags);
  746. while (!cpu_online(cpu)) {
  747. cpu_relax();
  748. touch_nmi_watchdog();
  749. }
  750. return 0;
  751. }
  752. /*
  753. * Fall back to non SMP mode after errors.
  754. *
  755. * RED-PEN audit/test this more. I bet there is more state messed up here.
  756. */
  757. static __init void disable_smp(void)
  758. {
  759. /* use the read/write pointers to the present and possible maps */
  760. cpumask_copy(&cpu_present_map, cpumask_of(0));
  761. cpumask_copy(&cpu_possible_map, cpumask_of(0));
  762. smpboot_clear_io_apic_irqs();
  763. if (smp_found_config)
  764. physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
  765. else
  766. physid_set_mask_of_physid(0, &phys_cpu_present_map);
  767. map_cpu_to_logical_apicid();
  768. cpumask_set_cpu(0, cpu_sibling_mask(0));
  769. cpumask_set_cpu(0, cpu_core_mask(0));
  770. }
  771. /*
  772. * Various sanity checks.
  773. */
  774. static int __init smp_sanity_check(unsigned max_cpus)
  775. {
  776. preempt_disable();
  777. #if !defined(CONFIG_X86_BIGSMP) && defined(CONFIG_X86_32)
  778. if (def_to_bigsmp && nr_cpu_ids > 8) {
  779. unsigned int cpu;
  780. unsigned nr;
  781. printk(KERN_WARNING
  782. "More than 8 CPUs detected - skipping them.\n"
  783. "Use CONFIG_X86_BIGSMP.\n");
  784. nr = 0;
  785. for_each_present_cpu(cpu) {
  786. if (nr >= 8)
  787. set_cpu_present(cpu, false);
  788. nr++;
  789. }
  790. nr = 0;
  791. for_each_possible_cpu(cpu) {
  792. if (nr >= 8)
  793. set_cpu_possible(cpu, false);
  794. nr++;
  795. }
  796. nr_cpu_ids = 8;
  797. }
  798. #endif
  799. if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) {
  800. printk(KERN_WARNING
  801. "weird, boot CPU (#%d) not listed by the BIOS.\n",
  802. hard_smp_processor_id());
  803. physid_set(hard_smp_processor_id(), phys_cpu_present_map);
  804. }
  805. /*
  806. * If we couldn't find an SMP configuration at boot time,
  807. * get out of here now!
  808. */
  809. if (!smp_found_config && !acpi_lapic) {
  810. preempt_enable();
  811. printk(KERN_NOTICE "SMP motherboard not detected.\n");
  812. disable_smp();
  813. if (APIC_init_uniprocessor())
  814. printk(KERN_NOTICE "Local APIC not detected."
  815. " Using dummy APIC emulation.\n");
  816. return -1;
  817. }
  818. /*
  819. * Should not be necessary because the MP table should list the boot
  820. * CPU too, but we do it for the sake of robustness anyway.
  821. */
  822. if (!apic->check_phys_apicid_present(boot_cpu_physical_apicid)) {
  823. printk(KERN_NOTICE
  824. "weird, boot CPU (#%d) not listed by the BIOS.\n",
  825. boot_cpu_physical_apicid);
  826. physid_set(hard_smp_processor_id(), phys_cpu_present_map);
  827. }
  828. preempt_enable();
  829. /*
  830. * If we couldn't find a local APIC, then get out of here now!
  831. */
  832. if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) &&
  833. !cpu_has_apic) {
  834. printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
  835. boot_cpu_physical_apicid);
  836. printk(KERN_ERR "... forcing use of dummy APIC emulation."
  837. "(tell your hw vendor)\n");
  838. smpboot_clear_io_apic();
  839. arch_disable_smp_support();
  840. return -1;
  841. }
  842. verify_local_APIC();
  843. /*
  844. * If SMP should be disabled, then really disable it!
  845. */
  846. if (!max_cpus) {
  847. printk(KERN_INFO "SMP mode deactivated.\n");
  848. smpboot_clear_io_apic();
  849. localise_nmi_watchdog();
  850. connect_bsp_APIC();
  851. setup_local_APIC();
  852. end_local_APIC_setup();
  853. return -1;
  854. }
  855. return 0;
  856. }
  857. static void __init smp_cpu_index_default(void)
  858. {
  859. int i;
  860. struct cpuinfo_x86 *c;
  861. for_each_possible_cpu(i) {
  862. c = &cpu_data(i);
  863. /* mark all to hotplug */
  864. c->cpu_index = nr_cpu_ids;
  865. }
  866. }
  867. /*
  868. * Prepare for SMP bootup. The MP table or ACPI has been read
  869. * earlier. Just do some sanity checking here and enable APIC mode.
  870. */
  871. void __init native_smp_prepare_cpus(unsigned int max_cpus)
  872. {
  873. preempt_disable();
  874. smp_cpu_index_default();
  875. current_cpu_data = boot_cpu_data;
  876. cpumask_copy(cpu_callin_mask, cpumask_of(0));
  877. mb();
  878. /*
  879. * Setup boot CPU information
  880. */
  881. smp_store_cpu_info(0); /* Final full version of the data */
  882. #ifdef CONFIG_X86_32
  883. boot_cpu_logical_apicid = logical_smp_processor_id();
  884. #endif
  885. current_thread_info()->cpu = 0; /* needed? */
  886. set_cpu_sibling_map(0);
  887. enable_IR_x2apic();
  888. #ifdef CONFIG_X86_64
  889. default_setup_apic_routing();
  890. #endif
  891. if (smp_sanity_check(max_cpus) < 0) {
  892. printk(KERN_INFO "SMP disabled\n");
  893. disable_smp();
  894. goto out;
  895. }
  896. preempt_disable();
  897. if (read_apic_id() != boot_cpu_physical_apicid) {
  898. panic("Boot APIC ID in local APIC unexpected (%d vs %d)",
  899. read_apic_id(), boot_cpu_physical_apicid);
  900. /* Or can we switch back to PIC here? */
  901. }
  902. preempt_enable();
  903. connect_bsp_APIC();
  904. /*
  905. * Switch from PIC to APIC mode.
  906. */
  907. setup_local_APIC();
  908. /*
  909. * Enable IO APIC before setting up error vector
  910. */
  911. if (!skip_ioapic_setup && nr_ioapics)
  912. enable_IO_APIC();
  913. end_local_APIC_setup();
  914. map_cpu_to_logical_apicid();
  915. if (apic->setup_portio_remap)
  916. apic->setup_portio_remap();
  917. smpboot_setup_io_apic();
  918. /*
  919. * Set up local APIC timer on boot CPU.
  920. */
  921. printk(KERN_INFO "CPU%d: ", 0);
  922. print_cpu_info(&cpu_data(0));
  923. setup_boot_clock();
  924. if (is_uv_system())
  925. uv_system_init();
  926. out:
  927. preempt_enable();
  928. }
  929. /*
  930. * Early setup to make printk work.
  931. */
  932. void __init native_smp_prepare_boot_cpu(void)
  933. {
  934. int me = smp_processor_id();
  935. switch_to_new_gdt(me);
  936. /* already set me in cpu_online_mask in boot_cpu_init() */
  937. cpumask_set_cpu(me, cpu_callout_mask);
  938. per_cpu(cpu_state, me) = CPU_ONLINE;
  939. }
  940. void __init native_smp_cpus_done(unsigned int max_cpus)
  941. {
  942. pr_debug("Boot done.\n");
  943. impress_friends();
  944. #ifdef CONFIG_X86_IO_APIC
  945. setup_ioapic_dest();
  946. #endif
  947. check_nmi_watchdog();
  948. }
  949. static int __initdata setup_possible_cpus = -1;
  950. static int __init _setup_possible_cpus(char *str)
  951. {
  952. get_option(&str, &setup_possible_cpus);
  953. return 0;
  954. }
  955. early_param("possible_cpus", _setup_possible_cpus);
  956. /*
  957. * cpu_possible_map should be static, it cannot change as cpu's
  958. * are onlined, or offlined. The reason is per-cpu data-structures
  959. * are allocated by some modules at init time, and dont expect to
  960. * do this dynamically on cpu arrival/departure.
  961. * cpu_present_map on the other hand can change dynamically.
  962. * In case when cpu_hotplug is not compiled, then we resort to current
  963. * behaviour, which is cpu_possible == cpu_present.
  964. * - Ashok Raj
  965. *
  966. * Three ways to find out the number of additional hotplug CPUs:
  967. * - If the BIOS specified disabled CPUs in ACPI/mptables use that.
  968. * - The user can overwrite it with possible_cpus=NUM
  969. * - Otherwise don't reserve additional CPUs.
  970. * We do this because additional CPUs waste a lot of memory.
  971. * -AK
  972. */
  973. __init void prefill_possible_map(void)
  974. {
  975. int i, possible;
  976. /* no processor from mptable or madt */
  977. if (!num_processors)
  978. num_processors = 1;
  979. if (setup_possible_cpus == -1)
  980. possible = num_processors + disabled_cpus;
  981. else
  982. possible = setup_possible_cpus;
  983. total_cpus = max_t(int, possible, num_processors + disabled_cpus);
  984. if (possible > CONFIG_NR_CPUS) {
  985. printk(KERN_WARNING
  986. "%d Processors exceeds NR_CPUS limit of %d\n",
  987. possible, CONFIG_NR_CPUS);
  988. possible = CONFIG_NR_CPUS;
  989. }
  990. printk(KERN_INFO "SMP: Allowing %d CPUs, %d hotplug CPUs\n",
  991. possible, max_t(int, possible - num_processors, 0));
  992. for (i = 0; i < possible; i++)
  993. set_cpu_possible(i, true);
  994. nr_cpu_ids = possible;
  995. }
  996. #ifdef CONFIG_HOTPLUG_CPU
  997. static void remove_siblinginfo(int cpu)
  998. {
  999. int sibling;
  1000. struct cpuinfo_x86 *c = &cpu_data(cpu);
  1001. for_each_cpu(sibling, cpu_core_mask(cpu)) {
  1002. cpumask_clear_cpu(cpu, cpu_core_mask(sibling));
  1003. /*/
  1004. * last thread sibling in this cpu core going down
  1005. */
  1006. if (cpumask_weight(cpu_sibling_mask(cpu)) == 1)
  1007. cpu_data(sibling).booted_cores--;
  1008. }
  1009. for_each_cpu(sibling, cpu_sibling_mask(cpu))
  1010. cpumask_clear_cpu(cpu, cpu_sibling_mask(sibling));
  1011. cpumask_clear(cpu_sibling_mask(cpu));
  1012. cpumask_clear(cpu_core_mask(cpu));
  1013. c->phys_proc_id = 0;
  1014. c->cpu_core_id = 0;
  1015. cpumask_clear_cpu(cpu, cpu_sibling_setup_mask);
  1016. }
  1017. static void __ref remove_cpu_from_maps(int cpu)
  1018. {
  1019. set_cpu_online(cpu, false);
  1020. cpumask_clear_cpu(cpu, cpu_callout_mask);
  1021. cpumask_clear_cpu(cpu, cpu_callin_mask);
  1022. /* was set by cpu_init() */
  1023. cpumask_clear_cpu(cpu, cpu_initialized_mask);
  1024. numa_remove_cpu(cpu);
  1025. }
  1026. void cpu_disable_common(void)
  1027. {
  1028. int cpu = smp_processor_id();
  1029. /*
  1030. * HACK:
  1031. * Allow any queued timer interrupts to get serviced
  1032. * This is only a temporary solution until we cleanup
  1033. * fixup_irqs as we do for IA64.
  1034. */
  1035. local_irq_enable();
  1036. mdelay(1);
  1037. local_irq_disable();
  1038. remove_siblinginfo(cpu);
  1039. /* It's now safe to remove this processor from the online map */
  1040. lock_vector_lock();
  1041. remove_cpu_from_maps(cpu);
  1042. unlock_vector_lock();
  1043. fixup_irqs();
  1044. }
  1045. int native_cpu_disable(void)
  1046. {
  1047. int cpu = smp_processor_id();
  1048. /*
  1049. * Perhaps use cpufreq to drop frequency, but that could go
  1050. * into generic code.
  1051. *
  1052. * We won't take down the boot processor on i386 due to some
  1053. * interrupts only being able to be serviced by the BSP.
  1054. * Especially so if we're not using an IOAPIC -zwane
  1055. */
  1056. if (cpu == 0)
  1057. return -EBUSY;
  1058. if (nmi_watchdog == NMI_LOCAL_APIC)
  1059. stop_apic_nmi_watchdog(NULL);
  1060. clear_local_APIC();
  1061. cpu_disable_common();
  1062. return 0;
  1063. }
  1064. void native_cpu_die(unsigned int cpu)
  1065. {
  1066. /* We don't do anything here: idle task is faking death itself. */
  1067. unsigned int i;
  1068. for (i = 0; i < 10; i++) {
  1069. /* They ack this in play_dead by setting CPU_DEAD */
  1070. if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
  1071. printk(KERN_INFO "CPU %d is now offline\n", cpu);
  1072. if (1 == num_online_cpus())
  1073. alternatives_smp_switch(0);
  1074. return;
  1075. }
  1076. msleep(100);
  1077. }
  1078. printk(KERN_ERR "CPU %u didn't die...\n", cpu);
  1079. }
  1080. void play_dead_common(void)
  1081. {
  1082. idle_task_exit();
  1083. reset_lazy_tlbstate();
  1084. irq_ctx_exit(raw_smp_processor_id());
  1085. c1e_remove_cpu(raw_smp_processor_id());
  1086. mb();
  1087. /* Ack it */
  1088. __get_cpu_var(cpu_state) = CPU_DEAD;
  1089. /*
  1090. * With physical CPU hotplug, we should halt the cpu
  1091. */
  1092. local_irq_disable();
  1093. }
  1094. void native_play_dead(void)
  1095. {
  1096. play_dead_common();
  1097. wbinvd_halt();
  1098. }
  1099. #else /* ... !CONFIG_HOTPLUG_CPU */
  1100. int native_cpu_disable(void)
  1101. {
  1102. return -ENOSYS;
  1103. }
  1104. void native_cpu_die(unsigned int cpu)
  1105. {
  1106. /* We said "no" in __cpu_disable */
  1107. BUG();
  1108. }
  1109. void native_play_dead(void)
  1110. {
  1111. BUG();
  1112. }
  1113. #endif