All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] Fix a cpufreq userspace limitation bug
@ 2009-03-19  9:02 Liu, Jinsong
  0 siblings, 0 replies; only message in thread
From: Liu, Jinsong @ 2009-03-19  9:02 UTC (permalink / raw)
  To: xen-devel; +Cc: Oriol, Mariusz, Keir Fraser

[-- Attachment #1: Type: text/plain, Size: 203 bytes --]

Fix a cpufreq userspace limitation bug, so that userspace freq can return to correct freq when freq_limitation return to high value (like ppc event)

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>

[-- Attachment #2: px-xen-1-gov-limit.patch --]
[-- Type: application/octet-stream, Size: 4169 bytes --]

Fix a cpufreq userspace limitation bug, so that userspace freq can return to correct freq when freq_limitation return to high value (like ppc event)

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>

diff -r 0e1449d6f231 xen/drivers/acpi/pmstat.c
--- a/xen/drivers/acpi/pmstat.c	Fri Mar 13 10:09:25 2009 +0000
+++ b/xen/drivers/acpi/pmstat.c	Thu Mar 19 16:57:04 2009 +0800
@@ -368,14 +368,7 @@ static int set_cpufreq_para(struct xen_s
 
         if ( !strnicmp(policy->governor->name,
                        "userspace", CPUFREQ_NAME_LEN) )
-        {
-            if ( freq < policy->min )
-                freq = policy->min;
-            if ( freq > policy->max )
-                freq = policy->max;
-
-            ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
-        }
+            ret = write_userspace_scaling_setspeed(op->cpuid, freq);
         else
             ret = -EINVAL;
 
diff -r 0e1449d6f231 xen/drivers/cpufreq/cpufreq_misc_governors.c
--- a/xen/drivers/cpufreq/cpufreq_misc_governors.c	Fri Mar 13 10:09:25 2009 +0000
+++ b/xen/drivers/cpufreq/cpufreq_misc_governors.c	Thu Mar 19 16:57:04 2009 +0800
@@ -18,34 +18,38 @@
 #include <xen/sched.h>
 #include <acpi/cpufreq/cpufreq.h>
 
-static unsigned int usr_speed;
-
 /*
  * cpufreq userspace governor
  */
+static unsigned int cpu_set_freq[NR_CPUS];
+
 static int cpufreq_governor_userspace(struct cpufreq_policy *policy,
                                       unsigned int event)
 {
     int ret = 0;
-    unsigned int freq;
+    unsigned int cpu;
 
-    if (!policy)
+    if (unlikely(!policy) || 
+        unlikely(!cpu_online(cpu = policy->cpu)))
         return -EINVAL;
 
     switch (event) {
     case CPUFREQ_GOV_START:
+        if (!cpu_set_freq[cpu])
+            cpu_set_freq[cpu] = policy->cur;
+        break;
     case CPUFREQ_GOV_STOP:
+        cpu_set_freq[cpu] = 0;
         break;
     case CPUFREQ_GOV_LIMITS:
-        freq = usr_speed ? : policy->cur;
-        if (policy->max < freq)
+        if (policy->max < cpu_set_freq[cpu])
             ret = __cpufreq_driver_target(policy, policy->max,
                         CPUFREQ_RELATION_H);
-        else if (policy->min > freq)
+        else if (policy->min > cpu_set_freq[cpu])
             ret = __cpufreq_driver_target(policy, policy->min,
                         CPUFREQ_RELATION_L);
-        else if (usr_speed)
-            ret = __cpufreq_driver_target(policy, freq,
+        else
+            ret = __cpufreq_driver_target(policy, cpu_set_freq[cpu],
                         CPUFREQ_RELATION_L);
 
         break;
@@ -57,11 +61,34 @@ static int cpufreq_governor_userspace(st
     return ret;
 }
 
+int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq)
+{
+    struct cpufreq_policy *policy = cpufreq_cpu_policy[cpu];
+
+    if (!cpu_online(cpu) || !policy)
+        return -EINVAL;
+
+    cpu_set_freq[cpu] = freq;
+
+    if (freq < policy->min)
+        freq = policy->min;
+    if (freq > policy->max)
+        freq = policy->max;
+
+    return __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
+}
+
 static void __init 
 cpufreq_userspace_handle_option(const char *name, const char *val)
 {
-    if (!strcmp(name, "speed") && val)
-        usr_speed = simple_strtoul(val, NULL, 0);
+    if (!strcmp(name, "speed") && val) {
+        unsigned int usr_cmdline_freq;
+        unsigned int cpu;
+
+        usr_cmdline_freq = simple_strtoul(val, NULL, 0);
+        for (cpu = 0; cpu < NR_CPUS; cpu++)
+            cpu_set_freq[cpu] = usr_cmdline_freq;
+    }
 }
 
 struct cpufreq_governor cpufreq_gov_userspace = {
diff -r 0e1449d6f231 xen/include/acpi/cpufreq/cpufreq.h
--- a/xen/include/acpi/cpufreq/cpufreq.h	Fri Mar 13 10:09:25 2009 +0000
+++ b/xen/include/acpi/cpufreq/cpufreq.h	Thu Mar 19 16:57:04 2009 +0800
@@ -227,4 +227,6 @@ int get_cpufreq_ondemand_para(uint32_t *
                               uint32_t *up_threshold);
 int write_ondemand_sampling_rate(unsigned int sampling_rate);
 int write_ondemand_up_threshold(unsigned int up_threshold);
+
+int write_userspace_scaling_setspeed(unsigned int cpu, unsigned int freq);
 #endif /* __XEN_CPUFREQ_PM_H__ */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-19  9:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-19  9:02 [Patch] Fix a cpufreq userspace limitation bug Liu, Jinsong

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.