All of lore.kernel.org
 help / color / mirror / Atom feed
* 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

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.