From: Andrew Morton Reimplement fix-cpu-frequency-detection-in-arch-i386-kernel-timers-timer_tsccrecalibrate_cpu_khz.patch on top of John's reworked timer code. Cc: Larry Finger Cc: Bruno Ducrot Cc: john stultz Signed-off-by: Andrew Morton --- arch/i386/kernel/tsc.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff -puN arch/i386/kernel/tsc.c~time-fix-cpu-frequency-detection arch/i386/kernel/tsc.c --- devel/arch/i386/kernel/tsc.c~time-fix-cpu-frequency-detection 2006-02-21 13:35:14.000000000 -0800 +++ devel-akpm/arch/i386/kernel/tsc.c 2006-02-21 13:35:14.000000000 -0800 @@ -130,6 +130,9 @@ static unsigned long calculate_cpu_khz(v unsigned long count; u64 delta64; int i; + unsigned long flags; + + local_irq_save(flags); /* run 3 times to ensure the cache is warm */ for (i = 0; i < 3; i++) { @@ -145,22 +148,26 @@ static unsigned long calculate_cpu_khz(v * 32 bits.. */ if (count <= 1) - return 0; + goto err; delta64 = end - start; /* cpu freq too fast: */ if (delta64 > (1ULL<<32)) - return 0; + goto err; /* cpu freq too slow: */ if (delta64 <= CALIBRATE_TIME_MSEC) - return 0; + goto err; delta64 += CALIBRATE_TIME_MSEC/2; /* round for do_div */ do_div(delta64,CALIBRATE_TIME_MSEC); + local_irq_restore(flags); return (unsigned long)delta64; +err: + local_irq_restore(flags); + return 0; } int recalibrate_cpu_khz(void) _