Skip to content

Commit

Permalink
i386: HPET, check if the counter works
Browse files Browse the repository at this point in the history
Some systems have a HPET which is not incrementing, which leads to a
complete hang.  Detect it during HPET setup.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: john stultz <johnstul@us.ibm.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Thomas Gleixner authored and Linus Torvalds committed Jul 22, 2007
1 parent df2edcf commit 075bcd1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion arch/i386/kernel/hpet.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ int __init hpet_enable(void)
{
unsigned long id;
uint64_t hpet_freq;
u64 tmp;
u64 tmp, start, now;
cycle_t t1;

if (!is_hpet_capable())
return 0;
Expand Down Expand Up @@ -279,6 +280,27 @@ int __init hpet_enable(void)
/* Start the counter */
hpet_start_counter();

/* Verify whether hpet counter works */
t1 = read_hpet();
rdtscll(start);

/*
* We don't know the TSC frequency yet, but waiting for
* 200000 TSC cycles is safe:
* 4 GHz == 50us
* 1 GHz == 200us
*/
do {
rep_nop();
rdtscll(now);
} while ((now - start) < 200000UL);

if (t1 == read_hpet()) {
printk(KERN_WARNING
"HPET counter not counting. HPET disabled\n");
goto out_nohpet;
}

/* Initialize and register HPET clocksource
*
* hpet period is in femto seconds per cycle
Expand Down

0 comments on commit 075bcd1

Please sign in to comment.