2 * x86 SMP booting functions
4 * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
5 * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
7 * Much of the core SMP work is based on previous work by Thomas Radke, to
8 * whom a great many thanks are extended.
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.
14 * This code is released under the GNU General Public License version 2 or
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
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. */
36 #include <linux/module.h>
37 #include <linux/init.h>
38 #include <linux/kernel.h>
41 #include <linux/sched.h>
42 #include <linux/kernel_stat.h>
43 #include <linux/bootmem.h>
44 #include <linux/notifier.h>
45 #include <linux/cpu.h>
46 #include <linux/percpu.h>
47 #include <linux/nmi.h>
49 #include <linux/delay.h>
50 #include <linux/mc146818rtc.h>
51 #include <asm/tlbflush.h>
53 #include <asm/arch_hooks.h>
56 #include <mach_apic.h>
57 #include <mach_wakecpu.h>
58 #include <smpboot_hooks.h>
62 /* which logical CPU number maps to which CPU (physical APIC ID) */
63 u16 x86_cpu_to_apicid_init
[NR_CPUS
] __initdata
=
64 { [0 ... NR_CPUS
-1] = BAD_APICID
};
65 void *x86_cpu_to_apicid_early_ptr
;
66 DEFINE_PER_CPU(u16
, x86_cpu_to_apicid
) = BAD_APICID
;
67 EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid
);
69 u16 x86_bios_cpu_apicid_init
[NR_CPUS
] __initdata
70 = { [0 ... NR_CPUS
-1] = BAD_APICID
};
71 void *x86_bios_cpu_apicid_early_ptr
;
72 DEFINE_PER_CPU(u16
, x86_bios_cpu_apicid
) = BAD_APICID
;
73 EXPORT_PER_CPU_SYMBOL(x86_bios_cpu_apicid
);
75 u8 apicid_2_node
[MAX_APICID
];
77 static void map_cpu_to_logical_apicid(void);
79 /* State of each CPU. */
80 DEFINE_PER_CPU(int, cpu_state
) = { 0 };
82 static atomic_t init_deasserted
;
84 static void __cpuinit
smp_callin(void)
87 unsigned long timeout
;
90 * If waken up by an INIT in an 82489DX configuration
91 * we may get here before an INIT-deassert IPI reaches
92 * our local APIC. We have to wait for the IPI or we'll
93 * lock up on an APIC access.
95 wait_for_init_deassert(&init_deasserted
);
98 * (This works even if the APIC is not enabled.)
100 phys_id
= GET_APIC_ID(apic_read(APIC_ID
));
101 cpuid
= smp_processor_id();
102 if (cpu_isset(cpuid
, cpu_callin_map
)) {
103 printk("huh, phys CPU#%d, CPU#%d already present??\n",
107 Dprintk("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid
, phys_id
);
110 * STARTUP IPIs are fragile beasts as they might sometimes
111 * trigger some glue motherboard logic. Complete APIC bus
112 * silence for 1 second, this overestimates the time the
113 * boot CPU is spending to send the up to 2 STARTUP IPIs
114 * by a factor of two. This should be enough.
118 * Waiting 2s total for startup (udelay is not yet working)
120 timeout
= jiffies
+ 2*HZ
;
121 while (time_before(jiffies
, timeout
)) {
123 * Has the boot CPU finished it's STARTUP sequence?
125 if (cpu_isset(cpuid
, cpu_callout_map
))
130 if (!time_before(jiffies
, timeout
)) {
131 printk("BUG: CPU%d started up but did not get a callout!\n",
137 * the boot CPU has finished the init stage and is spinning
138 * on callin_map until we finish. We are free to set up this
139 * CPU, first the APIC. (this is probably redundant on most
143 Dprintk("CALLIN, before setup_local_APIC().\n");
144 smp_callin_clear_local_apic();
146 map_cpu_to_logical_apicid();
152 Dprintk("Stack at about %p\n",&cpuid
);
155 * Save our processor parameters
157 smp_store_cpu_info(cpuid
);
160 * Allow the master to continue.
162 cpu_set(cpuid
, cpu_callin_map
);
166 * Activate a secondary processor.
168 static void __cpuinit
start_secondary(void *unused
)
171 * Don't put *anything* before cpu_init(), SMP booting is too
172 * fragile that we want to limit the things done here to the
173 * most necessary things.
182 /* otherwise gcc will move up smp_processor_id before the cpu_init */
185 * Check TSC synchronization with the BP:
187 check_tsc_sync_target();
189 if (nmi_watchdog
== NMI_IO_APIC
) {
190 disable_8259A_irq(0);
191 enable_NMI_through_LVT0();
195 /* This must be done before setting cpu_online_map */
196 set_cpu_sibling_map(raw_smp_processor_id());
200 * We need to hold call_lock, so there is no inconsistency
201 * between the time smp_call_function() determines number of
202 * IPI recipients, and the time when the determination is made
203 * for which cpus receive the IPI. Holding this
204 * lock helps us to not include this cpu in a currently in progress
205 * smp_call_function().
207 lock_ipi_call_lock();
208 cpu_set(smp_processor_id(), cpu_online_map
);
209 unlock_ipi_call_lock();
210 per_cpu(cpu_state
, smp_processor_id()) = CPU_ONLINE
;
212 setup_secondary_clock();
219 * Everything has been set up for the secondary
220 * CPUs - they just need to reload everything
221 * from the task structure
222 * This function must not return.
224 void __devinit
initialize_secondary(void)
227 * We don't actually need to load the full TSS,
228 * basically just the stack pointer and the ip.
235 :"m" (current
->thread
.sp
),"m" (current
->thread
.ip
));
238 /* Static state in head.S used to set up a CPU */
246 /* which logical CPUs are on which nodes */
247 cpumask_t node_to_cpumask_map
[MAX_NUMNODES
] __read_mostly
=
248 { [0 ... MAX_NUMNODES
-1] = CPU_MASK_NONE
};
249 EXPORT_SYMBOL(node_to_cpumask_map
);
250 /* which node each logical CPU is on */
251 int cpu_to_node_map
[NR_CPUS
] __read_mostly
= { [0 ... NR_CPUS
-1] = 0 };
252 EXPORT_SYMBOL(cpu_to_node_map
);
254 /* set up a mapping between cpu and node. */
255 static inline void map_cpu_to_node(int cpu
, int node
)
257 printk("Mapping cpu %d to node %d\n", cpu
, node
);
258 cpu_set(cpu
, node_to_cpumask_map
[node
]);
259 cpu_to_node_map
[cpu
] = node
;
262 /* undo a mapping between cpu and node. */
263 static inline void unmap_cpu_to_node(int cpu
)
267 printk("Unmapping cpu %d from all nodes\n", cpu
);
268 for (node
= 0; node
< MAX_NUMNODES
; node
++)
269 cpu_clear(cpu
, node_to_cpumask_map
[node
]);
270 cpu_to_node_map
[cpu
] = 0;
272 #else /* !CONFIG_NUMA */
274 #define map_cpu_to_node(cpu, node) ({})
275 #define unmap_cpu_to_node(cpu) ({})
277 #endif /* CONFIG_NUMA */
279 u8 cpu_2_logical_apicid
[NR_CPUS
] __read_mostly
= { [0 ... NR_CPUS
-1] = BAD_APICID
};
281 static void map_cpu_to_logical_apicid(void)
283 int cpu
= smp_processor_id();
284 int apicid
= logical_smp_processor_id();
285 int node
= apicid_to_node(apicid
);
287 if (!node_online(node
))
288 node
= first_online_node
;
290 cpu_2_logical_apicid
[cpu
] = apicid
;
291 map_cpu_to_node(cpu
, node
);
294 static void unmap_cpu_to_logical_apicid(int cpu
)
296 cpu_2_logical_apicid
[cpu
] = BAD_APICID
;
297 unmap_cpu_to_node(cpu
);
300 static inline void __inquire_remote_apic(int apicid
)
302 unsigned i
, regs
[] = { APIC_ID
>> 4, APIC_LVR
>> 4, APIC_SPIV
>> 4 };
303 char *names
[] = { "ID", "VERSION", "SPIV" };
307 printk(KERN_INFO
"Inquiring remote APIC #%d...\n", apicid
);
309 for (i
= 0; i
< ARRAY_SIZE(regs
); i
++) {
310 printk(KERN_INFO
"... APIC #%d %s: ", apicid
, names
[i
]);
315 status
= safe_apic_wait_icr_idle();
318 "a previous APIC delivery may have failed\n");
320 apic_write_around(APIC_ICR2
, SET_APIC_DEST_FIELD(apicid
));
321 apic_write_around(APIC_ICR
, APIC_DM_REMRD
| regs
[i
]);
326 status
= apic_read(APIC_ICR
) & APIC_ICR_RR_MASK
;
327 } while (status
== APIC_ICR_RR_INPROG
&& timeout
++ < 1000);
330 case APIC_ICR_RR_VALID
:
331 status
= apic_read(APIC_RRR
);
332 printk(KERN_CONT
"%08x\n", status
);
335 printk(KERN_CONT
"failed\n");
340 #ifdef WAKE_SECONDARY_VIA_NMI
342 * Poke the other CPU in the eye via NMI to wake it up. Remember that the normal
343 * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this
344 * won't ... remember to clear down the APIC, etc later.
347 wakeup_secondary_cpu(int logical_apicid
, unsigned long start_eip
)
349 unsigned long send_status
, accept_status
= 0;
353 apic_write_around(APIC_ICR2
, SET_APIC_DEST_FIELD(logical_apicid
));
355 /* Boot on the stack */
356 /* Kick the second */
357 apic_write_around(APIC_ICR
, APIC_DM_NMI
| APIC_DEST_LOGICAL
);
359 Dprintk("Waiting for send to finish...\n");
360 send_status
= safe_apic_wait_icr_idle();
363 * Give the other CPU some time to accept the IPI.
367 * Due to the Pentium erratum 3AP.
369 maxlvt
= lapic_get_maxlvt();
371 apic_read_around(APIC_SPIV
);
372 apic_write(APIC_ESR
, 0);
374 accept_status
= (apic_read(APIC_ESR
) & 0xEF);
375 Dprintk("NMI sent.\n");
378 printk("APIC never delivered???\n");
380 printk("APIC delivery error (%lx).\n", accept_status
);
382 return (send_status
| accept_status
);
384 #endif /* WAKE_SECONDARY_VIA_NMI */
386 #ifdef WAKE_SECONDARY_VIA_INIT
388 wakeup_secondary_cpu(int phys_apicid
, unsigned long start_eip
)
390 unsigned long send_status
, accept_status
= 0;
391 int maxlvt
, num_starts
, j
;
394 * Be paranoid about clearing APIC errors.
396 if (APIC_INTEGRATED(apic_version
[phys_apicid
])) {
397 apic_read_around(APIC_SPIV
);
398 apic_write(APIC_ESR
, 0);
402 Dprintk("Asserting INIT.\n");
405 * Turn INIT on target chip
407 apic_write_around(APIC_ICR2
, SET_APIC_DEST_FIELD(phys_apicid
));
412 apic_write_around(APIC_ICR
, APIC_INT_LEVELTRIG
| APIC_INT_ASSERT
415 Dprintk("Waiting for send to finish...\n");
416 send_status
= safe_apic_wait_icr_idle();
420 Dprintk("Deasserting INIT.\n");
423 apic_write_around(APIC_ICR2
, SET_APIC_DEST_FIELD(phys_apicid
));
426 apic_write_around(APIC_ICR
, APIC_INT_LEVELTRIG
| APIC_DM_INIT
);
428 Dprintk("Waiting for send to finish...\n");
429 send_status
= safe_apic_wait_icr_idle();
432 atomic_set(&init_deasserted
, 1);
435 * Should we send STARTUP IPIs ?
437 * Determine this based on the APIC version.
438 * If we don't have an integrated APIC, don't send the STARTUP IPIs.
440 if (APIC_INTEGRATED(apic_version
[phys_apicid
]))
446 * Paravirt / VMI wants a startup IPI hook here to set up the
447 * target processor state.
449 startup_ipi_hook(phys_apicid
, (unsigned long) start_secondary
,
450 (unsigned long) stack_start
.sp
);
453 * Run STARTUP IPI loop.
455 Dprintk("#startup loops: %d.\n", num_starts
);
457 maxlvt
= lapic_get_maxlvt();
459 for (j
= 1; j
<= num_starts
; j
++) {
460 Dprintk("Sending STARTUP #%d.\n",j
);
461 apic_read_around(APIC_SPIV
);
462 apic_write(APIC_ESR
, 0);
464 Dprintk("After apic_write.\n");
471 apic_write_around(APIC_ICR2
, SET_APIC_DEST_FIELD(phys_apicid
));
473 /* Boot on the stack */
474 /* Kick the second */
475 apic_write_around(APIC_ICR
, APIC_DM_STARTUP
476 | (start_eip
>> 12));
479 * Give the other CPU some time to accept the IPI.
483 Dprintk("Startup point 1.\n");
485 Dprintk("Waiting for send to finish...\n");
486 send_status
= safe_apic_wait_icr_idle();
489 * Give the other CPU some time to accept the IPI.
493 * Due to the Pentium erratum 3AP.
496 apic_read_around(APIC_SPIV
);
497 apic_write(APIC_ESR
, 0);
499 accept_status
= (apic_read(APIC_ESR
) & 0xEF);
500 if (send_status
|| accept_status
)
503 Dprintk("After Startup.\n");
506 printk("APIC never delivered???\n");
508 printk("APIC delivery error (%lx).\n", accept_status
);
510 return (send_status
| accept_status
);
512 #endif /* WAKE_SECONDARY_VIA_INIT */
514 extern cpumask_t cpu_initialized
;
516 #ifdef CONFIG_HOTPLUG_CPU
517 static struct task_struct
* __cpuinitdata cpu_idle_tasks
[NR_CPUS
];
518 static inline struct task_struct
* __cpuinit
alloc_idle_task(int cpu
)
520 struct task_struct
*idle
;
522 if ((idle
= cpu_idle_tasks
[cpu
]) != NULL
) {
523 /* initialize thread_struct. we really want to avoid destroy
526 idle
->thread
.sp
= (unsigned long)task_pt_regs(idle
);
527 init_idle(idle
, cpu
);
530 idle
= fork_idle(cpu
);
533 cpu_idle_tasks
[cpu
] = idle
;
537 #define alloc_idle_task(cpu) fork_idle(cpu)
540 static int __cpuinit
do_boot_cpu(int apicid
, int cpu
)
542 * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
543 * (ie clustered apic addressing mode), this is a LOGICAL apic ID.
544 * Returns zero if CPU booted OK, else error code from wakeup_secondary_cpu.
547 struct task_struct
*idle
;
548 unsigned long boot_error
;
550 unsigned long start_eip
;
551 unsigned short nmi_high
= 0, nmi_low
= 0;
554 * Save current MTRR state in case it was changed since early boot
555 * (e.g. by the ACPI SMI) to initialize new CPUs with MTRRs in sync:
560 * We can't use kernel_thread since we must avoid to
561 * reschedule the child.
563 idle
= alloc_idle_task(cpu
);
565 panic("failed fork for CPU %d", cpu
);
568 per_cpu(current_task
, cpu
) = idle
;
569 early_gdt_descr
.address
= (unsigned long)get_cpu_gdt_table(cpu
);
571 idle
->thread
.ip
= (unsigned long) start_secondary
;
572 /* start_eip had better be page-aligned! */
573 start_eip
= setup_trampoline();
575 alternatives_smp_switch(1);
577 /* So we see what's up */
578 printk("Booting processor %d/%d ip %lx\n", cpu
, apicid
, start_eip
);
579 /* Stack for startup_32 can be just as for start_secondary onwards */
580 stack_start
.sp
= (void *) idle
->thread
.sp
;
585 * This grunge runs the startup process for
586 * the targeted processor.
589 atomic_set(&init_deasserted
, 0);
591 Dprintk("Setting warm reset code and vector.\n");
593 store_NMI_vector(&nmi_high
, &nmi_low
);
595 smpboot_setup_warm_reset_vector(start_eip
);
598 * Starting actual IPI sequence...
600 boot_error
= wakeup_secondary_cpu(apicid
, start_eip
);
604 * allow APs to start initializing.
606 Dprintk("Before Callout %d.\n", cpu
);
607 cpu_set(cpu
, cpu_callout_map
);
608 Dprintk("After Callout %d.\n", cpu
);
611 * Wait 5s total for a response
613 for (timeout
= 0; timeout
< 50000; timeout
++) {
614 if (cpu_isset(cpu
, cpu_callin_map
))
615 break; /* It has booted */
619 if (cpu_isset(cpu
, cpu_callin_map
)) {
620 /* number CPUs logically, starting from 1 (BSP is 0) */
622 printk("CPU%d: ", cpu
);
623 print_cpu_info(&cpu_data(cpu
));
624 Dprintk("CPU has booted.\n");
627 if (*((volatile unsigned char *)trampoline_base
)
629 /* trampoline started but...? */
630 printk("Stuck ??\n");
632 /* trampoline code not run */
633 printk("Not responding.\n");
634 inquire_remote_apic(apicid
);
639 /* Try to put things back the way they were before ... */
640 unmap_cpu_to_logical_apicid(cpu
);
641 cpu_clear(cpu
, cpu_callout_map
); /* was set here (do_boot_cpu()) */
642 cpu_clear(cpu
, cpu_initialized
); /* was set by cpu_init() */
643 cpu_clear(cpu
, cpu_possible_map
);
644 per_cpu(x86_cpu_to_apicid
, cpu
) = BAD_APICID
;
647 /* mark "stuck" area as not stuck */
648 *((volatile unsigned long *)trampoline_base
) = 0;
653 #ifdef CONFIG_HOTPLUG_CPU
654 void cpu_exit_clear(void)
656 int cpu
= raw_smp_processor_id();
663 cpu_clear(cpu
, cpu_callout_map
);
664 cpu_clear(cpu
, cpu_callin_map
);
666 unmap_cpu_to_logical_apicid(cpu
);
670 struct warm_boot_cpu_info
{
671 struct completion
*complete
;
672 struct work_struct task
;
677 static void __cpuinit
do_warm_boot_cpu(struct work_struct
*work
)
679 struct warm_boot_cpu_info
*info
=
680 container_of(work
, struct warm_boot_cpu_info
, task
);
681 do_boot_cpu(info
->apicid
, info
->cpu
);
682 complete(info
->complete
);
685 static void __cpuinit
__smp_prepare_cpu(int cpu
)
687 DECLARE_COMPLETION_ONSTACK(done
);
688 struct warm_boot_cpu_info info
;
691 apicid
= per_cpu(x86_cpu_to_apicid
, cpu
);
693 info
.complete
= &done
;
694 info
.apicid
= apicid
;
696 INIT_WORK(&info
.task
, do_warm_boot_cpu
);
698 /* init low mem mapping */
699 clone_pgd_range(swapper_pg_dir
, swapper_pg_dir
+ USER_PGD_PTRS
,
700 min_t(unsigned long, KERNEL_PGD_PTRS
, USER_PGD_PTRS
));
702 if (!keventd_up() || current_is_keventd())
703 info
.task
.func(&info
.task
);
705 schedule_work(&info
.task
);
706 wait_for_completion(&done
);
710 static int boot_cpu_logical_apicid
;
711 /* Where the IO area was mapped on multiquad, always 0 otherwise */
713 #ifdef CONFIG_X86_NUMAQ
714 EXPORT_SYMBOL(xquad_portio
);
717 static void __init
disable_smp(void)
719 cpu_possible_map
= cpumask_of_cpu(0);
720 cpu_present_map
= cpumask_of_cpu(0);
721 smpboot_clear_io_apic_irqs();
722 phys_cpu_present_map
= physid_mask_of_physid(0);
723 map_cpu_to_logical_apicid();
724 cpu_set(0, per_cpu(cpu_sibling_map
, 0));
725 cpu_set(0, per_cpu(cpu_core_map
, 0));
728 static int __init
smp_sanity_check(unsigned max_cpus
)
731 * If we couldn't find an SMP configuration at boot time,
732 * get out of here now!
734 if (!smp_found_config
&& !acpi_lapic
) {
735 printk(KERN_NOTICE
"SMP motherboard not detected.\n");
737 if (APIC_init_uniprocessor())
738 printk(KERN_NOTICE
"Local APIC not detected."
739 " Using dummy APIC emulation.\n");
744 * Should not be necessary because the MP table should list the boot
745 * CPU too, but we do it for the sake of robustness anyway.
746 * Makes no sense to do this check in clustered apic mode, so skip it
748 if (!check_phys_apicid_present(boot_cpu_physical_apicid
)) {
749 printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
750 boot_cpu_physical_apicid
);
751 physid_set(hard_smp_processor_id(), phys_cpu_present_map
);
755 * If we couldn't find a local APIC, then get out of here now!
757 if (APIC_INTEGRATED(apic_version
[boot_cpu_physical_apicid
]) && !cpu_has_apic
) {
758 printk(KERN_ERR
"BIOS bug, local APIC #%d not detected!...\n",
759 boot_cpu_physical_apicid
);
760 printk(KERN_ERR
"... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
767 * If SMP should be disabled, then really disable it!
770 smp_found_config
= 0;
771 printk(KERN_INFO
"SMP mode deactivated, forcing use of dummy APIC emulation.\n");
773 if (nmi_watchdog
== NMI_LOCAL_APIC
) {
774 printk(KERN_INFO
"activating minimal APIC for NMI watchdog use.\n");
784 * Cycle through the processors sending APIC IPIs to boot each.
786 static void __init
smp_boot_cpus(unsigned int max_cpus
)
789 * Setup boot CPU information
791 smp_store_cpu_info(0); /* Final full version of the data */
792 printk(KERN_INFO
"CPU%d: ", 0);
793 print_cpu_info(&cpu_data(0));
795 boot_cpu_physical_apicid
= GET_APIC_ID(apic_read(APIC_ID
));
796 boot_cpu_logical_apicid
= logical_smp_processor_id();
798 current_thread_info()->cpu
= 0;
800 set_cpu_sibling_map(0);
802 if (smp_sanity_check(max_cpus
) < 0) {
803 printk(KERN_INFO
"SMP disabled\n");
810 map_cpu_to_logical_apicid();
813 setup_portio_remap();
815 smpboot_setup_io_apic();
820 /* These are wrappers to interface to the new boot process. Someone
821 who understands all this stuff should rewrite it properly. --RR 15/Jul/02 */
822 void __init
native_smp_prepare_cpus(unsigned int max_cpus
)
824 nmi_watchdog_default();
825 cpu_callin_map
= cpumask_of_cpu(0);
827 smp_boot_cpus(max_cpus
);
830 void __init
native_smp_prepare_boot_cpu(void)
832 unsigned int cpu
= smp_processor_id();
837 cpu_set(cpu
, cpu_callout_map
);
838 __get_cpu_var(cpu_state
) = CPU_ONLINE
;
841 int __cpuinit
native_cpu_up(unsigned int cpu
)
843 int apicid
= cpu_present_to_apicid(cpu
);
846 WARN_ON(irqs_disabled());
848 Dprintk("++++++++++++++++++++=_---CPU UP %u\n", cpu
);
850 if (apicid
== BAD_APICID
|| apicid
== boot_cpu_physical_apicid
||
851 !physid_isset(apicid
, phys_cpu_present_map
)) {
852 printk(KERN_ERR
"%s: bad cpu %d\n", __func__
, cpu
);
856 per_cpu(cpu_state
, cpu
) = CPU_UP_PREPARE
;
858 __smp_prepare_cpu(cpu
);
860 /* In case one didn't come up */
861 if (!cpu_isset(cpu
, cpu_callin_map
)) {
862 printk(KERN_DEBUG
"skipping cpu%d, didn't come online\n", cpu
);
868 * Check TSC synchronization with the AP (keep irqs disabled
871 local_irq_save(flags
);
872 check_tsc_sync_source(cpu
);
873 local_irq_restore(flags
);
875 while (!cpu_isset(cpu
, cpu_online_map
)) {
877 touch_nmi_watchdog();
883 extern void impress_friends(void);
884 extern void smp_checks(void);
886 void __init
native_smp_cpus_done(unsigned int max_cpus
)
889 * Cleanup possible dangling ends...
891 smpboot_restore_warm_reset_vector();
893 Dprintk("Boot done.\n");
897 #ifdef CONFIG_X86_IO_APIC
900 check_nmi_watchdog();