smpboot_32.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293
  1. /*
  2. * x86 SMP booting functions
  3. *
  4. * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
  5. * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
  6. *
  7. * Much of the core SMP work is based on previous work by Thomas Radke, to
  8. * whom a great many thanks are extended.
  9. *
  10. * Thanks to Intel for making available several different Pentium,
  11. * Pentium Pro and Pentium-II/Xeon MP machines.
  12. * Original development of Linux SMP code supported by Caldera.
  13. *
  14. * This code is released under the GNU General Public License version 2 or
  15. * later.
  16. *
  17. * Fixes
  18. * Felix Koop : NR_CPUS used properly
  19. * Jose Renau : Handle single CPU case.
  20. * Alan Cox : By repeated request 8) - Total BogoMIPS report.
  21. * Greg Wright : Fix for kernel stacks panic.
  22. * Erich Boleyn : MP v1.4 and additional changes.
  23. * Matthias Sattler : Changes for 2.1 kernel map.
  24. * Michel Lespinasse : Changes for 2.1 kernel map.
  25. * Michael Chastain : Change trampoline.S to gnu as.
  26. * Alan Cox : Dumb bug: 'B' step PPro's are fine
  27. * Ingo Molnar : Added APIC timers, based on code
  28. * from Jose Renau
  29. * Ingo Molnar : various cleanups and rewrites
  30. * Tigran Aivazian : fixed "0.00 in /proc/uptime on SMP" bug.
  31. * Maciej W. Rozycki : Bits for genuine 82489DX APICs
  32. * Martin J. Bligh : Added support for multi-quad systems
  33. * Dave Jones : Report invalid combinations of Athlon CPUs.
  34. * Rusty Russell : Hacked into shape for new "hotplug" boot process. */
  35. #include <linux/module.h>
  36. #include <linux/init.h>
  37. #include <linux/kernel.h>
  38. #include <linux/mm.h>
  39. #include <linux/sched.h>
  40. #include <linux/kernel_stat.h>
  41. #include <linux/bootmem.h>
  42. #include <linux/notifier.h>
  43. #include <linux/cpu.h>
  44. #include <linux/percpu.h>
  45. #include <linux/nmi.h>
  46. #include <linux/delay.h>
  47. #include <linux/mc146818rtc.h>
  48. #include <asm/tlbflush.h>
  49. #include <asm/desc.h>
  50. #include <asm/arch_hooks.h>
  51. #include <asm/nmi.h>
  52. #include <mach_apic.h>
  53. #include <mach_wakecpu.h>
  54. #include <smpboot_hooks.h>
  55. #include <asm/vmi.h>
  56. #include <asm/mtrr.h>
  57. /* Set if we find a B stepping CPU */
  58. static int __cpuinitdata smp_b_stepping;
  59. static cpumask_t smp_commenced_mask;
  60. /* which logical CPU number maps to which CPU (physical APIC ID) */
  61. u16 x86_cpu_to_apicid_init[NR_CPUS] __initdata =
  62. { [0 ... NR_CPUS-1] = BAD_APICID };
  63. void *x86_cpu_to_apicid_early_ptr;
  64. DEFINE_PER_CPU(u16, x86_cpu_to_apicid) = BAD_APICID;
  65. EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
  66. u8 apicid_2_node[MAX_APICID];
  67. /*
  68. * Trampoline 80x86 program as an array.
  69. */
  70. extern const unsigned char trampoline_data [];
  71. extern const unsigned char trampoline_end [];
  72. static unsigned char *trampoline_base;
  73. static void map_cpu_to_logical_apicid(void);
  74. /* State of each CPU. */
  75. DEFINE_PER_CPU(int, cpu_state) = { 0 };
  76. /*
  77. * Currently trivial. Write the real->protected mode
  78. * bootstrap into the page concerned. The caller
  79. * has made sure it's suitably aligned.
  80. */
  81. static unsigned long __cpuinit setup_trampoline(void)
  82. {
  83. memcpy(trampoline_base, trampoline_data, trampoline_end - trampoline_data);
  84. return virt_to_phys(trampoline_base);
  85. }
  86. /*
  87. * We are called very early to get the low memory for the
  88. * SMP bootup trampoline page.
  89. */
  90. void __init smp_alloc_memory(void)
  91. {
  92. trampoline_base = alloc_bootmem_low_pages(PAGE_SIZE);
  93. /*
  94. * Has to be in very low memory so we can execute
  95. * real-mode AP code.
  96. */
  97. if (__pa(trampoline_base) >= 0x9F000)
  98. BUG();
  99. }
  100. /*
  101. * The bootstrap kernel entry code has set these up. Save them for
  102. * a given CPU
  103. */
  104. void __cpuinit smp_store_cpu_info(int id)
  105. {
  106. struct cpuinfo_x86 *c = &cpu_data(id);
  107. *c = boot_cpu_data;
  108. c->cpu_index = id;
  109. if (id!=0)
  110. identify_secondary_cpu(c);
  111. /*
  112. * Mask B, Pentium, but not Pentium MMX
  113. */
  114. if (c->x86_vendor == X86_VENDOR_INTEL &&
  115. c->x86 == 5 &&
  116. c->x86_mask >= 1 && c->x86_mask <= 4 &&
  117. c->x86_model <= 3)
  118. /*
  119. * Remember we have B step Pentia with bugs
  120. */
  121. smp_b_stepping = 1;
  122. /*
  123. * Certain Athlons might work (for various values of 'work') in SMP
  124. * but they are not certified as MP capable.
  125. */
  126. if ((c->x86_vendor == X86_VENDOR_AMD) && (c->x86 == 6)) {
  127. if (num_possible_cpus() == 1)
  128. goto valid_k7;
  129. /* Athlon 660/661 is valid. */
  130. if ((c->x86_model==6) && ((c->x86_mask==0) || (c->x86_mask==1)))
  131. goto valid_k7;
  132. /* Duron 670 is valid */
  133. if ((c->x86_model==7) && (c->x86_mask==0))
  134. goto valid_k7;
  135. /*
  136. * Athlon 662, Duron 671, and Athlon >model 7 have capability bit.
  137. * It's worth noting that the A5 stepping (662) of some Athlon XP's
  138. * have the MP bit set.
  139. * See http://www.heise.de/newsticker/data/jow-18.10.01-000 for more.
  140. */
  141. if (((c->x86_model==6) && (c->x86_mask>=2)) ||
  142. ((c->x86_model==7) && (c->x86_mask>=1)) ||
  143. (c->x86_model> 7))
  144. if (cpu_has_mp)
  145. goto valid_k7;
  146. /* If we get here, it's not a certified SMP capable AMD system. */
  147. add_taint(TAINT_UNSAFE_SMP);
  148. }
  149. valid_k7:
  150. ;
  151. }
  152. static atomic_t init_deasserted;
  153. static void __cpuinit smp_callin(void)
  154. {
  155. int cpuid, phys_id;
  156. unsigned long timeout;
  157. /*
  158. * If waken up by an INIT in an 82489DX configuration
  159. * we may get here before an INIT-deassert IPI reaches
  160. * our local APIC. We have to wait for the IPI or we'll
  161. * lock up on an APIC access.
  162. */
  163. wait_for_init_deassert(&init_deasserted);
  164. /*
  165. * (This works even if the APIC is not enabled.)
  166. */
  167. phys_id = GET_APIC_ID(apic_read(APIC_ID));
  168. cpuid = smp_processor_id();
  169. if (cpu_isset(cpuid, cpu_callin_map)) {
  170. printk("huh, phys CPU#%d, CPU#%d already present??\n",
  171. phys_id, cpuid);
  172. BUG();
  173. }
  174. Dprintk("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid, phys_id);
  175. /*
  176. * STARTUP IPIs are fragile beasts as they might sometimes
  177. * trigger some glue motherboard logic. Complete APIC bus
  178. * silence for 1 second, this overestimates the time the
  179. * boot CPU is spending to send the up to 2 STARTUP IPIs
  180. * by a factor of two. This should be enough.
  181. */
  182. /*
  183. * Waiting 2s total for startup (udelay is not yet working)
  184. */
  185. timeout = jiffies + 2*HZ;
  186. while (time_before(jiffies, timeout)) {
  187. /*
  188. * Has the boot CPU finished it's STARTUP sequence?
  189. */
  190. if (cpu_isset(cpuid, cpu_callout_map))
  191. break;
  192. rep_nop();
  193. }
  194. if (!time_before(jiffies, timeout)) {
  195. printk("BUG: CPU%d started up but did not get a callout!\n",
  196. cpuid);
  197. BUG();
  198. }
  199. /*
  200. * the boot CPU has finished the init stage and is spinning
  201. * on callin_map until we finish. We are free to set up this
  202. * CPU, first the APIC. (this is probably redundant on most
  203. * boards)
  204. */
  205. Dprintk("CALLIN, before setup_local_APIC().\n");
  206. smp_callin_clear_local_apic();
  207. setup_local_APIC();
  208. map_cpu_to_logical_apicid();
  209. /*
  210. * Get our bogomips.
  211. */
  212. calibrate_delay();
  213. Dprintk("Stack at about %p\n",&cpuid);
  214. /*
  215. * Save our processor parameters
  216. */
  217. smp_store_cpu_info(cpuid);
  218. /*
  219. * Allow the master to continue.
  220. */
  221. cpu_set(cpuid, cpu_callin_map);
  222. }
  223. static int cpucount;
  224. /* maps the cpu to the sched domain representing multi-core */
  225. cpumask_t cpu_coregroup_map(int cpu)
  226. {
  227. struct cpuinfo_x86 *c = &cpu_data(cpu);
  228. /*
  229. * For perf, we return last level cache shared map.
  230. * And for power savings, we return cpu_core_map
  231. */
  232. if (sched_mc_power_savings || sched_smt_power_savings)
  233. return per_cpu(cpu_core_map, cpu);
  234. else
  235. return c->llc_shared_map;
  236. }
  237. /* representing cpus for which sibling maps can be computed */
  238. static cpumask_t cpu_sibling_setup_map;
  239. void __cpuinit set_cpu_sibling_map(int cpu)
  240. {
  241. int i;
  242. struct cpuinfo_x86 *c = &cpu_data(cpu);
  243. cpu_set(cpu, cpu_sibling_setup_map);
  244. if (smp_num_siblings > 1) {
  245. for_each_cpu_mask(i, cpu_sibling_setup_map) {
  246. if (c->phys_proc_id == cpu_data(i).phys_proc_id &&
  247. c->cpu_core_id == cpu_data(i).cpu_core_id) {
  248. cpu_set(i, per_cpu(cpu_sibling_map, cpu));
  249. cpu_set(cpu, per_cpu(cpu_sibling_map, i));
  250. cpu_set(i, per_cpu(cpu_core_map, cpu));
  251. cpu_set(cpu, per_cpu(cpu_core_map, i));
  252. cpu_set(i, c->llc_shared_map);
  253. cpu_set(cpu, cpu_data(i).llc_shared_map);
  254. }
  255. }
  256. } else {
  257. cpu_set(cpu, per_cpu(cpu_sibling_map, cpu));
  258. }
  259. cpu_set(cpu, c->llc_shared_map);
  260. if (current_cpu_data.x86_max_cores == 1) {
  261. per_cpu(cpu_core_map, cpu) = per_cpu(cpu_sibling_map, cpu);
  262. c->booted_cores = 1;
  263. return;
  264. }
  265. for_each_cpu_mask(i, cpu_sibling_setup_map) {
  266. if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&
  267. per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {
  268. cpu_set(i, c->llc_shared_map);
  269. cpu_set(cpu, cpu_data(i).llc_shared_map);
  270. }
  271. if (c->phys_proc_id == cpu_data(i).phys_proc_id) {
  272. cpu_set(i, per_cpu(cpu_core_map, cpu));
  273. cpu_set(cpu, per_cpu(cpu_core_map, i));
  274. /*
  275. * Does this new cpu bringup a new core?
  276. */
  277. if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) {
  278. /*
  279. * for each core in package, increment
  280. * the booted_cores for this new cpu
  281. */
  282. if (first_cpu(per_cpu(cpu_sibling_map, i)) == i)
  283. c->booted_cores++;
  284. /*
  285. * increment the core count for all
  286. * the other cpus in this package
  287. */
  288. if (i != cpu)
  289. cpu_data(i).booted_cores++;
  290. } else if (i != cpu && !c->booted_cores)
  291. c->booted_cores = cpu_data(i).booted_cores;
  292. }
  293. }
  294. }
  295. /*
  296. * Activate a secondary processor.
  297. */
  298. static void __cpuinit start_secondary(void *unused)
  299. {
  300. /*
  301. * Don't put *anything* before cpu_init(), SMP booting is too
  302. * fragile that we want to limit the things done here to the
  303. * most necessary things.
  304. */
  305. #ifdef CONFIG_VMI
  306. vmi_bringup();
  307. #endif
  308. cpu_init();
  309. preempt_disable();
  310. smp_callin();
  311. while (!cpu_isset(smp_processor_id(), smp_commenced_mask))
  312. rep_nop();
  313. /*
  314. * Check TSC synchronization with the BP:
  315. */
  316. check_tsc_sync_target();
  317. setup_secondary_clock();
  318. if (nmi_watchdog == NMI_IO_APIC) {
  319. disable_8259A_irq(0);
  320. enable_NMI_through_LVT0();
  321. enable_8259A_irq(0);
  322. }
  323. /*
  324. * low-memory mappings have been cleared, flush them from
  325. * the local TLBs too.
  326. */
  327. local_flush_tlb();
  328. /* This must be done before setting cpu_online_map */
  329. set_cpu_sibling_map(raw_smp_processor_id());
  330. wmb();
  331. /*
  332. * We need to hold call_lock, so there is no inconsistency
  333. * between the time smp_call_function() determines number of
  334. * IPI recipients, and the time when the determination is made
  335. * for which cpus receive the IPI. Holding this
  336. * lock helps us to not include this cpu in a currently in progress
  337. * smp_call_function().
  338. */
  339. lock_ipi_call_lock();
  340. cpu_set(smp_processor_id(), cpu_online_map);
  341. unlock_ipi_call_lock();
  342. per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
  343. /* We can take interrupts now: we're officially "up". */
  344. local_irq_enable();
  345. wmb();
  346. cpu_idle();
  347. }
  348. /*
  349. * Everything has been set up for the secondary
  350. * CPUs - they just need to reload everything
  351. * from the task structure
  352. * This function must not return.
  353. */
  354. void __devinit initialize_secondary(void)
  355. {
  356. /*
  357. * We don't actually need to load the full TSS,
  358. * basically just the stack pointer and the ip.
  359. */
  360. asm volatile(
  361. "movl %0,%%esp\n\t"
  362. "jmp *%1"
  363. :
  364. :"m" (current->thread.sp),"m" (current->thread.ip));
  365. }
  366. /* Static state in head.S used to set up a CPU */
  367. extern struct {
  368. void * sp;
  369. unsigned short ss;
  370. } stack_start;
  371. #ifdef CONFIG_NUMA
  372. /* which logical CPUs are on which nodes */
  373. cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly =
  374. { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE };
  375. EXPORT_SYMBOL(node_to_cpumask_map);
  376. /* which node each logical CPU is on */
  377. int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 };
  378. EXPORT_SYMBOL(cpu_to_node_map);
  379. /* set up a mapping between cpu and node. */
  380. static inline void map_cpu_to_node(int cpu, int node)
  381. {
  382. printk("Mapping cpu %d to node %d\n", cpu, node);
  383. cpu_set(cpu, node_to_cpumask_map[node]);
  384. cpu_to_node_map[cpu] = node;
  385. }
  386. /* undo a mapping between cpu and node. */
  387. static inline void unmap_cpu_to_node(int cpu)
  388. {
  389. int node;
  390. printk("Unmapping cpu %d from all nodes\n", cpu);
  391. for (node = 0; node < MAX_NUMNODES; node ++)
  392. cpu_clear(cpu, node_to_cpumask_map[node]);
  393. cpu_to_node_map[cpu] = 0;
  394. }
  395. #else /* !CONFIG_NUMA */
  396. #define map_cpu_to_node(cpu, node) ({})
  397. #define unmap_cpu_to_node(cpu) ({})
  398. #endif /* CONFIG_NUMA */
  399. u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID };
  400. static void map_cpu_to_logical_apicid(void)
  401. {
  402. int cpu = smp_processor_id();
  403. int apicid = logical_smp_processor_id();
  404. int node = apicid_to_node(apicid);
  405. if (!node_online(node))
  406. node = first_online_node;
  407. cpu_2_logical_apicid[cpu] = apicid;
  408. map_cpu_to_node(cpu, node);
  409. }
  410. static void unmap_cpu_to_logical_apicid(int cpu)
  411. {
  412. cpu_2_logical_apicid[cpu] = BAD_APICID;
  413. unmap_cpu_to_node(cpu);
  414. }
  415. static inline void __inquire_remote_apic(int apicid)
  416. {
  417. int i, regs[] = { APIC_ID >> 4, APIC_LVR >> 4, APIC_SPIV >> 4 };
  418. char *names[] = { "ID", "VERSION", "SPIV" };
  419. int timeout;
  420. unsigned long status;
  421. printk("Inquiring remote APIC #%d...\n", apicid);
  422. for (i = 0; i < ARRAY_SIZE(regs); i++) {
  423. printk("... APIC #%d %s: ", apicid, names[i]);
  424. /*
  425. * Wait for idle.
  426. */
  427. status = safe_apic_wait_icr_idle();
  428. if (status)
  429. printk("a previous APIC delivery may have failed\n");
  430. apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid));
  431. apic_write_around(APIC_ICR, APIC_DM_REMRD | regs[i]);
  432. timeout = 0;
  433. do {
  434. udelay(100);
  435. status = apic_read(APIC_ICR) & APIC_ICR_RR_MASK;
  436. } while (status == APIC_ICR_RR_INPROG && timeout++ < 1000);
  437. switch (status) {
  438. case APIC_ICR_RR_VALID:
  439. status = apic_read(APIC_RRR);
  440. printk("%lx\n", status);
  441. break;
  442. default:
  443. printk("failed\n");
  444. }
  445. }
  446. }
  447. #ifdef WAKE_SECONDARY_VIA_NMI
  448. /*
  449. * Poke the other CPU in the eye via NMI to wake it up. Remember that the normal
  450. * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this
  451. * won't ... remember to clear down the APIC, etc later.
  452. */
  453. static int __devinit
  454. wakeup_secondary_cpu(int logical_apicid, unsigned long start_eip)
  455. {
  456. unsigned long send_status, accept_status = 0;
  457. int maxlvt;
  458. /* Target chip */
  459. apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(logical_apicid));
  460. /* Boot on the stack */
  461. /* Kick the second */
  462. apic_write_around(APIC_ICR, APIC_DM_NMI | APIC_DEST_LOGICAL);
  463. Dprintk("Waiting for send to finish...\n");
  464. send_status = safe_apic_wait_icr_idle();
  465. /*
  466. * Give the other CPU some time to accept the IPI.
  467. */
  468. udelay(200);
  469. /*
  470. * Due to the Pentium erratum 3AP.
  471. */
  472. maxlvt = lapic_get_maxlvt();
  473. if (maxlvt > 3) {
  474. apic_read_around(APIC_SPIV);
  475. apic_write(APIC_ESR, 0);
  476. }
  477. accept_status = (apic_read(APIC_ESR) & 0xEF);
  478. Dprintk("NMI sent.\n");
  479. if (send_status)
  480. printk("APIC never delivered???\n");
  481. if (accept_status)
  482. printk("APIC delivery error (%lx).\n", accept_status);
  483. return (send_status | accept_status);
  484. }
  485. #endif /* WAKE_SECONDARY_VIA_NMI */
  486. #ifdef WAKE_SECONDARY_VIA_INIT
  487. static int __devinit
  488. wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip)
  489. {
  490. unsigned long send_status, accept_status = 0;
  491. int maxlvt, num_starts, j;
  492. /*
  493. * Be paranoid about clearing APIC errors.
  494. */
  495. if (APIC_INTEGRATED(apic_version[phys_apicid])) {
  496. apic_read_around(APIC_SPIV);
  497. apic_write(APIC_ESR, 0);
  498. apic_read(APIC_ESR);
  499. }
  500. Dprintk("Asserting INIT.\n");
  501. /*
  502. * Turn INIT on target chip
  503. */
  504. apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
  505. /*
  506. * Send IPI
  507. */
  508. apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT
  509. | APIC_DM_INIT);
  510. Dprintk("Waiting for send to finish...\n");
  511. send_status = safe_apic_wait_icr_idle();
  512. mdelay(10);
  513. Dprintk("Deasserting INIT.\n");
  514. /* Target chip */
  515. apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
  516. /* Send IPI */
  517. apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT);
  518. Dprintk("Waiting for send to finish...\n");
  519. send_status = safe_apic_wait_icr_idle();
  520. atomic_set(&init_deasserted, 1);
  521. /*
  522. * Should we send STARTUP IPIs ?
  523. *
  524. * Determine this based on the APIC version.
  525. * If we don't have an integrated APIC, don't send the STARTUP IPIs.
  526. */
  527. if (APIC_INTEGRATED(apic_version[phys_apicid]))
  528. num_starts = 2;
  529. else
  530. num_starts = 0;
  531. /*
  532. * Paravirt / VMI wants a startup IPI hook here to set up the
  533. * target processor state.
  534. */
  535. startup_ipi_hook(phys_apicid, (unsigned long) start_secondary,
  536. (unsigned long) stack_start.sp);
  537. /*
  538. * Run STARTUP IPI loop.
  539. */
  540. Dprintk("#startup loops: %d.\n", num_starts);
  541. maxlvt = lapic_get_maxlvt();
  542. for (j = 1; j <= num_starts; j++) {
  543. Dprintk("Sending STARTUP #%d.\n",j);
  544. apic_read_around(APIC_SPIV);
  545. apic_write(APIC_ESR, 0);
  546. apic_read(APIC_ESR);
  547. Dprintk("After apic_write.\n");
  548. /*
  549. * STARTUP IPI
  550. */
  551. /* Target chip */
  552. apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid));
  553. /* Boot on the stack */
  554. /* Kick the second */
  555. apic_write_around(APIC_ICR, APIC_DM_STARTUP
  556. | (start_eip >> 12));
  557. /*
  558. * Give the other CPU some time to accept the IPI.
  559. */
  560. udelay(300);
  561. Dprintk("Startup point 1.\n");
  562. Dprintk("Waiting for send to finish...\n");
  563. send_status = safe_apic_wait_icr_idle();
  564. /*
  565. * Give the other CPU some time to accept the IPI.
  566. */
  567. udelay(200);
  568. /*
  569. * Due to the Pentium erratum 3AP.
  570. */
  571. if (maxlvt > 3) {
  572. apic_read_around(APIC_SPIV);
  573. apic_write(APIC_ESR, 0);
  574. }
  575. accept_status = (apic_read(APIC_ESR) & 0xEF);
  576. if (send_status || accept_status)
  577. break;
  578. }
  579. Dprintk("After Startup.\n");
  580. if (send_status)
  581. printk("APIC never delivered???\n");
  582. if (accept_status)
  583. printk("APIC delivery error (%lx).\n", accept_status);
  584. return (send_status | accept_status);
  585. }
  586. #endif /* WAKE_SECONDARY_VIA_INIT */
  587. extern cpumask_t cpu_initialized;
  588. static inline int alloc_cpu_id(void)
  589. {
  590. cpumask_t tmp_map;
  591. int cpu;
  592. cpus_complement(tmp_map, cpu_present_map);
  593. cpu = first_cpu(tmp_map);
  594. if (cpu >= NR_CPUS)
  595. return -ENODEV;
  596. return cpu;
  597. }
  598. #ifdef CONFIG_HOTPLUG_CPU
  599. static struct task_struct * __cpuinitdata cpu_idle_tasks[NR_CPUS];
  600. static inline struct task_struct * __cpuinit alloc_idle_task(int cpu)
  601. {
  602. struct task_struct *idle;
  603. if ((idle = cpu_idle_tasks[cpu]) != NULL) {
  604. /* initialize thread_struct. we really want to avoid destroy
  605. * idle tread
  606. */
  607. idle->thread.sp = (unsigned long)task_pt_regs(idle);
  608. init_idle(idle, cpu);
  609. return idle;
  610. }
  611. idle = fork_idle(cpu);
  612. if (!IS_ERR(idle))
  613. cpu_idle_tasks[cpu] = idle;
  614. return idle;
  615. }
  616. #else
  617. #define alloc_idle_task(cpu) fork_idle(cpu)
  618. #endif
  619. static int __cpuinit do_boot_cpu(int apicid, int cpu)
  620. /*
  621. * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
  622. * (ie clustered apic addressing mode), this is a LOGICAL apic ID.
  623. * Returns zero if CPU booted OK, else error code from wakeup_secondary_cpu.
  624. */
  625. {
  626. struct task_struct *idle;
  627. unsigned long boot_error;
  628. int timeout;
  629. unsigned long start_eip;
  630. unsigned short nmi_high = 0, nmi_low = 0;
  631. /*
  632. * Save current MTRR state in case it was changed since early boot
  633. * (e.g. by the ACPI SMI) to initialize new CPUs with MTRRs in sync:
  634. */
  635. mtrr_save_state();
  636. /*
  637. * We can't use kernel_thread since we must avoid to
  638. * reschedule the child.
  639. */
  640. idle = alloc_idle_task(cpu);
  641. if (IS_ERR(idle))
  642. panic("failed fork for CPU %d", cpu);
  643. init_gdt(cpu);
  644. per_cpu(current_task, cpu) = idle;
  645. early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
  646. idle->thread.ip = (unsigned long) start_secondary;
  647. /* start_eip had better be page-aligned! */
  648. start_eip = setup_trampoline();
  649. ++cpucount;
  650. alternatives_smp_switch(1);
  651. /* So we see what's up */
  652. printk("Booting processor %d/%d ip %lx\n", cpu, apicid, start_eip);
  653. /* Stack for startup_32 can be just as for start_secondary onwards */
  654. stack_start.sp = (void *) idle->thread.sp;
  655. irq_ctx_init(cpu);
  656. per_cpu(x86_cpu_to_apicid, cpu) = apicid;
  657. /*
  658. * This grunge runs the startup process for
  659. * the targeted processor.
  660. */
  661. atomic_set(&init_deasserted, 0);
  662. Dprintk("Setting warm reset code and vector.\n");
  663. store_NMI_vector(&nmi_high, &nmi_low);
  664. smpboot_setup_warm_reset_vector(start_eip);
  665. /*
  666. * Starting actual IPI sequence...
  667. */
  668. boot_error = wakeup_secondary_cpu(apicid, start_eip);
  669. if (!boot_error) {
  670. /*
  671. * allow APs to start initializing.
  672. */
  673. Dprintk("Before Callout %d.\n", cpu);
  674. cpu_set(cpu, cpu_callout_map);
  675. Dprintk("After Callout %d.\n", cpu);
  676. /*
  677. * Wait 5s total for a response
  678. */
  679. for (timeout = 0; timeout < 50000; timeout++) {
  680. if (cpu_isset(cpu, cpu_callin_map))
  681. break; /* It has booted */
  682. udelay(100);
  683. }
  684. if (cpu_isset(cpu, cpu_callin_map)) {
  685. /* number CPUs logically, starting from 1 (BSP is 0) */
  686. Dprintk("OK.\n");
  687. printk("CPU%d: ", cpu);
  688. print_cpu_info(&cpu_data(cpu));
  689. Dprintk("CPU has booted.\n");
  690. } else {
  691. boot_error= 1;
  692. if (*((volatile unsigned char *)trampoline_base)
  693. == 0xA5)
  694. /* trampoline started but...? */
  695. printk("Stuck ??\n");
  696. else
  697. /* trampoline code not run */
  698. printk("Not responding.\n");
  699. inquire_remote_apic(apicid);
  700. }
  701. }
  702. if (boot_error) {
  703. /* Try to put things back the way they were before ... */
  704. unmap_cpu_to_logical_apicid(cpu);
  705. cpu_clear(cpu, cpu_callout_map); /* was set here (do_boot_cpu()) */
  706. cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */
  707. cpucount--;
  708. } else {
  709. per_cpu(x86_cpu_to_apicid, cpu) = apicid;
  710. cpu_set(cpu, cpu_present_map);
  711. }
  712. /* mark "stuck" area as not stuck */
  713. *((volatile unsigned long *)trampoline_base) = 0;
  714. return boot_error;
  715. }
  716. #ifdef CONFIG_HOTPLUG_CPU
  717. void cpu_exit_clear(void)
  718. {
  719. int cpu = raw_smp_processor_id();
  720. idle_task_exit();
  721. cpucount --;
  722. cpu_uninit();
  723. irq_ctx_exit(cpu);
  724. cpu_clear(cpu, cpu_callout_map);
  725. cpu_clear(cpu, cpu_callin_map);
  726. cpu_clear(cpu, smp_commenced_mask);
  727. unmap_cpu_to_logical_apicid(cpu);
  728. }
  729. struct warm_boot_cpu_info {
  730. struct completion *complete;
  731. struct work_struct task;
  732. int apicid;
  733. int cpu;
  734. };
  735. static void __cpuinit do_warm_boot_cpu(struct work_struct *work)
  736. {
  737. struct warm_boot_cpu_info *info =
  738. container_of(work, struct warm_boot_cpu_info, task);
  739. do_boot_cpu(info->apicid, info->cpu);
  740. complete(info->complete);
  741. }
  742. static int __cpuinit __smp_prepare_cpu(int cpu)
  743. {
  744. DECLARE_COMPLETION_ONSTACK(done);
  745. struct warm_boot_cpu_info info;
  746. int apicid, ret;
  747. apicid = per_cpu(x86_cpu_to_apicid, cpu);
  748. if (apicid == BAD_APICID) {
  749. ret = -ENODEV;
  750. goto exit;
  751. }
  752. info.complete = &done;
  753. info.apicid = apicid;
  754. info.cpu = cpu;
  755. INIT_WORK(&info.task, do_warm_boot_cpu);
  756. /* init low mem mapping */
  757. clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS,
  758. min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS));
  759. flush_tlb_all();
  760. schedule_work(&info.task);
  761. wait_for_completion(&done);
  762. zap_low_mappings();
  763. ret = 0;
  764. exit:
  765. return ret;
  766. }
  767. #endif
  768. /*
  769. * Cycle through the processors sending APIC IPIs to boot each.
  770. */
  771. static int boot_cpu_logical_apicid;
  772. /* Where the IO area was mapped on multiquad, always 0 otherwise */
  773. void *xquad_portio;
  774. #ifdef CONFIG_X86_NUMAQ
  775. EXPORT_SYMBOL(xquad_portio);
  776. #endif
  777. static void __init smp_boot_cpus(unsigned int max_cpus)
  778. {
  779. int apicid, cpu, bit, kicked;
  780. unsigned long bogosum = 0;
  781. /*
  782. * Setup boot CPU information
  783. */
  784. smp_store_cpu_info(0); /* Final full version of the data */
  785. printk("CPU%d: ", 0);
  786. print_cpu_info(&cpu_data(0));
  787. boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
  788. boot_cpu_logical_apicid = logical_smp_processor_id();
  789. per_cpu(x86_cpu_to_apicid, 0) = boot_cpu_physical_apicid;
  790. current_thread_info()->cpu = 0;
  791. set_cpu_sibling_map(0);
  792. /*
  793. * If we couldn't find an SMP configuration at boot time,
  794. * get out of here now!
  795. */
  796. if (!smp_found_config && !acpi_lapic) {
  797. printk(KERN_NOTICE "SMP motherboard not detected.\n");
  798. smpboot_clear_io_apic_irqs();
  799. phys_cpu_present_map = physid_mask_of_physid(0);
  800. if (APIC_init_uniprocessor())
  801. printk(KERN_NOTICE "Local APIC not detected."
  802. " Using dummy APIC emulation.\n");
  803. map_cpu_to_logical_apicid();
  804. cpu_set(0, per_cpu(cpu_sibling_map, 0));
  805. cpu_set(0, per_cpu(cpu_core_map, 0));
  806. return;
  807. }
  808. /*
  809. * Should not be necessary because the MP table should list the boot
  810. * CPU too, but we do it for the sake of robustness anyway.
  811. * Makes no sense to do this check in clustered apic mode, so skip it
  812. */
  813. if (!check_phys_apicid_present(boot_cpu_physical_apicid)) {
  814. printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
  815. boot_cpu_physical_apicid);
  816. physid_set(hard_smp_processor_id(), phys_cpu_present_map);
  817. }
  818. /*
  819. * If we couldn't find a local APIC, then get out of here now!
  820. */
  821. if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) && !cpu_has_apic) {
  822. printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
  823. boot_cpu_physical_apicid);
  824. printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
  825. smpboot_clear_io_apic_irqs();
  826. phys_cpu_present_map = physid_mask_of_physid(0);
  827. map_cpu_to_logical_apicid();
  828. cpu_set(0, per_cpu(cpu_sibling_map, 0));
  829. cpu_set(0, per_cpu(cpu_core_map, 0));
  830. return;
  831. }
  832. verify_local_APIC();
  833. /*
  834. * If SMP should be disabled, then really disable it!
  835. */
  836. if (!max_cpus) {
  837. smp_found_config = 0;
  838. printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
  839. if (nmi_watchdog == NMI_LOCAL_APIC) {
  840. printk(KERN_INFO "activating minimal APIC for NMI watchdog use.\n");
  841. connect_bsp_APIC();
  842. setup_local_APIC();
  843. }
  844. smpboot_clear_io_apic_irqs();
  845. phys_cpu_present_map = physid_mask_of_physid(0);
  846. map_cpu_to_logical_apicid();
  847. cpu_set(0, per_cpu(cpu_sibling_map, 0));
  848. cpu_set(0, per_cpu(cpu_core_map, 0));
  849. return;
  850. }
  851. connect_bsp_APIC();
  852. setup_local_APIC();
  853. map_cpu_to_logical_apicid();
  854. setup_portio_remap();
  855. /*
  856. * Scan the CPU present map and fire up the other CPUs via do_boot_cpu
  857. *
  858. * In clustered apic mode, phys_cpu_present_map is a constructed thus:
  859. * bits 0-3 are quad0, 4-7 are quad1, etc. A perverse twist on the
  860. * clustered apic ID.
  861. */
  862. Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map));
  863. kicked = 1;
  864. for (bit = 0; kicked < NR_CPUS && bit < MAX_APICS; bit++) {
  865. apicid = cpu_present_to_apicid(bit);
  866. /*
  867. * Don't even attempt to start the boot CPU!
  868. */
  869. if ((apicid == boot_cpu_apicid) || (apicid == BAD_APICID))
  870. continue;
  871. if (!check_apicid_present(bit))
  872. continue;
  873. if (max_cpus <= cpucount+1)
  874. continue;
  875. if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
  876. printk("CPU #%d not responding - cannot use it.\n",
  877. apicid);
  878. else
  879. ++kicked;
  880. }
  881. /*
  882. * Cleanup possible dangling ends...
  883. */
  884. smpboot_restore_warm_reset_vector();
  885. /*
  886. * Allow the user to impress friends.
  887. */
  888. Dprintk("Before bogomips.\n");
  889. for_each_possible_cpu(cpu)
  890. if (cpu_isset(cpu, cpu_callout_map))
  891. bogosum += cpu_data(cpu).loops_per_jiffy;
  892. printk(KERN_INFO
  893. "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
  894. cpucount+1,
  895. bogosum/(500000/HZ),
  896. (bogosum/(5000/HZ))%100);
  897. Dprintk("Before bogocount - setting activated=1.\n");
  898. if (smp_b_stepping)
  899. printk(KERN_WARNING "WARNING: SMP operation may be unreliable with B stepping processors.\n");
  900. /*
  901. * Don't taint if we are running SMP kernel on a single non-MP
  902. * approved Athlon
  903. */
  904. if (tainted & TAINT_UNSAFE_SMP) {
  905. if (cpucount)
  906. printk (KERN_INFO "WARNING: This combination of AMD processors is not suitable for SMP.\n");
  907. else
  908. tainted &= ~TAINT_UNSAFE_SMP;
  909. }
  910. Dprintk("Boot done.\n");
  911. /*
  912. * construct cpu_sibling_map, so that we can tell sibling CPUs
  913. * efficiently.
  914. */
  915. for_each_possible_cpu(cpu) {
  916. cpus_clear(per_cpu(cpu_sibling_map, cpu));
  917. cpus_clear(per_cpu(cpu_core_map, cpu));
  918. }
  919. cpu_set(0, per_cpu(cpu_sibling_map, 0));
  920. cpu_set(0, per_cpu(cpu_core_map, 0));
  921. smpboot_setup_io_apic();
  922. setup_boot_clock();
  923. }
  924. /* These are wrappers to interface to the new boot process. Someone
  925. who understands all this stuff should rewrite it properly. --RR 15/Jul/02 */
  926. void __init native_smp_prepare_cpus(unsigned int max_cpus)
  927. {
  928. smp_commenced_mask = cpumask_of_cpu(0);
  929. cpu_callin_map = cpumask_of_cpu(0);
  930. mb();
  931. smp_boot_cpus(max_cpus);
  932. }
  933. void __init native_smp_prepare_boot_cpu(void)
  934. {
  935. unsigned int cpu = smp_processor_id();
  936. init_gdt(cpu);
  937. switch_to_new_gdt();
  938. cpu_set(cpu, cpu_online_map);
  939. cpu_set(cpu, cpu_callout_map);
  940. cpu_set(cpu, cpu_present_map);
  941. cpu_set(cpu, cpu_possible_map);
  942. __get_cpu_var(cpu_state) = CPU_ONLINE;
  943. }
  944. #ifdef CONFIG_HOTPLUG_CPU
  945. void remove_siblinginfo(int cpu)
  946. {
  947. int sibling;
  948. struct cpuinfo_x86 *c = &cpu_data(cpu);
  949. for_each_cpu_mask(sibling, per_cpu(cpu_core_map, cpu)) {
  950. cpu_clear(cpu, per_cpu(cpu_core_map, sibling));
  951. /*/
  952. * last thread sibling in this cpu core going down
  953. */
  954. if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1)
  955. cpu_data(sibling).booted_cores--;
  956. }
  957. for_each_cpu_mask(sibling, per_cpu(cpu_sibling_map, cpu))
  958. cpu_clear(cpu, per_cpu(cpu_sibling_map, sibling));
  959. cpus_clear(per_cpu(cpu_sibling_map, cpu));
  960. cpus_clear(per_cpu(cpu_core_map, cpu));
  961. c->phys_proc_id = 0;
  962. c->cpu_core_id = 0;
  963. cpu_clear(cpu, cpu_sibling_setup_map);
  964. }
  965. int __cpu_disable(void)
  966. {
  967. cpumask_t map = cpu_online_map;
  968. int cpu = smp_processor_id();
  969. /*
  970. * Perhaps use cpufreq to drop frequency, but that could go
  971. * into generic code.
  972. *
  973. * We won't take down the boot processor on i386 due to some
  974. * interrupts only being able to be serviced by the BSP.
  975. * Especially so if we're not using an IOAPIC -zwane
  976. */
  977. if (cpu == 0)
  978. return -EBUSY;
  979. if (nmi_watchdog == NMI_LOCAL_APIC)
  980. stop_apic_nmi_watchdog(NULL);
  981. clear_local_APIC();
  982. /* Allow any queued timer interrupts to get serviced */
  983. local_irq_enable();
  984. mdelay(1);
  985. local_irq_disable();
  986. remove_siblinginfo(cpu);
  987. cpu_clear(cpu, map);
  988. fixup_irqs(map);
  989. /* It's now safe to remove this processor from the online map */
  990. cpu_clear(cpu, cpu_online_map);
  991. return 0;
  992. }
  993. void __cpu_die(unsigned int cpu)
  994. {
  995. /* We don't do anything here: idle task is faking death itself. */
  996. unsigned int i;
  997. for (i = 0; i < 10; i++) {
  998. /* They ack this in play_dead by setting CPU_DEAD */
  999. if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
  1000. printk ("CPU %d is now offline\n", cpu);
  1001. if (1 == num_online_cpus())
  1002. alternatives_smp_switch(0);
  1003. return;
  1004. }
  1005. msleep(100);
  1006. }
  1007. printk(KERN_ERR "CPU %u didn't die...\n", cpu);
  1008. }
  1009. #else /* ... !CONFIG_HOTPLUG_CPU */
  1010. int __cpu_disable(void)
  1011. {
  1012. return -ENOSYS;
  1013. }
  1014. void __cpu_die(unsigned int cpu)
  1015. {
  1016. /* We said "no" in __cpu_disable */
  1017. BUG();
  1018. }
  1019. #endif /* CONFIG_HOTPLUG_CPU */
  1020. int __cpuinit native_cpu_up(unsigned int cpu)
  1021. {
  1022. unsigned long flags;
  1023. #ifdef CONFIG_HOTPLUG_CPU
  1024. int ret = 0;
  1025. /*
  1026. * We do warm boot only on cpus that had booted earlier
  1027. * Otherwise cold boot is all handled from smp_boot_cpus().
  1028. * cpu_callin_map is set during AP kickstart process. Its reset
  1029. * when a cpu is taken offline from cpu_exit_clear().
  1030. */
  1031. if (!cpu_isset(cpu, cpu_callin_map))
  1032. ret = __smp_prepare_cpu(cpu);
  1033. if (ret)
  1034. return -EIO;
  1035. #endif
  1036. /* In case one didn't come up */
  1037. if (!cpu_isset(cpu, cpu_callin_map)) {
  1038. printk(KERN_DEBUG "skipping cpu%d, didn't come online\n", cpu);
  1039. return -EIO;
  1040. }
  1041. per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  1042. /* Unleash the CPU! */
  1043. cpu_set(cpu, smp_commenced_mask);
  1044. /*
  1045. * Check TSC synchronization with the AP (keep irqs disabled
  1046. * while doing so):
  1047. */
  1048. local_irq_save(flags);
  1049. check_tsc_sync_source(cpu);
  1050. local_irq_restore(flags);
  1051. while (!cpu_isset(cpu, cpu_online_map)) {
  1052. cpu_relax();
  1053. touch_nmi_watchdog();
  1054. }
  1055. return 0;
  1056. }
  1057. void __init native_smp_cpus_done(unsigned int max_cpus)
  1058. {
  1059. #ifdef CONFIG_X86_IO_APIC
  1060. setup_ioapic_dest();
  1061. #endif
  1062. zap_low_mappings();
  1063. }
  1064. void __init smp_intr_init(void)
  1065. {
  1066. /*
  1067. * IRQ0 must be given a fixed assignment and initialized,
  1068. * because it's used before the IO-APIC is set up.
  1069. */
  1070. set_intr_gate(FIRST_DEVICE_VECTOR, interrupt[0]);
  1071. /*
  1072. * The reschedule interrupt is a CPU-to-CPU reschedule-helper
  1073. * IPI, driven by wakeup.
  1074. */
  1075. set_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
  1076. /* IPI for invalidation */
  1077. set_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt);
  1078. /* IPI for generic function call */
  1079. set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
  1080. }
  1081. /*
  1082. * If the BIOS enumerates physical processors before logical,
  1083. * maxcpus=N at enumeration-time can be used to disable HT.
  1084. */
  1085. static int __init parse_maxcpus(char *arg)
  1086. {
  1087. extern unsigned int maxcpus;
  1088. maxcpus = simple_strtoul(arg, NULL, 0);
  1089. return 0;
  1090. }
  1091. early_param("maxcpus", parse_maxcpus);