[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86: Update powernow.c to latest cpufreq code



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1255678299 -3600
# Node ID a20335046ab8ec2c0fbda50d6724e27f18e89dc4
# Parent  bc27fe199094ec1e61228d1d775f45d3f6f1b684
x86: Update powernow.c to latest cpufreq code

The general cpufreq infrastructure has been improved over the
last year.  Update the AMD PowerNow! driver powernow.c to
take advantage of those improvements.

Specifically, addresses Novell bugzilla # 530035.

Signed-of-by: Mark Langsdorf <mark.langsdorf@xxxxxxx>
---
 xen/arch/x86/acpi/cpufreq/cpufreq.c       |    8 ++-
 xen/arch/x86/acpi/cpufreq/powernow.c      |   66 ++++++++++--------------------
 xen/include/acpi/cpufreq/processor_perf.h |    1 
 3 files changed, 29 insertions(+), 46 deletions(-)

diff -r bc27fe199094 -r a20335046ab8 xen/arch/x86/acpi/cpufreq/cpufreq.c
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c       Fri Oct 16 08:30:13 2009 +0100
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c       Fri Oct 16 08:31:39 2009 +0100
@@ -661,6 +661,9 @@ static int __init cpufreq_driver_init(vo
     if ((cpufreq_controller == FREQCTL_xen) &&
         (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
         ret = cpufreq_register_driver(&acpi_cpufreq_driver);
+    else if ((cpufreq_controller == FREQCTL_xen) &&
+        (boot_cpu_data.x86_vendor == X86_VENDOR_AMD))
+        ret = powernow_register_driver();
 
     return ret;
 }
@@ -676,9 +679,8 @@ int cpufreq_cpu_init(unsigned int cpuid)
     /* Currently we only handle Intel and AMD processor */
     if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
         ret = cpufreq_add_cpu(cpuid);
-    else if ( (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
-            (cpu_count == num_online_cpus()) )
-        ret = powernow_cpufreq_init();
+    else if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD )
+        ret = cpufreq_add_cpu(cpuid);
     else
         ret = -EFAULT;
     return ret;
diff -r bc27fe199094 -r a20335046ab8 xen/arch/x86/acpi/cpufreq/powernow.c
--- a/xen/arch/x86/acpi/cpufreq/powernow.c      Fri Oct 16 08:30:13 2009 +0100
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c      Fri Oct 16 08:31:39 2009 +0100
@@ -85,6 +85,7 @@ static int powernow_cpufreq_target(struc
     unsigned int next_state = 0; /* Index into freq_table */
     unsigned int next_perf_state = 0; /* Index into perf table */
     int result = 0;
+    int j = 0;
 
     if (unlikely(data == NULL ||
         data->acpi_data == NULL || data->freq_table == NULL)) {
@@ -123,6 +124,9 @@ static int powernow_cpufreq_target(struc
 
     on_selected_cpus(&cmd.mask, transition_pstate, &cmd, 0);
 
+    for_each_cpu_mask(j, online_policy_cpus)
+        cpufreq_statistic_update(j, perf->state, next_perf_state);
+
     perf->state = next_perf_state;
     policy->cur = freqs.new;
 
@@ -132,9 +136,16 @@ static int powernow_cpufreq_verify(struc
 static int powernow_cpufreq_verify(struct cpufreq_policy *policy)
 {
     struct powernow_cpufreq_data *data;
-
-    if (!policy || !(data = drv_data[policy->cpu]))
+    struct processor_performance *perf;
+
+    if (!policy || !(data = drv_data[policy->cpu]) ||
+        !processor_pminfo[policy->cpu])
         return -EINVAL;
+
+    perf = &processor_pminfo[policy->cpu]->perf;
+
+    cpufreq_verify_within_limits(policy, 0, 
+        perf->states[perf->platform_limit].core_frequency * 1000);
 
     return cpufreq_frequency_table_verify(policy, data->freq_table);
 }
@@ -202,6 +213,8 @@ static int powernow_cpufreq_cpu_init(str
                 perf->states[i].transition_latency * 1000;
     }
 
+    policy->governor = cpufreq_opt_governor ? : CPUFREQ_DEFAULT_GOVERNOR;
+
     data->max_freq = perf->states[0].core_frequency * 1000;
     /* table init */
     for (i = 0; i < perf->state_count && i <= max_hw_pstate; i++) {
@@ -259,10 +272,17 @@ static struct cpufreq_driver powernow_cp
     .exit   = powernow_cpufreq_cpu_exit
 };
 
+unsigned int powernow_register_driver()
+{
+    unsigned int ret;
+    ret = cpufreq_register_driver(&powernow_cpufreq_driver);
+    return ret;
+}
+
 int powernow_cpufreq_init(void)
 {
     unsigned int i, ret = 0;
-    unsigned int dom, max_dom = 0;
+    unsigned int max_dom = 0;
     cpumask_t *pt;
     unsigned long *dom_mask;
 
@@ -304,46 +324,6 @@ int powernow_cpufreq_init(void)
         processor_pminfo[i]->perf.shared_cpu_map =
             pt[processor_pminfo[i]->perf.domain_info.domain];
 
-    cpufreq_driver = &powernow_cpufreq_driver;
-
-    /* setup cpufreq infrastructure */
-    for_each_online_cpu(i) {
-        struct cpufreq_policy *policy = cpufreq_cpu_policy[i];
-
-        if (!policy) {
-            unsigned int firstcpu;
-
-            firstcpu = first_cpu(processor_pminfo[i]->perf.shared_cpu_map);
-            if (i == firstcpu) {
-                policy = xmalloc(struct cpufreq_policy);
-                if (!policy) {
-                    ret = -ENOMEM;
-                    goto cpufreq_init_out;
-                }
-                memset(policy, 0, sizeof(struct cpufreq_policy));
-                policy->cpu = i;
-            } else
-                policy = cpufreq_cpu_policy[firstcpu];
-            cpu_set(i, policy->cpus);
-            cpufreq_cpu_policy[i] = policy;
-        }
-
-        ret = powernow_cpufreq_cpu_init(policy);
-        if (ret)
-            goto cpufreq_init_out;
-    }
-
-    /* setup ondemand cpufreq */
-    for (dom = 0; dom < max_dom; dom++) {
-        if (!test_bit(dom, dom_mask))
-            continue;
-        i = first_cpu(pt[dom]);
-        ret = cpufreq_governor_dbs(cpufreq_cpu_policy[i], CPUFREQ_GOV_START);
-        if (ret)
-            goto cpufreq_init_out;
-    }
-
-cpufreq_init_out:
     xfree(pt);
     xfree(dom_mask);
    
diff -r bc27fe199094 -r a20335046ab8 xen/include/acpi/cpufreq/processor_perf.h
--- a/xen/include/acpi/cpufreq/processor_perf.h Fri Oct 16 08:30:13 2009 +0100
+++ b/xen/include/acpi/cpufreq/processor_perf.h Fri Oct 16 08:31:39 2009 +0100
@@ -8,6 +8,7 @@
 
 int get_cpu_id(u8);
 int powernow_cpufreq_init(void);
+unsigned int powernow_register_driver(void);
 
 void cpufreq_residency_update(unsigned int, uint8_t);
 void cpufreq_statistic_update(unsigned int, uint8_t, uint8_t);

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.