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
......@@ -47,10 +47,15 @@ static void __init longrun_get_policy(struct cpufreq_policy *policy)
msr_lo &= 0x0000007F;
msr_hi &= 0x0000007F;
if ( longrun_high_freq <= longrun_low_freq ) {
/* Assume degenerate Longrun table */
policy->min = policy->max = longrun_high_freq;
} 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;
}
......@@ -70,10 +75,15 @@ static int longrun_set_policy(struct cpufreq_policy *policy)
if (!policy)
return -EINVAL;
if ( longrun_high_freq <= longrun_low_freq ) {
/* Assume degenerate Longrun table */
pctg_lo = pctg_hi = 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)
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