cpufreq: e_powersaver: Fix checking brand for EPS_BRAND_C3
RFC PATCH 1/1 cpufreq: e_powersaver: Fix checking brand for EPS_BRAND_C3
Do not return -ENODEV for EPS_BRAND_C3.
---
I just found the code is suspect.
I don't have this hardware handy.
Anyone can help to confirm and test if this patch works? Axel
drivers/cpufreq/e_powersaver.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/cpufreq/e_powersaver.c +2 -1
@@ -199,8 +199,9 @@ static int eps_cpu_init(struct cpufreq_policy *policy)break ;case EPS_BRAND_C3 :printk (KERN_CONT "C3\n" ); -return -ENODEV ;break ; +default : +return -ENODEV ; }/* Enable Enhanced PowerSaver */ rdmsrl (MSR_IA32_MISC_ENABLE , val);
Signature · 1 line
1.7.4.1
Quoted 18 lines
Do not return
-ENODEVforEPS_BRAND_C3.Signed-off-by Axel Lin<[email protected]>---
I just found the code is suspect.
I don't have this hardware handy.
Anyone can help to confirm and test if this patch works? Axeldrivers/cpufreq/e_powersaver.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/cpufreq/e_powersaver.c +0
-0
drivers/cpufreq/e_powersaver.c static int eps_cpu_init(struct cpufreq_policy *policy) · line 207
Quoted 10 lines
drivers/cpufreq/e_powersaver.c +2
-1@@ -199,8 +199,9 @@ static int eps_cpu_init(struct cpufreq_policy *policy)break ;case EPS_BRAND_C3 :printk (KERN_CONT "C3\n" ); -return -ENODEV ;break ; +default : +return -ENODEV ; }/* Enable Enhanced PowerSaver */ rdmsrl (MSR_IA32_MISC_ENABLE , val);
EPS_BRAND_C3 isn't handled by this driver. So you have to return -ENODEV for it. Why this code is suspect? If you looking for an error it is probably in:
Quoted 2 lines
rdmsr(0x1154, lo, hi);
brand = (((lo >> 4) ^ (lo >> 2))) &0x000000ff;
which was added later to this driver. Probably & 0xff should be replaced by & 3.
Best regards
Rafał Bilski
----------------------------------------------------------------
Najwieksza baza samochodow nowych i uzywanych
Sprawdz >> http://linkint.pl/f29e3
PATCH 1/1 e_powersaver: Add sanity checks to code provided by VIA
In reply to Axel LinPatch from VIA is forcing "e_powersaver" to accept any processor >=A, but code supports only A and D. Patch from VIA is forcing "e_powersaver" to support new brand, but code was intended for 2 bits only. Looks like model D is using 8 bits for brand. Compensate.
Thanks to Axel Lin for pointing it out!
--- drivers/cpufreq/e_powersaver.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/cpufreq/e_powersaver.c +12 -3
@@ -179,9 +179,13 @@ static int eps_cpu_init(struct cpufreq_policy *policy)break ;case 13 :rdmsr (0x1154 , lo, hi); - brand = (((lo >>4 ) ^ (lo >>2 ))) &0x000000ff ; + brand = (((lo >>4 ) ^ (lo >>2 ))) &0xff ;printk (KERN_CONT "Model D " );break ; +default : +printk (KERN_CONT "unknown processor\n" ); +return -ENODEV ; +break ; }switch (brand) {
@@ -194,14 +198,19 @@ static int eps_cpu_init(struct cpufreq_policy *policy)case EPS_BRAND_EDEN :printk (KERN_CONT "Eden\n" );break ; +case EPS_BRAND_C3 : +printk (KERN_CONT "C3\n" ); +return -ENODEV ; +break ;case EPS_BRAND_C7D :printk (KERN_CONT "C7-D\n" );break ; -case EPS_BRAND_C3 : -printk (KERN_CONT "C3\n" ); +default : +printk (KERN_CONT "unsupported brand\n" );return -ENODEV ;break ; } +/* Enable Enhanced PowerSaver */ rdmsrl (MSR_IA32_MISC_ENABLE , val);if (!(val &MSR_IA32_MISC_ENABLE_ENHANCED_SPEEDSTEP )) {
Signature · 7 lines
1.7.6 ---------------------------------------------------------------- Znajdz samochod idealny dla siebie! Szukaj >> http://linkint.pl/f29e2
PATCH 1/1 e_powersaver: Underclock checks
Some systems are using 1.2GHz@844mV processors running at 600MHz@796mV. Try to detect such systems and don't touch anything on it. If CPU doesn't have P-States in BIOS it will run on maximum frequency anyway.
Allow user to bypass checks by means of two new options.
Don't set frequency to maximum on module unloading to avoid bada boom.
Code totally untested as I have abadoned Centaur for Intel Atom two years ago.
--- drivers/cpufreq/e_powersaver.c | 42 +++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 11 deletions(-)
drivers/cpufreq/e_powersaver.c +31 -11
@@ -32,6 +32,10 @@ struct eps_cpu_data {static struct eps_cpu_data *eps_cpu[NR_CPUS ]; +/* Module parameters */ +static int freq_failsafe_off; +static int voltage_failsafe_off; +static unsigned int eps_get (unsigned int cpu) {
@@ -253,9 +257,28 @@ static int eps_cpu_init(struct cpufreq_policy *policy)return -EINVAL ;if (current_voltage >0x1f || max_voltage >0x1f )return -EINVAL ; -if (max_voltage < min_voltage) +if (max_voltage < min_voltage || current_voltage < min_voltage)return -EINVAL ; +/* Check for systems using underclocked CPU */ +if (!freq_failsafe_off && max_multiplier != current_multiplier) { +printk (KERN_INFO "eps: Your processor is running at different then " +"its maximum frequency.\n" ); +printk (KERN_INFO "eps: Some systems use underclocked CPU's\n" ); +printk (KERN_INFO "eps: Use of \"e_powersaver\" on them may cause " +"irreperable damage.\n" ); +printk (KERN_INFO "eps: You can use freq_failsafe_off option to disable " +"this check.\n" ); +return -EINVAL ; + } +if (!voltage_failsafe_off && max_voltage != current_voltage) { +printk (KERN_INFO "eps: Your processor is running at different then " +"its maximum voltage.\n" ); +printk (KERN_INFO "eps: You can use voltage_failsafe_off option to disable " +"this check.\n" ); +return -EINVAL ; + } +/* Calc FSB speed */ fsb = cpu_khz / current_multiplier;/* Calc number of p-states supported */
@@ -312,17 +335,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy)static int eps_cpu_exit (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu; -struct eps_cpu_data *centaur; -u32 lo, hi; - -if (eps_cpu[cpu] ==NULL ) -return -ENODEV ; - centaur = eps_cpu[cpu]; -/* Get max frequency */ -rdmsr (MSR_IA32_PERF_STATUS , lo, hi); -/* Set max frequency */ -eps_set_state (centaur, cpu, hi &0xffff );/* Bye */ cpufreq_frequency_table_put_attr (policy->cpu);kfree (eps_cpu[cpu]);
@@ -368,6 +381,13 @@ static void __exit eps_exit(void)cpufreq_unregister_driver (&eps_driver); } +/* Allow user to overclock his machine or to change frequency to higher after +* unloading module */ +module_param (freq_failsafe_off, int,0644 ); +MODULE_PARM_DESC (freq_failsafe_off,"Disable current vs max frequency check" ); +module_param (voltage_failsafe_off, int,0644 ); +MODULE_PARM_DESC (voltage_failsafe_off,"Disable current vs max voltage check" ); +MODULE_AUTHOR ("Rafal Bilski <[email protected]>" );MODULE_DESCRIPTION ("Enhanced PowerSaver driver for VIA C7 CPU's." );MODULE_LICENSE ("GPL" );
Signature · 7 lines
1.7.6 ---------------------------------------------------------------- Znajdz samochod idealny dla siebie! Szukaj >> http://linkint.pl/f29e2
Re: [PATCH] e_powersaver: Underclock checks
On Tue, Jul 12, 2011 at 12:15:16AM +0100, Rafał Bilski wrote:
Your email client word-wrapped your patch so it won't apply. When you resend, there's a few small typos/grammar..
Quoted 5 lines
drivers/cpufreq/e_powersaver.c +3
-0+/* Check for systems using underclocked CPU */ + if (!freq_failsafe_off && max_multiplier != current_multiplier) { + printk(KERN_INFO "eps: Your processor is running atdifferent then "
+ "its maximum frequency.\n");
"is running at a different frequency than its maximum" reads a little clearer.
drivers/cpufreq/e_powersaver.c static int eps_cpu_init(struct cpufreq_policy *policy) · line 269
Quoted 3 lines
drivers/cpufreq/e_powersaver.c +3
-0+printk (KERN_INFO "eps: Some systems use underclocked CPU's\n" ); +printk (KERN_INFO "eps: Use of \"e_powersaver\" on them may cause " +"irreperable damage.\n" );
'irreparable'.
Quoted 4 lines
(quoted diff) +2
-0+ if (!voltage_failsafe_off && max_voltage != current_voltage) { + printk(KERN_INFO "eps: Your processor is running atdifferent then "
+ "its maximum voltage.\n");
similar to above.
Dave
Re: [PATCH] e_powersaver: Underclock checks
Some systems are using 1.2GHz@844mV processors running at 600MHz@796mV. Try to detect such systems and don't touch anything on it. If CPU doesn't have P-States in BIOS it will run on maximum frequency anyway.
Allow user to bypass checks by means of two new options.
Don't set frequency to maximum on module unloading to avoid bada boom.
It is also possible that these, or other, processors have incorrect values in mix/max registers caused by error in manufacturing process. Probably it would be BIOS job to set them to right frequency.
For the first time CPU is reporting higher supported frequency then system is able to support. In old times of C3 CPUs on EPIA M10000 1,4GHz processors were reporting 1GHz as highest supported frequency because cooler was too small. With bigger cooler and patched "Longhaul" board was (and still is somewhere) running perfectly at 1,4GHz. I still wonder why they didn't change voltage to lower one.
Code totally untested as I have abadoned Centaur for Intel Atom two years ago.
--- drivers/cpufreq/e_powersaver.c | 42 +++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 11 deletions(-)
drivers/cpufreq/e_powersaver.c +31 -11
@@ -32,6 +32,10 @@ struct eps_cpu_data {static struct eps_cpu_data *eps_cpu[NR_CPUS ]; +/* Module parameters */ +static int freq_failsafe_off; +static int voltage_failsafe_off; +static unsigned int eps_get (unsigned int cpu) {
@@ -253,9 +257,28 @@ static int eps_cpu_init(struct cpufreq_policy *policy)return -EINVAL ;if (current_voltage >0x1f || max_voltage >0x1f )return -EINVAL ; -if (max_voltage < min_voltage) +if (max_voltage < min_voltage || current_voltage < min_voltage)return -EINVAL ; +/* Check for systems using underclocked CPU */ +if (!freq_failsafe_off && max_multiplier != current_multiplier) { +printk (KERN_INFO "eps: Your processor is running at different frequency " +"then its maximum.\n" ); +printk (KERN_INFO "eps: Some systems use underclocked CPU's\n" ); +printk (KERN_INFO "eps: Use of \"e_powersaver\" on them may cause " +"irreparable damage.\n" ); +printk (KERN_INFO "eps: You can use freq_failsafe_off option to disable " +"this check.\n" ); +return -EINVAL ; + } +if (!voltage_failsafe_off && max_voltage != current_voltage) { +printk (KERN_INFO "eps: Your processor is running at different voltage " +"then its maximum.\n" ); +printk (KERN_INFO "eps: You can use voltage_failsafe_off option to disable " +"this check.\n" ); +return -EINVAL ; + } +/* Calc FSB speed */ fsb = cpu_khz / current_multiplier;/* Calc number of p-states supported */
@@ -312,17 +335,7 @@ static int eps_cpu_init(struct cpufreq_policy *policy)static int eps_cpu_exit (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu; -struct eps_cpu_data *centaur; -u32 lo, hi; - -if (eps_cpu[cpu] ==NULL ) -return -ENODEV ; - centaur = eps_cpu[cpu]; -/* Get max frequency */ -rdmsr (MSR_IA32_PERF_STATUS , lo, hi); -/* Set max frequency */ -eps_set_state (centaur, cpu, hi &0xffff );/* Bye */ cpufreq_frequency_table_put_attr (policy->cpu);kfree (eps_cpu[cpu]);
@@ -368,6 +381,13 @@ static void __exit eps_exit(void)cpufreq_unregister_driver (&eps_driver); } +/* Allow user to overclock his machine or to change frequency to higher after +* unloading module */ +module_param (freq_failsafe_off, int,0644 ); +MODULE_PARM_DESC (freq_failsafe_off,"Disable current vs max frequency check" ); +module_param (voltage_failsafe_off, int,0644 ); +MODULE_PARM_DESC (voltage_failsafe_off,"Disable current vs max voltage check" ); +MODULE_AUTHOR ("Rafal Bilski <[email protected]>" );MODULE_DESCRIPTION ("Enhanced PowerSaver driver for VIA C7 CPU's." );MODULE_LICENSE ("GPL" );
Signature · 7 lines
1.7.6 ---------------------------------------------------------------- Znajdz samochod idealny dla siebie! Szukaj >> http://linkint.pl/f29e2
Re: [PATCH] e_powersaver: Underclock checks
Quoted 2 lines
Some systems are using 1.2GHz@844mV processors running at 600MHz@796mV.
OK. That's strange. It is 1,2GHz system. Can both ACPI p-states and "e_powersaver" drivers be running at the same time? Can BIOS change processor frequencies without Linux knowing and without p-states driver loaded?
I can't test system in question. I will try to buy something similar to test it.
Thank you
Rafał Bilski
----------------------------------------------------------------
Dom marzen - kup lub wynajmij taniej niz myslisz!
Szukaj >> http://linkint.pl/f29e5
Re: [PATCH] e_powersaver: Underclock checks
Quoted 4 lines · RafaÅ‚ Bilski
Quoted 2 lines
Some systems are using 1.2GHz@844mV processors running at 600MHz@796mV.
OK. That's strange. It is 1,2GHz system. Can both ACPI p-states and "
e_powersaver" drivers be running at the same time?
no
Quoted 2 lines
Can BIOS change processor frequencies without
Linux knowing and without p-states driver loaded?
yes. Usually via SMI. some laptops do this when switching between power/battery, and/or when overheating.
cpufreq usually detects when this happens and logs messages.
Dave
Re: [PATCH] e_powersaver: Add sanity checks to code provided by VIA
In reply to Rafał BilskiQuoted 9 lines · Rafał Bilski
Patch from VIA is forcing "
e_powersaver" to accept any processorQuoted 1 line
=A, but code supports only A and D.
Patch from VIA is forcing "
e_powersaver" to support new brand, but code was intended for 2 bits only.
Looks like model D is using 8 bits for brand. Compensate.Thanks to Axel Lin for pointing it out!
Signed-off-by Rafał Bilski <[email protected]>
This, and your other patch still don't apply, because your email client has converted all tabs to spaces.
Dave
Re: [PATCH] e_powersaver: Add sanity checks to code provided by VIA
Quoted 8 lines · Rafał Bilski
Quoted 6 lines
Patch from VIA is forcing "
e_powersaver" to accept any processorQuoted 1 line
=A, but code supports only A and D.
Patch from VIA is forcing "
e_powersaver" to support new brand, but code was intended for 2 bits only.
Looks like model D is using 8 bits for brand. Compensate.
Quoted 9 lines
Quoted 3 lines
Thanks to Axel Lin for pointing it out!
Signed-off-by Rafał Bilski<[email protected]>This, and your other patch still don't apply, because your email client has converted all tabs to spaces.
Dave
Sorry. I was sure in past I used Mozilla Thunderbird to send patches. I will resend patches tomorrow. Second patch seems a bit premature now anyway. Do you mind if I shorten message to: CPU isn't running at max frequency (as I expected), you can use option to...?
Sorry
Rafał
----------------------------------------------------------------
Znajdz samochod idealny dla siebie!
Szukaj >> http://linkint.pl/f29e2