Commit 2798b95d authored by Dave Jones's avatar Dave Jones

[CPUFREQ] Fix longhaul's mult,fsb -> MHz conversions.

this was wrong in several places by a factor of 100.
Introduce a calc_speed helper to make this harder to get wrong.
Additionally, clean up some printk's to print out useful values
like MinMult=3.5x instead of MinMult(x10)=35.
parent a69aa156
...@@ -254,6 +254,12 @@ static int longhaul_version; ...@@ -254,6 +254,12 @@ static int longhaul_version;
static struct cpufreq_frequency_table *longhaul_table; static struct cpufreq_frequency_table *longhaul_table;
static unsigned int calc_speed (int mult, int fsb)
{
return ((mult/10)*fsb) + ((mult%10)*(fsb/2));
}
static unsigned int longhaul_get_cpu_fsb (void) static unsigned int longhaul_get_cpu_fsb (void)
{ {
unsigned long lo, hi; unsigned long lo, hi;
...@@ -292,7 +298,7 @@ static int longhaul_get_cpu_mult (void) ...@@ -292,7 +298,7 @@ static int longhaul_get_cpu_mult (void)
static void longhaul_setstate (unsigned int clock_ratio_index) static void longhaul_setstate (unsigned int clock_ratio_index)
{ {
int vidindex, i; int vidindex, i, speed, mult;
struct cpufreq_freqs freqs; struct cpufreq_freqs freqs;
union msr_longhaul longhaul; union msr_longhaul longhaul;
union msr_bcr2 bcr2; union msr_bcr2 bcr2;
...@@ -300,18 +306,19 @@ static void longhaul_setstate (unsigned int clock_ratio_index) ...@@ -300,18 +306,19 @@ static void longhaul_setstate (unsigned int clock_ratio_index)
if (clock_ratio[clock_ratio_index] == -1) if (clock_ratio[clock_ratio_index] == -1)
return; return;
if (((clock_ratio[clock_ratio_index] * fsb * 100) > highest_speed) || mult = clock_ratio[clock_ratio_index];
((clock_ratio[clock_ratio_index] * fsb * 100) < lowest_speed)) speed = calc_speed (mult, fsb);
if ((speed > highest_speed) || (speed < lowest_speed))
return; return;
freqs.old = longhaul_get_cpu_mult() * longhaul_get_cpu_fsb() * 100; freqs.old = calc_speed (longhaul_get_cpu_mult(), fsb);
freqs.new = clock_ratio[clock_ratio_index] * fsb * 100; freqs.new = speed;
freqs.cpu = 0; /* longhaul.c is UP only driver */ freqs.cpu = 0; /* longhaul.c is UP only driver */
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
dprintk (KERN_INFO PFX "FSB:%d Mult(x10):%d\n", dprintk (KERN_INFO PFX "FSB:%d Mult:%d.%dx\n", fsb,
fsb * 100, clock_ratio[clock_ratio_index]); mult/10, mult%10);
switch (longhaul_version) { switch (longhaul_version) {
case 1: case 1:
...@@ -432,11 +439,11 @@ static int __init longhaul_get_ranges (void) ...@@ -432,11 +439,11 @@ static int __init longhaul_get_ranges (void)
break; break;
} }
highest_speed = maxmult * fsb * 100; dprintk (KERN_INFO PFX "MinMult=%d.%dx MaxMult=%d.%dx\n",
lowest_speed = minmult * fsb * 100; minmult/10, minmult%10, maxmult/10, maxmult%10);
dprintk (KERN_INFO PFX "MinMult(x10)=%d MaxMult(x10)=%d\n", highest_speed = calc_speed (maxmult, fsb);
minmult, maxmult); lowest_speed = calc_speed (minmult,fsb);
dprintk (KERN_INFO PFX "Lowestspeed=%d Highestspeed=%d\n", dprintk (KERN_INFO PFX "Lowestspeed=%dMHz Highestspeed=%dMHz\n",
lowest_speed, highest_speed); lowest_speed, highest_speed);
longhaul_table = kmalloc((numscales + 1) * sizeof(struct cpufreq_frequency_table), GFP_KERNEL); longhaul_table = kmalloc((numscales + 1) * sizeof(struct cpufreq_frequency_table), GFP_KERNEL);
...@@ -448,7 +455,7 @@ static int __init longhaul_get_ranges (void) ...@@ -448,7 +455,7 @@ static int __init longhaul_get_ranges (void)
continue; continue;
if (((unsigned int)clock_ratio[j] > maxmult) || ((unsigned int)clock_ratio[j] < minmult)) if (((unsigned int)clock_ratio[j] > maxmult) || ((unsigned int)clock_ratio[j] < minmult))
continue; continue;
longhaul_table[k].frequency= clock_ratio[j] * fsb * 100; longhaul_table[k].frequency = calc_speed (clock_ratio[j], fsb);
longhaul_table[k].index = (j << 8); longhaul_table[k].index = (j << 8);
k++; k++;
} }
...@@ -588,8 +595,7 @@ static int longhaul_cpu_init (struct cpufreq_policy *policy) ...@@ -588,8 +595,7 @@ static int longhaul_cpu_init (struct cpufreq_policy *policy)
policy->governor = CPUFREQ_DEFAULT_GOVERNOR; policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = calc_speed (longhaul_get_cpu_mult(), fsb);
policy->cur = (unsigned int) (longhaul_get_cpu_fsb() * longhaul_get_cpu_mult() * 100);
return cpufreq_frequency_table_cpuinfo(policy, longhaul_table); return cpufreq_frequency_table_cpuinfo(policy, longhaul_table);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment