Commit a7615aeb authored by Dave Jones's avatar Dave Jones Committed by Dave Jones

[CPUFREQ] Fix for longrun.c for degenerate case

From H. Peter Anvin

I ran into a system the other day which had a Transmeta processor, but
configured in a degenerate, fixed-frequency configuration.  It crashed
booting Fedora Core 2 test 3 due to a division by zero in the longrun
cpufreq driver.
parent 06393d0f
...@@ -46,11 +46,16 @@ static void __init longrun_get_policy(struct cpufreq_policy *policy) ...@@ -46,11 +46,16 @@ static void __init longrun_get_policy(struct cpufreq_policy *policy)
rdmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi); rdmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi);
msr_lo &= 0x0000007F; msr_lo &= 0x0000007F;
msr_hi &= 0x0000007F; msr_hi &= 0x0000007F;
policy->min = longrun_low_freq + msr_lo * if ( longrun_high_freq <= longrun_low_freq ) {
((longrun_high_freq - longrun_low_freq) / 100); /* Assume degenerate Longrun table */
policy->max = longrun_low_freq + msr_hi * policy->min = policy->max = longrun_high_freq;
((longrun_high_freq - longrun_low_freq) / 100); } else {
policy->min = longrun_low_freq + msr_lo *
((longrun_high_freq - longrun_low_freq) / 100);
policy->max = longrun_low_freq + msr_hi *
((longrun_high_freq - longrun_low_freq) / 100);
}
policy->cpu = 0; policy->cpu = 0;
} }
...@@ -70,10 +75,15 @@ static int longrun_set_policy(struct cpufreq_policy *policy) ...@@ -70,10 +75,15 @@ static int longrun_set_policy(struct cpufreq_policy *policy)
if (!policy) if (!policy)
return -EINVAL; return -EINVAL;
pctg_lo = (policy->min - longrun_low_freq) / if ( longrun_high_freq <= longrun_low_freq ) {
((longrun_high_freq - longrun_low_freq) / 100); /* Assume degenerate Longrun table */
pctg_hi = (policy->max - longrun_low_freq) / pctg_lo = pctg_hi = 100;
((longrun_high_freq - longrun_low_freq) / 100); } else {
pctg_lo = (policy->min - longrun_low_freq) /
((longrun_high_freq - longrun_low_freq) / 100);
pctg_hi = (policy->max - longrun_low_freq) /
((longrun_high_freq - longrun_low_freq) / 100);
}
if (pctg_hi > 100) if (pctg_hi > 100)
pctg_hi = 100; pctg_hi = 100;
......
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