Skip to content

Commit 9ebd680

Browse files
Suresh SiddhaIngo Molnar
authored andcommitted
x86, apic: Use probe routines to simplify apic selection
Use the unused probe routine in the apic driver to finalize the apic model selection. This cleans up the default_setup_apic_routing() and this probe routine in future can also be used for doing any apic model specific initialisation. Signed-off-by: Suresh Siddha <[email protected]> Acked-by: Cyrill Gorcunov <[email protected]> Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 8f18c97 commit 9ebd680

File tree

5 files changed

+37
-19
lines changed

5 files changed

+37
-19
lines changed

arch/x86/kernel/apic/apic_flat_64.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,18 @@ physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
312312
return per_cpu(x86_cpu_to_apicid, cpu);
313313
}
314314

315+
static int physflat_probe(void)
316+
{
317+
if (apic == &apic_physflat || num_possible_cpus() > 8)
318+
return 1;
319+
320+
return 0;
321+
}
322+
315323
struct apic apic_physflat = {
316324

317325
.name = "physical flat",
318-
.probe = NULL,
326+
.probe = physflat_probe,
319327
.acpi_madt_oem_check = physflat_acpi_madt_oem_check,
320328
.apic_id_registered = flat_apic_id_registered,
321329

arch/x86/kernel/apic/probe_64.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,18 @@ static int apicid_phys_pkg_id(int initial_apic_id, int index_msb)
5454
*/
5555
void __init default_setup_apic_routing(void)
5656
{
57+
int i;
5758

5859
enable_IR_x2apic();
5960

60-
#ifdef CONFIG_X86_X2APIC
61-
if (x2apic_mode
62-
#ifdef CONFIG_X86_UV
63-
&& apic != &apic_x2apic_uv_x
64-
#endif
65-
) {
66-
if (x2apic_phys)
67-
apic = &apic_x2apic_phys;
68-
else
69-
apic = &apic_x2apic_cluster;
61+
for (i = 0; apic_probe[i]; ++i) {
62+
if (apic_probe[i]->probe()) {
63+
apic = apic_probe[i];
64+
break;
65+
}
7066
}
71-
#endif
72-
73-
if (apic == &apic_flat && num_possible_cpus() > 8)
74-
apic = &apic_physflat;
7567

76-
printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
68+
printk(KERN_INFO "APIC routing finalized to %s.\n", apic->name);
7769

7870
if (is_vsmp_box()) {
7971
/* need to update phys_pkg_id */

arch/x86/kernel/apic/x2apic_cluster.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,15 @@ static void init_x2apic_ldr(void)
184184
per_cpu(x86_cpu_to_logical_apicid, cpu) = apic_read(APIC_LDR);
185185
}
186186

187+
static int x2apic_cluster_probe(void)
188+
{
189+
return x2apic_mode;
190+
}
191+
187192
struct apic apic_x2apic_cluster = {
188193

189194
.name = "cluster x2apic",
190-
.probe = NULL,
195+
.probe = x2apic_cluster_probe,
191196
.acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
192197
.apic_id_registered = x2apic_apic_id_registered,
193198

arch/x86/kernel/apic/x2apic_phys.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,18 @@ static void init_x2apic_ldr(void)
173173
{
174174
}
175175

176+
static int x2apic_phys_probe(void)
177+
{
178+
if (x2apic_mode && x2apic_phys)
179+
return 1;
180+
181+
return apic == &apic_x2apic_phys;
182+
}
183+
176184
struct apic apic_x2apic_phys = {
177185

178186
.name = "physical x2apic",
179-
.probe = NULL,
187+
.probe = x2apic_phys_probe,
180188
.acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
181189
.apic_id_registered = x2apic_apic_id_registered,
182190

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,15 @@ static void uv_send_IPI_self(int vector)
326326
apic_write(APIC_SELF_IPI, vector);
327327
}
328328

329+
static int uv_probe(void)
330+
{
331+
return apic == &apic_x2apic_uv_x;
332+
}
333+
329334
struct apic __refdata apic_x2apic_uv_x = {
330335

331336
.name = "UV large system",
332-
.probe = NULL,
337+
.probe = uv_probe,
333338
.acpi_madt_oem_check = uv_acpi_madt_oem_check,
334339
.apic_id_registered = uv_apic_id_registered,
335340

0 commit comments

Comments
 (0)