Skip to content

Commit

Permalink
x86/x2apic: Add proper state tracking
Browse files Browse the repository at this point in the history
Having 3 different variables to track the state is just silly and
error prone. Add a proper state tracking variable which covers the
three possible states: ON/OFF/DISABLED.

We cannot use x2apic_mode for this as this would require to change all
users of x2apic_mode with explicit comparisons for a state value
instead of treating it as boolean.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Borislav Petkov <bp@alien8.de>
Cc: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Tony Luck <tony.luck@intel.com>
Link: http://lkml.kernel.org/r/20150115211702.955392443@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Thomas Gleixner committed Jan 22, 2015
1 parent 62e6163 commit 12e189d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion arch/x86/kernel/apic/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,14 @@ static bool nox2apic __initdata;
#ifdef CONFIG_X86_X2APIC
int x2apic_mode;
static int x2apic_disabled;

enum {
X2APIC_OFF,
X2APIC_ON,
X2APIC_DISABLED,
};
static int x2apic_state;

static int __init setup_nox2apic(char *str)
{
if (x2apic_enabled()) {
Expand All @@ -1496,7 +1504,7 @@ static int __init setup_nox2apic(char *str)
setup_clear_cpu_cap(X86_FEATURE_X2APIC);

nox2apic = true;

x2apic_state = X2APIC_DISABLED;
return 0;
}
early_param("nox2apic", setup_nox2apic);
Expand Down Expand Up @@ -1539,6 +1547,7 @@ static __init void disable_x2apic(void)
}

x2apic_disabled = 1;
x2apic_state = X2APIC_DISABLED;
}

void enable_x2apic(void)
Expand All @@ -1559,6 +1568,7 @@ void enable_x2apic(void)
printk_once(KERN_INFO "Enabling x2apic\n");
wrmsrl(MSR_IA32_APICBASE, msr | X2APIC_ENABLE);
}
x2apic_state = X2APIC_ON;
}

static __init void try_to_enable_x2apic(int remap_mode)
Expand Down Expand Up @@ -1597,6 +1607,9 @@ void __init check_x2apic(void)
if (x2apic_enabled()) {
pr_info("x2apic: enabled by BIOS, switching to x2apic ops\n");
x2apic_mode = 1;
x2apic_state = X2APIC_ON;
} else if (!cpu_has_x2apic) {
x2apic_state = X2APIC_DISABLED;
}
}
#else /* CONFIG_X86_X2APIC */
Expand Down

0 comments on commit 12e189d

Please sign in to comment.