cpufreq: fix powernow-k7 smp kernel driver on up machines
PATCH 1/1 cpufreq: fix powernow-k7 smp kernel driver on up machines
From: Thomas Meyer <[email protected]>
This patch fixes the powernow-k7 cpufreq driver smp kernel on an up machine.
---
This patch is against branch v2.6.16-rc4. Please give me positive and/or negativ feedback about this fixing approach!
With kind regads
Thomas
(quoted diff) +0 -0
b/arch/i386/kernel/cpu/common.c
index 7eb9213..67fcee6 100644
arch/i386/kernel/cpu/common.c +1 -0
@@ -336,6 +336,7 @@ void __devinit identify_cpu(struct cpuinint i; c->loops_per_jiffy = loops_per_jiffy; + c->cpu_khz = cpu_khz; c->x86_cache_size =-1 ; c->x86_vendor =X86_VENDOR_UNKNOWN ; c->cpuid_level =-1 ;/* CPUID not detected */
(quoted diff) +0 -0
b/arch/i386/kernel/cpu/cpufreq/powernow-k7.c
index edcd626..2125026 100644
arch/i386/kernel/cpu/cpufreq/powernow-k7.c +1 -1
@@ -586,7 +586,7 @@ static int __init powernow_cpu_init (strif (result)return result; - fsb = (10 * cpu_khz) / fid_codes[fidvidstatus.bits.CFID]; + fsb = (10 * current_cpu_data.cpu_khz) /
fid_codes[fidvidstatus.bits.CFID];
if (!fsb) {
printk(KERN_WARNING PFX "can not determine bus frequency\n"); return -EINVAL;
arch/i386/kernel/smpboot.c +0 -0
(quoted diff) +0 -0
b/arch/i386/kernel/timers/common.c
index 8163fe0..760add2 100644
arch/i386/kernel/timers/common.c +1 -1
@@ -148,7 +148,9 @@ unsigned long read_timer_tsc(void) } -/* calculate cpu_khz */ +/* calculate cpu_khz for boot_cpu only, because timer_init ->
select_timer
+ * calls init_cpu_khz, before boot_cpu_data is transfered to cpu_data[x]
+ */
void init_cpu_khz(void)
{
if (cpu_has_tsc) {
@@ -170,3 +172,26 @@ void init_cpu_khz(void)
}
}
+void init_cpu_khz_smp(void)
+{
+ if (cpu_has(&(current_cpu_data), X86_FEATURE_TSC)) {
+ unsigned long tsc_quotient = calibrate_tsc();
+
+ if (tsc_quotient) {
+ /* report CPU clock rate in Hz.
+ * The formula is (10^6 * 2^32) / (2^32 * 1 / (clocks/us)) =
+ * clock/second. Our precision is about 100 ppm.
+ */
+ { unsigned long eax=0, edx=1000;
+ __asm__("divl %2"
+ :"=a" (current_cpu_data.cpu_khz), "=d" (edx)
+ :"r" (tsc_quotient),
+ "0" (eax), "1" (edx));
+ printk("Detected %u.%03u MHz processor.\n",
+ current_cpu_data.cpu_khz / 1000,
+ current_cpu_data.cpu_khz % 1000);
+ }
+ }
+ }
+}
+
(quoted diff) +0 -0
b/arch/i386/kernel/timers/timer_tsc.c
index a7f5a2a..0a3e29e 100644
arch/i386/kernel/timers/timer_tsc.c +7 -10
@@ -341,23 +341,20 @@ static inline void cpufreq_delayed_get(vint recalibrate_cpu_khz (void ) { -#ifndef CONFIG_SMP -unsigned int cpu_khz_old = cpu_khz; +unsigned int cpu_khz_old = current_cpu_data.cpu_khz; -if (cpu_has_tsc) { +if (cpu_has (&(current_cpu_data),X86_FEATURE_TSC )) {local_irq_disable (); -init_cpu_khz (); +init_cpu_khz_smp ();local_irq_enable (); - cpu_data[0 ].loops_per_jiffy = -cpufreq_scale (cpu_data[0 ].loops_per_jiffy, + current_cpu_data.loops_per_jiffy = +cpufreq_scale (current_cpu_data.loops_per_jiffy, cpu_khz_old, - cpu_khz); + current_cpu_data.cpu_khz);return 0 ; }else return -ENODEV ; -#else -return -ENODEV ; -#endif + }EXPORT_SYMBOL (recalibrate_cpu_khz);
include/asm-i386/processor.h +1 -0
@@ -67,6 +67,7 @@ struct cpuinfo_x86 {char pad0;int x86_power;unsigned long loops_per_jiffy; +unsigned int cpu_khz;unsigned char x86_max_cores;/* cpuid returned max cores value */ unsigned char booted_cores;/* number of cores as seen by OS */ unsigned char apicid;
include/asm-i386/timer.h +1 -0
@@ -58,6 +58,7 @@ extern struct init_timer_opts timer_cyclextern unsigned long calibrate_tsc (void );extern unsigned long read_timer_tsc (void );extern void init_cpu_khz (void ); +extern void init_cpu_khz_smp (void );extern int recalibrate_cpu_khz (void );#ifdef CONFIG_HPET_TIMER extern struct init_timer_opts timer_hpet_init;
Quoted 3 lines · Thomas Meyer
This patch fixes the powernow-k7 cpufreq driver smp kernel on an up
machine.
- It was wordwrapped.
- Your description doesn't describe what is being fixed, nor how it was fixed.
- That open-coded assembly-language divide should probably be converted to div64(). If that's not possible we'd need to see a description of why.
- Please cc [email protected] on the next submission.