x86: clean up using smp_register_lapic_address()
cover x86: clean up using smp_register_lapic_address()
Merge acpi_register_lapic_address, smp_register_lapic_address, sfi_register_lapic_address
Thanks
Yinghai Lu
[PATCH 01/10] x86: Fix lapic mapping with construct ISA and visws mptable path [PATCH 02/10] x86, acpi: merge two register_lapic_address()
[PATCH 03/10] x86: remove early_init_lapic_mapping
[PATCH 04/10] x86: call smp_register_lapic_address for contruct_default mptable path [PATCH 05/10] x86, apic: use smp_register_lapic_address in init_apic_mapping [PATCH 06/10] x86, sfi: used smp_register_lapic_address
[PATCH 07/10] x86,visws: set_fixmap in find_smp_config
[PATCH 08/10] x86: !find_smp_config path use smp_register_lapic_address [PATCH 09/10] x86, apic: set fixmap only one time
[PATCH 10/10] x86, ioapic: only print mapping for ioapic in right place
arch/x86/include/asm/apic.h | 2 +- arch/x86/kernel/acpi/boot.c | 16 +---------- arch/x86/kernel/apic/apic.c | 54 +++++++++++++++++---------------------- arch/x86/kernel/apic/io_apic.c | 11 +++++--- arch/x86/kernel/mpparse.c | 24 +++-------------- arch/x86/kernel/sfi.c | 13 +--------- arch/x86/kernel/visws_quirks.c | 1 + arch/x86/mm/k8topology_64.c | 1 - 8 files changed, 40 insertions(+), 82 deletions(-)
PATCH 1/10 x86: Fix lapic mapping with construct ISA and visws mptable path
do need to set lapic mapping for them
in arch/x86/kernel/visws_quirks.c:
we only have visws_find_smp_config() to set mp_lapic_addr to APIC_DEFAULT_PHYS_BASE visws_get_smp_config() is nop call. default_get_smp_config/check_physptr/smp_read_mpc is not called in the path. So smp_register_lapic_address() is not called, and lapic is not mapped.
in arch/x86/kernel/mpparse.c
if mpf->feature1 != 0, it will go through contruct_default_ISA_mptable instead of check_phystr path, so smp_register_lapic_address is not called.
those two path all have smp_found_config set.
So let remove !smp_found_config checking
Actually set fixmap two times does not hurt.
--- arch/x86/kernel/apic/apic.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/apic/apic.c +1 -1
@@ -1606,7 +1606,7 @@ void __init init_apic_mappings(void)* acpi lapic path already maps that address in * acpi_register_lapic_address() */ -if (!acpi_lapic && !smp_found_config) +if (!acpi_lapic)set_fixmap_nocache (FIX_APIC_BASE , apic_phys); apic_printk(APIC_VERBOSE, "mapped APIC to %08lx (%08lx)\n",
Signature · 1 line
1.6.4.2
PATCH 2/10 x86, acpi: merge two register_lapic_address()
In reply to Yinghai LuThey are the same, move it to apic.c
--- arch/x86/include/asm/apic.h | 1 + arch/x86/kernel/acpi/boot.c | 16 ++-------------- arch/x86/kernel/apic/apic.c | 12 ++++++++++++ arch/x86/kernel/mpparse.c | 12 ------------ 4 files changed, 15 insertions(+), 26 deletions(-)
arch/x86/include/asm/apic.h +1 -0
@@ -234,6 +234,7 @@ extern void init_bsp_APIC(void);extern void setup_local_APIC (void );extern void end_local_APIC_setup (void );extern void init_apic_mappings (void ); +void smp_register_lapic_address (unsigned long address);extern void setup_boot_APIC_clock (void );extern void setup_secondary_APIC_clock (void );extern int APIC_init_uniprocessor (void );
arch/x86/kernel/acpi/boot.c +2 -14
@@ -820,18 +820,6 @@ static int __init acpi_parse_fadt(struct acpi_table_header *table)* returns 0 on success, < 0 on error */ -static void __init acpi_register_lapic_address (unsigned long address) -{ - mp_lapic_addr = address; - -set_fixmap_nocache (FIX_APIC_BASE , address); -if (boot_cpu_physical_apicid ==-1U ) { - boot_cpu_physical_apicid =read_apic_id (); - apic_version[boot_cpu_physical_apicid] = -GET_APIC_VERSION (apic_read (APIC_LVR )); - } -} -static int __init early_acpi_parse_madt_lapic_addr_ovr (void ) {int count;
@@ -853,7 +841,7 @@ static int __init early_acpi_parse_madt_lapic_addr_ovr(void)return count; } -acpi_register_lapic_address (acpi_lapic_addr); +smp_register_lapic_address (acpi_lapic_addr);return count; }
@@ -880,7 +868,7 @@ static int __init acpi_parse_madt_lapic_entries(void)return count; } -acpi_register_lapic_address (acpi_lapic_addr); +smp_register_lapic_address (acpi_lapic_addr); count =acpi_table_parse_madt (ACPI_MADT_TYPE_LOCAL_SAPIC , acpi_parse_sapic,MAX_APICS );
arch/x86/kernel/apic/apic.c +12 -0
@@ -1632,6 +1632,18 @@ void __init init_apic_mappings(void) } } +void __init smp_register_lapic_address (unsigned long address) +{ + mp_lapic_addr = address; + +set_fixmap_nocache (FIX_APIC_BASE , address); +if (boot_cpu_physical_apicid ==-1U ) { + boot_cpu_physical_apicid =read_apic_id (); + apic_version[boot_cpu_physical_apicid] = +GET_APIC_VERSION (apic_read (APIC_LVR )); + } +} +/* * This initializes the IO-APIC and APIC hardware if this is * a UP kernel.
arch/x86/kernel/mpparse.c +0 -12
@@ -274,18 +274,6 @@ static void __init smp_dump_mptable(struct mpc_table *mpc, unsigned char *mpt)void __init default_smp_read_mpc_oem (struct mpc_table *mpc) { } -static void __init smp_register_lapic_address (unsigned long address) -{ - mp_lapic_addr = address; - -set_fixmap_nocache (FIX_APIC_BASE , address); -if (boot_cpu_physical_apicid ==-1U ) { - boot_cpu_physical_apicid =read_apic_id (); - apic_version[boot_cpu_physical_apicid] = -GET_APIC_VERSION (apic_read (APIC_LVR )); - } -} -static int __init smp_read_mpc (struct mpc_table *mpc,unsigned early) {char str[16 ];
Signature · 1 line
1.6.4.2
PATCH 3/10 x86: remove early_init_lapic_mapping
In reply to Yinghai LuIt is almost the same as smp_register_lapic_addr()
Just need to make smp_read_mpc() call smp_register_lapic_addr when early==1.
also add printing out in smp_register_lapic_address()
--- arch/x86/include/asm/apic.h | 1 - arch/x86/kernel/apic/apic.c | 24 ++---------------------- arch/x86/kernel/mpparse.c | 8 ++------ arch/x86/mm/k8topology_64.c | 1 - 4 files changed, 4 insertions(+), 30 deletions(-)
arch/x86/include/asm/apic.h +0 -1
@@ -244,7 +244,6 @@ extern void enable_NMI_through_LVT0(void);* On 32bit this is mach-xxx local */ #ifdef CONFIG_X86_64 -extern void early_init_lapic_mapping (void );extern int apic_is_clustered_box (void );#else static inline int apic_is_clustered_box (void )
arch/x86/kernel/apic/apic.c +2 -22
@@ -1560,28 +1560,6 @@ no_apic: }#endif -#ifdef CONFIG_X86_64 -void __init early_init_lapic_mapping (void ) -{ -/* -* If no local APIC can be found then go out -* : it means there is no mpatable and MADT -*/ -if (!smp_found_config) -return ; - -set_fixmap_nocache (FIX_APIC_BASE , mp_lapic_addr); -apic_printk (APIC_VERBOSE ,"mapped APIC to %16lx (%16lx)\n" , -APIC_BASE , mp_lapic_addr); - -/* -* Fetch the APIC ID of the BSP in case we have a -* default configuration (or the MP table is broken). -*/ - boot_cpu_physical_apicid =read_apic_id (); -} -#endif -/** * init_apic_mappings - initialize APIC mappings */
@@ -1637,6 +1615,8 @@ void __init smp_register_lapic_address(unsigned long address) mp_lapic_addr = address;set_fixmap_nocache (FIX_APIC_BASE , address); +apic_printk (APIC_VERBOSE ,"mapped APIC to %16lx (%16lx)\n" , +APIC_BASE , mp_lapic_addr);if (boot_cpu_physical_apicid ==-1U ) { boot_cpu_physical_apicid =read_apic_id (); apic_version[boot_cpu_physical_apicid] =
arch/x86/kernel/mpparse.c +2 -6
@@ -288,17 +288,13 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)#ifdef CONFIG_X86_32 generic_mps_oem_check (mpc, oem, str);#endif -/* save the local APIC address, it might be non-default */ +/* Initialize the lapic mapping */ if (!acpi_lapic) - mp_lapic_addr = mpc->lapic; +smp_register_lapic_address (mpc->lapic);if (early)return 1 ; -/* Initialize the lapic mapping */ -if (!acpi_lapic) -smp_register_lapic_address (mpc->lapic); -if (mpc->oemptr) x86_init.mpparse.smp_read_mpc_oem (mpc);
arch/x86/mm/k8topology_64.c +0 -1
@@ -64,7 +64,6 @@ static __init void early_get_boot_cpu_id(void)if (smp_found_config)early_get_smp_config ();#endif -early_init_lapic_mapping (); }int __init k8_get_nodes (struct bootnode *physnodes)
Signature · 1 line
1.6.4.2
PATCH 4/10 x86: call smp_register_lapic_address for contruct_default mptable path
In reply to Yinghai Lubecause it already finds smp config.
make it like other find_smp_config path
--- arch/x86/kernel/mpparse.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/mpparse.c +2 -2
@@ -480,7 +480,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)/* * local APIC has default address */ - mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; +smp_register_lapic_address (APIC_DEFAULT_PHYS_BASE );/* * 2 CPUs, numbered 0 & 1.
@@ -616,7 +616,7 @@ void __init default_get_smp_config(unsigned int early)/* * local APIC has default address */ - mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; +smp_register_lapic_address (APIC_DEFAULT_PHYS_BASE );return ; }
Signature · 1 line
1.6.4.2
PATCH 5/10 x86, apic: use smp_register_lapic_address in init_apic_mapping
In reply to Yinghai Luso if set_fixmap_nocache is not called, don't print out anything
--- arch/x86/kernel/apic/apic.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
arch/x86/kernel/apic/apic.c +1 -4
@@ -1585,10 +1585,7 @@ void __init init_apic_mappings(void)* acpi_register_lapic_address() */ if (!acpi_lapic) -set_fixmap_nocache (FIX_APIC_BASE , apic_phys); - -apic_printk (APIC_VERBOSE ,"mapped APIC to %08lx (%08lx)\n" , -APIC_BASE , apic_phys); +smp_register_lapic_address (apic_phys); }/*
Signature · 1 line
1.6.4.2
PATCH 6/10 x86, sfi: used smp_register_lapic_address
In reply to Yinghai Lukill mp_sfi_register_lapic_address, they are the same
--- arch/x86/kernel/sfi.c | 13 +------------ 1 files changed, 1 insertions(+), 12 deletions(-)
arch/x86/kernel/sfi.c +1 -12
@@ -34,17 +34,6 @@#ifdef CONFIG_X86_LOCAL_APIC static unsigned long sfi_lapic_addr__initdata =APIC_DEFAULT_PHYS_BASE ; -void __init mp_sfi_register_lapic_address (unsigned long address) -{ - mp_lapic_addr = address; - -set_fixmap_nocache (FIX_APIC_BASE , mp_lapic_addr); -if (boot_cpu_physical_apicid ==-1U ) - boot_cpu_physical_apicid =read_apic_id (); - -pr_info ("Boot CPU = %d\n" , boot_cpu_physical_apicid); -} -/* All CPUs enumerated by SFI must be present and enabled */ void __cpuinit mp_sfi_register_lapic (u8 id) {
@@ -110,7 +99,7 @@ static int __init sfi_parse_ioapic(struct sfi_table_header *table)int __init sfi_platform_init (void ) {#ifdef CONFIG_X86_LOCAL_APIC -mp_sfi_register_lapic_address (sfi_lapic_addr); +smp_register_lapic_address (sfi_lapic_addr);sfi_table_parse (SFI_SIG_CPUS ,NULL ,NULL , sfi_parse_cpus);#endif #ifdef CONFIG_X86_IO_APIC
Signature · 1 line
1.6.4.2
PATCH 7/10 x86,visws: set_fixmap in find_smp_config
In reply to Yinghai Lu--- arch/x86/kernel/visws_quirks.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/visws_quirks.c +1 -0
@@ -214,6 +214,7 @@ static void __init visws_find_smp_config(void)MP_processor_info (mp++); mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; +set_fixmap (FIX_APIC_BASE ,APIC_DEFAULT_PHYS_BASE ); }static void visws_trap_init (void );
Signature · 1 line
1.6.4.2
PATCH 8/10 x86: !find_smp_config path use smp_register_lapic_address
In reply to Yinghai Luso fixmap will be setup there.
--- arch/x86/kernel/apic/apic.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/kernel/apic/apic.c +5 -3
@@ -1477,7 +1477,7 @@ static int __init detect_init_APIC(void) return -1; } - mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; +smp_register_lapic_addr (APIC_DEFAULT_PHYS_BASE );return 0 ; }#else
@@ -1487,6 +1487,7 @@ static int __init detect_init_APIC(void)static int __init detect_init_APIC (void ) {u32 h, l, features; +unsigned long lapic_addr;/* Disabled by kernel option? */ if (disable_apic)
@@ -1541,13 +1542,14 @@ static int __init detect_init_APIC(void)return -1 ; }set_cpu_cap (&boot_cpu_data,X86_FEATURE_APIC ); - mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; + lapic_addr =APIC_DEFAULT_PHYS_BASE ;/* The BIOS may have set up the APIC at some other address */ rdmsr (MSR_IA32_APICBASE , l, h);if (l &MSR_IA32_APICBASE_ENABLE ) - mp_lapic_addr = l &MSR_IA32_APICBASE_BASE ; + lapic_addr = l &MSR_IA32_APICBASE_BASE ; + smp_register_lapic_address(lapic_addr) pr_info("Found and enabled local APIC!\n");apic_pm_activate ();
Signature · 1 line
1.6.4.2
PATCH 8/10 x86: !find_smp_config path use smp_register_lapic_address
In reply to Yinghai Luso fixmap will be setup there.
-v2: fix typo
--- arch/x86/kernel/apic/apic.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
arch/x86/kernel/apic/apic.c +5 -3
@@ -1477,7 +1477,7 @@ static int __init detect_init_APIC(void) return -1; } - mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; +smp_register_lapic_address (APIC_DEFAULT_PHYS_BASE );return 0 ; }#else
@@ -1487,6 +1487,7 @@ static int __init detect_init_APIC(void)static int __init detect_init_APIC (void ) {u32 h, l, features; +unsigned long lapic_addr;/* Disabled by kernel option? */ if (disable_apic)
@@ -1541,13 +1542,14 @@ static int __init detect_init_APIC(void)return -1 ; }set_cpu_cap (&boot_cpu_data,X86_FEATURE_APIC ); - mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; + lapic_addr =APIC_DEFAULT_PHYS_BASE ;/* The BIOS may have set up the APIC at some other address */ rdmsr (MSR_IA32_APICBASE , l, h);if (l &MSR_IA32_APICBASE_ENABLE ) - mp_lapic_addr = l &MSR_IA32_APICBASE_BASE ; + lapic_addr = l &MSR_IA32_APICBASE_BASE ; +smp_register_lapic_address (lapic_addr);pr_info ("Found and enabled local APIC!\n" );apic_pm_activate ();
Signature · 1 line
1.6.4.2
PATCH 9/10 x86, apic: set fixmap only one time
In reply to Yinghai Lucheck if mp_lapic_addr is assigned or not.
--- arch/x86/kernel/apic/apic.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/x86/kernel/apic/apic.c +3 -0
@@ -1611,6 +1611,9 @@ void __init init_apic_mappings(void)void __init smp_register_lapic_address (unsigned long address) { +if (mp_lapic_addr) +return ; + mp_lapic_addr = address;set_fixmap_nocache (FIX_APIC_BASE , address);
Signature · 1 line
1.6.4.2
PATCH 10/10 x86, ioapic: only print mapping for ioapic in right place
In reply to Yinghai Luwhen mapping does happen.
And only map ioapic address one time when mp_register_ioapic() is called.
--- arch/x86/kernel/apic/io_apic.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
arch/x86/kernel/apic/io_apic.c +7 -4
@@ -4192,11 +4192,11 @@ fake_ioapic_page:#endif ioapic_phys = (unsigned long )alloc_bootmem_pages (PAGE_SIZE ); ioapic_phys =__pa (ioapic_phys); +set_fixmap_nocache (idx, ioapic_phys); +apic_printk (APIC_VERBOSE ,"mapped IOAPIC to %08lx (%08lx)\n" , +__fix_to_virt (idx) + (ioapic_phys & ~PAGE_MASK ), + ioapic_phys); } -set_fixmap_nocache (idx, ioapic_phys); -apic_printk (APIC_VERBOSE ,"mapped IOAPIC to %08lx (%08lx)\n" , -__fix_to_virt (idx) + (ioapic_phys & ~PAGE_MASK ), - ioapic_phys); idx++; ioapic_res->start = ioapic_phys;
@@ -4278,6 +4278,9 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base) mp_ioapics[idx].apicaddr = address;set_fixmap_nocache (FIX_IO_APIC_BASE_0 + idx, address); +apic_printk (APIC_VERBOSE ,"mapped IOAPIC to %08lx (%08x)\n" , +__fix_to_virt (FIX_IO_APIC_BASE_0 + idx) + (address & ~PAGE_MASK ), + address); mp_ioapics[idx].apicid =io_apic_unique_id (id); mp_ioapics[idx].apicver =io_apic_get_version (idx);
Signature · 1 line
1.6.4.2