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

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



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1255679973 -3600
# Node ID 8c7e71d2fdb2db88fb21a4a012c08dac8ef08c2b
# Parent  adb8716ef44bad5fd987a211d4fe3e2dee3e32c6
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-unstable changeset:   20325:a20335046ab8
xen-unstable date:        Fri Oct 16 08:31:39 2009 +0100
---
 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 adb8716ef44b -r 8c7e71d2fdb2 xen/arch/x86/acpi/cpufreq/cpufreq.c
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c       Fri Oct 16 08:58:57 2009 +0100
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c       Fri Oct 16 08:59:33 2009 +0100
@@ -663,6 +663,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;
 }
@@ -678,9 +681,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 adb8716ef44b -r 8c7e71d2fdb2 xen/arch/x86/acpi/cpufreq/powernow.c
--- a/xen/arch/x86/acpi/cpufreq/powernow.c      Fri Oct 16 08:58:57 2009 +0100
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c      Fri Oct 16 08:59:33 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, (void *) &cmd, 0, 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 adb8716ef44b -r 8c7e71d2fdb2 xen/include/acpi/cpufreq/processor_perf.h
--- a/xen/include/acpi/cpufreq/processor_perf.h Fri Oct 16 08:58:57 2009 +0100
+++ b/xen/include/acpi/cpufreq/processor_perf.h Fri Oct 16 08:59:33 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®.