Skip to contentSkip to conversation

cpufreq/linux/arch/i386/kernel/cpufreq powernow-k7.c,1.44,1.45

PATCH Ducrot Bruno 1 participant 1 message Sep 19, 2003

lore
Share & tools
lore
#0 lore raw

Update of /mnt/src/cvsroot/cpufreq/linux/arch/i386/kernel/cpufreq In directory flint:/tmp/cvs-serv13924/linux/arch/i386/kernel/cpufreq

Modified Files:
powernow-k7.c
Log Message:
Bug fix from current bk:
* update davej email.
* Add missing config.h includes
* Read MSRs before trying to use them in powernow-k7
* We need to set SGTC when we change powernow-k7 voltage.
* Work around buggy powernow-k7 BIOSes with low settling times.
* Powernow-k7 latency timer needs to be in values of 10ns.
* Explicitly disable scaling we don't need in powernow-k7

Index: powernow-k7.c
===================================================================
RCS file: /mnt/src/cvsroot/cpufreq/linux/arch/i386/kernel/cpufreq/powernow-k7.c,v retrieving revision 1.44
retrieving revision 1.45

powernow-k7.c +15 -2
diff -u -r1.44 -r1.45
@@ -1,6 +1,7 @@
 /*
  *  AMD K7 Powernow driver.
  *  (C) 2003 Dave Jones <[email protected]> on behalf of SuSE Labs.
+ *  (C) 2003 Dave Jones <[email protected]>
  *
  *  Licensed under the terms of the GNU GPL License version 2.
  *  Based upon datasheets & sample CPUs kindly provided by AMD.
@@ -13,6 +14,7 @@
  * - We disable half multipliers if ACPI is used on A0 stepping CPUs.
  */
 
+#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h> 
 #include <linux/init.h>
@@ -190,10 +192,11 @@
 {
 	union msr_fidvidctl fidvidctl;
 
+	rdmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
 	if (fidvidctl.bits.FID != fid) {
-		rdmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
 		fidvidctl.bits.SGTC = latency;
 		fidvidctl.bits.FID = fid;
+		fidvidctl.bits.VIDC = 0;
 		fidvidctl.bits.FIDC = 1;
 		wrmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
 	}
@@ -204,9 +207,11 @@
 {
 	union msr_fidvidctl fidvidctl;
 
+	rdmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
 	if (fidvidctl.bits.VID != vid) {
-		rdmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
+		fidvidctl.bits.SGTC = latency;
 		fidvidctl.bits.VID = vid;
+		fidvidctl.bits.FIDC = 0;
 		fidvidctl.bits.VIDC = 1;
 		wrmsrl (MSR_K7_FID_VID_CTL, fidvidctl.val);
 	}
@@ -296,8 +301,14 @@
 			dprintk (" voltage regulator)\n");
 
 			latency = psb->settlingtime;
+			if (latency < 100) {
+				printk (KERN_INFO PFX "BIOS set settling time to %d microseconds."
+						"Should be at least 100. Correcting.\n", latency);
+				latency = 100;
+			}
 			dprintk (KERN_INFO PFX "Settling Time: %d microseconds.\n", psb->settlingtime);
 			dprintk (KERN_INFO PFX "Has %d PST tables. (Only dumping ones relevant to this CPU).\n", psb->numpst);
+			latency *= 100;	/* SGTC needs to be in units of 10ns */
 
 			p += sizeof (struct psb_s);
 
@@ -325,6 +336,8 @@
 						p+=2;
 				}
 			}
+			printk (KERN_INFO PFX "No PST tables match this cpuid (0x%x)\n", etuple);
+			printk ("This is indicative of a broken BIOS. Email [email protected]\n");
 			return -EINVAL;
 		}
 		p++;