Commit c9c57929 authored by Ravikiran G Thirumalai's avatar Ravikiran G Thirumalai Committed by Linus Torvalds
Browse files

failsafe mechanism to HPET clock calibration

Provide a failsafe mechanism to avoid kernel spinning forever at
read_hpet_tsc during early kernel bootup.

This failsafe mechanism was originally introduced in commit

, but looks like the hpet split
from time.c lost it again.

This reintroduces the failsafe mechanism
Signed-off-by: default avatarRavikiran Thirumalai <>
Signed-off-by: default avatarShai Fultheim <>
Cc: Jack Steiner <>
Cc: john stultz <>
Cc: Andi Kleen <>
Signed-off-by: default avatarLinus Torvalds <>
parent ff99e402
......@@ -191,6 +191,7 @@ int hpet_reenable(void)
#define TICK_COUNT 100000000
#define TICK_MIN 5000
#define MAX_TRIES 5
* Some platforms take periodic SMI interrupts with 5ms duration. Make sure none
......@@ -198,13 +199,15 @@ int hpet_reenable(void)
static void __init read_hpet_tsc(int *hpet, int *tsc)
int tsc1, tsc2, hpet1;
int tsc1, tsc2, hpet1, i;
do {
for (i = 0; i < MAX_TRIES; i++) {
tsc1 = get_cycles_sync();
hpet1 = hpet_readl(HPET_COUNTER);
tsc2 = get_cycles_sync();
} while (tsc2 - tsc1 > TICK_MIN);
if (tsc2 - tsc1 > TICK_MIN)
*hpet = hpet1;
*tsc = tsc2;
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