WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] [retry 3] 2/3 Add Xen support for AMD Turbo boost

To: xen-devel@xxxxxxxxxxxxxxxxxxx, ke.yu@xxxxxxxxx
Subject: [Xen-devel] [PATCH] [retry 3] 2/3 Add Xen support for AMD Turbo boost
From: Mark Langsdorf <mark.langsdorf@xxxxxxx>
Date: Wed, 31 Mar 2010 14:25:57 -0500
Cc:
Delivery-date: Wed, 31 Mar 2010 12:26:46 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: KMail/1.12.4 (Linux/2.6.31-rc6-tip; KDE/4.3.5; x86_64; ; )
# HG changeset patch
# User mark.langsdorf@xxxxxxx
# Date 1270061925 18000
# Node ID c00eb5a678e61f4da0db7b4bdeab1660060376d2
# Parent  e86769595f59664124dcc5fef3d10e08338a3ef1
Add support for disabling AMD's Boost feature.  Boost is similar to
Intel's Turbo and uses the same high level interface.  The low
level implementation is different and encapsulated in the powernow
driver for cpufreq.

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

diff -r e86769595f59 -r c00eb5a678e6 xen/arch/x86/acpi/cpufreq/powernow.c
--- a/xen/arch/x86/acpi/cpufreq/powernow.c      Wed Mar 31 13:58:13 2010 -0500
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c      Wed Mar 31 13:58:45 2010 -0500
@@ -39,6 +39,7 @@
 #include <acpi/cpufreq/cpufreq.h>
 
 #define CPUID_FREQ_VOLT_CAPABILITIES    0x80000007
+#define CPB_CAPABLE             0x00000200
 #define USE_HW_PSTATE           0x00000080
 #define HW_PSTATE_MASK          0x00000007
 #define HW_PSTATE_VALID_MASK    0x80000000
@@ -48,6 +49,7 @@
 #define MSR_PSTATE_STATUS       0xc0010063 /* Pstate Status MSR */
 #define MSR_PSTATE_CTRL         0xc0010062 /* Pstate control MSR */
 #define MSR_PSTATE_CUR_LIMIT    0xc0010061 /* pstate current limit MSR */
+#define MSR_HWCR_CPBDIS_MASK    0x02000000
 
 struct powernow_cpufreq_data {
     struct processor_performance *acpi_data;
@@ -62,8 +64,8 @@
 struct drv_cmd {
     unsigned int type;
     cpumask_t mask;
-    u64 addr;
     u32 val;
+    int turbo;
 };
 
 static void transition_pstate(void *drvcmd)
@@ -71,6 +73,15 @@
     struct drv_cmd *cmd;
     cmd = (struct drv_cmd *) drvcmd;
 
+    if (cmd->turbo != CPUFREQ_TURBO_UNSUPPORTED) {
+        u32 lo, hi;
+        rdmsr(MSR_K8_HWCR, lo, hi);
+        if (cmd->turbo == CPUFREQ_TURBO_ENABLED)
+            lo &= ~MSR_HWCR_CPBDIS_MASK;
+        else
+            lo |= MSR_HWCR_CPBDIS_MASK; 
+        wrmsr(MSR_K8_HWCR, lo, hi);
+    }
     wrmsr(MSR_PSTATE_CTRL, cmd->val, 0);
 }
 
@@ -121,6 +132,7 @@
     freqs.new = data->freq_table[next_state].frequency;
 
     cmd.val = next_perf_state;
+    cmd.turbo = policy->turbo;
 
     on_selected_cpus(&cmd.mask, transition_pstate, &cmd, 0);
 
@@ -159,6 +171,7 @@
     unsigned int result = 0;
     struct processor_performance *perf;
     u32 max_hw_pstate, hi = 0, lo = 0;
+    struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
 
     data = xmalloc(struct powernow_cpufreq_data);
     if (!data)
@@ -234,6 +247,15 @@
     if (result)
         goto err_freqfree;
 
+    if (c->cpuid_level >= 6) {
+        unsigned int edx;
+        edx = cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES);
+        if ((edx & CPB_CAPABLE) == CPB_CAPABLE) {
+            policy->turbo = CPUFREQ_TURBO_ENABLED;
+            printk(XENLOG_INFO "Core Boost/Turbo detected and enabled\n");
+        }
+    }
+      
     /*
      * the first call to ->target() should result in us actually
      * writing something to the appropriate registers.


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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] [retry 3] 2/3 Add Xen support for AMD Turbo boost, Mark Langsdorf <=