All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Langsdorf <mark.langsdorf@amd.com>
To: xen-devel@lists.xensource.com, guanqun.lu@intel.com
Subject: [PATCH] 1/3 Refactor Xen support for Intel Turbo boost
Date: Mon, 29 Mar 2010 13:27:41 -0500	[thread overview]
Message-ID: <201003291327.41749.mark.langsdorf@amd.com> (raw)

# HG changeset patch
# User mark.langsdorf@amd.com
# Date 1269540083 18000
# Node ID 6d42054cb1947841ab34f04c1172971068487922
# Parent  18f4db5f72d756dda30e28d5872d91d35fdf9f0c
Refactor the existing code that supports the Intel Turbo feature to
move all the driver specific bits in the cpufreq driver.  Create
a tri-state interface for the Turbo feature that can distinguish
amongst enabled Turbo, disabled Turbo, and processors that don't
support Turbo at all.

Changing the code this way is necessary because the similar AMD
feature Boost has a similar external interface but a very
different internal implementation.

Signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>

diff -r 18f4db5f72d7 -r 6d42054cb194 tools/misc/xenpm.c
--- a/tools/misc/xenpm.c	Thu Mar 25 10:01:05 2010 +0000
+++ b/tools/misc/xenpm.c	Thu Mar 25 13:01:23 2010 -0500
@@ -529,8 +529,13 @@
                p_cpufreq->u.ondemand.sampling_rate);
         printf("    up_threshold     : %u\n",
                p_cpufreq->u.ondemand.up_threshold);
-        printf("    turbo mode       : %s\n",
-               p_cpufreq->u.ondemand.turbo_enabled ? "enabled" : "disabled");
+        if (p_cpufreq->u.ondemand.turbo_enabled != 0) {
+               printf("    turbo mode       : ");
+               if (p_cpufreq->u.ondemand.turbo_enabled == 1)
+                   printf("enabled\n");
+               else
+                   printf("disabled\n");
+        }
     }
 
     printf("scaling_avail_freq   :");
diff -r 18f4db5f72d7 -r 6d42054cb194 xen/arch/x86/acpi/cpufreq/cpufreq.c
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c	Thu Mar 25 10:01:05 2010 +0000
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c	Thu Mar 25 13:01:23 2010 -0500
@@ -410,6 +410,10 @@
         return -ENODEV;
     }
 
+    if (policy->turbo == -1)
+        if (target_freq > policy->cpuinfo.second_max_freq)
+            target_freq = policy->cpuinfo.second_max_freq;
+
     perf = data->acpi_data;
     result = cpufreq_frequency_table_target(policy,
                                             data->freq_table,
@@ -610,12 +614,19 @@
         break;
     }
 
-    /* Check for APERF/MPERF support in hardware */
+    /* Check for APERF/MPERF support in hardware
+     * also check for boost support */
     if (c->x86_vendor == X86_VENDOR_INTEL && c->cpuid_level >= 6) {
         unsigned int ecx;
+        unsigned int eax;
         ecx = cpuid_ecx(6);
         if (ecx & CPUID_6_ECX_APERFMPERF_CAPABILITY)
             acpi_cpufreq_driver.getavg = get_measured_perf;
+        eax = cpuid_eax(6);
+        if ( eax & 0x2 ) {
+            policy->turbo = 1;
+            printk(XENLOG_INFO "Turbo Mode detected and enabled!\n");
+        }
     }
 
     /*
diff -r 18f4db5f72d7 -r 6d42054cb194 xen/drivers/cpufreq/cpufreq_ondemand.c
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c	Thu Mar 25 10:01:05 2010 +0000
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c	Thu Mar 25 13:01:23 2010 -0500
@@ -58,9 +58,6 @@
 
 static struct timer dbs_timer[NR_CPUS];
 
-/* Turbo Mode */
-static int turbo_detected = 0;
-
 int write_ondemand_sampling_rate(unsigned int sampling_rate)
 {
     if ( (sampling_rate > MAX_SAMPLING_RATE / MICROSECS(1)) ||
@@ -111,10 +108,6 @@
 
     policy = this_dbs_info->cur_policy;
     max = policy->max;
-    if (turbo_detected && !this_dbs_info->turbo_enabled) {
-        if (max > policy->cpuinfo.second_max_freq)
-            max = policy->cpuinfo.second_max_freq;
-    }
 
     if (unlikely(policy->resume)) {
         __cpufreq_driver_target(policy, max,CPUFREQ_RELATION_H);
@@ -275,7 +268,6 @@
             } else
                 dbs_tuners_ins.sampling_rate = usr_sampling_rate;
         }
-        this_dbs_info->turbo_enabled = 1;
         dbs_timer_init(this_dbs_info);
 
         break;
@@ -352,13 +344,6 @@
 
 static int __init cpufreq_gov_dbs_init(void)
 {
-#ifdef CONFIG_X86
-    unsigned int eax = cpuid_eax(6);
-    if ( eax & 0x2 ) {
-        turbo_detected = 1;
-        printk(XENLOG_INFO "Turbo Mode detected!\n");
-    }
-#endif
     return cpufreq_register_governor(&cpufreq_gov_dbs);
 }
 __initcall(cpufreq_gov_dbs_init);
@@ -406,16 +391,27 @@
 
 void cpufreq_dbs_enable_turbo(int cpuid)
 {
-    per_cpu(cpu_dbs_info, cpuid).turbo_enabled = 1;
+    struct cpufreq_policy *policy;
+
+    policy = per_cpu(cpu_dbs_info, cpuid).cur_policy;
+    if (policy->turbo != 0)
+        policy->turbo = 1;
 }
 
 void cpufreq_dbs_disable_turbo(int cpuid)
 {
-    per_cpu(cpu_dbs_info, cpuid).turbo_enabled = 0;
+    struct cpufreq_policy *policy;
+
+    policy = per_cpu(cpu_dbs_info, cpuid).cur_policy;
+    if (policy->turbo != 0)
+        policy->turbo = -1;
 }
 
 unsigned int cpufreq_dbs_get_turbo_status(int cpuid)
 {
-    return turbo_detected && per_cpu(cpu_dbs_info, cpuid).turbo_enabled;
+    struct cpufreq_policy *policy;
+
+    policy = per_cpu(cpu_dbs_info, cpuid).cur_policy;
+    return policy->turbo;
 }
 
diff -r 18f4db5f72d7 -r 6d42054cb194 xen/include/acpi/cpufreq/cpufreq.h
--- a/xen/include/acpi/cpufreq/cpufreq.h	Thu Mar 25 10:01:05 2010 +0000
+++ b/xen/include/acpi/cpufreq/cpufreq.h	Thu Mar 25 13:01:23 2010 -0500
@@ -55,6 +55,8 @@
 
     unsigned int        resume; /* flag for cpufreq 1st run
                                  * S3 wakeup, hotplug cpu, etc */
+    int                 turbo;  /* tristate flag: 0 for unsupported
+                                 * -1 for disable, 1 for enabled */
 };
 extern struct cpufreq_policy *cpufreq_cpu_policy[NR_CPUS];
 

-------------------------------------------------------

             reply	other threads:[~2010-03-29 18:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-29 18:27 Mark Langsdorf [this message]
2010-03-30  9:16 ` [PATCH] 1/3 Refactor Xen support for Intel Turbo boost Yu, Ke

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=201003291327.41749.mark.langsdorf@amd.com \
    --to=mark.langsdorf@amd.com \
    --cc=guanqun.lu@intel.com \
    --cc=xen-devel@lists.xensource.com \
    /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.