Skip to content

Commit

Permalink
failsafe mechanism to HPET clock calibration
Browse files Browse the repository at this point in the history
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
2f7a2a7, but looks like the hpet split
from time.c lost it again.

This reintroduces the failsafe mechanism

Signed-off-by: Ravikiran Thirumalai <kiran@scalex86.org>
Signed-off-by: Shai Fultheim <shai@scalex86.org>
Cc: Jack Steiner <steiner@sgi.com>
Cc: john stultz <johnstul@us.ibm.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Ravikiran G Thirumalai authored and Linus Torvalds committed Apr 15, 2007
1 parent ff99e40 commit c9c5792
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/x86_64/kernel/hpet.c
Expand Up @@ -191,20 +191,23 @@ 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
* occurs between the reads of the hpet & TSC.
*/
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)
break;
}
*hpet = hpet1;
*tsc = tsc2;
}
Expand Down

0 comments on commit c9c5792

Please sign in to comment.