Re: Regression: unable to boot after commit bd9240a18edf ("x86/apic: Add TSC_DEADLINE quirk due to errata") - Surface Pro 4 SKL

From: Zhang Rui
Date: Tue Dec 19 2017 - 05:48:35 EST


On Mon, 2017-12-18 at 21:28 +0100, Peter Zijlstra wrote:
> Hi, can you see if this makes you Surface boot?
>
No, it does not boot.

> I tested it on my IVB by making has_legacy_pic() return unconditional
> true.
>
> [ÂÂÂÂ0.024000] tsc: Unable to calibrate against PIT
> [ÂÂÂÂ0.025000] tsc: using HPET reference calibration
> [ÂÂÂÂ0.026000] tsc: Detected 2792.451 MHz processor
>
> ---
>
>
> diff --git a/arch/x86/include/asm/i8259.h
> b/arch/x86/include/asm/i8259.h
> index c8376b40e882..e2cfc4b52ee4 100644
> --- a/arch/x86/include/asm/i8259.h
> +++ b/arch/x86/include/asm/i8259.h
> @@ -69,6 +69,11 @@ struct legacy_pic {
> Âextern struct legacy_pic *legacy_pic;
> Âextern struct legacy_pic null_legacy_pic;
> Â
> +static inline bool has_legacy_pic(void)
> +{
> + return legacy_pic == &null_legacy_pic;
> +}
> +
shouldn't this be
return legacy_pic == &default_legacy_pic;
?

thanks,
rui
> Âstatic inline int nr_legacy_irqs(void)
> Â{
> Â return legacy_pic->nr_legacy_irqs;
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 8ea117f8142e..2afc623b2280 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -25,6 +25,7 @@
> Â#include <asm/geode.h>
> Â#include <asm/apic.h>
> Â#include <asm/intel-family.h>
> +#include <asm/i8259.h>
> Â
> Âunsigned int __read_mostly cpu_khz; /* TSC clocks / usec, not
> used here */
> ÂEXPORT_SYMBOL(cpu_khz);
> @@ -363,6 +364,15 @@ static unsigned long pit_calibrate_tsc(u32
> latch, unsigned long ms, int loopmin)
> Â unsigned long tscmin, tscmax;
> Â int pitcnt;
> Â
> + if (!has_legacy_pic()) {
> + udelay(10 * USEC_PER_MSEC);
> + udelay(10 * USEC_PER_MSEC);
> + udelay(10 * USEC_PER_MSEC);
> + udelay(10 * USEC_PER_MSEC);
> + udelay(10 * USEC_PER_MSEC);
> + return ULONG_MAX;
> + }
> +
> Â /* Set the Gate high, disable speaker */
> Â outb((inb(0x61) & ~0x02) | 0x01, 0x61);
> Â
> @@ -487,6 +497,9 @@ static unsigned long quick_pit_calibrate(void)
> Â u64 tsc, delta;
> Â unsigned long d1, d2;
> Â
> + if (!has_legacy_pic())
> + return 0;
> +
> Â /* Set the Gate high, disable speaker */
> Â outb((inb(0x61) & ~0x02) | 0x01, 0x61);
> Â