From f158c9c96156475c524742ada013453887d86af9 Mon Sep 17 00:00:00 2001 From: Arthur Heymans Date: Wed, 31 Aug 2022 09:43:45 +0200 Subject: [PATCH] cpu/x86/lapic.h: Fix CONFIG_X2APIC_RUNTIME The deadlock prevention is also needed with CONFIG_X2APIC_RUNTIME when the cpu is in x2apic mode. TESTED: Fixes SMI generation on xeon_sp hardware with CONFIG_X2APIC_RUNTIME. Change-Id: I6a71204fcff35e11613fc8363ce061b348e73496 Signed-off-by: Arthur Heymans Reviewed-on: https://review.coreboot.org/c/coreboot/+/67239 Tested-by: build bot (Jenkins) Reviewed-by: Jonathan Zhang Reviewed-by: Angel Pons --- src/include/cpu/x86/lapic.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index 5fa5608db9..cfb9c9098b 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -155,7 +155,9 @@ static __always_inline void lapic_send_ipi_self(uint32_t icrlow) /* In case of X2APIC force a short delay, to prevent deadlock in a case * the immediately following code acquires some lock, like with printk(). */ - while (CONFIG(X2APIC_ONLY) && i--) + const bool x2apic = is_x2apic_mode(); + + while (x2apic && i--) cpu_relax(); }