2004-01-31 20:35:28

by Tony Lindgren

[permalink] [raw]
Subject: [PATCH] powernow-k8 max speed sanity check

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.1550 -> 1.1551
# arch/i386/kernel/cpu/cpufreq/powernow-k8.c 1.9 -> 1.10
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 04/01/31 [email protected] 1.1551
# Sanity check on the BIOS provided max speed vs. current speed
#
# - Moves the current speed detection a bit earlier
# - Overrides the max speed and voltage if current running values are
# greater than BIOS provided values
# - Ignores incorrect BIOS numpst value as it is not used anyways
# --------------------------------------------
#
diff -Nru a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c Sat Jan 31 12:21:04 2004
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c Sat Jan 31 12:21:05 2004
@@ -539,6 +539,34 @@
return 1;
}

+/* Use current frequency if greater than BIOS value. */
+static inline int
+fid_check_max(int cur, int max)
+{
+ if (max < cur) {
+ printk(KERN_WARNING BFX "max speed fid listed as 0x%02x, "
+ "should be at least 0x%02x. Using current speed.\n",
+ max, cur);
+ return cur;
+ }
+
+ return max;
+}
+
+/* Use current voltage if greater than BIOS value. */
+static inline int
+vid_check_max(int cur, int max)
+{
+ if (max < cur) {
+ printk(KERN_WARNING BFX "max voltage vid listed as 0x%02x, "
+ "should be at least 0x%02x. Using current speed.\n",
+ max, cur);
+ return cur;
+ }
+
+ return max;
+}
+
/* Find and validate the PSB/PST table in BIOS. */
static inline int
find_psb_table(void)
@@ -603,8 +631,8 @@

dprintk(KERN_DEBUG PFX "numpst: 0x%x\n", psb->numpst);
if (psb->numpst != 1) {
- printk(KERN_ERR BFX "numpst must be 1\n");
- return -ENODEV;
+ printk(KERN_WARNING BFX "numpst listed as %i "
+ "should be 1. Using 1.\n", psb->numpst);
}

dprintk(KERN_DEBUG PFX "cpuid: 0x%x\n", psb->cpuid);
@@ -668,6 +696,15 @@
return -ENODEV;
}

+ if (query_current_values_with_pending_wait()) {
+ kfree(ppst);
+ return -EIO;
+ }
+
+ /* Do a sanity check on the max values vs. current values */
+ ppst[numps-1].fid = fid_check_max(currfid, ppst[numps-1].fid);
+ ppst[numps-1].vid = vid_check_max(currvid, ppst[numps-1].vid);
+
for (j = 1; j < numps; j++) {
if ((lastfid >= ppst[j].fid)
|| (ppst[j].fid & 1)
@@ -696,11 +733,6 @@
kfree(ppst);
return -ENODEV;
}
- }
-
- if (query_current_values_with_pending_wait()) {
- kfree(ppst);
- return -EIO;
}

printk(KERN_INFO PFX "currfid 0x%x, currvid 0x%x\n",


Attachments:
(No filename) (1.40 kB)
patch-2.6.2-pre3-powernow-k8-max-speed-check (2.74 kB)
Download all attachments

2004-01-31 23:21:41

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] powernow-k8 max speed sanity check

On Sat, Jan 31, 2004 at 12:35:12PM -0800, Tony Lindgren wrote:
> Hi all,
>
> Following is a little patch to do a sanity check on the max speed and
> voltage values provided by the bios.
>
> Some buggy bioses provide bad values if the cpu changes, for example, in
> my case the bios claims the max cpu speed is 1600MHz, while it's running at
> 1800MHz. (Cheapo Emachines m6805 you know...) This could also happen on
> machines where the cpu is upgraded.
>
> These checks should be safe, as they only change things if the machine is
> already running at a higher speed than the bios claims.

ye gads, yet another problem with eMachines PST tables.
Conclusive proof I think that we need the 'read from ACPI P state tables
when PST contains garbage' patch.

Dave