x86, apic: apicdriver probe cleanups - V2
Subsystems (2)
cover x86, apic: apicdriver probe cleanups - V2
Updated patchset for cleaning up apic probe sequence by using apicdriver section.
Changes from V1:
* split up the patch into four small patches
* misc cleanups, specifying section alignment, removing duplicate messages (from Cyrill and Yinghai's review comments)
* fixed a crash on smaller x64 systems
PATCH 1/4 x86, apic: introduce .apicdrivers section to find the list of apic drivers
This will pave the way for each apic driver to be self-contained and eliminate the need for apic_probe[].
Order in which apic drivers are listed in the .apicdrivers section is important, as this determines the apic probe order. And this is enforced by the ordering of apic driver files in the Makefile and the macros apic_driver()/apic_drivers().
--- arch/x86/include/asm/apic.h | 20 ++++++++++++++++++++ arch/x86/kernel/apic/Makefile | 17 +++++++++++------ arch/x86/kernel/apic/apic_flat_64.c | 5 +++++ arch/x86/kernel/apic/bigsmp_32.c | 2 ++ arch/x86/kernel/apic/es7000_32.c | 6 ++++++ arch/x86/kernel/apic/numaq_32.c | 2 ++ arch/x86/kernel/apic/probe_32.c | 2 ++ arch/x86/kernel/apic/summit_32.c | 2 ++ arch/x86/kernel/apic/x2apic_cluster.c | 2 ++ arch/x86/kernel/apic/x2apic_phys.c | 2 ++ arch/x86/kernel/apic/x2apic_uv_x.c | 2 ++ arch/x86/kernel/vmlinux.lds.S | 7 +++++++ 12 files changed, 63 insertions(+), 6 deletions(-)
arch/x86/include/asm/apic.h +20 -0
@@ -381,6 +381,26 @@ struct apic {extern struct apic *apic;/* +* APIC drivers are probed based on how they are listed in the .apicdrivers +* section. So the order is important and enforced by the ordering +* of different apic driver files in the Makefile. +* +* For the files having two apic drivers, we use apic_drivers() +* to enforce the order with in them. +*/ +#define apic_driver (sym) \ + static struct apic *__apicdrivers_##sym __used \ + __aligned(sizeof(struct apic *)) \ + __section(.apicdrivers) = { &sym } + +#define apic_drivers (sym1, sym2) \ + static struct apic *__apicdrivers_##sym1##sym2[2] __used \ + __aligned(sizeof(struct apic *)) \ + __section(.apicdrivers) = { &sym1, &sym2 } + +extern struct apic *__apicdrivers[], *__apicdrivers_end[]; + +/* * APIC functionality to boot other CPUs - only used on SMP: */ #ifdef CONFIG_SMP
arch/x86/kernel/apic/Makefile +11 -6
@@ -2,20 +2,25 @@ # Makefile for local APIC drivers and for the IO-APIC code # -obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o probe_$(BITS).o ipi.o +obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o ipi.o obj-y += hw_nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_SMP) += ipi.o ifeq ($(CONFIG_X86_64),y) -obj-y += apic_flat_64.o -obj-$(CONFIG_X86_X2APIC) += x2apic_cluster.o -obj-$(CONFIG_X86_X2APIC) += x2apic_phys.o +# APIC probe will depend on the listing order here obj-$(CONFIG_X86_UV) += x2apic_uv_x.o +obj-$(CONFIG_X86_X2APIC) += x2apic_phys.o +obj-$(CONFIG_X86_X2APIC) += x2apic_cluster.o +obj-y += apic_flat_64.o endif -obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o +# APIC probe will depend on the listing order here obj-$(CONFIG_X86_NUMAQ) += numaq_32.o -obj-$(CONFIG_X86_ES7000) += es7000_32.o obj-$(CONFIG_X86_SUMMIT) += summit_32.o +obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o +obj-$(CONFIG_X86_ES7000) += es7000_32.o + +# For 32bit, probe_32 need to be listed last +obj-$(CONFIG_X86_LOCAL_APIC) += probe_$(BITS).o
arch/x86/kernel/apic/apic_flat_64.c +5 -0
@@ -377,3 +377,8 @@ struct apic apic_physflat = { .wait_icr_idle = native_apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, }; + +/* +* We need to check for physflat first, so this order is important. +*/ +apic_drivers (apic_physflat, apic_flat);
arch/x86/kernel/apic/x2apic_cluster.c +2 -0
@@ -264,3 +264,5 @@ struct apic apic_x2apic_cluster = { .wait_icr_idle = native_x2apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; + +apic_driver (apic_x2apic_cluster);
arch/x86/kernel/apic/x2apic_phys.c +2 -0
@@ -168,3 +168,5 @@ struct apic apic_x2apic_phys = { .wait_icr_idle = native_x2apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; + +apic_driver (apic_x2apic_phys);
arch/x86/kernel/apic/x2apic_uv_x.c +2 -0
@@ -864,3 +864,5 @@ void __init uv_system_init(void)if (is_kdump_kernel ()) reboot_type =BOOT_ACPI ; } + +apic_driver (apic_x2apic_uv_x);
arch/x86/kernel/vmlinux.lds.S +7 -0
@@ -306,6 +306,13 @@ SECTIONS } . = ALIGN(8); + .apicdrivers : AT(ADDR(.apicdrivers) - LOAD_OFFSET) { + __apicdrivers = .; + *(.apicdrivers); + __apicdrivers_end = .; + } + + . = ALIGN(8); /* * .exit.text is discard at runtime, not link time, to deal with * references from .altinstructions and .eh_frame
arch/x86/kernel/apic/bigsmp_32.c +2 -0
@@ -254,3 +254,5 @@ struct apic apic_bigsmp = { .x86_32_early_logical_apicid = bigsmp_early_logical_apicid, }; + +apic_driver (apic_bigsmp);
arch/x86/kernel/apic/es7000_32.c +6 -0
@@ -747,3 +747,9 @@ struct apic __refdata apic_es7000 = { .x86_32_early_logical_apicid = es7000_early_logical_apicid, }; + +/* +* Need to check for es7000 followed by es7000_cluster, so this order +* in apic_drivers is important. +*/ +apic_drivers (apic_es7000, apic_es7000_cluster);
arch/x86/kernel/apic/numaq_32.c +2 -0
@@ -537,3 +537,5 @@ struct apic __refdata apic_numaq = { .x86_32_early_logical_apicid = noop_x86_32_early_logical_apicid, .x86_32_numa_cpu_node = numaq_numa_cpu_node, }; + +apic_driver (apic_numaq);
arch/x86/kernel/apic/summit_32.c +2 -0
@@ -552,3 +552,5 @@ struct apic apic_summit = { .x86_32_early_logical_apicid = summit_early_logical_apicid, }; + +apic_driver (apic_summit);
arch/x86/kernel/apic/probe_32.c +2 -0
@@ -174,6 +174,8 @@ struct apic apic_default = { .x86_32_early_logical_apicid = default_x86_32_early_logical_apicid, }; +apic_driver (apic_default); +extern struct apic apic_numaq;extern struct apic apic_summit;extern struct apic apic_bigsmp;
[tip:x86/apic] x86, apic: Introduce .apicdrivers section to find the list of apic drivers
Commit-ID: 107e0e0cd85beeee05af7ea374fda14d037ee500 Gitweb: http://git.kernel.org/tip/107e0e0cd85beeee05af7ea374fda14d037ee500 Author: Suresh Siddha <[email protected]> AuthorDate: Fri, 20 May 2011 17:51:17 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 22 May 2011 11:48:03 +0200
x86, apic: Introduce .apicdrivers section to find the list of apic drivers
This will pave the way for each apic driver to be self-contained and eliminate the need for apic_probe[].
Order in which apic drivers are listed in the .apicdrivers section is important, as this determines the apic probe order. And this is enforced by the ordering of apic driver files in the Makefile and the macros apic_driver()/apic_drivers().
--- arch/x86/include/asm/apic.h | 20 ++++++++++++++++++++ arch/x86/kernel/apic/Makefile | 17 +++++++++++------ arch/x86/kernel/apic/apic_flat_64.c | 5 +++++ arch/x86/kernel/apic/bigsmp_32.c | 2 ++ arch/x86/kernel/apic/es7000_32.c | 6 ++++++ arch/x86/kernel/apic/numaq_32.c | 2 ++ arch/x86/kernel/apic/probe_32.c | 2 ++ arch/x86/kernel/apic/summit_32.c | 2 ++ arch/x86/kernel/apic/x2apic_cluster.c | 2 ++ arch/x86/kernel/apic/x2apic_phys.c | 2 ++ arch/x86/kernel/apic/x2apic_uv_x.c | 2 ++ arch/x86/kernel/vmlinux.lds.S | 7 +++++++ 12 files changed, 63 insertions(+), 6 deletions(-)
arch/x86/include/asm/apic.h +20 -0
@@ -381,6 +381,26 @@ struct apic {extern struct apic *apic;/* +* APIC drivers are probed based on how they are listed in the .apicdrivers +* section. So the order is important and enforced by the ordering +* of different apic driver files in the Makefile. +* +* For the files having two apic drivers, we use apic_drivers() +* to enforce the order with in them. +*/ +#define apic_driver (sym) \ + static struct apic *__apicdrivers_##sym __used \ + __aligned(sizeof(struct apic *)) \ + __section(.apicdrivers) = { &sym } + +#define apic_drivers (sym1, sym2) \ + static struct apic *__apicdrivers_##sym1##sym2[2] __used \ + __aligned(sizeof(struct apic *)) \ + __section(.apicdrivers) = { &sym1, &sym2 } + +extern struct apic *__apicdrivers[], *__apicdrivers_end[]; + +/* * APIC functionality to boot other CPUs - only used on SMP: */ #ifdef CONFIG_SMP
arch/x86/kernel/apic/Makefile +11 -6
@@ -2,20 +2,25 @@ # Makefile for local APIC drivers and for the IO-APIC code # -obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o probe_$(BITS).o ipi.o +obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_noop.o ipi.o obj-y += hw_nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o obj-$(CONFIG_SMP) += ipi.o ifeq ($(CONFIG_X86_64),y) -obj-y += apic_flat_64.o -obj-$(CONFIG_X86_X2APIC) += x2apic_cluster.o -obj-$(CONFIG_X86_X2APIC) += x2apic_phys.o +# APIC probe will depend on the listing order here obj-$(CONFIG_X86_UV) += x2apic_uv_x.o +obj-$(CONFIG_X86_X2APIC) += x2apic_phys.o +obj-$(CONFIG_X86_X2APIC) += x2apic_cluster.o +obj-y += apic_flat_64.o endif -obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o +# APIC probe will depend on the listing order here obj-$(CONFIG_X86_NUMAQ) += numaq_32.o -obj-$(CONFIG_X86_ES7000) += es7000_32.o obj-$(CONFIG_X86_SUMMIT) += summit_32.o +obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o +obj-$(CONFIG_X86_ES7000) += es7000_32.o + +# For 32bit, probe_32 need to be listed last +obj-$(CONFIG_X86_LOCAL_APIC) += probe_$(BITS).o
arch/x86/kernel/apic/apic_flat_64.c +5 -0
@@ -377,3 +377,8 @@ struct apic apic_physflat = { .wait_icr_idle = native_apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, }; + +/* +* We need to check for physflat first, so this order is important. +*/ +apic_drivers (apic_physflat, apic_flat);
arch/x86/kernel/apic/bigsmp_32.c +2 -0
@@ -254,3 +254,5 @@ struct apic apic_bigsmp = { .x86_32_early_logical_apicid = bigsmp_early_logical_apicid, }; + +apic_driver (apic_bigsmp);
arch/x86/kernel/apic/es7000_32.c +6 -0
@@ -747,3 +747,9 @@ struct apic __refdata apic_es7000 = { .x86_32_early_logical_apicid = es7000_early_logical_apicid, }; + +/* +* Need to check for es7000 followed by es7000_cluster, so this order +* in apic_drivers is important. +*/ +apic_drivers (apic_es7000, apic_es7000_cluster);
arch/x86/kernel/apic/numaq_32.c +2 -0
@@ -537,3 +537,5 @@ struct apic __refdata apic_numaq = { .x86_32_early_logical_apicid = noop_x86_32_early_logical_apicid, .x86_32_numa_cpu_node = numaq_numa_cpu_node, }; + +apic_driver (apic_numaq);
arch/x86/kernel/apic/probe_32.c +2 -0
@@ -174,6 +174,8 @@ struct apic apic_default = { .x86_32_early_logical_apicid = default_x86_32_early_logical_apicid, }; +apic_driver (apic_default); +extern struct apic apic_numaq;extern struct apic apic_summit;extern struct apic apic_bigsmp;
arch/x86/kernel/apic/summit_32.c +2 -0
@@ -552,3 +552,5 @@ struct apic apic_summit = { .x86_32_early_logical_apicid = summit_early_logical_apicid, }; + +apic_driver (apic_summit);
arch/x86/kernel/apic/x2apic_cluster.c +2 -0
@@ -264,3 +264,5 @@ struct apic apic_x2apic_cluster = { .wait_icr_idle = native_x2apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; + +apic_driver (apic_x2apic_cluster);
arch/x86/kernel/apic/x2apic_phys.c +2 -0
@@ -168,3 +168,5 @@ struct apic apic_x2apic_phys = { .wait_icr_idle = native_x2apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; + +apic_driver (apic_x2apic_phys);
arch/x86/kernel/apic/x2apic_uv_x.c +2 -0
@@ -864,3 +864,5 @@ void __init uv_system_init(void)if (is_kdump_kernel ()) reboot_type =BOOT_ACPI ; } + +apic_driver (apic_x2apic_uv_x);
arch/x86/kernel/vmlinux.lds.S +7 -0
@@ -306,6 +306,13 @@ SECTIONS } . = ALIGN(8); + .apicdrivers : AT(ADDR(.apicdrivers) - LOAD_OFFSET) { + __apicdrivers = .; + *(.apicdrivers); + __apicdrivers_end = .; + } + + . = ALIGN(8); /* * .exit.text is discard at runtime, not link time, to deal with * references from .altinstructions and .eh_frame
PATCH 2/4 x86, apic: use .apicdrivers section for the apic drivers list
In reply to Suresh SiddhaThis will eliminate the need for apic_probe[], as the probing now will happen based on the apic drivers order in the .apcidrivers section.
--- arch/x86/kernel/apic/probe_32.c | 39 ++++++++++++++++++++------------------- arch/x86/kernel/apic/probe_64.c | 28 ++++++++++++++++------------ 2 files changed, 36 insertions(+), 31 deletions(-)
arch/x86/kernel/apic/probe_64.c +16 -12
@@ -54,19 +54,21 @@ static int apicid_phys_pkg_id(int initia*/ void __init default_setup_apic_routing (void ) { -int i; +struct apic **drv;enable_IR_x2apic (); -for (i =0 ; apic_probe[i]; ++i) { -if (apic_probe[i]->probe ()) { - apic = apic_probe[i]; +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if ((*drv)->probe && (*drv)->probe ()) { +if (apic != *drv) { + apic = *drv; +pr_info ("Switched APIC routing to %s.\n" , + apic->name); + }break ; } } -printk (KERN_INFO "APIC routing finalized to %s.\n" , apic->name); -if (is_vsmp_box ()) {/* need to update phys_pkg_id */ apic->phys_pkg_id = apicid_phys_pkg_id;
@@ -82,13 +84,15 @@ void apic_send_IPI_self(int vector)int __init default_acpi_madt_oem_check (char *oem_id,char *oem_table_id) { -int i; +struct apic **drv; -for (i =0 ; apic_probe[i]; ++i) { -if (apic_probe[i]->acpi_madt_oem_check (oem_id, oem_table_id)) { - apic = apic_probe[i]; -printk (KERN_INFO "Setting APIC routing to %s.\n" , - apic->name); +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if ((*drv)->acpi_madt_oem_check (oem_id, oem_table_id)) { +if (apic != *drv) { + apic = *drv; +pr_info ("Setting APIC routing to %s.\n" , + apic->name); + }return 1 ; } }
arch/x86/kernel/apic/probe_32.c +20 -19
@@ -206,14 +206,14 @@ static struct apic *apic_probe[] __initdstatic int cmdline_apic__initdata ;static int __init parse_apic (char *arg) { -int i; +struct apic **drv;if (!arg)return -EINVAL ; -for (i =0 ; apic_probe[i]; i++) { -if (!strcmp (apic_probe[i]->name, arg)) { - apic = apic_probe[i]; +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if (!strcmp ((*drv)->name, arg)) { + apic = *drv; cmdline_apic =1 ;return 0 ; }
@@ -247,15 +247,16 @@ void __init generic_bigsmp_probe(void)void __init generic_apic_probe (void ) {if (!cmdline_apic) { -int i; -for (i =0 ; apic_probe[i]; i++) { -if (apic_probe[i]->probe ()) { - apic = apic_probe[i]; +struct apic **drv; + +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if ((*drv)->probe ()) { + apic = *drv;break ; } }/* Not visible without early console */ -if (!apic_probe[i]) +if (drv == __apicdrivers_end)panic ("Didn't find an APIC driver" ); }printk (KERN_INFO "Using APIC driver %s\n" , apic->name);
@@ -266,16 +267,16 @@ void __init generic_apic_probe(void)int __init generic_mps_oem_check (struct mpc_table *mpc,char *oem,char *productid) { -int i; +struct apic **drv; -for (i =0 ; apic_probe[i]; ++i) { -if (!apic_probe[i]->mps_oem_check) +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if (!((*drv)->mps_oem_check))continue ; -if (!apic_probe[i]->mps_oem_check (mpc, oem, productid)) +if (!(*drv)->mps_oem_check (mpc, oem, productid))continue ;if (!cmdline_apic) { - apic = apic_probe[i]; + apic = *drv;printk (KERN_INFO "Switched to APIC driver `%s'.\n" , apic->name); }
@@ -286,16 +287,16 @@ generic_mps_oem_check(struct mpc_table *int __init default_acpi_madt_oem_check (char *oem_id,char *oem_table_id) { -int i; +struct apic **drv; -for (i =0 ; apic_probe[i]; ++i) { -if (!apic_probe[i]->acpi_madt_oem_check) +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if (!(*drv)->acpi_madt_oem_check)continue ; -if (!apic_probe[i]->acpi_madt_oem_check (oem_id, oem_table_id)) +if (!(*drv)->acpi_madt_oem_check (oem_id, oem_table_id))continue ;if (!cmdline_apic) { - apic = apic_probe[i]; + apic = *drv;printk (KERN_INFO "Switched to APIC driver `%s'.\n" , apic->name); }
[tip:x86/apic] x86, apic: Use .apicdrivers section for the apic drivers list
Commit-ID: 8b37e88061e229e78959fe3257649fd5ce05f8af Gitweb: http://git.kernel.org/tip/8b37e88061e229e78959fe3257649fd5ce05f8af Author: Suresh Siddha <[email protected]> AuthorDate: Fri, 20 May 2011 17:51:18 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 22 May 2011 11:48:03 +0200
x86, apic: Use .apicdrivers section for the apic drivers list
This will eliminate the need for apic_probe[], as the probing now will happen based on the apic drivers order in the .apcidrivers section.
--- arch/x86/kernel/apic/probe_32.c | 39 ++++++++++++++++++++------------------- arch/x86/kernel/apic/probe_64.c | 28 ++++++++++++++++------------ 2 files changed, 36 insertions(+), 31 deletions(-)
arch/x86/kernel/apic/probe_32.c +20 -19
@@ -206,14 +206,14 @@ static struct apic *apic_probe[] __initdata = {static int cmdline_apic__initdata ;static int __init parse_apic (char *arg) { -int i; +struct apic **drv;if (!arg)return -EINVAL ; -for (i =0 ; apic_probe[i]; i++) { -if (!strcmp (apic_probe[i]->name, arg)) { - apic = apic_probe[i]; +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if (!strcmp ((*drv)->name, arg)) { + apic = *drv; cmdline_apic =1 ;return 0 ; }
@@ -247,15 +247,16 @@ void __init generic_bigsmp_probe(void)void __init generic_apic_probe (void ) {if (!cmdline_apic) { -int i; -for (i =0 ; apic_probe[i]; i++) { -if (apic_probe[i]->probe ()) { - apic = apic_probe[i]; +struct apic **drv; + +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if ((*drv)->probe ()) { + apic = *drv;break ; } }/* Not visible without early console */ -if (!apic_probe[i]) +if (drv == __apicdrivers_end)panic ("Didn't find an APIC driver" ); }printk (KERN_INFO "Using APIC driver %s\n" , apic->name);
@@ -266,16 +267,16 @@ void __init generic_apic_probe(void)int __init generic_mps_oem_check (struct mpc_table *mpc,char *oem,char *productid) { -int i; +struct apic **drv; -for (i =0 ; apic_probe[i]; ++i) { -if (!apic_probe[i]->mps_oem_check) +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if (!((*drv)->mps_oem_check))continue ; -if (!apic_probe[i]->mps_oem_check (mpc, oem, productid)) +if (!(*drv)->mps_oem_check (mpc, oem, productid))continue ;if (!cmdline_apic) { - apic = apic_probe[i]; + apic = *drv;printk (KERN_INFO "Switched to APIC driver `%s'.\n" , apic->name); }
@@ -286,16 +287,16 @@ generic_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)int __init default_acpi_madt_oem_check (char *oem_id,char *oem_table_id) { -int i; +struct apic **drv; -for (i =0 ; apic_probe[i]; ++i) { -if (!apic_probe[i]->acpi_madt_oem_check) +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if (!(*drv)->acpi_madt_oem_check)continue ; -if (!apic_probe[i]->acpi_madt_oem_check (oem_id, oem_table_id)) +if (!(*drv)->acpi_madt_oem_check (oem_id, oem_table_id))continue ;if (!cmdline_apic) { - apic = apic_probe[i]; + apic = *drv;printk (KERN_INFO "Switched to APIC driver `%s'.\n" , apic->name); }
arch/x86/kernel/apic/probe_64.c +16 -12
@@ -54,19 +54,21 @@ static int apicid_phys_pkg_id(int initial_apic_id, int index_msb)*/ void __init default_setup_apic_routing (void ) { -int i; +struct apic **drv;enable_IR_x2apic (); -for (i =0 ; apic_probe[i]; ++i) { -if (apic_probe[i]->probe ()) { - apic = apic_probe[i]; +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if ((*drv)->probe && (*drv)->probe ()) { +if (apic != *drv) { + apic = *drv; +pr_info ("Switched APIC routing to %s.\n" , + apic->name); + }break ; } } -printk (KERN_INFO "APIC routing finalized to %s.\n" , apic->name); -if (is_vsmp_box ()) {/* need to update phys_pkg_id */ apic->phys_pkg_id = apicid_phys_pkg_id;
@@ -82,13 +84,15 @@ void apic_send_IPI_self(int vector)int __init default_acpi_madt_oem_check (char *oem_id,char *oem_table_id) { -int i; +struct apic **drv; -for (i =0 ; apic_probe[i]; ++i) { -if (apic_probe[i]->acpi_madt_oem_check (oem_id, oem_table_id)) { - apic = apic_probe[i]; -printk (KERN_INFO "Setting APIC routing to %s.\n" , - apic->name); +for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { +if ((*drv)->acpi_madt_oem_check (oem_id, oem_table_id)) { +if (apic != *drv) { + apic = *drv; +pr_info ("Setting APIC routing to %s.\n" , + apic->name); + }return 1 ; } }
PATCH 3/4 x86, apic: cleanup bigsmp apic selection code
In reply to Suresh SiddhaMake generic_bigsmp_probe() return struct apic *. This will avoid exporting apic_bigsmp, which will be consistent with others.
--- arch/x86/include/asm/apic.h | 2 - arch/x86/kernel/apic/bigsmp_32.c | 8 ++++++ arch/x86/kernel/apic/probe_32.c | 52 +++++++++++++++++---------------------- 3 files changed, 32 insertions(+), 30 deletions(-)
arch/x86/include/asm/apic.h +1 -1
@@ -500,7 +500,7 @@ static inline void default_wait_for_initreturn ; } -extern void generic_bigsmp_probe (void ); +extern struct apic *generic_bigsmp_probe (void );#ifdef CONFIG_X86_LOCAL_APIC
arch/x86/kernel/apic/bigsmp_32.c +8 -0
@@ -255,4 +255,12 @@ struct apic apic_bigsmp = { .x86_32_early_logical_apicid = bigsmp_early_logical_apicid, }; +struct apic *__init generic_bigsmp_probe (void ) +{ +if (probe_bigsmp ()) +return &apic_bigsmp; + +return NULL ; +} +apic_driver (apic_bigsmp);
arch/x86/kernel/apic/probe_32.c +23 -29
78 lines not on this page · raw message
[tip:x86/apic] x86, apic: Clean up bigsmp apic selection code
Commit-ID: 69c252ffce77f4e38347d536ee4eab4aa162dc67 Gitweb: http://git.kernel.org/tip/69c252ffce77f4e38347d536ee4eab4aa162dc67 Author: Suresh Siddha <[email protected]> AuthorDate: Fri, 20 May 2011 17:51:19 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 22 May 2011 11:48:03 +0200
x86, apic: Clean up bigsmp apic selection code
Make generic_bigsmp_probe() return struct apic *. This will avoid exporting apic_bigsmp, which will be consistent with others.
--- arch/x86/include/asm/apic.h | 2 +- arch/x86/kernel/apic/bigsmp_32.c | 8 ++++++ arch/x86/kernel/apic/probe_32.c | 52 ++++++++++++++++--------------------- 3 files changed, 32 insertions(+), 30 deletions(-)
arch/x86/include/asm/apic.h +1 -1
@@ -500,7 +500,7 @@ static inline void default_wait_for_init_deassert(atomic_t *deassert)return ; } -extern void generic_bigsmp_probe (void ); +extern struct apic *generic_bigsmp_probe (void );#ifdef CONFIG_X86_LOCAL_APIC
arch/x86/kernel/apic/bigsmp_32.c +8 -0
@@ -255,4 +255,12 @@ struct apic apic_bigsmp = { .x86_32_early_logical_apicid = bigsmp_early_logical_apicid, }; +struct apic *__init generic_bigsmp_probe (void ) +{ +if (probe_bigsmp ()) +return &apic_bigsmp; + +return NULL ; +} +apic_driver (apic_bigsmp);
arch/x86/kernel/apic/probe_32.c +23 -29
78 lines not on this page · raw message
PATCH 4/4 x86, apic: make apic drivers static
In reply to Suresh SiddhaApic probe now looks at the apic drivers listed in the .apicdrivers section. Remove apic_probe[] and make each apic driver static.
--- arch/x86/include/asm/apic.h | 7 ------- arch/x86/kernel/apic/apic_flat_64.c | 10 ++++++++-- arch/x86/kernel/apic/bigsmp_32.c | 2 +- arch/x86/kernel/apic/es7000_32.c | 4 ++-- arch/x86/kernel/apic/numaq_32.c | 4 ++-- arch/x86/kernel/apic/probe_32.c | 28 ++-------------------------- arch/x86/kernel/apic/probe_64.c | 21 --------------------- arch/x86/kernel/apic/summit_32.c | 2 +- arch/x86/kernel/apic/x2apic_cluster.c | 2 +- arch/x86/kernel/apic/x2apic_phys.c | 4 +++- arch/x86/kernel/apic/x2apic_uv_x.c | 4 +++- 11 files changed, 23 insertions(+), 65 deletions(-)
arch/x86/include/asm/apic.h +0 -7
@@ -478,15 +478,10 @@ static inline unsigned default_get_apic_#define DEFAULT_TRAMPOLINE_PHYS_HIGH 0x469#ifdef CONFIG_X86_64 -extern struct apic apic_flat; -extern struct apic apic_physflat; -extern struct apic apic_x2apic_cluster; -extern struct apic apic_x2apic_phys;extern int default_acpi_madt_oem_check (char *,char *);extern void apic_send_IPI_self (int vector); -extern struct apic apic_x2apic_uv_x;DECLARE_PER_CPU (int, x2apic_extra_bits);extern int default_cpu_present_to_apicid (int mps_cpu);
@@ -536,8 +531,6 @@ extern struct apic apic_noop;#ifdef CONFIG_X86_32 -extern struct apic apic_default; -static inline int noop_x86_32_early_logical_apicid (int cpu) {return BAD_APICID ;
arch/x86/kernel/apic/apic_flat_64.c +8 -2
@@ -24,6 +24,12 @@#include <acpi/acpi_bus.h> #endif +static struct apic apic_physflat; +static struct apic apic_flat; + +struct apic __read_mostly *apic = &apic_flat; +EXPORT_SYMBOL_GPL (apic); +static int flat_acpi_madt_oem_check (char *oem_id,char *oem_table_id) {return 1 ;
@@ -164,7 +170,7 @@ static int flat_phys_pkg_id(int initial_return initial_apic_id >> index_msb; } -struct apic apic_flat = { +static struct apic apic_flat = { .name ="flat" , .probe =NULL , .acpi_madt_oem_check = flat_acpi_madt_oem_check,
@@ -320,7 +326,7 @@ static int physflat_probe(void)return 0 ; } -struct apic apic_physflat = { +static struct apic apic_physflat = { .name ="physical flat" , .probe = physflat_probe,
arch/x86/kernel/apic/probe_64.c +0 -21
@@ -23,27 +23,6 @@#include <asm/ipi.h> #include <asm/setup.h> -extern struct apic apic_flat; -extern struct apic apic_physflat; -extern struct apic apic_x2xpic_uv_x; -extern struct apic apic_x2apic_phys; -extern struct apic apic_x2apic_cluster; - -struct apic __read_mostly *apic = &apic_flat; -EXPORT_SYMBOL_GPL (apic); - -static struct apic *apic_probe[]__initdata = { -#ifdef CONFIG_X86_UV - &apic_x2apic_uv_x, -#endif -#ifdef CONFIG_X86_X2APIC - &apic_x2apic_phys, - &apic_x2apic_cluster, -#endif - &apic_physflat, -NULL , -}; -static int apicid_phys_pkg_id (int initial_apic_id,int index_msb) {return hard_smp_processor_id () >> index_msb;
arch/x86/kernel/apic/x2apic_cluster.c +1 -1
@@ -208,7 +208,7 @@ static int x2apic_cluster_probe(void)return 0 ; } -struct apic apic_x2apic_cluster = { +static struct apic apic_x2apic_cluster = { .name ="cluster x2apic" , .probe = x2apic_cluster_probe,
arch/x86/kernel/apic/x2apic_phys.c +3 -1
@@ -11,6 +11,8 @@int x2apic_phys; +static struct apic apic_x2apic_phys; +static int set_x2apic_phys_mode (char *arg) { x2apic_phys =1 ;
@@ -112,7 +114,7 @@ static int x2apic_phys_probe(void)return apic == &apic_x2apic_phys; } -struct apic apic_x2apic_phys = { +static struct apic apic_x2apic_phys = { .name ="physical x2apic" , .probe = x2apic_phys_probe,
arch/x86/kernel/apic/x2apic_uv_x.c +3 -1
@@ -58,6 +58,8 @@ unsigned int uv_apicid_hibits;EXPORT_SYMBOL_GPL (uv_apicid_hibits);static DEFINE_SPINLOCK (uv_nmi_lock); +static struct apic apic_x2apic_uv_x; +static unsigned long __init uv_early_read_mmr (unsigned long addr) {unsigned long val, *mmr;
@@ -331,7 +333,7 @@ static int uv_probe(void)return apic == &apic_x2apic_uv_x; } -struct apic __refdata apic_x2apic_uv_x = { +static struct apic __refdata apic_x2apic_uv_x = { .name ="UV large system" , .probe = uv_probe,
arch/x86/kernel/apic/es7000_32.c +2 -2
@@ -620,7 +620,7 @@ static int es7000_mps_oem_check_cluster( }/* We've been warned by a false positive warning.Use __refdata to keep calm. */ -struct apic __refdata apic_es7000_cluster = { +static struct apic __refdata apic_es7000_cluster = { .name ="es7000" , .probe = probe_es7000,
@@ -685,7 +685,7 @@ struct apic __refdata apic_es7000_cluste .x86_32_early_logical_apicid = es7000_early_logical_apicid, }; -struct apic __refdata apic_es7000 = { +static struct apic __refdata apic_es7000 = { .name ="es7000" , .probe = probe_es7000,
arch/x86/kernel/apic/numaq_32.c +2 -2
@@ -472,8 +472,8 @@ static void numaq_setup_portio_remap(voi (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD); } -/* Use __refdata to keep false positive warning calm. */ -struct apic __refdata apic_numaq = { +/* Use __refdata to keep false positive warning calm. */ +static struct apic __refdata apic_numaq = { .name ="NUMAQ" , .probe = probe_numaq,
arch/x86/kernel/apic/probe_32.c +1 -25
@@ -87,7 +87,7 @@ static int probe_default(void)return 1 ; } -struct apic apic_default = { +static struct apic apic_default = { .name ="default" , .probe = probe_default,
@@ -151,33 +151,9 @@ struct apic apic_default = {apic_driver (apic_default); -extern struct apic apic_numaq; -extern struct apic apic_summit; -extern struct apic apic_bigsmp; -extern struct apic apic_es7000; -extern struct apic apic_es7000_cluster; -struct apic *apic = &apic_default;EXPORT_SYMBOL_GPL (apic); -static struct apic *apic_probe[]__initdata = { -#ifdef CONFIG_X86_NUMAQ - &apic_numaq, -#endif -#ifdef CONFIG_X86_SUMMIT - &apic_summit, -#endif -#ifdef CONFIG_X86_BIGSMP - &apic_bigsmp, -#endif -#ifdef CONFIG_X86_ES7000 - &apic_es7000, - &apic_es7000_cluster, -#endif - &apic_default,/* must be last */ -NULL , -}; -static int cmdline_apic__initdata ;static int __init parse_apic (char *arg) {
arch/x86/kernel/apic/summit_32.c +1 -1
@@ -491,7 +491,7 @@ void setup_summit(void) }#endif -struct apic apic_summit = { +static struct apic apic_summit = { .name ="summit" , .probe = probe_summit,
arch/x86/kernel/apic/bigsmp_32.c +1 -1
@@ -193,7 +193,7 @@ static int probe_bigsmp(void)return dmi_bigsmp; } -struct apic apic_bigsmp = { +static struct apic apic_bigsmp = { .name ="bigsmp" , .probe = probe_bigsmp,
[tip:x86/apic] x86, apic: Make apic drivers static
Commit-ID: 1a8880a14270814dae0d226a2ad065d30587e60a Gitweb: http://git.kernel.org/tip/1a8880a14270814dae0d226a2ad065d30587e60a Author: Suresh Siddha <[email protected]> AuthorDate: Fri, 20 May 2011 17:51:20 -0700 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 22 May 2011 11:48:04 +0200
x86, apic: Make apic drivers static
Apic probe now looks at the apic drivers listed in the .apicdrivers section. Remove apic_probe[] and make each apic driver static.
--- arch/x86/include/asm/apic.h | 7 ------- arch/x86/kernel/apic/apic_flat_64.c | 10 ++++++++-- arch/x86/kernel/apic/bigsmp_32.c | 2 +- arch/x86/kernel/apic/es7000_32.c | 4 ++-- arch/x86/kernel/apic/numaq_32.c | 4 ++-- arch/x86/kernel/apic/probe_32.c | 26 +------------------------- arch/x86/kernel/apic/probe_64.c | 21 --------------------- arch/x86/kernel/apic/summit_32.c | 2 +- arch/x86/kernel/apic/x2apic_cluster.c | 2 +- arch/x86/kernel/apic/x2apic_phys.c | 4 +++- arch/x86/kernel/apic/x2apic_uv_x.c | 4 +++- 11 files changed, 22 insertions(+), 64 deletions(-)
arch/x86/include/asm/apic.h +0 -7
@@ -478,15 +478,10 @@ static inline unsigned default_get_apic_id(unsigned long x)#define DEFAULT_TRAMPOLINE_PHYS_HIGH 0x469#ifdef CONFIG_X86_64 -extern struct apic apic_flat; -extern struct apic apic_physflat; -extern struct apic apic_x2apic_cluster; -extern struct apic apic_x2apic_phys;extern int default_acpi_madt_oem_check (char *,char *);extern void apic_send_IPI_self (int vector); -extern struct apic apic_x2apic_uv_x;DECLARE_PER_CPU (int, x2apic_extra_bits);extern int default_cpu_present_to_apicid (int mps_cpu);
@@ -536,8 +531,6 @@ extern struct apic apic_noop;#ifdef CONFIG_X86_32 -extern struct apic apic_default; -static inline int noop_x86_32_early_logical_apicid (int cpu) {return BAD_APICID ;
arch/x86/kernel/apic/apic_flat_64.c +8 -2
@@ -24,6 +24,12 @@#include <acpi/acpi_bus.h> #endif +static struct apic apic_physflat; +static struct apic apic_flat; + +struct apic __read_mostly *apic = &apic_flat; +EXPORT_SYMBOL_GPL (apic); +static int flat_acpi_madt_oem_check (char *oem_id,char *oem_table_id) {return 1 ;
@@ -164,7 +170,7 @@ static int flat_phys_pkg_id(int initial_apic_id, int index_msb)return initial_apic_id >> index_msb; } -struct apic apic_flat = { +static struct apic apic_flat = { .name ="flat" , .probe =NULL , .acpi_madt_oem_check = flat_acpi_madt_oem_check,
@@ -320,7 +326,7 @@ static int physflat_probe(void)return 0 ; } -struct apic apic_physflat = { +static struct apic apic_physflat = { .name ="physical flat" , .probe = physflat_probe,
arch/x86/kernel/apic/bigsmp_32.c +1 -1
@@ -193,7 +193,7 @@ static int probe_bigsmp(void)return dmi_bigsmp; } -struct apic apic_bigsmp = { +static struct apic apic_bigsmp = { .name ="bigsmp" , .probe = probe_bigsmp,
arch/x86/kernel/apic/es7000_32.c +2 -2
@@ -620,7 +620,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem, }/* We've been warned by a false positive warning.Use __refdata to keep calm. */ -struct apic __refdata apic_es7000_cluster = { +static struct apic __refdata apic_es7000_cluster = { .name ="es7000" , .probe = probe_es7000,
@@ -685,7 +685,7 @@ struct apic __refdata apic_es7000_cluster = { .x86_32_early_logical_apicid = es7000_early_logical_apicid, }; -struct apic __refdata apic_es7000 = { +static struct apic __refdata apic_es7000 = { .name ="es7000" , .probe = probe_es7000,
arch/x86/kernel/apic/numaq_32.c +2 -2
@@ -472,8 +472,8 @@ static void numaq_setup_portio_remap(void) (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD); } -/* Use __refdata to keep false positive warning calm. */ -struct apic __refdata apic_numaq = { +/* Use __refdata to keep false positive warning calm. */ +static struct apic __refdata apic_numaq = { .name ="NUMAQ" , .probe = probe_numaq,
arch/x86/kernel/apic/probe_32.c +1 -25
@@ -87,7 +87,7 @@ static int probe_default(void)return 1 ; } -struct apic apic_default = { +static struct apic apic_default = { .name ="default" , .probe = probe_default,
@@ -151,33 +151,9 @@ struct apic apic_default = {apic_driver (apic_default); -extern struct apic apic_numaq; -extern struct apic apic_summit; -extern struct apic apic_bigsmp; -extern struct apic apic_es7000; -extern struct apic apic_es7000_cluster; -struct apic *apic = &apic_default;EXPORT_SYMBOL_GPL (apic); -static struct apic *apic_probe[]__initdata = { -#ifdef CONFIG_X86_NUMAQ - &apic_numaq, -#endif -#ifdef CONFIG_X86_SUMMIT - &apic_summit, -#endif -#ifdef CONFIG_X86_BIGSMP - &apic_bigsmp, -#endif -#ifdef CONFIG_X86_ES7000 - &apic_es7000, - &apic_es7000_cluster, -#endif - &apic_default,/* must be last */ -NULL , -}; -static int cmdline_apic__initdata ;static int __init parse_apic (char *arg) {
arch/x86/kernel/apic/probe_64.c +0 -21
@@ -23,27 +23,6 @@#include <asm/ipi.h> #include <asm/setup.h> -extern struct apic apic_flat; -extern struct apic apic_physflat; -extern struct apic apic_x2xpic_uv_x; -extern struct apic apic_x2apic_phys; -extern struct apic apic_x2apic_cluster; - -struct apic __read_mostly *apic = &apic_flat; -EXPORT_SYMBOL_GPL (apic); - -static struct apic *apic_probe[]__initdata = { -#ifdef CONFIG_X86_UV - &apic_x2apic_uv_x, -#endif -#ifdef CONFIG_X86_X2APIC - &apic_x2apic_phys, - &apic_x2apic_cluster, -#endif - &apic_physflat, -NULL , -}; -static int apicid_phys_pkg_id (int initial_apic_id,int index_msb) {return hard_smp_processor_id () >> index_msb;
arch/x86/kernel/apic/summit_32.c +1 -1
@@ -491,7 +491,7 @@ void setup_summit(void) }#endif -struct apic apic_summit = { +static struct apic apic_summit = { .name ="summit" , .probe = probe_summit,
arch/x86/kernel/apic/x2apic_cluster.c +1 -1
@@ -208,7 +208,7 @@ static int x2apic_cluster_probe(void)return 0 ; } -struct apic apic_x2apic_cluster = { +static struct apic apic_x2apic_cluster = { .name ="cluster x2apic" , .probe = x2apic_cluster_probe,
arch/x86/kernel/apic/x2apic_phys.c +3 -1
@@ -11,6 +11,8 @@int x2apic_phys; +static struct apic apic_x2apic_phys; +static int set_x2apic_phys_mode (char *arg) { x2apic_phys =1 ;
@@ -112,7 +114,7 @@ static int x2apic_phys_probe(void)return apic == &apic_x2apic_phys; } -struct apic apic_x2apic_phys = { +static struct apic apic_x2apic_phys = { .name ="physical x2apic" , .probe = x2apic_phys_probe,
arch/x86/kernel/apic/x2apic_uv_x.c +3 -1
@@ -58,6 +58,8 @@ unsigned int uv_apicid_hibits;EXPORT_SYMBOL_GPL (uv_apicid_hibits);static DEFINE_SPINLOCK (uv_nmi_lock); +static struct apic apic_x2apic_uv_x; +static unsigned long __init uv_early_read_mmr (unsigned long addr) {unsigned long val, *mmr;
@@ -331,7 +333,7 @@ static int uv_probe(void)return apic == &apic_x2apic_uv_x; } -struct apic __refdata apic_x2apic_uv_x = { +static struct apic __refdata apic_x2apic_uv_x = { .name ="UV large system" , .probe = uv_probe,
Quoted 9 lines · Suresh Siddha
Updated patchset for cleaning up apic probe sequence by using apicdriver section.
Changes from V1:
* split up the patch into four small patches
* misc cleanups, specifying section alignment, removing duplicate messages (from Cyrill and Yinghai's review comments)
* fixed a crash on smaller x64 systems
I'll give them a spin tonight (if noone manage earlier). Thanks a lot Suresh!
Signature · 1 line
Cyrill
Quoted 9 lines · Suresh Siddha
Updated patchset for cleaning up apic probe sequence by using apicdriver section.
Changes from V1:
* split up the patch into four small patches
* misc cleanups, specifying section alignment, removing duplicate messages (from Cyrill and Yinghai's review comments)
* fixed a crash on smaller x64 systems
FWIW it runs fine on my Core 2 machine, setting apic driver to flat as expected. For flat apic mode
Thanks a lot Suresh!
Signature · 1 line
Cyrill
Quoted 8 lines · Suresh Siddha
Updated patchset for cleaning up apic probe sequence by using apicdriver section.
Changes from V1:
* split up the patch into four small patches
* misc cleanups, specifying section alignment, removing duplicate messages (from Cyrill and Yinghai's review comments)
* fixed a crash on smaller x64 systems
Ok, this split-up looks a lot nicer. Applied - thanks guys!
Ingo