]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/x86/kernel/probe_32.c
5fa48332c5c8359c927b01cb7e14bf5916d65b22
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / probe_32.c
1 /*
2  * Default generic APIC driver. This handles up to 8 CPUs.
3  *
4  * Copyright 2003 Andi Kleen, SuSE Labs.
5  * Subject to the GNU Public License, v.2
6  *
7  * Generic x86 APIC driver probe layer.
8  */
9 #include <linux/threads.h>
10 #include <linux/cpumask.h>
11 #include <linux/module.h>
12 #include <linux/string.h>
13 #include <linux/kernel.h>
14 #include <linux/ctype.h>
15 #include <linux/init.h>
16 #include <linux/errno.h>
17 #include <asm/fixmap.h>
18 #include <asm/mpspec.h>
19 #include <asm/apicdef.h>
20 #include <asm/apic.h>
21 #include <asm/setup.h>
22
23 #include <linux/threads.h>
24 #include <linux/cpumask.h>
25 #include <asm/mpspec.h>
26 #include <asm/fixmap.h>
27 #include <asm/apicdef.h>
28 #include <linux/kernel.h>
29 #include <linux/string.h>
30 #include <linux/smp.h>
31 #include <linux/init.h>
32 #include <asm/ipi.h>
33
34 #include <linux/smp.h>
35 #include <linux/init.h>
36 #include <linux/interrupt.h>
37 #include <asm/acpi.h>
38 #include <asm/arch_hooks.h>
39 #include <asm/e820.h>
40 #include <asm/setup.h>
41
42 #ifdef CONFIG_HOTPLUG_CPU
43 #define DEFAULT_SEND_IPI        (1)
44 #else
45 #define DEFAULT_SEND_IPI        (0)
46 #endif
47
48 int no_broadcast = DEFAULT_SEND_IPI;
49
50 #ifdef CONFIG_X86_LOCAL_APIC
51
52 void default_setup_apic_routing(void)
53 {
54 #ifdef CONFIG_X86_IO_APIC
55         printk(KERN_INFO
56                 "Enabling APIC mode:  Flat.  Using %d I/O APICs\n",
57                 nr_ioapics);
58 #endif
59 }
60
61 static void default_vector_allocation_domain(int cpu, struct cpumask *retmask)
62 {
63         /*
64          * Careful. Some cpus do not strictly honor the set of cpus
65          * specified in the interrupt destination when using lowest
66          * priority interrupt delivery mode.
67          *
68          * In particular there was a hyperthreading cpu observed to
69          * deliver interrupts to the wrong hyperthread when only one
70          * hyperthread was specified in the interrupt desitination.
71          */
72         *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } };
73 }
74
75 /* should be called last. */
76 static int probe_default(void)
77 {
78         return 1;
79 }
80
81 struct apic apic_default = {
82
83         .name                           = "default",
84         .probe                          = probe_default,
85         .acpi_madt_oem_check            = NULL,
86         .apic_id_registered             = default_apic_id_registered,
87
88         .irq_delivery_mode              = dest_LowestPrio,
89         /* logical delivery broadcast to all CPUs: */
90         .irq_dest_mode                  = 1,
91
92         .target_cpus                    = default_target_cpus,
93         .disable_esr                    = 0,
94         .dest_logical                   = APIC_DEST_LOGICAL,
95         .check_apicid_used              = default_check_apicid_used,
96         .check_apicid_present           = default_check_apicid_present,
97
98         .vector_allocation_domain       = default_vector_allocation_domain,
99         .init_apic_ldr                  = default_init_apic_ldr,
100
101         .ioapic_phys_id_map             = default_ioapic_phys_id_map,
102         .setup_apic_routing             = default_setup_apic_routing,
103         .multi_timer_check              = NULL,
104         .apicid_to_node                 = default_apicid_to_node,
105         .cpu_to_logical_apicid          = default_cpu_to_logical_apicid,
106         .cpu_present_to_apicid          = default_cpu_present_to_apicid,
107         .apicid_to_cpu_present          = default_apicid_to_cpu_present,
108         .setup_portio_remap             = NULL,
109         .check_phys_apicid_present      = default_check_phys_apicid_present,
110         .enable_apic_mode               = NULL,
111         .phys_pkg_id                    = default_phys_pkg_id,
112         .mps_oem_check                  = NULL,
113
114         .get_apic_id                    = default_get_apic_id,
115         .set_apic_id                    = NULL,
116         .apic_id_mask                   = 0x0F << 24,
117
118         .cpu_mask_to_apicid             = default_cpu_mask_to_apicid,
119         .cpu_mask_to_apicid_and         = default_cpu_mask_to_apicid_and,
120
121         .send_IPI_mask                  = default_send_IPI_mask_logical,
122         .send_IPI_mask_allbutself       = default_send_IPI_mask_allbutself_logical,
123         .send_IPI_allbutself            = default_send_IPI_allbutself,
124         .send_IPI_all                   = default_send_IPI_all,
125         .send_IPI_self                  = default_send_IPI_self,
126
127         .wakeup_cpu                     = NULL,
128         .trampoline_phys_low            = DEFAULT_TRAMPOLINE_PHYS_LOW,
129         .trampoline_phys_high           = DEFAULT_TRAMPOLINE_PHYS_HIGH,
130
131         .wait_for_init_deassert         = default_wait_for_init_deassert,
132
133         .smp_callin_clear_local_apic    = NULL,
134         .inquire_remote_apic            = default_inquire_remote_apic,
135
136         .read                           = native_apic_mem_read,
137         .write                          = native_apic_mem_write,
138         .icr_read                       = native_apic_icr_read,
139         .icr_write                      = native_apic_icr_write,
140         .wait_icr_idle                  = native_apic_wait_icr_idle,
141         .safe_wait_icr_idle             = native_safe_apic_wait_icr_idle,
142 };
143
144 extern struct apic apic_numaq;
145 extern struct apic apic_summit;
146 extern struct apic apic_bigsmp;
147 extern struct apic apic_es7000;
148 extern struct apic apic_default;
149
150 struct apic *apic = &apic_default;
151 EXPORT_SYMBOL_GPL(apic);
152
153 static struct apic *apic_probe[] __initdata = {
154 #ifdef CONFIG_X86_NUMAQ
155         &apic_numaq,
156 #endif
157 #ifdef CONFIG_X86_SUMMIT
158         &apic_summit,
159 #endif
160 #ifdef CONFIG_X86_BIGSMP
161         &apic_bigsmp,
162 #endif
163 #ifdef CONFIG_X86_ES7000
164         &apic_es7000,
165 #endif
166         &apic_default,  /* must be last */
167         NULL,
168 };
169
170 static int cmdline_apic __initdata;
171 static int __init parse_apic(char *arg)
172 {
173         int i;
174
175         if (!arg)
176                 return -EINVAL;
177
178         for (i = 0; apic_probe[i]; i++) {
179                 if (!strcmp(apic_probe[i]->name, arg)) {
180                         apic = apic_probe[i];
181                         cmdline_apic = 1;
182                         return 0;
183                 }
184         }
185
186         if (x86_quirks->update_apic)
187                 x86_quirks->update_apic();
188
189         /* Parsed again by __setup for debug/verbose */
190         return 0;
191 }
192 early_param("apic", parse_apic);
193
194 void __init generic_bigsmp_probe(void)
195 {
196 #ifdef CONFIG_X86_BIGSMP
197         /*
198          * This routine is used to switch to bigsmp mode when
199          * - There is no apic= option specified by the user
200          * - generic_apic_probe() has chosen apic_default as the sub_arch
201          * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
202          */
203
204         if (!cmdline_apic && apic == &apic_default) {
205                 if (apic_bigsmp.probe()) {
206                         apic = &apic_bigsmp;
207                         if (x86_quirks->update_apic)
208                                 x86_quirks->update_apic();
209                         printk(KERN_INFO "Overriding APIC driver with %s\n",
210                                apic->name);
211                 }
212         }
213 #endif
214 }
215
216 void __init generic_apic_probe(void)
217 {
218         if (!cmdline_apic) {
219                 int i;
220                 for (i = 0; apic_probe[i]; i++) {
221                         if (apic_probe[i]->probe()) {
222                                 apic = apic_probe[i];
223                                 break;
224                         }
225                 }
226                 /* Not visible without early console */
227                 if (!apic_probe[i])
228                         panic("Didn't find an APIC driver");
229
230                 if (x86_quirks->update_apic)
231                         x86_quirks->update_apic();
232         }
233         printk(KERN_INFO "Using APIC driver %s\n", apic->name);
234 }
235
236 /* These functions can switch the APIC even after the initial ->probe() */
237
238 int __init
239 generic_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
240 {
241         int i;
242
243         for (i = 0; apic_probe[i]; ++i) {
244                 if (!apic_probe[i]->mps_oem_check)
245                         continue;
246                 if (!apic_probe[i]->mps_oem_check(mpc, oem, productid))
247                         continue;
248
249                 if (!cmdline_apic) {
250                         apic = apic_probe[i];
251                         if (x86_quirks->update_apic)
252                                 x86_quirks->update_apic();
253                         printk(KERN_INFO "Switched to APIC driver `%s'.\n",
254                                apic->name);
255                 }
256                 return 1;
257         }
258         return 0;
259 }
260
261 int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
262 {
263         int i;
264
265         for (i = 0; apic_probe[i]; ++i) {
266                 if (!apic_probe[i]->acpi_madt_oem_check)
267                         continue;
268                 if (!apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id))
269                         continue;
270
271                 if (!cmdline_apic) {
272                         apic = apic_probe[i];
273                         if (x86_quirks->update_apic)
274                                 x86_quirks->update_apic();
275                         printk(KERN_INFO "Switched to APIC driver `%s'.\n",
276                                apic->name);
277                 }
278                 return 1;
279         }
280         return 0;
281 }
282
283 #endif /* CONFIG_X86_LOCAL_APIC */
284
285 /**
286  * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
287  *
288  * Description:
289  *      Perform any necessary interrupt initialisation prior to setting up
290  *      the "ordinary" interrupt call gates.  For legacy reasons, the ISA
291  *      interrupts should be initialised here if the machine emulates a PC
292  *      in any way.
293  **/
294 void __init pre_intr_init_hook(void)
295 {
296         if (x86_quirks->arch_pre_intr_init) {
297                 if (x86_quirks->arch_pre_intr_init())
298                         return;
299         }
300         init_ISA_irqs();
301 }
302
303 /**
304  * intr_init_hook - post gate setup interrupt initialisation
305  *
306  * Description:
307  *      Fill in any interrupts that may have been left out by the general
308  *      init_IRQ() routine.  interrupts having to do with the machine rather
309  *      than the devices on the I/O bus (like APIC interrupts in intel MP
310  *      systems) are started here.
311  **/
312 void __init intr_init_hook(void)
313 {
314         if (x86_quirks->arch_intr_init) {
315                 if (x86_quirks->arch_intr_init())
316                         return;
317         }
318 }
319
320 /**
321  * pre_setup_arch_hook - hook called prior to any setup_arch() execution
322  *
323  * Description:
324  *      generally used to activate any machine specific identification
325  *      routines that may be needed before setup_arch() runs.  On Voyager
326  *      this is used to get the board revision and type.
327  **/
328 void __init pre_setup_arch_hook(void)
329 {
330 }
331
332 /**
333  * trap_init_hook - initialise system specific traps
334  *
335  * Description:
336  *      Called as the final act of trap_init().  Used in VISWS to initialise
337  *      the various board specific APIC traps.
338  **/
339 void __init trap_init_hook(void)
340 {
341         if (x86_quirks->arch_trap_init) {
342                 if (x86_quirks->arch_trap_init())
343                         return;
344         }
345 }
346
347 static struct irqaction irq0  = {
348         .handler = timer_interrupt,
349         .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL,
350         .mask = CPU_MASK_NONE,
351         .name = "timer"
352 };
353
354 /**
355  * pre_time_init_hook - do any specific initialisations before.
356  *
357  **/
358 void __init pre_time_init_hook(void)
359 {
360         if (x86_quirks->arch_pre_time_init)
361                 x86_quirks->arch_pre_time_init();
362 }
363
364 /**
365  * time_init_hook - do any specific initialisations for the system timer.
366  *
367  * Description:
368  *      Must plug the system timer interrupt source at HZ into the IRQ listed
369  *      in irq_vectors.h:TIMER_IRQ
370  **/
371 void __init time_init_hook(void)
372 {
373         if (x86_quirks->arch_time_init) {
374                 /*
375                  * A nonzero return code does not mean failure, it means
376                  * that the architecture quirk does not want any
377                  * generic (timer) setup to be performed after this:
378                  */
379                 if (x86_quirks->arch_time_init())
380                         return;
381         }
382
383         irq0.mask = cpumask_of_cpu(0);
384         setup_irq(0, &irq0);
385 }
386
387 #ifdef CONFIG_MCA
388 /**
389  * mca_nmi_hook - hook into MCA specific NMI chain
390  *
391  * Description:
392  *      The MCA (Microchannel Architecture) has an NMI chain for NMI sources
393  *      along the MCA bus.  Use this to hook into that chain if you will need
394  *      it.
395  **/
396 void mca_nmi_hook(void)
397 {
398         /*
399          * If I recall correctly, there's a whole bunch of other things that
400          * we can do to check for NMI problems, but that's all I know about
401          * at the moment.
402          */
403         pr_warning("NMI generated from unknown source!\n");
404 }
405 #endif
406
407 static __init int no_ipi_broadcast(char *str)
408 {
409         get_option(&str, &no_broadcast);
410         pr_info("Using %s mode\n",
411                 no_broadcast ? "No IPI Broadcast" : "IPI Broadcast");
412         return 1;
413 }
414 __setup("no_ipi_broadcast=", no_ipi_broadcast);
415
416 static int __init print_ipi_mode(void)
417 {
418         pr_info("Using IPI %s mode\n",
419                 no_broadcast ? "No-Shortcut" : "Shortcut");
420         return 0;
421 }
422
423 late_initcall(print_ipi_mode);
424