Skip to content

Commit d524165

Browse files
committed
x86/apic: Check x2apic early
No point in delaying the x2apic detection for the CONFIG_X86_X2APIC=n case to enable_IR_x2apic(). We rather detect that before we try to setup anything there. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Jiang Liu <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Tony Luck <[email protected]> Cc: Borislav Petkov <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 9aa1636 commit d524165

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

arch/x86/include/asm/apic.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static inline u64 native_x2apic_icr_read(void)
178178

179179
extern int x2apic_mode;
180180
extern int x2apic_phys;
181-
extern void check_x2apic(void);
181+
extern void __init check_x2apic(void);
182182
extern void enable_x2apic(void);
183183
static inline int x2apic_enabled(void)
184184
{

arch/x86/kernel/apic/apic.c

+20-14
Original file line numberDiff line numberDiff line change
@@ -1541,14 +1541,6 @@ static __init void disable_x2apic(void)
15411541
x2apic_disabled = 1;
15421542
}
15431543

1544-
void check_x2apic(void)
1545-
{
1546-
if (x2apic_enabled()) {
1547-
pr_info("x2apic enabled by BIOS, switching to x2apic ops\n");
1548-
x2apic_mode = 1;
1549-
}
1550-
}
1551-
15521544
void enable_x2apic(void)
15531545
{
15541546
u64 msr;
@@ -1568,7 +1560,26 @@ void enable_x2apic(void)
15681560
wrmsrl(MSR_IA32_APICBASE, msr | X2APIC_ENABLE);
15691561
}
15701562
}
1571-
#endif /* CONFIG_X86_X2APIC */
1563+
1564+
void __init check_x2apic(void)
1565+
{
1566+
if (x2apic_enabled()) {
1567+
pr_info("x2apic enabled by BIOS, switching to x2apic ops\n");
1568+
x2apic_mode = 1;
1569+
}
1570+
}
1571+
#else /* CONFIG_X86_X2APIC */
1572+
static int __init validate_x2apic(void)
1573+
{
1574+
if (!apic_is_x2apic_enabled())
1575+
return 0;
1576+
/*
1577+
* Checkme: Can we simply turn off x2apic here instead of panic?
1578+
*/
1579+
panic("BIOS has enabled x2apic but kernel doesn't support x2apic, please disable x2apic in BIOS.\n");
1580+
}
1581+
early_initcall(validate_x2apic);
1582+
#endif /* !CONFIG_X86_X2APIC */
15721583

15731584
static int __init try_to_enable_IR(void)
15741585
{
@@ -1620,11 +1631,6 @@ void __init enable_IR_x2apic(void)
16201631
unsigned long flags;
16211632
int ret, ir_stat;
16221633

1623-
if (!IS_ENABLED(CONFIG_X86_X2APIC)) {
1624-
if (apic_is_x2apic_enabled())
1625-
panic("BIOS has enabled x2apic but kernel doesn't support x2apic, please disable x2apic in BIOS.\n");
1626-
}
1627-
16281634
ir_stat = irq_remapping_prepare();
16291635
if (ir_stat < 0 && !x2apic_supported())
16301636
return;

0 commit comments

Comments
 (0)