Commit | Line | Data |
---|---|---|
9b0c5028 | 1 | /* |
7b387253 IM |
2 | * Default generic APIC driver. This handles up to 8 CPUs. |
3 | * | |
9b0c5028 PC |
4 | * Copyright 2003 Andi Kleen, SuSE Labs. |
5 | * Subject to the GNU Public License, v.2 | |
6 | * | |
1da177e4 | 7 | * Generic x86 APIC driver probe layer. |
9b0c5028 | 8 | */ |
1da177e4 LT |
9 | #include <linux/threads.h> |
10 | #include <linux/cpumask.h> | |
7d01d32d | 11 | #include <linux/module.h> |
1da177e4 LT |
12 | #include <linux/string.h> |
13 | #include <linux/kernel.h> | |
14 | #include <linux/ctype.h> | |
15 | #include <linux/init.h> | |
1a3f239d | 16 | #include <linux/errno.h> |
1da177e4 LT |
17 | #include <asm/fixmap.h> |
18 | #include <asm/mpspec.h> | |
19 | #include <asm/apicdef.h> | |
7b6aa335 | 20 | #include <asm/apic.h> |
54ac14a8 | 21 | #include <asm/setup.h> |
1da177e4 | 22 | |
7b387253 IM |
23 | #include <linux/threads.h> |
24 | #include <linux/cpumask.h> | |
25 | #include <asm/mpspec.h> | |
7b387253 IM |
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> | |
7b387253 IM |
32 | #include <asm/ipi.h> |
33 | ||
6bda2c8b IM |
34 | #include <linux/smp.h> |
35 | #include <linux/init.h> | |
36 | #include <linux/interrupt.h> | |
37 | #include <asm/acpi.h> | |
6bda2c8b IM |
38 | #include <asm/e820.h> |
39 | #include <asm/setup.h> | |
40 | ||
6bda2c8b IM |
41 | #ifdef CONFIG_HOTPLUG_CPU |
42 | #define DEFAULT_SEND_IPI (1) | |
43 | #else | |
44 | #define DEFAULT_SEND_IPI (0) | |
45 | #endif | |
46 | ||
47 | int no_broadcast = DEFAULT_SEND_IPI; | |
48 | ||
9be1b56a IM |
49 | static __init int no_ipi_broadcast(char *str) |
50 | { | |
51 | get_option(&str, &no_broadcast); | |
52 | pr_info("Using %s mode\n", | |
53 | no_broadcast ? "No IPI Broadcast" : "IPI Broadcast"); | |
54 | return 1; | |
55 | } | |
56 | __setup("no_ipi_broadcast=", no_ipi_broadcast); | |
57 | ||
58 | static int __init print_ipi_mode(void) | |
59 | { | |
60 | pr_info("Using IPI %s mode\n", | |
61 | no_broadcast ? "No-Shortcut" : "Shortcut"); | |
62 | return 0; | |
63 | } | |
64 | late_initcall(print_ipi_mode); | |
6bda2c8b | 65 | |
28aa29ee IM |
66 | void default_setup_apic_routing(void) |
67 | { | |
68 | #ifdef CONFIG_X86_IO_APIC | |
69 | printk(KERN_INFO | |
70 | "Enabling APIC mode: Flat. Using %d I/O APICs\n", | |
71 | nr_ioapics); | |
72 | #endif | |
73 | } | |
74 | ||
7b387253 IM |
75 | static void default_vector_allocation_domain(int cpu, struct cpumask *retmask) |
76 | { | |
77 | /* | |
78 | * Careful. Some cpus do not strictly honor the set of cpus | |
79 | * specified in the interrupt destination when using lowest | |
80 | * priority interrupt delivery mode. | |
81 | * | |
82 | * In particular there was a hyperthreading cpu observed to | |
83 | * deliver interrupts to the wrong hyperthread when only one | |
84 | * hyperthread was specified in the interrupt desitination. | |
85 | */ | |
5c6cb5e2 RR |
86 | cpumask_clear(retmask); |
87 | cpumask_bits(retmask)[0] = APIC_ALL_CPUS; | |
7b387253 IM |
88 | } |
89 | ||
90 | /* should be called last. */ | |
91 | static int probe_default(void) | |
92 | { | |
93 | return 1; | |
94 | } | |
95 | ||
be163a15 | 96 | struct apic apic_default = { |
7b387253 IM |
97 | |
98 | .name = "default", | |
99 | .probe = probe_default, | |
100 | .acpi_madt_oem_check = NULL, | |
101 | .apic_id_registered = default_apic_id_registered, | |
102 | ||
103 | .irq_delivery_mode = dest_LowestPrio, | |
104 | /* logical delivery broadcast to all CPUs: */ | |
105 | .irq_dest_mode = 1, | |
106 | ||
107 | .target_cpus = default_target_cpus, | |
108 | .disable_esr = 0, | |
109 | .dest_logical = APIC_DEST_LOGICAL, | |
110 | .check_apicid_used = default_check_apicid_used, | |
111 | .check_apicid_present = default_check_apicid_present, | |
112 | ||
113 | .vector_allocation_domain = default_vector_allocation_domain, | |
114 | .init_apic_ldr = default_init_apic_ldr, | |
115 | ||
116 | .ioapic_phys_id_map = default_ioapic_phys_id_map, | |
117 | .setup_apic_routing = default_setup_apic_routing, | |
118 | .multi_timer_check = NULL, | |
119 | .apicid_to_node = default_apicid_to_node, | |
120 | .cpu_to_logical_apicid = default_cpu_to_logical_apicid, | |
121 | .cpu_present_to_apicid = default_cpu_present_to_apicid, | |
122 | .apicid_to_cpu_present = default_apicid_to_cpu_present, | |
123 | .setup_portio_remap = NULL, | |
124 | .check_phys_apicid_present = default_check_phys_apicid_present, | |
125 | .enable_apic_mode = NULL, | |
126 | .phys_pkg_id = default_phys_pkg_id, | |
127 | .mps_oem_check = NULL, | |
128 | ||
129 | .get_apic_id = default_get_apic_id, | |
130 | .set_apic_id = NULL, | |
131 | .apic_id_mask = 0x0F << 24, | |
132 | ||
133 | .cpu_mask_to_apicid = default_cpu_mask_to_apicid, | |
134 | .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and, | |
135 | ||
43f39890 YL |
136 | .send_IPI_mask = default_send_IPI_mask_logical, |
137 | .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical, | |
7b387253 IM |
138 | .send_IPI_allbutself = default_send_IPI_allbutself, |
139 | .send_IPI_all = default_send_IPI_all, | |
6b64ee02 | 140 | .send_IPI_self = default_send_IPI_self, |
7b387253 | 141 | |
7b387253 IM |
142 | .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW, |
143 | .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH, | |
144 | ||
145 | .wait_for_init_deassert = default_wait_for_init_deassert, | |
146 | ||
147 | .smp_callin_clear_local_apic = NULL, | |
7b387253 | 148 | .inquire_remote_apic = default_inquire_remote_apic, |
c1eeb2de YL |
149 | |
150 | .read = native_apic_mem_read, | |
151 | .write = native_apic_mem_write, | |
152 | .icr_read = native_apic_icr_read, | |
153 | .icr_write = native_apic_icr_write, | |
154 | .wait_icr_idle = native_apic_wait_icr_idle, | |
155 | .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, | |
7b387253 IM |
156 | }; |
157 | ||
be163a15 IM |
158 | extern struct apic apic_numaq; |
159 | extern struct apic apic_summit; | |
160 | extern struct apic apic_bigsmp; | |
161 | extern struct apic apic_es7000; | |
2b6163bf | 162 | extern struct apic apic_es7000_cluster; |
be163a15 | 163 | extern struct apic apic_default; |
1da177e4 | 164 | |
be163a15 | 165 | struct apic *apic = &apic_default; |
7d01d32d | 166 | EXPORT_SYMBOL_GPL(apic); |
1da177e4 | 167 | |
be163a15 | 168 | static struct apic *apic_probe[] __initdata = { |
d49c4288 YL |
169 | #ifdef CONFIG_X86_NUMAQ |
170 | &apic_numaq, | |
171 | #endif | |
172 | #ifdef CONFIG_X86_SUMMIT | |
1da177e4 | 173 | &apic_summit, |
d49c4288 YL |
174 | #endif |
175 | #ifdef CONFIG_X86_BIGSMP | |
9b0c5028 | 176 | &apic_bigsmp, |
d49c4288 YL |
177 | #endif |
178 | #ifdef CONFIG_X86_ES7000 | |
1da177e4 | 179 | &apic_es7000, |
2b6163bf | 180 | &apic_es7000_cluster, |
d49c4288 | 181 | #endif |
1da177e4 LT |
182 | &apic_default, /* must be last */ |
183 | NULL, | |
184 | }; | |
185 | ||
1a3f239d RR |
186 | static int cmdline_apic __initdata; |
187 | static int __init parse_apic(char *arg) | |
188 | { | |
189 | int i; | |
190 | ||
191 | if (!arg) | |
192 | return -EINVAL; | |
193 | ||
194 | for (i = 0; apic_probe[i]; i++) { | |
195 | if (!strcmp(apic_probe[i]->name, arg)) { | |
c8d46cf0 | 196 | apic = apic_probe[i]; |
1a3f239d RR |
197 | cmdline_apic = 1; |
198 | return 0; | |
199 | } | |
200 | } | |
9a8cb626 AK |
201 | |
202 | /* Parsed again by __setup for debug/verbose */ | |
203 | return 0; | |
1a3f239d RR |
204 | } |
205 | early_param("apic", parse_apic); | |
911a62d4 VP |
206 | |
207 | void __init generic_bigsmp_probe(void) | |
208 | { | |
b20d70b7 | 209 | #ifdef CONFIG_X86_BIGSMP |
911a62d4 VP |
210 | /* |
211 | * This routine is used to switch to bigsmp mode when | |
212 | * - There is no apic= option specified by the user | |
27b46d76 | 213 | * - generic_apic_probe() has chosen apic_default as the sub_arch |
911a62d4 VP |
214 | * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support |
215 | */ | |
216 | ||
c8d46cf0 | 217 | if (!cmdline_apic && apic == &apic_default) { |
911a62d4 | 218 | if (apic_bigsmp.probe()) { |
c8d46cf0 | 219 | apic = &apic_bigsmp; |
911a62d4 | 220 | printk(KERN_INFO "Overriding APIC driver with %s\n", |
c8d46cf0 | 221 | apic->name); |
911a62d4 | 222 | } |
87f76065 | 223 | } |
d49c4288 | 224 | #endif |
911a62d4 VP |
225 | } |
226 | ||
1a3f239d | 227 | void __init generic_apic_probe(void) |
9b0c5028 | 228 | { |
1a3f239d RR |
229 | if (!cmdline_apic) { |
230 | int i; | |
231 | for (i = 0; apic_probe[i]; i++) { | |
232 | if (apic_probe[i]->probe()) { | |
c8d46cf0 | 233 | apic = apic_probe[i]; |
1a3f239d | 234 | break; |
1da177e4 LT |
235 | } |
236 | } | |
1a3f239d RR |
237 | /* Not visible without early console */ |
238 | if (!apic_probe[i]) | |
239 | panic("Didn't find an APIC driver"); | |
1da177e4 | 240 | } |
c8d46cf0 | 241 | printk(KERN_INFO "Using APIC driver %s\n", apic->name); |
9b0c5028 | 242 | } |
1da177e4 LT |
243 | |
244 | /* These functions can switch the APIC even after the initial ->probe() */ | |
245 | ||
9c764247 IM |
246 | int __init |
247 | generic_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid) | |
9b0c5028 | 248 | { |
1da177e4 | 249 | int i; |
5f836405 | 250 | |
9b0c5028 | 251 | for (i = 0; apic_probe[i]; ++i) { |
5f836405 IM |
252 | if (!apic_probe[i]->mps_oem_check) |
253 | continue; | |
254 | if (!apic_probe[i]->mps_oem_check(mpc, oem, productid)) | |
255 | continue; | |
256 | ||
257 | if (!cmdline_apic) { | |
258 | apic = apic_probe[i]; | |
5f836405 IM |
259 | printk(KERN_INFO "Switched to APIC driver `%s'.\n", |
260 | apic->name); | |
9b0c5028 | 261 | } |
5f836405 | 262 | return 1; |
9b0c5028 | 263 | } |
1da177e4 | 264 | return 0; |
9b0c5028 | 265 | } |
1da177e4 | 266 | |
306db03b | 267 | int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
1da177e4 LT |
268 | { |
269 | int i; | |
306db03b | 270 | |
9b0c5028 | 271 | for (i = 0; apic_probe[i]; ++i) { |
306db03b IM |
272 | if (!apic_probe[i]->acpi_madt_oem_check) |
273 | continue; | |
274 | if (!apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) | |
275 | continue; | |
276 | ||
277 | if (!cmdline_apic) { | |
278 | apic = apic_probe[i]; | |
306db03b IM |
279 | printk(KERN_INFO "Switched to APIC driver `%s'.\n", |
280 | apic->name); | |
9b0c5028 | 281 | } |
306db03b | 282 | return 1; |
9b0c5028 PC |
283 | } |
284 | return 0; | |
1da177e4 | 285 | } |