Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 36 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | #include <linux/init.h> |
| 38 | #include <linux/kernel.h> |
| 39 | |
| 40 | #include <linux/mm.h> |
| 41 | #include <linux/sched.h> |
| 42 | #include <linux/kernel_stat.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <linux/bootmem.h> |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 44 | #include <linux/notifier.h> |
| 45 | #include <linux/cpu.h> |
| 46 | #include <linux/percpu.h> |
Ingo Molnar | d04f41e | 2007-03-07 18:12:31 +0100 | [diff] [blame] | 47 | #include <linux/nmi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 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> |
Don Zickus | 3e4ff11 | 2006-06-26 13:57:01 +0200 | [diff] [blame] | 54 | #include <asm/nmi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
| 56 | #include <mach_apic.h> |
| 57 | #include <mach_wakecpu.h> |
| 58 | #include <smpboot_hooks.h> |
Zachary Amsden | 7ce0bcf | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 59 | #include <asm/vmi.h> |
Bernhard Kaindl | 2b1f627 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 60 | #include <asm/mtrr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Glauber de Oliveira Costa | 1d89a7f | 2008-03-19 14:25:05 -0300 | [diff] [blame] | 62 | extern int smp_b_stepping; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | static cpumask_t smp_commenced_mask; |
| 65 | |
travis@sgi.com | 3b41908 | 2008-01-30 13:33:11 +0100 | [diff] [blame] | 66 | /* which logical CPU number maps to which CPU (physical APIC ID) */ |
Glauber Costa | 5382e89 | 2008-03-03 14:12:57 -0300 | [diff] [blame] | 67 | u16 x86_cpu_to_apicid_init[NR_CPUS] __initdata = |
Mike Travis | 71fff5e | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 68 | { [0 ... NR_CPUS-1] = BAD_APICID }; |
travis@sgi.com | 3b41908 | 2008-01-30 13:33:11 +0100 | [diff] [blame] | 69 | void *x86_cpu_to_apicid_early_ptr; |
Glauber Costa | 5382e89 | 2008-03-03 14:12:57 -0300 | [diff] [blame] | 70 | DEFINE_PER_CPU(u16, x86_cpu_to_apicid) = BAD_APICID; |
Mike Travis | 71fff5e | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 71 | EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Glauber de Oliveira Costa | cbe879f | 2008-03-19 14:25:19 -0300 | [diff] [blame^] | 73 | u16 x86_bios_cpu_apicid_init[NR_CPUS] __initdata |
| 74 | = { [0 ... NR_CPUS-1] = BAD_APICID }; |
| 75 | void *x86_bios_cpu_apicid_early_ptr; |
| 76 | DEFINE_PER_CPU(u16, x86_bios_cpu_apicid) = BAD_APICID; |
| 77 | EXPORT_PER_CPU_SYMBOL(x86_bios_cpu_apicid); |
| 78 | |
keith mannthey | 3b08606 | 2006-09-29 01:58:46 -0700 | [diff] [blame] | 79 | u8 apicid_2_node[MAX_APICID]; |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | static void map_cpu_to_logical_apicid(void); |
| 82 | |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 83 | /* State of each CPU. */ |
| 84 | DEFINE_PER_CPU(int, cpu_state) = { 0 }; |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | static atomic_t init_deasserted; |
| 87 | |
Vivek Goyal | 4a5d107 | 2007-01-11 01:52:44 +0100 | [diff] [blame] | 88 | static void __cpuinit smp_callin(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | { |
| 90 | int cpuid, phys_id; |
| 91 | unsigned long timeout; |
| 92 | |
| 93 | /* |
| 94 | * If waken up by an INIT in an 82489DX configuration |
| 95 | * we may get here before an INIT-deassert IPI reaches |
| 96 | * our local APIC. We have to wait for the IPI or we'll |
| 97 | * lock up on an APIC access. |
| 98 | */ |
| 99 | wait_for_init_deassert(&init_deasserted); |
| 100 | |
| 101 | /* |
| 102 | * (This works even if the APIC is not enabled.) |
| 103 | */ |
| 104 | phys_id = GET_APIC_ID(apic_read(APIC_ID)); |
| 105 | cpuid = smp_processor_id(); |
| 106 | if (cpu_isset(cpuid, cpu_callin_map)) { |
| 107 | printk("huh, phys CPU#%d, CPU#%d already present??\n", |
| 108 | phys_id, cpuid); |
| 109 | BUG(); |
| 110 | } |
| 111 | Dprintk("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid, phys_id); |
| 112 | |
| 113 | /* |
| 114 | * STARTUP IPIs are fragile beasts as they might sometimes |
| 115 | * trigger some glue motherboard logic. Complete APIC bus |
| 116 | * silence for 1 second, this overestimates the time the |
| 117 | * boot CPU is spending to send the up to 2 STARTUP IPIs |
| 118 | * by a factor of two. This should be enough. |
| 119 | */ |
| 120 | |
| 121 | /* |
| 122 | * Waiting 2s total for startup (udelay is not yet working) |
| 123 | */ |
| 124 | timeout = jiffies + 2*HZ; |
| 125 | while (time_before(jiffies, timeout)) { |
| 126 | /* |
| 127 | * Has the boot CPU finished it's STARTUP sequence? |
| 128 | */ |
| 129 | if (cpu_isset(cpuid, cpu_callout_map)) |
| 130 | break; |
Glauber Costa | e104383 | 2008-03-03 14:13:14 -0300 | [diff] [blame] | 131 | cpu_relax(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | if (!time_before(jiffies, timeout)) { |
| 135 | printk("BUG: CPU%d started up but did not get a callout!\n", |
| 136 | cpuid); |
| 137 | BUG(); |
| 138 | } |
| 139 | |
| 140 | /* |
| 141 | * the boot CPU has finished the init stage and is spinning |
| 142 | * on callin_map until we finish. We are free to set up this |
| 143 | * CPU, first the APIC. (this is probably redundant on most |
| 144 | * boards) |
| 145 | */ |
| 146 | |
| 147 | Dprintk("CALLIN, before setup_local_APIC().\n"); |
| 148 | smp_callin_clear_local_apic(); |
| 149 | setup_local_APIC(); |
| 150 | map_cpu_to_logical_apicid(); |
| 151 | |
| 152 | /* |
| 153 | * Get our bogomips. |
| 154 | */ |
| 155 | calibrate_delay(); |
| 156 | Dprintk("Stack at about %p\n",&cpuid); |
| 157 | |
| 158 | /* |
| 159 | * Save our processor parameters |
| 160 | */ |
Thomas Gleixner | e9e2cdb | 2007-02-16 01:28:04 -0800 | [diff] [blame] | 161 | smp_store_cpu_info(cpuid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
| 163 | /* |
| 164 | * Allow the master to continue. |
| 165 | */ |
| 166 | cpu_set(cpuid, cpu_callin_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | static int cpucount; |
| 170 | |
| 171 | /* |
| 172 | * Activate a secondary processor. |
| 173 | */ |
Vivek Goyal | 4a5d107 | 2007-01-11 01:52:44 +0100 | [diff] [blame] | 174 | static void __cpuinit start_secondary(void *unused) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | { |
| 176 | /* |
Rusty Russell | d2cbcc4 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 177 | * Don't put *anything* before cpu_init(), SMP booting is too |
| 178 | * fragile that we want to limit the things done here to the |
| 179 | * most necessary things. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | */ |
Zachary Amsden | 7ce0bcf | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 181 | #ifdef CONFIG_VMI |
| 182 | vmi_bringup(); |
| 183 | #endif |
Rusty Russell | d2cbcc4 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 184 | cpu_init(); |
Nick Piggin | 5bfb5d6 | 2005-11-08 21:39:01 -0800 | [diff] [blame] | 185 | preempt_disable(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | smp_callin(); |
| 187 | while (!cpu_isset(smp_processor_id(), smp_commenced_mask)) |
Glauber Costa | e104383 | 2008-03-03 14:13:14 -0300 | [diff] [blame] | 188 | cpu_relax(); |
Glauber de Oliveira Costa | fa8004d | 2008-03-19 14:25:12 -0300 | [diff] [blame] | 189 | |
| 190 | /* otherwise gcc will move up smp_processor_id before the cpu_init */ |
| 191 | barrier(); |
Ingo Molnar | 95492e4 | 2007-02-16 01:27:34 -0800 | [diff] [blame] | 192 | /* |
| 193 | * Check TSC synchronization with the BP: |
| 194 | */ |
| 195 | check_tsc_sync_target(); |
| 196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | if (nmi_watchdog == NMI_IO_APIC) { |
| 198 | disable_8259A_irq(0); |
Jan Beulich | e942710 | 2008-01-30 13:31:24 +0100 | [diff] [blame] | 199 | enable_NMI_through_LVT0(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | enable_8259A_irq(0); |
| 201 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | /* |
| 203 | * low-memory mappings have been cleared, flush them from |
| 204 | * the local TLBs too. |
| 205 | */ |
| 206 | local_flush_tlb(); |
Li Shaohua | 6fe940d | 2005-06-25 14:54:53 -0700 | [diff] [blame] | 207 | |
Li Shaohua | d720803 | 2005-06-25 14:54:54 -0700 | [diff] [blame] | 208 | /* This must be done before setting cpu_online_map */ |
| 209 | set_cpu_sibling_map(raw_smp_processor_id()); |
| 210 | wmb(); |
| 211 | |
Li Shaohua | 6fe940d | 2005-06-25 14:54:53 -0700 | [diff] [blame] | 212 | /* |
| 213 | * We need to hold call_lock, so there is no inconsistency |
| 214 | * between the time smp_call_function() determines number of |
Simon Arlott | 27b46d7 | 2007-10-20 01:13:56 +0200 | [diff] [blame] | 215 | * IPI recipients, and the time when the determination is made |
Li Shaohua | 6fe940d | 2005-06-25 14:54:53 -0700 | [diff] [blame] | 216 | * for which cpus receive the IPI. Holding this |
| 217 | * lock helps us to not include this cpu in a currently in progress |
| 218 | * smp_call_function(). |
| 219 | */ |
| 220 | lock_ipi_call_lock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | cpu_set(smp_processor_id(), cpu_online_map); |
Li Shaohua | 6fe940d | 2005-06-25 14:54:53 -0700 | [diff] [blame] | 222 | unlock_ipi_call_lock(); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 223 | per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | |
Glauber de Oliveira Costa | 8f15b82 | 2008-03-19 14:25:08 -0300 | [diff] [blame] | 225 | setup_secondary_clock(); |
| 226 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | wmb(); |
| 228 | cpu_idle(); |
| 229 | } |
| 230 | |
| 231 | /* |
| 232 | * Everything has been set up for the secondary |
| 233 | * CPUs - they just need to reload everything |
| 234 | * from the task structure |
| 235 | * This function must not return. |
| 236 | */ |
Li Shaohua | 0bb3184 | 2005-06-25 14:54:55 -0700 | [diff] [blame] | 237 | void __devinit initialize_secondary(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | { |
| 239 | /* |
| 240 | * We don't actually need to load the full TSS, |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 241 | * basically just the stack pointer and the ip. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | */ |
| 243 | |
| 244 | asm volatile( |
| 245 | "movl %0,%%esp\n\t" |
| 246 | "jmp *%1" |
| 247 | : |
H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 248 | :"m" (current->thread.sp),"m" (current->thread.ip)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Jeremy Fitzhardinge | 6211119 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 251 | /* Static state in head.S used to set up a CPU */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | extern struct { |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 253 | void * sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | unsigned short ss; |
| 255 | } stack_start; |
| 256 | |
| 257 | #ifdef CONFIG_NUMA |
| 258 | |
| 259 | /* which logical CPUs are on which nodes */ |
Thomas Gleixner | fe21a44 | 2008-01-30 13:30:38 +0100 | [diff] [blame] | 260 | cpumask_t node_to_cpumask_map[MAX_NUMNODES] __read_mostly = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | { [0 ... MAX_NUMNODES-1] = CPU_MASK_NONE }; |
Thomas Gleixner | fe21a44 | 2008-01-30 13:30:38 +0100 | [diff] [blame] | 262 | EXPORT_SYMBOL(node_to_cpumask_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | /* which node each logical CPU is on */ |
travis@sgi.com | 602a54a | 2008-01-30 13:33:21 +0100 | [diff] [blame] | 264 | int cpu_to_node_map[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = 0 }; |
Thomas Gleixner | fe21a44 | 2008-01-30 13:30:38 +0100 | [diff] [blame] | 265 | EXPORT_SYMBOL(cpu_to_node_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | |
| 267 | /* set up a mapping between cpu and node. */ |
| 268 | static inline void map_cpu_to_node(int cpu, int node) |
| 269 | { |
| 270 | printk("Mapping cpu %d to node %d\n", cpu, node); |
Thomas Gleixner | fe21a44 | 2008-01-30 13:30:38 +0100 | [diff] [blame] | 271 | cpu_set(cpu, node_to_cpumask_map[node]); |
| 272 | cpu_to_node_map[cpu] = node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | /* undo a mapping between cpu and node. */ |
| 276 | static inline void unmap_cpu_to_node(int cpu) |
| 277 | { |
| 278 | int node; |
| 279 | |
| 280 | printk("Unmapping cpu %d from all nodes\n", cpu); |
| 281 | for (node = 0; node < MAX_NUMNODES; node ++) |
Thomas Gleixner | fe21a44 | 2008-01-30 13:30:38 +0100 | [diff] [blame] | 282 | cpu_clear(cpu, node_to_cpumask_map[node]); |
| 283 | cpu_to_node_map[cpu] = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | } |
| 285 | #else /* !CONFIG_NUMA */ |
| 286 | |
| 287 | #define map_cpu_to_node(cpu, node) ({}) |
| 288 | #define unmap_cpu_to_node(cpu) ({}) |
| 289 | |
| 290 | #endif /* CONFIG_NUMA */ |
| 291 | |
Christoph Lameter | 6c03652 | 2005-07-07 17:56:59 -0700 | [diff] [blame] | 292 | u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | |
| 294 | static void map_cpu_to_logical_apicid(void) |
| 295 | { |
| 296 | int cpu = smp_processor_id(); |
| 297 | int apicid = logical_smp_processor_id(); |
Keith Mannthey | 78b656b | 2006-10-03 18:25:52 -0700 | [diff] [blame] | 298 | int node = apicid_to_node(apicid); |
keith mannthey | bfa0e9a | 2006-09-25 16:25:35 -0700 | [diff] [blame] | 299 | |
| 300 | if (!node_online(node)) |
| 301 | node = first_online_node; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
| 303 | cpu_2_logical_apicid[cpu] = apicid; |
keith mannthey | bfa0e9a | 2006-09-25 16:25:35 -0700 | [diff] [blame] | 304 | map_cpu_to_node(cpu, node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | static void unmap_cpu_to_logical_apicid(int cpu) |
| 308 | { |
| 309 | cpu_2_logical_apicid[cpu] = BAD_APICID; |
| 310 | unmap_cpu_to_node(cpu); |
| 311 | } |
| 312 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | static inline void __inquire_remote_apic(int apicid) |
| 314 | { |
Glauber de Oliveira Costa | 26c6b5e | 2008-03-19 14:24:56 -0300 | [diff] [blame] | 315 | unsigned i, regs[] = { APIC_ID >> 4, APIC_LVR >> 4, APIC_SPIV >> 4 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | char *names[] = { "ID", "VERSION", "SPIV" }; |
Fernando Luis VazquezCao | 4312fa8 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 317 | int timeout; |
Glauber de Oliveira Costa | 26c6b5e | 2008-03-19 14:24:56 -0300 | [diff] [blame] | 318 | u32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
Glauber de Oliveira Costa | ba10485 | 2008-03-19 14:24:57 -0300 | [diff] [blame] | 320 | printk(KERN_INFO "Inquiring remote APIC #%d...\n", apicid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Tobias Klauser | 38e548e | 2005-11-07 00:58:31 -0800 | [diff] [blame] | 322 | for (i = 0; i < ARRAY_SIZE(regs); i++) { |
Glauber de Oliveira Costa | ba10485 | 2008-03-19 14:24:57 -0300 | [diff] [blame] | 323 | printk(KERN_INFO "... APIC #%d %s: ", apicid, names[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
| 325 | /* |
| 326 | * Wait for idle. |
| 327 | */ |
Fernando Luis VazquezCao | 4312fa8 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 328 | status = safe_apic_wait_icr_idle(); |
| 329 | if (status) |
Glauber de Oliveira Costa | ba10485 | 2008-03-19 14:24:57 -0300 | [diff] [blame] | 330 | printk(KERN_CONT |
| 331 | "a previous APIC delivery may have failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(apicid)); |
| 334 | apic_write_around(APIC_ICR, APIC_DM_REMRD | regs[i]); |
| 335 | |
| 336 | timeout = 0; |
| 337 | do { |
| 338 | udelay(100); |
| 339 | status = apic_read(APIC_ICR) & APIC_ICR_RR_MASK; |
| 340 | } while (status == APIC_ICR_RR_INPROG && timeout++ < 1000); |
| 341 | |
| 342 | switch (status) { |
| 343 | case APIC_ICR_RR_VALID: |
| 344 | status = apic_read(APIC_RRR); |
Glauber de Oliveira Costa | ba10485 | 2008-03-19 14:24:57 -0300 | [diff] [blame] | 345 | printk(KERN_CONT "%08x\n", status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | break; |
| 347 | default: |
Glauber de Oliveira Costa | ba10485 | 2008-03-19 14:24:57 -0300 | [diff] [blame] | 348 | printk(KERN_CONT "failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
| 353 | #ifdef WAKE_SECONDARY_VIA_NMI |
| 354 | /* |
| 355 | * Poke the other CPU in the eye via NMI to wake it up. Remember that the normal |
| 356 | * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this |
| 357 | * won't ... remember to clear down the APIC, etc later. |
| 358 | */ |
Li Shaohua | 0bb3184 | 2005-06-25 14:54:55 -0700 | [diff] [blame] | 359 | static int __devinit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | wakeup_secondary_cpu(int logical_apicid, unsigned long start_eip) |
| 361 | { |
Fernando Luis VazquezCao | ae08e43 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 362 | unsigned long send_status, accept_status = 0; |
| 363 | int maxlvt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | |
| 365 | /* Target chip */ |
| 366 | apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(logical_apicid)); |
| 367 | |
| 368 | /* Boot on the stack */ |
| 369 | /* Kick the second */ |
| 370 | apic_write_around(APIC_ICR, APIC_DM_NMI | APIC_DEST_LOGICAL); |
| 371 | |
| 372 | Dprintk("Waiting for send to finish...\n"); |
Fernando Luis VazquezCao | ae08e43 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 373 | send_status = safe_apic_wait_icr_idle(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | |
| 375 | /* |
| 376 | * Give the other CPU some time to accept the IPI. |
| 377 | */ |
| 378 | udelay(200); |
| 379 | /* |
| 380 | * Due to the Pentium erratum 3AP. |
| 381 | */ |
Thomas Gleixner | e05d723 | 2007-02-16 01:27:58 -0800 | [diff] [blame] | 382 | maxlvt = lapic_get_maxlvt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | if (maxlvt > 3) { |
| 384 | apic_read_around(APIC_SPIV); |
| 385 | apic_write(APIC_ESR, 0); |
| 386 | } |
| 387 | accept_status = (apic_read(APIC_ESR) & 0xEF); |
| 388 | Dprintk("NMI sent.\n"); |
| 389 | |
| 390 | if (send_status) |
| 391 | printk("APIC never delivered???\n"); |
| 392 | if (accept_status) |
| 393 | printk("APIC delivery error (%lx).\n", accept_status); |
| 394 | |
| 395 | return (send_status | accept_status); |
| 396 | } |
| 397 | #endif /* WAKE_SECONDARY_VIA_NMI */ |
| 398 | |
| 399 | #ifdef WAKE_SECONDARY_VIA_INIT |
Li Shaohua | 0bb3184 | 2005-06-25 14:54:55 -0700 | [diff] [blame] | 400 | static int __devinit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip) |
| 402 | { |
Fernando Luis VazquezCao | ae08e43 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 403 | unsigned long send_status, accept_status = 0; |
| 404 | int maxlvt, num_starts, j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
| 406 | /* |
| 407 | * Be paranoid about clearing APIC errors. |
| 408 | */ |
| 409 | if (APIC_INTEGRATED(apic_version[phys_apicid])) { |
| 410 | apic_read_around(APIC_SPIV); |
| 411 | apic_write(APIC_ESR, 0); |
| 412 | apic_read(APIC_ESR); |
| 413 | } |
| 414 | |
| 415 | Dprintk("Asserting INIT.\n"); |
| 416 | |
| 417 | /* |
| 418 | * Turn INIT on target chip |
| 419 | */ |
| 420 | apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); |
| 421 | |
| 422 | /* |
| 423 | * Send IPI |
| 424 | */ |
| 425 | apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_INT_ASSERT |
| 426 | | APIC_DM_INIT); |
| 427 | |
| 428 | Dprintk("Waiting for send to finish...\n"); |
Fernando Luis VazquezCao | ae08e43 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 429 | send_status = safe_apic_wait_icr_idle(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 430 | |
| 431 | mdelay(10); |
| 432 | |
| 433 | Dprintk("Deasserting INIT.\n"); |
| 434 | |
| 435 | /* Target chip */ |
| 436 | apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); |
| 437 | |
| 438 | /* Send IPI */ |
| 439 | apic_write_around(APIC_ICR, APIC_INT_LEVELTRIG | APIC_DM_INIT); |
| 440 | |
| 441 | Dprintk("Waiting for send to finish...\n"); |
Fernando Luis VazquezCao | ae08e43 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 442 | send_status = safe_apic_wait_icr_idle(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | |
Glauber de Oliveira Costa | fa8004d | 2008-03-19 14:25:12 -0300 | [diff] [blame] | 444 | mb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | atomic_set(&init_deasserted, 1); |
| 446 | |
| 447 | /* |
| 448 | * Should we send STARTUP IPIs ? |
| 449 | * |
| 450 | * Determine this based on the APIC version. |
| 451 | * If we don't have an integrated APIC, don't send the STARTUP IPIs. |
| 452 | */ |
| 453 | if (APIC_INTEGRATED(apic_version[phys_apicid])) |
| 454 | num_starts = 2; |
| 455 | else |
| 456 | num_starts = 0; |
| 457 | |
| 458 | /* |
Zachary Amsden | ae5da27 | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 459 | * Paravirt / VMI wants a startup IPI hook here to set up the |
| 460 | * target processor state. |
| 461 | */ |
| 462 | startup_ipi_hook(phys_apicid, (unsigned long) start_secondary, |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 463 | (unsigned long) stack_start.sp); |
Zachary Amsden | ae5da27 | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 464 | |
| 465 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | * Run STARTUP IPI loop. |
| 467 | */ |
| 468 | Dprintk("#startup loops: %d.\n", num_starts); |
| 469 | |
Thomas Gleixner | e05d723 | 2007-02-16 01:27:58 -0800 | [diff] [blame] | 470 | maxlvt = lapic_get_maxlvt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 471 | |
| 472 | for (j = 1; j <= num_starts; j++) { |
| 473 | Dprintk("Sending STARTUP #%d.\n",j); |
| 474 | apic_read_around(APIC_SPIV); |
| 475 | apic_write(APIC_ESR, 0); |
| 476 | apic_read(APIC_ESR); |
| 477 | Dprintk("After apic_write.\n"); |
| 478 | |
| 479 | /* |
| 480 | * STARTUP IPI |
| 481 | */ |
| 482 | |
| 483 | /* Target chip */ |
| 484 | apic_write_around(APIC_ICR2, SET_APIC_DEST_FIELD(phys_apicid)); |
| 485 | |
| 486 | /* Boot on the stack */ |
| 487 | /* Kick the second */ |
| 488 | apic_write_around(APIC_ICR, APIC_DM_STARTUP |
| 489 | | (start_eip >> 12)); |
| 490 | |
| 491 | /* |
| 492 | * Give the other CPU some time to accept the IPI. |
| 493 | */ |
| 494 | udelay(300); |
| 495 | |
| 496 | Dprintk("Startup point 1.\n"); |
| 497 | |
| 498 | Dprintk("Waiting for send to finish...\n"); |
Fernando Luis VazquezCao | ae08e43 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 499 | send_status = safe_apic_wait_icr_idle(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
| 501 | /* |
| 502 | * Give the other CPU some time to accept the IPI. |
| 503 | */ |
| 504 | udelay(200); |
| 505 | /* |
| 506 | * Due to the Pentium erratum 3AP. |
| 507 | */ |
| 508 | if (maxlvt > 3) { |
| 509 | apic_read_around(APIC_SPIV); |
| 510 | apic_write(APIC_ESR, 0); |
| 511 | } |
| 512 | accept_status = (apic_read(APIC_ESR) & 0xEF); |
| 513 | if (send_status || accept_status) |
| 514 | break; |
| 515 | } |
| 516 | Dprintk("After Startup.\n"); |
| 517 | |
| 518 | if (send_status) |
| 519 | printk("APIC never delivered???\n"); |
| 520 | if (accept_status) |
| 521 | printk("APIC delivery error (%lx).\n", accept_status); |
| 522 | |
| 523 | return (send_status | accept_status); |
| 524 | } |
| 525 | #endif /* WAKE_SECONDARY_VIA_INIT */ |
| 526 | |
| 527 | extern cpumask_t cpu_initialized; |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 528 | static inline int alloc_cpu_id(void) |
| 529 | { |
| 530 | cpumask_t tmp_map; |
| 531 | int cpu; |
| 532 | cpus_complement(tmp_map, cpu_present_map); |
| 533 | cpu = first_cpu(tmp_map); |
| 534 | if (cpu >= NR_CPUS) |
| 535 | return -ENODEV; |
| 536 | return cpu; |
| 537 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 539 | #ifdef CONFIG_HOTPLUG_CPU |
Adrian Bunk | f2206ec | 2007-12-19 23:20:18 +0100 | [diff] [blame] | 540 | static struct task_struct * __cpuinitdata cpu_idle_tasks[NR_CPUS]; |
| 541 | static inline struct task_struct * __cpuinit alloc_idle_task(int cpu) |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 542 | { |
| 543 | struct task_struct *idle; |
| 544 | |
| 545 | if ((idle = cpu_idle_tasks[cpu]) != NULL) { |
| 546 | /* initialize thread_struct. we really want to avoid destroy |
| 547 | * idle tread |
| 548 | */ |
H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 549 | idle->thread.sp = (unsigned long)task_pt_regs(idle); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 550 | init_idle(idle, cpu); |
| 551 | return idle; |
| 552 | } |
| 553 | idle = fork_idle(cpu); |
| 554 | |
| 555 | if (!IS_ERR(idle)) |
| 556 | cpu_idle_tasks[cpu] = idle; |
| 557 | return idle; |
| 558 | } |
| 559 | #else |
| 560 | #define alloc_idle_task(cpu) fork_idle(cpu) |
| 561 | #endif |
| 562 | |
Vivek Goyal | 4a5d107 | 2007-01-11 01:52:44 +0100 | [diff] [blame] | 563 | static int __cpuinit do_boot_cpu(int apicid, int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | /* |
| 565 | * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad |
| 566 | * (ie clustered apic addressing mode), this is a LOGICAL apic ID. |
| 567 | * Returns zero if CPU booted OK, else error code from wakeup_secondary_cpu. |
| 568 | */ |
| 569 | { |
| 570 | struct task_struct *idle; |
| 571 | unsigned long boot_error; |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 572 | int timeout; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | unsigned long start_eip; |
| 574 | unsigned short nmi_high = 0, nmi_low = 0; |
| 575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | /* |
Bernhard Kaindl | 2b1f627 | 2007-05-02 19:27:17 +0200 | [diff] [blame] | 577 | * Save current MTRR state in case it was changed since early boot |
| 578 | * (e.g. by the ACPI SMI) to initialize new CPUs with MTRRs in sync: |
| 579 | */ |
| 580 | mtrr_save_state(); |
| 581 | |
| 582 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | * We can't use kernel_thread since we must avoid to |
| 584 | * reschedule the child. |
| 585 | */ |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 586 | idle = alloc_idle_task(cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 587 | if (IS_ERR(idle)) |
| 588 | panic("failed fork for CPU %d", cpu); |
Jeremy Fitzhardinge | 6211119 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 589 | |
Jeremy Fitzhardinge | 7c3576d | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 590 | init_gdt(cpu); |
| 591 | per_cpu(current_task, cpu) = idle; |
Rusty Russell | bf504672 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 592 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); |
Jeremy Fitzhardinge | 6211119 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 593 | |
H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 594 | idle->thread.ip = (unsigned long) start_secondary; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | /* start_eip had better be page-aligned! */ |
| 596 | start_eip = setup_trampoline(); |
| 597 | |
Jeremy Fitzhardinge | 6211119 | 2006-12-07 02:14:02 +0100 | [diff] [blame] | 598 | ++cpucount; |
| 599 | alternatives_smp_switch(1); |
| 600 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 601 | /* So we see what's up */ |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 602 | printk("Booting processor %d/%d ip %lx\n", cpu, apicid, start_eip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | /* Stack for startup_32 can be just as for start_secondary onwards */ |
H. Peter Anvin | faca622 | 2008-01-30 13:31:02 +0100 | [diff] [blame] | 604 | stack_start.sp = (void *) idle->thread.sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | |
| 606 | irq_ctx_init(cpu); |
| 607 | |
Mike Travis | 71fff5e | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 608 | per_cpu(x86_cpu_to_apicid, cpu) = apicid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 609 | /* |
| 610 | * This grunge runs the startup process for |
| 611 | * the targeted processor. |
| 612 | */ |
| 613 | |
| 614 | atomic_set(&init_deasserted, 0); |
| 615 | |
| 616 | Dprintk("Setting warm reset code and vector.\n"); |
| 617 | |
| 618 | store_NMI_vector(&nmi_high, &nmi_low); |
| 619 | |
| 620 | smpboot_setup_warm_reset_vector(start_eip); |
| 621 | |
| 622 | /* |
| 623 | * Starting actual IPI sequence... |
| 624 | */ |
| 625 | boot_error = wakeup_secondary_cpu(apicid, start_eip); |
| 626 | |
| 627 | if (!boot_error) { |
| 628 | /* |
| 629 | * allow APs to start initializing. |
| 630 | */ |
| 631 | Dprintk("Before Callout %d.\n", cpu); |
| 632 | cpu_set(cpu, cpu_callout_map); |
| 633 | Dprintk("After Callout %d.\n", cpu); |
| 634 | |
| 635 | /* |
| 636 | * Wait 5s total for a response |
| 637 | */ |
| 638 | for (timeout = 0; timeout < 50000; timeout++) { |
| 639 | if (cpu_isset(cpu, cpu_callin_map)) |
| 640 | break; /* It has booted */ |
| 641 | udelay(100); |
| 642 | } |
| 643 | |
| 644 | if (cpu_isset(cpu, cpu_callin_map)) { |
| 645 | /* number CPUs logically, starting from 1 (BSP is 0) */ |
| 646 | Dprintk("OK.\n"); |
| 647 | printk("CPU%d: ", cpu); |
Mike Travis | 92cb761 | 2007-10-19 20:35:04 +0200 | [diff] [blame] | 648 | print_cpu_info(&cpu_data(cpu)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | Dprintk("CPU has booted.\n"); |
| 650 | } else { |
| 651 | boot_error= 1; |
| 652 | if (*((volatile unsigned char *)trampoline_base) |
| 653 | == 0xA5) |
| 654 | /* trampoline started but...? */ |
| 655 | printk("Stuck ??\n"); |
| 656 | else |
| 657 | /* trampoline code not run */ |
| 658 | printk("Not responding.\n"); |
| 659 | inquire_remote_apic(apicid); |
| 660 | } |
| 661 | } |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 662 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | if (boot_error) { |
| 664 | /* Try to put things back the way they were before ... */ |
| 665 | unmap_cpu_to_logical_apicid(cpu); |
| 666 | cpu_clear(cpu, cpu_callout_map); /* was set here (do_boot_cpu()) */ |
| 667 | cpu_clear(cpu, cpu_initialized); /* was set by cpu_init() */ |
| 668 | cpucount--; |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 669 | } else { |
Mike Travis | 71fff5e | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 670 | per_cpu(x86_cpu_to_apicid, cpu) = apicid; |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 671 | cpu_set(cpu, cpu_present_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | /* mark "stuck" area as not stuck */ |
| 675 | *((volatile unsigned long *)trampoline_base) = 0; |
| 676 | |
| 677 | return boot_error; |
| 678 | } |
| 679 | |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 680 | #ifdef CONFIG_HOTPLUG_CPU |
| 681 | void cpu_exit_clear(void) |
| 682 | { |
| 683 | int cpu = raw_smp_processor_id(); |
| 684 | |
| 685 | idle_task_exit(); |
| 686 | |
| 687 | cpucount --; |
| 688 | cpu_uninit(); |
| 689 | irq_ctx_exit(cpu); |
| 690 | |
| 691 | cpu_clear(cpu, cpu_callout_map); |
| 692 | cpu_clear(cpu, cpu_callin_map); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 693 | |
| 694 | cpu_clear(cpu, smp_commenced_mask); |
| 695 | unmap_cpu_to_logical_apicid(cpu); |
| 696 | } |
| 697 | |
| 698 | struct warm_boot_cpu_info { |
| 699 | struct completion *complete; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 700 | struct work_struct task; |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 701 | int apicid; |
| 702 | int cpu; |
| 703 | }; |
| 704 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 705 | static void __cpuinit do_warm_boot_cpu(struct work_struct *work) |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 706 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 707 | struct warm_boot_cpu_info *info = |
| 708 | container_of(work, struct warm_boot_cpu_info, task); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 709 | do_boot_cpu(info->apicid, info->cpu); |
| 710 | complete(info->complete); |
| 711 | } |
| 712 | |
Glauber de Oliveira Costa | f3ce446 | 2008-03-19 14:25:16 -0300 | [diff] [blame] | 713 | static void __cpuinit __smp_prepare_cpu(int cpu) |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 714 | { |
Peter Zijlstra | 6e9a473 | 2006-09-30 23:28:10 -0700 | [diff] [blame] | 715 | DECLARE_COMPLETION_ONSTACK(done); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 716 | struct warm_boot_cpu_info info; |
Glauber de Oliveira Costa | f3ce446 | 2008-03-19 14:25:16 -0300 | [diff] [blame] | 717 | int apicid; |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 718 | |
Mike Travis | 71fff5e | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 719 | apicid = per_cpu(x86_cpu_to_apicid, cpu); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 720 | |
| 721 | info.complete = &done; |
| 722 | info.apicid = apicid; |
| 723 | info.cpu = cpu; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 724 | INIT_WORK(&info.task, do_warm_boot_cpu); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 725 | |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 726 | /* init low mem mapping */ |
Zachary Amsden | d7271b1 | 2005-09-03 15:56:50 -0700 | [diff] [blame] | 727 | clone_pgd_range(swapper_pg_dir, swapper_pg_dir + USER_PGD_PTRS, |
Shaohua Li | 3b1bdf4 | 2006-12-08 02:41:13 -0800 | [diff] [blame] | 728 | min_t(unsigned long, KERNEL_PGD_PTRS, USER_PGD_PTRS)); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 729 | flush_tlb_all(); |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 730 | schedule_work(&info.task); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 731 | wait_for_completion(&done); |
| 732 | |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 733 | zap_low_mappings(); |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 734 | } |
| 735 | #endif |
| 736 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | static int boot_cpu_logical_apicid; |
| 738 | /* Where the IO area was mapped on multiquad, always 0 otherwise */ |
| 739 | void *xquad_portio; |
Alexey Dobriyan | 129f694 | 2005-06-23 00:08:33 -0700 | [diff] [blame] | 740 | #ifdef CONFIG_X86_NUMAQ |
| 741 | EXPORT_SYMBOL(xquad_portio); |
| 742 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 743 | |
Glauber de Oliveira Costa | b675f11 | 2008-03-19 14:25:14 -0300 | [diff] [blame] | 744 | static void __init disable_smp(void) |
| 745 | { |
| 746 | smpboot_clear_io_apic_irqs(); |
| 747 | phys_cpu_present_map = physid_mask_of_physid(0); |
| 748 | map_cpu_to_logical_apicid(); |
| 749 | cpu_set(0, per_cpu(cpu_sibling_map, 0)); |
| 750 | cpu_set(0, per_cpu(cpu_core_map, 0)); |
| 751 | } |
| 752 | |
Glauber de Oliveira Costa | 4780b26 | 2008-03-19 14:25:13 -0300 | [diff] [blame] | 753 | static int __init smp_sanity_check(unsigned max_cpus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | /* |
| 756 | * If we couldn't find an SMP configuration at boot time, |
| 757 | * get out of here now! |
| 758 | */ |
| 759 | if (!smp_found_config && !acpi_lapic) { |
| 760 | printk(KERN_NOTICE "SMP motherboard not detected.\n"); |
Glauber de Oliveira Costa | b675f11 | 2008-03-19 14:25:14 -0300 | [diff] [blame] | 761 | disable_smp(); |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 762 | if (APIC_init_uniprocessor()) |
| 763 | printk(KERN_NOTICE "Local APIC not detected." |
| 764 | " Using dummy APIC emulation.\n"); |
Glauber de Oliveira Costa | 4780b26 | 2008-03-19 14:25:13 -0300 | [diff] [blame] | 765 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | /* |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 769 | * Should not be necessary because the MP table should list the boot |
| 770 | * CPU too, but we do it for the sake of robustness anyway. |
| 771 | * Makes no sense to do this check in clustered apic mode, so skip it |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | */ |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 773 | if (!check_phys_apicid_present(boot_cpu_physical_apicid)) { |
| 774 | printk("weird, boot CPU (#%d) not listed by the BIOS.\n", |
| 775 | boot_cpu_physical_apicid); |
| 776 | physid_set(hard_smp_processor_id(), phys_cpu_present_map); |
| 777 | } |
| 778 | |
| 779 | /* |
| 780 | * If we couldn't find a local APIC, then get out of here now! |
| 781 | */ |
| 782 | if (APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid]) && !cpu_has_apic) { |
| 783 | printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n", |
| 784 | boot_cpu_physical_apicid); |
| 785 | printk(KERN_ERR "... forcing use of dummy APIC emulation. (tell your hw vendor)\n"); |
Glauber de Oliveira Costa | 4780b26 | 2008-03-19 14:25:13 -0300 | [diff] [blame] | 786 | return -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | } |
| 788 | |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 789 | verify_local_APIC(); |
| 790 | |
| 791 | /* |
| 792 | * If SMP should be disabled, then really disable it! |
| 793 | */ |
| 794 | if (!max_cpus) { |
| 795 | smp_found_config = 0; |
| 796 | printk(KERN_INFO "SMP mode deactivated, forcing use of dummy APIC emulation.\n"); |
Ingo Molnar | 3fb450a | 2007-10-17 18:04:34 +0200 | [diff] [blame] | 797 | |
| 798 | if (nmi_watchdog == NMI_LOCAL_APIC) { |
| 799 | printk(KERN_INFO "activating minimal APIC for NMI watchdog use.\n"); |
| 800 | connect_bsp_APIC(); |
| 801 | setup_local_APIC(); |
| 802 | } |
Glauber de Oliveira Costa | 4780b26 | 2008-03-19 14:25:13 -0300 | [diff] [blame] | 803 | return -1; |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 804 | } |
Glauber de Oliveira Costa | 4780b26 | 2008-03-19 14:25:13 -0300 | [diff] [blame] | 805 | return 0; |
| 806 | } |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 807 | |
Glauber de Oliveira Costa | 4780b26 | 2008-03-19 14:25:13 -0300 | [diff] [blame] | 808 | |
| 809 | /* |
| 810 | * Cycle through the processors sending APIC IPIs to boot each. |
| 811 | */ |
| 812 | static void __init smp_boot_cpus(unsigned int max_cpus) |
| 813 | { |
| 814 | int apicid, cpu, bit, kicked; |
| 815 | unsigned long bogosum = 0; |
| 816 | |
| 817 | /* |
| 818 | * Setup boot CPU information |
| 819 | */ |
| 820 | smp_store_cpu_info(0); /* Final full version of the data */ |
| 821 | printk(KERN_INFO "CPU%d: ", 0); |
| 822 | print_cpu_info(&cpu_data(0)); |
| 823 | |
| 824 | boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID)); |
| 825 | boot_cpu_logical_apicid = logical_smp_processor_id(); |
| 826 | per_cpu(x86_cpu_to_apicid, 0) = boot_cpu_physical_apicid; |
| 827 | |
| 828 | current_thread_info()->cpu = 0; |
| 829 | |
| 830 | set_cpu_sibling_map(0); |
| 831 | |
Glauber de Oliveira Costa | b675f11 | 2008-03-19 14:25:14 -0300 | [diff] [blame] | 832 | if (smp_sanity_check(max_cpus) < 0) { |
| 833 | printk(KERN_INFO "SMP disabled\n"); |
| 834 | disable_smp(); |
| 835 | return; |
| 836 | } |
| 837 | |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 838 | connect_bsp_APIC(); |
| 839 | setup_local_APIC(); |
| 840 | map_cpu_to_logical_apicid(); |
| 841 | |
| 842 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | setup_portio_remap(); |
| 844 | |
| 845 | /* |
| 846 | * Scan the CPU present map and fire up the other CPUs via do_boot_cpu |
| 847 | * |
| 848 | * In clustered apic mode, phys_cpu_present_map is a constructed thus: |
| 849 | * bits 0-3 are quad0, 4-7 are quad1, etc. A perverse twist on the |
| 850 | * clustered apic ID. |
| 851 | */ |
| 852 | Dprintk("CPU present map: %lx\n", physids_coerce(phys_cpu_present_map)); |
| 853 | |
| 854 | kicked = 1; |
| 855 | for (bit = 0; kicked < NR_CPUS && bit < MAX_APICS; bit++) { |
| 856 | apicid = cpu_present_to_apicid(bit); |
| 857 | /* |
| 858 | * Don't even attempt to start the boot CPU! |
| 859 | */ |
| 860 | if ((apicid == boot_cpu_apicid) || (apicid == BAD_APICID)) |
| 861 | continue; |
| 862 | |
| 863 | if (!check_apicid_present(bit)) |
| 864 | continue; |
| 865 | if (max_cpus <= cpucount+1) |
| 866 | continue; |
| 867 | |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 868 | if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 869 | printk("CPU #%d not responding - cannot use it.\n", |
| 870 | apicid); |
| 871 | else |
| 872 | ++kicked; |
| 873 | } |
| 874 | |
| 875 | /* |
| 876 | * Cleanup possible dangling ends... |
| 877 | */ |
| 878 | smpboot_restore_warm_reset_vector(); |
| 879 | |
| 880 | /* |
| 881 | * Allow the user to impress friends. |
| 882 | */ |
| 883 | Dprintk("Before bogomips.\n"); |
Mike Travis | 7bf0c23 | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 884 | for_each_possible_cpu(cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 885 | if (cpu_isset(cpu, cpu_callout_map)) |
Mike Travis | 92cb761 | 2007-10-19 20:35:04 +0200 | [diff] [blame] | 886 | bogosum += cpu_data(cpu).loops_per_jiffy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | printk(KERN_INFO |
| 888 | "Total of %d processors activated (%lu.%02lu BogoMIPS).\n", |
| 889 | cpucount+1, |
| 890 | bogosum/(500000/HZ), |
| 891 | (bogosum/(5000/HZ))%100); |
| 892 | |
| 893 | Dprintk("Before bogocount - setting activated=1.\n"); |
| 894 | |
| 895 | if (smp_b_stepping) |
| 896 | printk(KERN_WARNING "WARNING: SMP operation may be unreliable with B stepping processors.\n"); |
| 897 | |
| 898 | /* |
| 899 | * Don't taint if we are running SMP kernel on a single non-MP |
| 900 | * approved Athlon |
| 901 | */ |
| 902 | if (tainted & TAINT_UNSAFE_SMP) { |
| 903 | if (cpucount) |
| 904 | printk (KERN_INFO "WARNING: This combination of AMD processors is not suitable for SMP.\n"); |
| 905 | else |
| 906 | tainted &= ~TAINT_UNSAFE_SMP; |
| 907 | } |
| 908 | |
| 909 | Dprintk("Boot done.\n"); |
| 910 | |
| 911 | /* |
Mike Travis | d5a7430 | 2007-10-16 01:24:05 -0700 | [diff] [blame] | 912 | * construct cpu_sibling_map, so that we can tell sibling CPUs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | * efficiently. |
| 914 | */ |
Mike Travis | 7bf0c23 | 2008-01-30 13:30:55 +0100 | [diff] [blame] | 915 | for_each_possible_cpu(cpu) { |
Mike Travis | d5a7430 | 2007-10-16 01:24:05 -0700 | [diff] [blame] | 916 | cpus_clear(per_cpu(cpu_sibling_map, cpu)); |
Mike Travis | 0835761 | 2007-10-16 01:24:04 -0700 | [diff] [blame] | 917 | cpus_clear(per_cpu(cpu_core_map, cpu)); |
Andi Kleen | 3dd9d51 | 2005-04-16 15:25:15 -0700 | [diff] [blame] | 918 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | |
Mike Travis | d5a7430 | 2007-10-16 01:24:05 -0700 | [diff] [blame] | 920 | cpu_set(0, per_cpu(cpu_sibling_map, 0)); |
Mike Travis | 0835761 | 2007-10-16 01:24:04 -0700 | [diff] [blame] | 921 | cpu_set(0, per_cpu(cpu_core_map, 0)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 922 | |
Linus Torvalds | 1e4c85f | 2005-10-31 19:16:17 -0800 | [diff] [blame] | 923 | smpboot_setup_io_apic(); |
| 924 | |
Zachary Amsden | bbab4f3 | 2007-02-13 13:26:21 +0100 | [diff] [blame] | 925 | setup_boot_clock(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | /* These are wrappers to interface to the new boot process. Someone |
| 929 | who understands all this stuff should rewrite it properly. --RR 15/Jul/02 */ |
Jeremy Fitzhardinge | 01a2f43 | 2007-05-02 19:27:11 +0200 | [diff] [blame] | 930 | void __init native_smp_prepare_cpus(unsigned int max_cpus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | { |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 932 | smp_commenced_mask = cpumask_of_cpu(0); |
| 933 | cpu_callin_map = cpumask_of_cpu(0); |
| 934 | mb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | smp_boot_cpus(max_cpus); |
| 936 | } |
| 937 | |
Jeremy Fitzhardinge | 01a2f43 | 2007-05-02 19:27:11 +0200 | [diff] [blame] | 938 | void __init native_smp_prepare_boot_cpu(void) |
Rusty Russell | bf504672 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 939 | { |
| 940 | unsigned int cpu = smp_processor_id(); |
| 941 | |
Jeremy Fitzhardinge | 7c3576d | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 942 | init_gdt(cpu); |
Rusty Russell | bf504672 | 2007-05-02 19:27:10 +0200 | [diff] [blame] | 943 | switch_to_new_gdt(); |
| 944 | |
| 945 | cpu_set(cpu, cpu_online_map); |
| 946 | cpu_set(cpu, cpu_callout_map); |
| 947 | cpu_set(cpu, cpu_present_map); |
| 948 | cpu_set(cpu, cpu_possible_map); |
| 949 | __get_cpu_var(cpu_state) = CPU_ONLINE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 950 | } |
| 951 | |
Jeremy Fitzhardinge | 01a2f43 | 2007-05-02 19:27:11 +0200 | [diff] [blame] | 952 | int __cpuinit native_cpu_up(unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | { |
Glauber de Oliveira Costa | f915d7f | 2008-03-19 14:25:15 -0300 | [diff] [blame] | 954 | int apicid = cpu_present_to_apicid(cpu); |
Ingo Molnar | d04f41e | 2007-03-07 18:12:31 +0100 | [diff] [blame] | 955 | unsigned long flags; |
Ashok Raj | 34f361a | 2006-03-25 03:08:18 -0800 | [diff] [blame] | 956 | |
Glauber de Oliveira Costa | f915d7f | 2008-03-19 14:25:15 -0300 | [diff] [blame] | 957 | WARN_ON(irqs_disabled()); |
| 958 | |
| 959 | Dprintk("++++++++++++++++++++=_---CPU UP %u\n", cpu); |
| 960 | |
| 961 | if (apicid == BAD_APICID || apicid == boot_cpu_physical_apicid || |
| 962 | !physid_isset(apicid, phys_cpu_present_map)) { |
| 963 | printk(KERN_ERR "%s: bad cpu %d\n", __func__, cpu); |
| 964 | return -EINVAL; |
| 965 | } |
| 966 | |
Glauber de Oliveira Costa | 8154fa3 | 2008-03-19 14:25:17 -0300 | [diff] [blame] | 967 | per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; |
Glauber de Oliveira Costa | f915d7f | 2008-03-19 14:25:15 -0300 | [diff] [blame] | 968 | #ifdef CONFIG_HOTPLUG_CPU |
| 969 | |
Ashok Raj | 34f361a | 2006-03-25 03:08:18 -0800 | [diff] [blame] | 970 | /* |
| 971 | * We do warm boot only on cpus that had booted earlier |
| 972 | * Otherwise cold boot is all handled from smp_boot_cpus(). |
| 973 | * cpu_callin_map is set during AP kickstart process. Its reset |
| 974 | * when a cpu is taken offline from cpu_exit_clear(). |
| 975 | */ |
| 976 | if (!cpu_isset(cpu, cpu_callin_map)) |
Glauber de Oliveira Costa | f3ce446 | 2008-03-19 14:25:16 -0300 | [diff] [blame] | 977 | __smp_prepare_cpu(cpu); |
Ashok Raj | 34f361a | 2006-03-25 03:08:18 -0800 | [diff] [blame] | 978 | #endif |
| 979 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | /* In case one didn't come up */ |
| 981 | if (!cpu_isset(cpu, cpu_callin_map)) { |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 982 | printk(KERN_DEBUG "skipping cpu%d, didn't come online\n", cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | return -EIO; |
| 984 | } |
| 985 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | /* Unleash the CPU! */ |
| 987 | cpu_set(cpu, smp_commenced_mask); |
Ingo Molnar | 95492e4 | 2007-02-16 01:27:34 -0800 | [diff] [blame] | 988 | |
| 989 | /* |
Ingo Molnar | d04f41e | 2007-03-07 18:12:31 +0100 | [diff] [blame] | 990 | * Check TSC synchronization with the AP (keep irqs disabled |
| 991 | * while doing so): |
Ingo Molnar | 95492e4 | 2007-02-16 01:27:34 -0800 | [diff] [blame] | 992 | */ |
Ingo Molnar | d04f41e | 2007-03-07 18:12:31 +0100 | [diff] [blame] | 993 | local_irq_save(flags); |
Ingo Molnar | 95492e4 | 2007-02-16 01:27:34 -0800 | [diff] [blame] | 994 | check_tsc_sync_source(cpu); |
Ingo Molnar | d04f41e | 2007-03-07 18:12:31 +0100 | [diff] [blame] | 995 | local_irq_restore(flags); |
Ingo Molnar | 95492e4 | 2007-02-16 01:27:34 -0800 | [diff] [blame] | 996 | |
Ingo Molnar | d04f41e | 2007-03-07 18:12:31 +0100 | [diff] [blame] | 997 | while (!cpu_isset(cpu, cpu_online_map)) { |
Andreas Mohr | 1869891 | 2006-06-25 05:46:52 -0700 | [diff] [blame] | 998 | cpu_relax(); |
Ingo Molnar | d04f41e | 2007-03-07 18:12:31 +0100 | [diff] [blame] | 999 | touch_nmi_watchdog(); |
| 1000 | } |
Siddha, Suresh B | b0d0a4b | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 1001 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | return 0; |
| 1003 | } |
| 1004 | |
Jeremy Fitzhardinge | 01a2f43 | 2007-05-02 19:27:11 +0200 | [diff] [blame] | 1005 | void __init native_smp_cpus_done(unsigned int max_cpus) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | { |
| 1007 | #ifdef CONFIG_X86_IO_APIC |
| 1008 | setup_ioapic_dest(); |
| 1009 | #endif |
| 1010 | zap_low_mappings(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | void __init smp_intr_init(void) |
| 1014 | { |
| 1015 | /* |
| 1016 | * IRQ0 must be given a fixed assignment and initialized, |
| 1017 | * because it's used before the IO-APIC is set up. |
| 1018 | */ |
| 1019 | set_intr_gate(FIRST_DEVICE_VECTOR, interrupt[0]); |
| 1020 | |
| 1021 | /* |
| 1022 | * The reschedule interrupt is a CPU-to-CPU reschedule-helper |
| 1023 | * IPI, driven by wakeup. |
| 1024 | */ |
| 1025 | set_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt); |
| 1026 | |
| 1027 | /* IPI for invalidation */ |
| 1028 | set_intr_gate(INVALIDATE_TLB_VECTOR, invalidate_interrupt); |
| 1029 | |
| 1030 | /* IPI for generic function call */ |
| 1031 | set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); |
| 1032 | } |