From: "H. Peter Anvin" <hpa@zytor.com>
To: cpufreq@www.linux.org.uk, davej@codemonkey.org.uk, linux@brodo.de
Subject: Fix for longrun.c for degenerate case
Date: Fri, 07 May 2004 19:06:49 -0700 [thread overview]
Message-ID: <409C40B9.6000603@zytor.com> (raw)
[-- 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
next reply other threads:[~2004-05-08 2:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-08 2:06 H. Peter Anvin [this message]
2004-05-09 14:16 ` Fix for longrun.c for degenerate case Dominik Brodowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=409C40B9.6000603@zytor.com \
--to=hpa@zytor.com \
--cc=cpufreq@www.linux.org.uk \
--cc=davej@codemonkey.org.uk \
--cc=linux@brodo.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox