* [RFC][PATCH] cpufreq: e_powersaver: Fix checking brand for EPS_BRAND_C3 @ 2011-07-08 8:37 Axel Lin 2011-07-11 16:36 ` Rafał Bilski 2011-07-11 22:08 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Rafał Bilski 0 siblings, 2 replies; 10+ messages in thread From: Axel Lin @ 2011-07-08 8:37 UTC (permalink / raw) To: linux-kernel; +Cc: Rafal Bilski, Dave Jones, cpufreq Do not return -ENODEV for EPS_BRAND_C3. Signed-off-by: Axel Lin <axel.lin@gmail.com> --- 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(-) diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 35a257d..637f055 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c @@ -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); -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [RFC][PATCH] cpufreq: e_powersaver: Fix checking brand for EPS_BRAND_C3 2011-07-08 8:37 [RFC][PATCH] cpufreq: e_powersaver: Fix checking brand for EPS_BRAND_C3 Axel Lin @ 2011-07-11 16:36 ` Rafał Bilski 2011-07-11 22:08 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Rafał Bilski 1 sibling, 0 replies; 10+ messages in thread From: Rafał Bilski @ 2011-07-11 16:36 UTC (permalink / raw) To: Axel Lin; +Cc: linux-kernel, Dave Jones, cpufreq > Do not return -ENODEV for EPS_BRAND_C3. > > Signed-off-by: Axel Lin<axel.lin@gmail.com> > --- > 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(-) > > diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c > index 35a257d..637f055 100644 > --- a/drivers/cpufreq/e_powersaver.c > +++ b/drivers/cpufreq/e_powersaver.c > @@ -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: > 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] e_powersaver: Add sanity checks to code provided by VIA 2011-07-08 8:37 [RFC][PATCH] cpufreq: e_powersaver: Fix checking brand for EPS_BRAND_C3 Axel Lin 2011-07-11 16:36 ` Rafał Bilski @ 2011-07-11 22:08 ` Rafał Bilski 2011-07-11 23:15 ` [PATCH] e_powersaver: Underclock checks Rafał Bilski 2011-07-13 22:24 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Dave Jones 1 sibling, 2 replies; 10+ messages in thread From: Rafał Bilski @ 2011-07-11 22:08 UTC (permalink / raw) To: Axel Lin; +Cc: linux-kernel, Dave Jones, cpufreq Patch 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! Signed-off-by: Rafał Bilski <rafalbilski@interia.pl> --- drivers/cpufreq/e_powersaver.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 35a257d..7883ffa 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c @@ -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)) { -- 1.7.6 ---------------------------------------------------------------- Znajdz samochod idealny dla siebie! Szukaj >> http://linkint.pl/f29e2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] e_powersaver: Underclock checks 2011-07-11 22:08 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Rafał Bilski @ 2011-07-11 23:15 ` Rafał Bilski 2011-07-11 23:25 ` Dave Jones 2011-07-13 22:24 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Dave Jones 1 sibling, 1 reply; 10+ messages in thread From: Rafał Bilski @ 2011-07-11 23:15 UTC (permalink / raw) To: Axel Lin; +Cc: linux-kernel, Dave Jones, cpufreq 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. Signed-off-by: Rafał Bilski <rafalbilski@interia.pl> --- drivers/cpufreq/e_powersaver.c | 42 +++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 7883ffa..2e28af2 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c @@ -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 <rafalbilski@interia.pl>"); MODULE_DESCRIPTION("Enhanced PowerSaver driver for VIA C7 CPU's."); MODULE_LICENSE("GPL"); -- 1.7.6 ---------------------------------------------------------------- Znajdz samochod idealny dla siebie! Szukaj >> http://linkint.pl/f29e2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] e_powersaver: Underclock checks 2011-07-11 23:15 ` [PATCH] e_powersaver: Underclock checks Rafał Bilski @ 2011-07-11 23:25 ` Dave Jones 2011-07-12 17:00 ` Rafał Bilski 0 siblings, 1 reply; 10+ messages in thread From: Dave Jones @ 2011-07-11 23:25 UTC (permalink / raw) To: Rafał Bilski; +Cc: Axel Lin, linux-kernel, cpufreq 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.. > + /* 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"); "is running at a different frequency than its maximum" reads a little clearer. > + 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'. > + if (!voltage_failsafe_off && max_voltage != current_voltage) { > + printk(KERN_INFO "eps: Your processor is running at > different then " > + "its maximum voltage.\n"); similar to above. Dave ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] e_powersaver: Underclock checks 2011-07-11 23:25 ` Dave Jones @ 2011-07-12 17:00 ` Rafał Bilski 2011-07-13 16:40 ` Rafał Bilski 0 siblings, 1 reply; 10+ messages in thread From: Rafał Bilski @ 2011-07-12 17:00 UTC (permalink / raw) To: Dave Jones, Axel Lin, linux-kernel, cpufreq 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. Signed-off-by: Rafał Bilski <rafalbilski@interia.pl> --- drivers/cpufreq/e_powersaver.c | 42 +++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/cpufreq/e_powersaver.c b/drivers/cpufreq/e_powersaver.c index 7883ffa..46176b2 100644 --- a/drivers/cpufreq/e_powersaver.c +++ b/drivers/cpufreq/e_powersaver.c @@ -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 <rafalbilski@interia.pl>"); MODULE_DESCRIPTION("Enhanced PowerSaver driver for VIA C7 CPU's."); MODULE_LICENSE("GPL"); -- 1.7.6 ---------------------------------------------------------------- Znajdz samochod idealny dla siebie! Szukaj >> http://linkint.pl/f29e2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] e_powersaver: Underclock checks 2011-07-12 17:00 ` Rafał Bilski @ 2011-07-13 16:40 ` Rafał Bilski 2011-07-13 16:45 ` Dave Jones 0 siblings, 1 reply; 10+ messages in thread From: Rafał Bilski @ 2011-07-13 16:40 UTC (permalink / raw) To: Dave Jones, Axel Lin, linux-kernel, cpufreq > 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] e_powersaver: Underclock checks 2011-07-13 16:40 ` Rafał Bilski @ 2011-07-13 16:45 ` Dave Jones 0 siblings, 0 replies; 10+ messages in thread From: Dave Jones @ 2011-07-13 16:45 UTC (permalink / raw) To: Rafał Bilski; +Cc: Axel Lin, linux-kernel, cpufreq On Wed, Jul 13, 2011 at 05:40:22PM +0100, Rafał Bilski wrote: > > >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 > 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] e_powersaver: Add sanity checks to code provided by VIA 2011-07-11 22:08 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Rafał Bilski 2011-07-11 23:15 ` [PATCH] e_powersaver: Underclock checks Rafał Bilski @ 2011-07-13 22:24 ` Dave Jones 2011-07-13 23:01 ` Rafał Bilski 1 sibling, 1 reply; 10+ messages in thread From: Dave Jones @ 2011-07-13 22:24 UTC (permalink / raw) To: Rafał Bilski; +Cc: Axel Lin, linux-kernel, cpufreq On Mon, Jul 11, 2011 at 11:08:26PM +0100, Rafał Bilski wrote: > Patch 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! > > Signed-off-by: Rafał Bilski <rafalbilski@interia.pl> This, and your other patch still don't apply, because your email client has converted all tabs to spaces. Dave ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] e_powersaver: Add sanity checks to code provided by VIA 2011-07-13 22:24 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Dave Jones @ 2011-07-13 23:01 ` Rafał Bilski 0 siblings, 0 replies; 10+ messages in thread From: Rafał Bilski @ 2011-07-13 23:01 UTC (permalink / raw) To: Dave Jones, Axel Lin, linux-kernel, cpufreq > On Mon, Jul 11, 2011 at 11:08:26PM +0100, Rafał Bilski wrote: > > Patch 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! > > > > Signed-off-by: Rafał Bilski<rafalbilski@interia.pl> > > 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-07-13 23:02 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-07-08 8:37 [RFC][PATCH] cpufreq: e_powersaver: Fix checking brand for EPS_BRAND_C3 Axel Lin 2011-07-11 16:36 ` Rafał Bilski 2011-07-11 22:08 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Rafał Bilski 2011-07-11 23:15 ` [PATCH] e_powersaver: Underclock checks Rafał Bilski 2011-07-11 23:25 ` Dave Jones 2011-07-12 17:00 ` Rafał Bilski 2011-07-13 16:40 ` Rafał Bilski 2011-07-13 16:45 ` Dave Jones 2011-07-13 22:24 ` [PATCH] e_powersaver: Add sanity checks to code provided by VIA Dave Jones 2011-07-13 23:01 ` Rafał Bilski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).