[CPUFREQ] Recalibrate cpu_khz [2/2] Some cpufreq drivers (at that time, only powernow-k7) need to recalibrate the cpu_khz at runtime. Signed-off-by: Bruno Ducrot Signed-off-by: Andrew Morton Signed-off-by: Dave Jones --- 25-akpm/arch/i386/kernel/timers/common.c | 6 ++++-- 25-akpm/arch/i386/kernel/timers/timer_tsc.c | 20 ++++++++++++++++++++ 25-akpm/include/asm-i386/timer.h | 1 + 3 files changed, 25 insertions(+), 2 deletions(-) diff -puN arch/i386/kernel/timers/common.c~cpufreq-timers-recalibrate_cpu_khz arch/i386/kernel/timers/common.c --- 25/arch/i386/kernel/timers/common.c~cpufreq-timers-recalibrate_cpu_khz Wed Mar 30 13:17:44 2005 +++ 25-akpm/arch/i386/kernel/timers/common.c Wed Mar 30 13:17:44 2005 @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -24,7 +25,7 @@ #define CALIBRATE_TIME (5 * 1000020/HZ) -unsigned long __init calibrate_tsc(void) +unsigned long calibrate_tsc(void) { mach_prepare_counter(); @@ -139,7 +140,7 @@ bad_calibration: #endif /* calculate cpu_khz */ -void __init init_cpu_khz(void) +void init_cpu_khz(void) { if (cpu_has_tsc) { unsigned long tsc_quotient = calibrate_tsc(); @@ -158,3 +159,4 @@ void __init init_cpu_khz(void) } } } + diff -puN arch/i386/kernel/timers/timer_tsc.c~cpufreq-timers-recalibrate_cpu_khz arch/i386/kernel/timers/timer_tsc.c --- 25/arch/i386/kernel/timers/timer_tsc.c~cpufreq-timers-recalibrate_cpu_khz Wed Mar 30 13:17:44 2005 +++ 25-akpm/arch/i386/kernel/timers/timer_tsc.c Wed Mar 30 13:17:44 2005 @@ -320,6 +320,26 @@ core_initcall(cpufreq_tsc); static inline void cpufreq_delayed_get(void) { return; } #endif +int recalibrate_cpu_khz(void) +{ +#ifndef CONFIG_SMP + unsigned long cpu_khz_old = cpu_khz; + + if (cpu_has_tsc) { + init_cpu_khz(); + cpu_data[0].loops_per_jiffy = + cpufreq_scale(cpu_data[0].loops_per_jiffy, + cpu_khz_old, + cpu_khz); + return 0; + } else + return -ENODEV; +#else + return -ENODEV; +#endif +} +EXPORT_SYMBOL(recalibrate_cpu_khz); + static void mark_offset_tsc(void) { unsigned long lost,delay; diff -puN include/asm-i386/timer.h~cpufreq-timers-recalibrate_cpu_khz include/asm-i386/timer.h --- 25/include/asm-i386/timer.h~cpufreq-timers-recalibrate_cpu_khz Wed Mar 30 13:17:44 2005 +++ 25-akpm/include/asm-i386/timer.h Wed Mar 30 13:17:44 2005 @@ -53,6 +53,7 @@ extern struct init_timer_opts timer_cycl extern unsigned long calibrate_tsc(void); extern void init_cpu_khz(void); +extern int recalibrate_cpu_khz(void); #ifdef CONFIG_HPET_TIMER extern struct init_timer_opts timer_hpet_init; extern unsigned long calibrate_tsc_hpet(unsigned long *tsc_hpet_quotient_ptr); _