x86: get rid of smp_boot_cpus
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / kernel / smpboot_32.c
blobd153d8423740a6759f75b91ebad1b880bfd40523
1 /*
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
15 * later.
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. */
36 #include <linux/module.h>
37 #include <linux/init.h>
38 #include <linux/kernel.h>
40 #include <linux/mm.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>
52 #include <asm/desc.h>
53 #include <asm/arch_hooks.h>
54 #include <asm/nmi.h>
56 #include <mach_apic.h>
57 #include <mach_wakecpu.h>
58 #include <smpboot_hooks.h>
59 #include <asm/vmi.h>
60 #include <asm/mtrr.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 extern void map_cpu_to_logical_apicid(void);
78 extern void unmap_cpu_to_logical_apicid(int cpu);
80 #ifdef CONFIG_HOTPLUG_CPU
81 void cpu_exit_clear(void)
83 int cpu = raw_smp_processor_id();
85 idle_task_exit();
87 cpu_uninit();
88 irq_ctx_exit(cpu);
90 cpu_clear(cpu, cpu_callout_map);
91 cpu_clear(cpu, cpu_callin_map);
93 unmap_cpu_to_logical_apicid(cpu);
95 #endif
97 static int boot_cpu_logical_apicid;
98 /* Where the IO area was mapped on multiquad, always 0 otherwise */
99 void *xquad_portio;
100 #ifdef CONFIG_X86_NUMAQ
101 EXPORT_SYMBOL(xquad_portio);
102 #endif
104 static void __init disable_smp(void)
106 cpu_possible_map = cpumask_of_cpu(0);
107 cpu_present_map = cpumask_of_cpu(0);
108 smpboot_clear_io_apic_irqs();
109 if (smp_found_config)
110 phys_cpu_present_map =
111 physid_mask_of_physid(boot_cpu_physical_apicid);
112 else
113 phys_cpu_present_map = physid_mask_of_physid(0);
114 map_cpu_to_logical_apicid();
115 cpu_set(0, per_cpu(cpu_sibling_map, 0));
116 cpu_set(0, per_cpu(cpu_core_map, 0));
119 static int __init smp_sanity_check(unsigned max_cpus)
122 * If we couldn't find an SMP configuration at boot time,
123 * get out of here now!
125 if (!smp_found_config && !acpi_lapic) {
126 printk(KERN_NOTICE "SMP motherboard not detected.\n");
127 disable_smp();
128 if (APIC_init_uniprocessor())
129 printk(KERN_NOTICE "Local APIC not detected."
130 " Using dummy APIC emulation.\n");
131 return -1;
135 * Should not be necessary because the MP table should list the boot
136 * CPU too, but we do it for the sake of robustness anyway.
137 * Makes no sense to do this check in clustered apic mode, so skip it
139 if (!check_phys_apicid_present(boot_cpu_physical_apicid)) {
140 printk("weird, boot CPU (#%d) not listed by the BIOS.\n",
141 boot_cpu_physical_apicid);
142 physid_set(hard_smp_processor_id(), phys_cpu_present_map);
146 * If we couldn't find a local APIC, then get out of here now!
148 if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) && !cpu_has_apic) {
149 printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
150 boot_cpu_physical_apicid);
151 printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n");
152 return -1;
155 verify_local_APIC();
158 * If SMP should be disabled, then really disable it!
160 if (!max_cpus) {
161 smp_found_config = 0;
162 printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n");
164 if (nmi_watchdog == NMI_LOCAL_APIC) {
165 printk(KERN_INFO "activating minimal APIC for NMI watchdog use.\n");
166 connect_bsp_APIC();
167 setup_local_APIC();
168 end_local_APIC_setup();
170 return -1;
172 return 0;
175 /* These are wrappers to interface to the new boot process. Someone
176 who understands all this stuff should rewrite it properly. --RR 15/Jul/02 */
177 void __init native_smp_prepare_cpus(unsigned int max_cpus)
179 nmi_watchdog_default();
180 cpu_callin_map = cpumask_of_cpu(0);
181 mb();
184 * Setup boot CPU information
186 smp_store_cpu_info(0); /* Final full version of the data */
187 boot_cpu_logical_apicid = logical_smp_processor_id();
188 current_thread_info()->cpu = 0;
190 set_cpu_sibling_map(0);
192 if (smp_sanity_check(max_cpus) < 0) {
193 printk(KERN_INFO "SMP disabled\n");
194 disable_smp();
195 return;
198 boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
200 connect_bsp_APIC();
201 setup_local_APIC();
202 end_local_APIC_setup();
203 map_cpu_to_logical_apicid();
205 setup_portio_remap();
207 smpboot_setup_io_apic();
209 printk(KERN_INFO "CPU%d: ", 0);
210 print_cpu_info(&cpu_data(0));
211 setup_boot_clock();