Powernow-k8 buggy BIOS override for 2.6.6
PATCH 1/1 Powernow-k8 buggy BIOS override for 2.6.6
Hi,
Following is the updated patch to make the powernow-k8 driver work on machines with buggy BIOS, such as emachines m6805.
The patch overrides the PST table only if check_pst_table() fails.
The minimum value for the override is 800MHz, which is the lowest value on all x86_64 systems AFAIK. The max value is the current running value.
This patch should be safe to apply, even if Pavel's ACPI table check is added to the driver. Or does anybody see a problem with it?
Regards,
Tony
Amd64 cpufreq driver patch to override a buggy BIOS table with current running speed as max value, and 800MHz as the low value. Allows the driver to work on buggy BIOSes, such as m680x laptops.
This patch contains updates to the following files:
b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +43 -13
@@ -42,6 +42,8 @@#define VERSION "version 1.00.08b"#include "powernow-k8.h" +#define MAX_NR_PST 16 +/* serialize freq changes */ static DECLARE_MUTEX (fidvid_sem);
@@ -482,6 +484,23 @@ } +/* +* This is the place to override the buggy BIOS values +*/ +static int override_pst_table (struct powernow_k8_data *data,struct pst_s *pst) { + printk(KERN_INFO PFX "BIOS error: overriding frequency table\n"); + +/* Use a safe minimum speed 800MHz */ + pst[0 ].fid =0x00 ; + pst[0 ].vid =0x12 ; + +/* Use current speed as the maximum speed */ + pst[1 ].fid = data->currfid; + pst[1 ].vid = data->currvid; + +return 2 ; +} +static int check_pst_table (struct powernow_k8_data *data,struct pst_s *pst,u8 maxvid) {unsigned int j;
@@ -538,6 +557,7 @@ {struct cpufreq_frequency_table *powernow_table;unsigned int j; +struct pst_s *pst_tmp;if (data->batps) {/* use ACPI support to get full speed on mains power */ printk(KERN_WARNING PFX "Only %d pstates usable (use ACPI driver for full range\n", data->batps);
@@ -555,39 +575,49 @@ printk(KERN_ERR PFX "no p states to transition\n");return -ENODEV ; } - + +/* Must have the current values early in case of override_pst_table() */ +if (query_current_values_with_pending_wait (data)) +return -EIO ; + +/* Copy the BIOS table into a temporary table in case it needs override */ + pst_tmp =kmalloc (sizeof (struct pst_s ) *MAX_NR_PST ,GFP_KERNEL ); +if (!pst_tmp) { + printk(KERN_ERR PFX "pst_tmp memory alloc failure\n"); +return -ENOMEM ; + } +memset (pst_tmp,0 ,sizeof (struct pst_s ) *MAX_NR_PST ); +memcpy (pst_tmp, pst,sizeof (struct pst_s ) * data->numps); +if (check_pst_table (data, pst, maxvid)) -return -EINVAL ; + data->numps =override_pst_table (data, pst_tmp); powernow_table =kmalloc ((sizeof (struct cpufreq_frequency_table ) * (data->numps +1 )),GFP_KERNEL );if (!powernow_table) { printk(KERN_ERR PFX "powernow_table memory alloc failure\n"); +kfree (pst_tmp);return -ENOMEM ; }for (j =0 ; j < data->numps; j++) { - powernow_table[j].index = pst[j].fid;/* lower 8 bits */ - powernow_table[j].index |= (pst[j].vid <<8 );/* upper 8 bits */ - powernow_table[j].frequency =find_khz_freq_from_fid (pst[j].fid); + powernow_table[j].index = pst_tmp[j].fid;/* lower 8 bits */ + powernow_table[j].index |= (pst_tmp[j].vid <<8 );/* upper 8 bits */ + powernow_table[j].frequency =find_khz_freq_from_fid (pst_tmp[j].fid); } powernow_table[data->numps].frequency =CPUFREQ_TABLE_END ; powernow_table[data->numps].index =0 ; -if (query_current_values_with_pending_wait (data)) { -kfree (powernow_table); -return -EIO ; - } - dprintk(KERN_INFO PFX "cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid); data->powernow_table = powernow_table;print_basics (data);for (j =0 ; j < data->numps; j++) -if ((pst[j].fid==data->currfid) && (pst[j].vid==data->currvid)) +if ((pst_tmp[j].fid==data->currfid) && (pst_tmp[j].vid==data->currvid))return 0 ; dprintk(KERN_ERR PFX "currfid/vid do not match PST, ignoring\n"); +kfree (pst_tmp);return 0 ; }
@@ -637,8 +667,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. Ignoring it.\n", psb->numpst); } data->plllock = psb->plllocktime;
Hi!
Quoted 10 lines
Following is the updated patch to make the powernow-k8 driver work on machines with buggy BIOS, such as emachines m6805.
The patch overrides the PST table only if
check_pst_table()fails.The minimum value for the override is 800MHz, which is the lowest value on all
x86_64systems AFAIK. The max value is the current running value.This patch should be safe to apply, even if Pavel's ACPI table check is added to the driver. Or does anybody see a problem with it?
Well, there may be problems with that.
BIOSen sometimes run cpu at too high voltage. Plus, for changing frequency you need to run at even higher voltage... and that may be too high.
Is there some problem with ACPI on your system?
Pavel
Signature · 2 lines
Horseback riding is like software... ...vgf orggre jura vgf serr.
Quoted 7 lines · Pavel Machek
Hi!
Quoted 5 lines
Following is the updated patch to make the powernow-k8 driver work on machines with buggy BIOS, such as emachines m6805.
The patch overrides the PST table only if
check_pst_table()fails.
Quoted 7 lines
Quoted 5 lines
The minimum value for the override is 800MHz, which is the lowest value on all
x86_64systems AFAIK. The max value is the current running value.This patch should be safe to apply, even if Pavel's ACPI table check is added to the driver. Or does anybody see a problem with it?
Well, there may be problems with that.
That works good now, see my recent posting to the thread on the cpufreq list for more details. I had ACPI processor as module, and that made the powernow-k8 ACPI detection to fail. I fixed it with the following little patch, attaching it here too for reference.
Quoted 5 lines
BIOSen sometimes run cpu at too high voltage. Plus, for changing frequency you need to run at even higher voltage... and that may be too high.
Is there some problem with ACPI on your system?
Works now, from cpufreq point of view. As of 2.6.6 the ACPI processor module hangs the system if compiled in. Loading it as module after init does not hang.
Regards,
Tony
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +2 -2
@@ -32,7 +32,7 @@#include <asm/io.h> #include <asm/delay.h> -#ifdef CONFIG_ACPI_PROCESSOR +#if defined(CONFIG_ACPI_PROCESSOR ) || defined(CONFIG_ACPI_PROCESSOR_MODULE )#include <linux/acpi.h> #include <acpi/processor.h> #endif
@@ -666,7 +696,7 @@return -ENODEV ; } -#ifdef CONFIG_ACPI_PROCESSOR +#if defined(CONFIG_ACPI_PROCESSOR ) || defined(CONFIG_ACPI_PROCESSOR_MODULE )static void powernow_k8_acpi_pst_values (struct powernow_k8_data *data,unsigned int index) {if (!data->acpi_data.state_count)
arch/i386/kernel/cpu/cpufreq/powernow-k8.h +1 -1
@@ -29,7 +29,7 @@* frequency is in kHz */ struct cpufreq_frequency_table *powernow_table; -#ifdef CONFIG_ACPI_PROCESSOR +#if defined(CONFIG_ACPI_PROCESSOR ) || defined(CONFIG_ACPI_PROCESSOR_MODULE )/* the acpi table needs to be kept. it's only available if ACPI was * used to determine valid frequency/vid/fid states */ struct acpi_processor_performance acpi_data;
Hi!
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Following is the updated patch to make the powernow-k8 driver work on machines with buggy BIOS, such as emachines m6805.
The patch overrides the PST table only if
check_pst_table()fails.The minimum value for the override is 800MHz, which is the lowest value on all
x86_64systems AFAIK. The max value is the current running value.This patch should be safe to apply, even if Pavel's ACPI table check is added to the driver. Or does anybody see a problem with it?
Quoted 6 lines
Quoted 1 line
Well, there may be problems with that.
That works good now, see my recent posting to the thread on the cpufreq list for more details. I had ACPI processor as module, and that made the powernow-k8 ACPI detection to fail. I fixed it with the following little patch, attaching it here too for reference.
This patch is okay if you insert modules in right order, but not if you attempt to insert cpufreq before acpi, right?
Please do not make that go in like it is.
Pavel
Quoted 12 lines
diff -Nru
a/arch/i386/kernel/cpu/cpufreq/powernow-k8.cb/arch/i386/kernel/cpu/cpufreq/powernow-k8.carch/i386/kernel/cpu/cpufreq/powernow-k8.c +1
-1@@ -32,7 +32,7 @@#include <asm/io.h> #include <asm/delay.h> -#ifdef CONFIG_ACPI_PROCESSOR +#if defined(CONFIG_ACPI_PROCESSOR ) || defined(CONFIG_ACPI_PROCESSOR_MODULE )#include <linux/acpi.h> #include <acpi/processor.h> #endif
Signature · 2 lines
Horseback riding is like software... ...vgf orggre jura vgf serr.
Quoted 3 lines · Pavel Machek
This patch is okay if you insert modules in right order, but not if you attempt to insert cpufreq before acpi, right?
For me modprobe powernow-k8 automatically also loads processor.
Quoted 1 line
Please do not make that go in like it is.
What would you suggest?
Tony
Hi!
Quoted 8 lines
Quoted 2 lines
This patch is okay if you insert modules in right order, but not if you attempt to insert cpufreq before acpi, right?
For me modprobe powernow-k8 automatically also loads processor.
Quoted 1 line
Please do not make that go in like it is.
What would you suggest?
Really? Things might have changed from last time. If it is so, perhaps patch is okay...
Pavel
Signature · 2 lines
Horseback riding is like software... ...vgf orggre jura vgf serr.
Quoted 6 lines · Pavel Machek
Hi!
Quoted 3 lines
Quoted 2 lines
This patch is okay if you insert modules in right order, but not if you attempt to insert cpufreq before acpi, right?
Quoted 8 lines
Quoted 5 lines
For me modprobe powernow-k8 automatically also loads processor.
Quoted 1 line
Please do not make that go in like it is.
What would you suggest?
Really? Things might have changed from last time. If it is so, perhaps patch is okay...
Yeah, maybe acpi_processor_register_performance() was not exported earlier, or something.
Tony