2 * Default generic APIC driver. This handles up to 8 CPUs.
4 * Copyright 2003 Andi Kleen, SuSE Labs.
5 * Subject to the GNU Public License, v.2
7 * Generic x86 APIC driver probe layer.
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>
21 #include <asm/setup.h>
23 #include <linux/smp.h>
26 #include <linux/interrupt.h>
30 #ifdef CONFIG_HOTPLUG_CPU
31 #define DEFAULT_SEND_IPI (1)
33 #define DEFAULT_SEND_IPI (0)
36 int no_broadcast
= DEFAULT_SEND_IPI
;
38 static __init
int no_ipi_broadcast(char *str
)
40 get_option(&str
, &no_broadcast
);
41 pr_info("Using %s mode\n",
42 no_broadcast
? "No IPI Broadcast" : "IPI Broadcast");
45 __setup("no_ipi_broadcast=", no_ipi_broadcast
);
47 static int __init
print_ipi_mode(void)
49 pr_info("Using IPI %s mode\n",
50 no_broadcast
? "No-Shortcut" : "Shortcut");
53 late_initcall(print_ipi_mode
);
55 void default_setup_apic_routing(void)
57 #ifdef CONFIG_X86_IO_APIC
59 "Enabling APIC mode: Flat. Using %d I/O APICs\n",
64 static void default_vector_allocation_domain(int cpu
, struct cpumask
*retmask
)
67 * Careful. Some cpus do not strictly honor the set of cpus
68 * specified in the interrupt destination when using lowest
69 * priority interrupt delivery mode.
71 * In particular there was a hyperthreading cpu observed to
72 * deliver interrupts to the wrong hyperthread when only one
73 * hyperthread was specified in the interrupt desitination.
75 cpumask_clear(retmask
);
76 cpumask_bits(retmask
)[0] = APIC_ALL_CPUS
;
79 /* should be called last. */
80 static int probe_default(void)
85 struct apic apic_default
= {
88 .probe
= probe_default
,
89 .acpi_madt_oem_check
= NULL
,
90 .apic_id_registered
= default_apic_id_registered
,
92 .irq_delivery_mode
= dest_LowestPrio
,
93 /* logical delivery broadcast to all CPUs: */
96 .target_cpus
= default_target_cpus
,
98 .dest_logical
= APIC_DEST_LOGICAL
,
99 .check_apicid_used
= default_check_apicid_used
,
100 .check_apicid_present
= default_check_apicid_present
,
102 .vector_allocation_domain
= default_vector_allocation_domain
,
103 .init_apic_ldr
= default_init_apic_ldr
,
105 .ioapic_phys_id_map
= default_ioapic_phys_id_map
,
106 .setup_apic_routing
= default_setup_apic_routing
,
107 .multi_timer_check
= NULL
,
108 .apicid_to_node
= default_apicid_to_node
,
109 .cpu_to_logical_apicid
= default_cpu_to_logical_apicid
,
110 .cpu_present_to_apicid
= default_cpu_present_to_apicid
,
111 .apicid_to_cpu_present
= default_apicid_to_cpu_present
,
112 .setup_portio_remap
= NULL
,
113 .check_phys_apicid_present
= default_check_phys_apicid_present
,
114 .enable_apic_mode
= NULL
,
115 .phys_pkg_id
= default_phys_pkg_id
,
116 .mps_oem_check
= NULL
,
118 .get_apic_id
= default_get_apic_id
,
120 .apic_id_mask
= 0x0F << 24,
122 .cpu_mask_to_apicid
= default_cpu_mask_to_apicid
,
123 .cpu_mask_to_apicid_and
= default_cpu_mask_to_apicid_and
,
125 .send_IPI_mask
= default_send_IPI_mask_logical
,
126 .send_IPI_mask_allbutself
= default_send_IPI_mask_allbutself_logical
,
127 .send_IPI_allbutself
= default_send_IPI_allbutself
,
128 .send_IPI_all
= default_send_IPI_all
,
129 .send_IPI_self
= default_send_IPI_self
,
131 .trampoline_phys_low
= DEFAULT_TRAMPOLINE_PHYS_LOW
,
132 .trampoline_phys_high
= DEFAULT_TRAMPOLINE_PHYS_HIGH
,
134 .wait_for_init_deassert
= default_wait_for_init_deassert
,
136 .smp_callin_clear_local_apic
= NULL
,
137 .inquire_remote_apic
= default_inquire_remote_apic
,
139 .read
= native_apic_mem_read
,
140 .write
= native_apic_mem_write
,
141 .icr_read
= native_apic_icr_read
,
142 .icr_write
= native_apic_icr_write
,
143 .wait_icr_idle
= native_apic_wait_icr_idle
,
144 .safe_wait_icr_idle
= native_safe_apic_wait_icr_idle
,
147 extern struct apic apic_numaq
;
148 extern struct apic apic_summit
;
149 extern struct apic apic_bigsmp
;
150 extern struct apic apic_es7000
;
151 extern struct apic apic_es7000_cluster
;
153 struct apic
*apic
= &apic_default
;
154 EXPORT_SYMBOL_GPL(apic
);
156 static struct apic
*apic_probe
[] __initdata
= {
157 #ifdef CONFIG_X86_NUMAQ
160 #ifdef CONFIG_X86_SUMMIT
163 #ifdef CONFIG_X86_BIGSMP
166 #ifdef CONFIG_X86_ES7000
168 &apic_es7000_cluster
,
170 &apic_default
, /* must be last */
174 static int cmdline_apic __initdata
;
175 static int __init
parse_apic(char *arg
)
182 for (i
= 0; apic_probe
[i
]; i
++) {
183 if (!strcmp(apic_probe
[i
]->name
, arg
)) {
184 apic
= apic_probe
[i
];
190 /* Parsed again by __setup for debug/verbose */
193 early_param("apic", parse_apic
);
195 void __init
generic_bigsmp_probe(void)
197 #ifdef CONFIG_X86_BIGSMP
199 * This routine is used to switch to bigsmp mode when
200 * - There is no apic= option specified by the user
201 * - generic_apic_probe() has chosen apic_default as the sub_arch
202 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
205 if (!cmdline_apic
&& apic
== &apic_default
) {
206 if (apic_bigsmp
.probe()) {
208 printk(KERN_INFO
"Overriding APIC driver with %s\n",
215 void __init
generic_apic_probe(void)
219 for (i
= 0; apic_probe
[i
]; i
++) {
220 if (apic_probe
[i
]->probe()) {
221 apic
= apic_probe
[i
];
225 /* Not visible without early console */
227 panic("Didn't find an APIC driver");
229 printk(KERN_INFO
"Using APIC driver %s\n", apic
->name
);
232 /* These functions can switch the APIC even after the initial ->probe() */
235 generic_mps_oem_check(struct mpc_table
*mpc
, char *oem
, char *productid
)
239 for (i
= 0; apic_probe
[i
]; ++i
) {
240 if (!apic_probe
[i
]->mps_oem_check
)
242 if (!apic_probe
[i
]->mps_oem_check(mpc
, oem
, productid
))
246 apic
= apic_probe
[i
];
247 printk(KERN_INFO
"Switched to APIC driver `%s'.\n",
255 int __init
default_acpi_madt_oem_check(char *oem_id
, char *oem_table_id
)
259 for (i
= 0; apic_probe
[i
]; ++i
) {
260 if (!apic_probe
[i
]->acpi_madt_oem_check
)
262 if (!apic_probe
[i
]->acpi_madt_oem_check(oem_id
, oem_table_id
))
266 apic
= apic_probe
[i
];
267 printk(KERN_INFO
"Switched to APIC driver `%s'.\n",