x86/timer: Don't skip PIT setup when APIC is disabled or in legacy mode
authorThomas Gleixner <tglx@linutronix.de>
Thu, 23 Jan 2020 11:54:53 +0000 (12:54 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 29 Jan 2020 11:50:12 +0000 (12:50 +0100)
commit979923871f69a4dc926658f9f9a1a4c1bde57552
treee9067d24ec18e59a887eada03aead116d17935a8
parent6bd3357b6181bd38c1a757168a8842e09ec6f3fb
x86/timer: Don't skip PIT setup when APIC is disabled or in legacy mode

Tony reported a boot regression caused by the recent workaround for systems
which have a disabled (clock gate off) PIT.

On his machine the kernel fails to initialize the PIT because
apic_needs_pit() does not take into account whether the local APIC
interrupt delivery mode will actually allow to setup and use the local
APIC timer. This should be easy to reproduce with acpi=off on the
command line which also disables HPET.

Due to the way the PIT/HPET and APIC setup ordering works (APIC setup can
require working PIT/HPET) the information is not available at the point
where apic_needs_pit() makes this decision.

To address this, split out the interrupt mode selection from
apic_intr_mode_init(), invoke the selection before making the decision
whether PIT is required or not, and add the missing checks into
apic_needs_pit().

Fixes: c8c4076723da ("x86/timer: Skip PIT initialization on modern chipsets")
Reported-by: Anthony Buckley <tony.buckley000@gmail.com>
Tested-by: Anthony Buckley <tony.buckley000@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Daniel Drake <drake@endlessm.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206125
Link: https://lore.kernel.org/r/87sgk6tmk2.fsf@nanos.tec.linutronix.de
arch/x86/include/asm/apic.h
arch/x86/include/asm/x86_init.h
arch/x86/kernel/apic/apic.c
arch/x86/kernel/time.c
arch/x86/kernel/x86_init.c
arch/x86/xen/enlighten_pv.c