All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafał Bilski" <rafalbilski@interia.pl>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel@vger.kernel.org, Dave Jones <davej@redhat.com>,
	cpufreq@vger.kernel.org
Subject: [PATCH] e_powersaver: Underclock checks
Date: Tue, 12 Jul 2011 00:15:16 +0100	[thread overview]
Message-ID: <4E1B8404.1050909@interia.pl> (raw)
In-Reply-To: <4E1B745A.5000802@interia.pl>

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

WARNING: multiple messages have this Message-ID (diff)
From: "Rafał Bilski" <rafalbilski@interia.pl>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel@vger.kernel.org, Dave Jones <davej@redhat.com>,
	cpufreq@vger.kernel.org
Subject: [PATCH] e_powersaver: Underclock checks
Date: Tue, 12 Jul 2011 00:15:16 +0100	[thread overview]
Message-ID: <4E1B8404.1050909@interia.pl> (raw)
In-Reply-To: <4E1B745A.5000802@interia.pl>

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

  reply	other threads:[~2011-07-11 23:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 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 22:08   ` Rafał Bilski
2011-07-11 23:15   ` Rafał Bilski [this message]
2011-07-11 23:15     ` [PATCH] e_powersaver: Underclock checks Rafał Bilski
2011-07-11 23:25     ` Dave Jones
2011-07-11 23:25       ` Dave Jones
2011-07-12 17:00       ` Rafał Bilski
2011-07-12 17:00         ` Rafał Bilski
2011-07-13 16:40         ` Rafał Bilski
2011-07-13 16:40           ` Rafał Bilski
2011-07-13 16:45           ` Dave Jones
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E1B8404.1050909@interia.pl \
    --to=rafalbilski@interia.pl \
    --cc=axel.lin@gmail.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.