* Fix for longrun.c for degenerate case
@ 2004-05-08 2:06 H. Peter Anvin
2004-05-09 14:16 ` Dominik Brodowski
0 siblings, 1 reply; 2+ messages in thread
From: H. Peter Anvin @ 2004-05-08 2:06 UTC (permalink / raw)
To: cpufreq, davej, linux
[-- Attachment #1: Type: text/plain, Size: 279 bytes --]
Hi all,
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. The attached patch fixes this.
-hpa
[-- Attachment #2: linux-2.6.5-longrun.patch --]
[-- Type: text/plain, Size: 1740 bytes --]
Index: linux-2.5/arch/i386/kernel/cpu/cpufreq/longrun.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/arch/i386/kernel/cpu/cpufreq/longrun.c,v
retrieving revision 1.19
diff -u -r1.19 longrun.c
--- linux-2.5/arch/i386/kernel/cpu/cpufreq/longrun.c 13 Apr 2004 15:52:00 -0000 1.19
+++ linux-2.5/arch/i386/kernel/cpu/cpufreq/longrun.c 6 May 2004 05:32:50 -0000
@@ -46,11 +46,16 @@
rdmsr(MSR_TMTA_LONGRUN_CTRL, msr_lo, msr_hi);
msr_lo &= 0x0000007F;
msr_hi &= 0x0000007F;
-
- 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);
+
+ 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 @@
if (!policy)
return -EINVAL;
- 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 ( 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;
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
_______________________________________________
Cpufreq mailing list
Cpufreq@www.linux.org.uk
http://www.linux.org.uk/mailman/listinfo/cpufreq
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fix for longrun.c for degenerate case
2004-05-08 2:06 Fix for longrun.c for degenerate case H. Peter Anvin
@ 2004-05-09 14:16 ` Dominik Brodowski
0 siblings, 0 replies; 2+ messages in thread
From: Dominik Brodowski @ 2004-05-09 14:16 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: davej, cpufreq
On Fri, May 07, 2004 at 07:06:49PM -0700, H. Peter Anvin wrote:
> Hi all,
>
> 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. The attached patch fixes this.
Thanks. I'd suggest that driver initialization should fail instead --
there's no reason to keep the cpufreq infrastructure up and running if
nothing at all can be done, e.g. the frequency is fixed. The attached patch
(untested due to lack of hardware) should do right that. Dave, please decide
which patch you prefer, and merge accordingly.
Thanks,
Dominik
diff -ruN linux-original/arch/i386/kernel/cpu/cpufreq/longrun.c linux/arch/i386/kernel/cpu/cpufreq/longrun.c
--- linux-original/arch/i386/kernel/cpu/cpufreq/longrun.c 2004-04-28 22:07:55.000000000 +0200
+++ linux/arch/i386/kernel/cpu/cpufreq/longrun.c 2004-05-09 16:13:49.272043792 +0200
@@ -239,6 +239,9 @@
if (result)
return result;
+ if (longrun_high_freq <= longrun_low_freq)
+ return -ENODEV; /* degenerate Longrun table */
+
/* cpuinfo and default policy values */
policy->cpuinfo.min_freq = longrun_low_freq;
policy->cpuinfo.max_freq = longrun_high_freq;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-05-09 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-08 2:06 Fix for longrun.c for degenerate case H. Peter Anvin
2004-05-09 14:16 ` Dominik Brodowski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.