Commit 8180a550 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Linus Torvalds

x86_64: hpet tsc calibration fix broken smi detection logic

The current SMI detection logic in read_hpet_tsc() makes sure,
that when a SMI happens between the read of the HPET counter and
the read of the TSC, this wrong value is used for TSC calibration.

This is not the intention of the function. The comparison must ensure,
that we do _NOT_ use such a value.

Fix the check to use calibration values where delta of the two TSC reads
is smaller than a reasonable threshold.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarChris Wright <chrisw@sous-sol.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e82f64e5
...@@ -190,7 +190,7 @@ int hpet_reenable(void) ...@@ -190,7 +190,7 @@ int hpet_reenable(void)
*/ */
#define TICK_COUNT 100000000 #define TICK_COUNT 100000000
#define TICK_MIN 5000 #define SMI_THRESHOLD 50000
#define MAX_TRIES 5 #define MAX_TRIES 5
/* /*
...@@ -205,7 +205,7 @@ static void __init read_hpet_tsc(int *hpet, int *tsc) ...@@ -205,7 +205,7 @@ static void __init read_hpet_tsc(int *hpet, int *tsc)
tsc1 = get_cycles_sync(); tsc1 = get_cycles_sync();
hpet1 = hpet_readl(HPET_COUNTER); hpet1 = hpet_readl(HPET_COUNTER);
tsc2 = get_cycles_sync(); tsc2 = get_cycles_sync();
if (tsc2 - tsc1 > TICK_MIN) if ((tsc2 - tsc1) < SMI_THRESHOLD)
break; break;
} }
*hpet = hpet1; *hpet = hpet1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment