Messages in this thread Patch in this message | | | From | () | Subject | [PATCH] 2.6.14 - Fix for incorrect CPU speed determination in powernow for i386 | Date | Sat, 29 Oct 2005 02:57:06 +0000 |
| |
On an HP ze1115 notebook with a Mobile AMD K7, the CPU speed is measured twice, once when the CPU is initialized, and a second time when the powerrnow system is started. Sometimes the two readings agree; however, the second reading is usually higher, sometimes by very large factors. The dmesg excerpts below show one case where the difference is small.
Initializing CPU#0 PID hash table entries: 4096 (order: 12, 65536 bytes) Detected 1100.134 MHz process
powernow: PowerNOW! Technology present. Can scale: frequency and voltage. Detected 1148.044 MHz processor. powernow: SGTC: 10000 powernow: Minimum speed 521 MHz. Maximum speed 1148 MHz.
The cpu frequency on this machine is measured using calibrate_tsc, which calls mach_countup between rdtsc calls. When the second speed determination is made, interrupts have been enabled, which makes the loop counter value in mach_count to be too small and the cpu frequency to be too high.
The two-line patch against 2.6.14 is shown below. With it, a second (faulty) determination of cpu_khz is avoided. BTW, this fix handles Bugzilla bugs #5266 and 5435.
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c @@ -78,7 +78,7 @@ u64 jiffies_64 = INITIAL_JIFFIES;
EXPORT_SYMBOL(jiffies_64);
-unsigned int cpu_khz; /* Detected as we calibrate the TSC */ +unsigned int cpu_khz=0; /* Detected as we calibrate the TSC */ EXPORT_SYMBOL(cpu_khz);
extern unsigned long wall_jiffies; diff --git a/arch/i386/kernel/timers/common.c b/arch/i386/kernel/timers/common.c --- a/arch/i386/kernel/timers/common.c +++ b/arch/i386/kernel/timers/common.c @@ -151,7 +151,7 @@ unsigned long read_timer_tsc(void) /* calculate cpu_khz */ void init_cpu_khz(void) { - if (cpu_has_tsc) { + if (cpu_has_tsc && !cpu_khz) { unsigned long tsc_quotient = calibrate_tsc(); if (tsc_quotient) { /* report CPU clock rate in Hz. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |