[RFC PATCH v2 09/12] x86/apic: Setup interrupt mode earlier in case of no SMP motherboard

From: Dou Liyang
Date: Wed Apr 19 2017 - 05:07:33 EST


Kernel falls back to non SMP mode and sets up interrupt delivery mode
in APIC_init_uniprocessor() in case of no SMP motherboard.

Setting up interrupt delivery mode as soon as possible should wraps
this case too.

Wrap this case, make it consistent with SMP-capable systems.
Incidentally,
-Extract apic_bsp_setup() and Refine init_interrupt_mode().

Signed-off-by: Dou Liyang <douly.fnst@xxxxxxxxxxxxxx>
---
arch/x86/kernel/apic/apic.c | 26 ++++++++++++++++++--------
arch/x86/kernel/smpboot.c | 2 --
2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 170cd1a..a915f09 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1157,11 +1157,12 @@ enum apic_interrupt_mode {
APIC_PIC = 0,
APIC_VIRTUAL_WIRE,
APIC_SYMMETRIC_IO,
+ APIC_SYMMETRIC_IO_NO_CONFIG,
APIC_SYMMETRIC_IO_NO_ROUTING,
APIC_MODE_COUNT
};

-static int __init apic_bsp_mode_check(void)
+static int __init apic_bsp_mode_check(int *upmode)
{

/* Check kernel option */
@@ -1200,8 +1201,11 @@ static int __init apic_bsp_mode_check(void)
disable_ioapic_support();

/* Check local APIC, if there is no SMP motherboard */
- if (!acpi_lapic)
+ if (!acpi_lapic) {
+ *upmode = true;
pr_info("SMP motherboard not detected\n");
+ return APIC_SYMMETRIC_IO_NO_CONFIG;
+ }

return APIC_VIRTUAL_WIRE;
}
@@ -1277,23 +1281,29 @@ void __init apic_virtual_wire_mode_setup(void)
/* Init the interrupt delivery mode for the BSP */
void __init init_interrupt_mode(void)
{
- switch (apic_bsp_mode_check()) {
+ int upmode = false;
+
+ switch (apic_bsp_mode_check(&upmode)) {
case APIC_PIC:
pr_info("Keep in PIC mode(8259)\n");
return;
case APIC_VIRTUAL_WIRE:
pr_info("Switch to virtual wire mode\n");
- return;
+ break;
case APIC_SYMMETRIC_IO:
pr_info("Switch to symmectic I/O mode\n");
default_setup_apic_routing();
- apic_bsp_setup(false);
- return;
+ break;
+ case APIC_SYMMETRIC_IO_NO_CONFIG:
+ pr_info("Switch to symmectic I/O mode with no SMP config\n");
+ default_setup_apic_routing();
+ break;
case APIC_SYMMETRIC_IO_NO_ROUTING:
pr_info("Switch to symmectic I/O mode with no APIC routing\n");
- apic_bsp_setup(false);
- return;
+ break;
}
+
+ apic_bsp_setup(upmode);
}

static void lapic_setup_esr(void)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 345ad20..19d36ca 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1324,8 +1324,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
switch (smp_sanity_check(max_cpus)) {
case SMP_NO_CONFIG:
disable_smp();
- if (APIC_init_uniprocessor())
- pr_notice("Local APIC not detected. Using dummy APIC emulation.\n");
return;
case SMP_NO_APIC:
disable_smp();
--
2.5.5