Commit fa2bd35a authored by Yinghai Lu's avatar Yinghai Lu Committed by Ingo Molnar

x86: merge APIC_init_uniprocessor

Signed-off-by: default avatarYinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent f28c0ae2
...@@ -1355,6 +1355,17 @@ int apic_version[MAX_APICS]; ...@@ -1355,6 +1355,17 @@ int apic_version[MAX_APICS];
int __init APIC_init_uniprocessor(void) int __init APIC_init_uniprocessor(void)
{ {
#ifdef CONFIG_X86_64
if (disable_apic) {
printk(KERN_INFO "Apic disabled\n");
return -1;
}
if (!cpu_has_apic) {
disable_apic = 1;
printk(KERN_INFO "Apic disabled by BIOS\n");
return -1;
}
#else
if (!smp_found_config && !cpu_has_apic) if (!smp_found_config && !cpu_has_apic)
return -1; return -1;
...@@ -1368,34 +1379,62 @@ int __init APIC_init_uniprocessor(void) ...@@ -1368,34 +1379,62 @@ int __init APIC_init_uniprocessor(void)
clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC); clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
return -1; return -1;
} }
#endif
#ifdef HAVE_X2APIC
enable_IR_x2apic();
#endif
#ifdef CONFIG_X86_64
setup_apic_routing();
#endif
verify_local_APIC(); verify_local_APIC();
connect_bsp_APIC(); connect_bsp_APIC();
#ifdef CONFIG_X86_64
apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid));
#else
/* /*
* Hack: In case of kdump, after a crash, kernel might be booting * Hack: In case of kdump, after a crash, kernel might be booting
* on a cpu with non-zero lapic id. But boot_cpu_physical_apicid * on a cpu with non-zero lapic id. But boot_cpu_physical_apicid
* might be zero if read from MP tables. Get it from LAPIC. * might be zero if read from MP tables. Get it from LAPIC.
*/ */
#ifdef CONFIG_CRASH_DUMP # ifdef CONFIG_CRASH_DUMP
boot_cpu_physical_apicid = read_apic_id(); boot_cpu_physical_apicid = read_apic_id();
# endif
#endif #endif
physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
setup_local_APIC(); setup_local_APIC();
#ifdef CONFIG_X86_64
/*
* Now enable IO-APICs, actually call clear_IO_APIC
* We need clear_IO_APIC before enabling vector on BP
*/
if (!skip_ioapic_setup && nr_ioapics)
enable_IO_APIC();
#endif
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
if (!smp_found_config || skip_ioapic_setup || !nr_ioapics) if (!smp_found_config || skip_ioapic_setup || !nr_ioapics)
#endif #endif
localise_nmi_watchdog(); localise_nmi_watchdog();
end_local_APIC_setup(); end_local_APIC_setup();
#ifdef CONFIG_X86_IO_APIC #ifdef CONFIG_X86_IO_APIC
if (smp_found_config) if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
if (!skip_ioapic_setup && nr_ioapics)
setup_IO_APIC(); setup_IO_APIC();
# ifdef CONFIG_X86_64
else
nr_ioapics = 0;
# endif
#endif #endif
#ifdef CONFIG_X86_64
setup_boot_APIC_clock();
check_nmi_watchdog();
#else
setup_boot_clock(); setup_boot_clock();
#endif
return 0; return 0;
} }
......
...@@ -1351,6 +1351,7 @@ int apic_version[MAX_APICS]; ...@@ -1351,6 +1351,7 @@ int apic_version[MAX_APICS];
int __init APIC_init_uniprocessor(void) int __init APIC_init_uniprocessor(void)
{ {
#ifdef CONFIG_X86_64
if (disable_apic) { if (disable_apic) {
printk(KERN_INFO "Apic disabled\n"); printk(KERN_INFO "Apic disabled\n");
return -1; return -1;
...@@ -1360,37 +1361,78 @@ int __init APIC_init_uniprocessor(void) ...@@ -1360,37 +1361,78 @@ int __init APIC_init_uniprocessor(void)
printk(KERN_INFO "Apic disabled by BIOS\n"); printk(KERN_INFO "Apic disabled by BIOS\n");
return -1; return -1;
} }
#else
if (!smp_found_config && !cpu_has_apic)
return -1;
/*
* Complain if the BIOS pretends there is one.
*/
if (!cpu_has_apic &&
APIC_INTEGRATED(apic_version[boot_cpu_physical_apicid])) {
printk(KERN_ERR "BIOS bug, local APIC #%d not detected!...\n",
boot_cpu_physical_apicid);
clear_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
return -1;
}
#endif
#ifdef HAVE_X2APIC #ifdef HAVE_X2APIC
enable_IR_x2apic(); enable_IR_x2apic();
#endif #endif
#ifdef CONFIG_X86_64
setup_apic_routing(); setup_apic_routing();
#endif
verify_local_APIC(); verify_local_APIC();
connect_bsp_APIC(); connect_bsp_APIC();
physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); #ifdef CONFIG_X86_64
apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid)); apic_write(APIC_ID, SET_APIC_ID(boot_cpu_physical_apicid));
#else
/*
* Hack: In case of kdump, after a crash, kernel might be booting
* on a cpu with non-zero lapic id. But boot_cpu_physical_apicid
* might be zero if read from MP tables. Get it from LAPIC.
*/
# ifdef CONFIG_CRASH_DUMP
boot_cpu_physical_apicid = read_apic_id();
# endif
#endif
physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map);
setup_local_APIC(); setup_local_APIC();
#ifdef CONFIG_X86_64
/* /*
* Now enable IO-APICs, actually call clear_IO_APIC * Now enable IO-APICs, actually call clear_IO_APIC
* We need clear_IO_APIC before enabling vector on BP * We need clear_IO_APIC before enabling vector on BP
*/ */
if (!skip_ioapic_setup && nr_ioapics) if (!skip_ioapic_setup && nr_ioapics)
enable_IO_APIC(); enable_IO_APIC();
#endif
#ifdef CONFIG_X86_IO_APIC
if (!smp_found_config || skip_ioapic_setup || !nr_ioapics) if (!smp_found_config || skip_ioapic_setup || !nr_ioapics)
#endif
localise_nmi_watchdog(); localise_nmi_watchdog();
end_local_APIC_setup(); end_local_APIC_setup();
#ifdef CONFIG_X86_IO_APIC
if (smp_found_config && !skip_ioapic_setup && nr_ioapics) if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
setup_IO_APIC(); setup_IO_APIC();
# ifdef CONFIG_X86_64
else else
nr_ioapics = 0; nr_ioapics = 0;
# endif
#endif
#ifdef CONFIG_X86_64
setup_boot_APIC_clock(); setup_boot_APIC_clock();
check_nmi_watchdog(); check_nmi_watchdog();
#else
setup_boot_clock();
#endif
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment