debuggers.hg

changeset 21170:b432d7d9be92

Add Xen support for AMD Turbo/Boost

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@amd.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Apr 09 08:53:19 2010 +0100 (2010-04-09)
parents 6c3db6c83a02
children b44a4f9b9a62
files xen/arch/x86/acpi/cpufreq/powernow.c
line diff
     1.1 --- a/xen/arch/x86/acpi/cpufreq/powernow.c	Fri Apr 09 08:52:43 2010 +0100
     1.2 +++ b/xen/arch/x86/acpi/cpufreq/powernow.c	Fri Apr 09 08:53:19 2010 +0100
     1.3 @@ -39,6 +39,7 @@
     1.4  #include <acpi/cpufreq/cpufreq.h>
     1.5  
     1.6  #define CPUID_FREQ_VOLT_CAPABILITIES    0x80000007
     1.7 +#define CPB_CAPABLE             0x00000200
     1.8  #define USE_HW_PSTATE           0x00000080
     1.9  #define HW_PSTATE_MASK          0x00000007
    1.10  #define HW_PSTATE_VALID_MASK    0x80000000
    1.11 @@ -48,6 +49,7 @@
    1.12  #define MSR_PSTATE_STATUS       0xc0010063 /* Pstate Status MSR */
    1.13  #define MSR_PSTATE_CTRL         0xc0010062 /* Pstate control MSR */
    1.14  #define MSR_PSTATE_CUR_LIMIT    0xc0010061 /* pstate current limit MSR */
    1.15 +#define MSR_HWCR_CPBDIS_MASK    0x02000000
    1.16  
    1.17  struct powernow_cpufreq_data {
    1.18      struct processor_performance *acpi_data;
    1.19 @@ -62,8 +64,8 @@ static struct powernow_cpufreq_data *drv
    1.20  struct drv_cmd {
    1.21      unsigned int type;
    1.22      cpumask_t mask;
    1.23 -    u64 addr;
    1.24      u32 val;
    1.25 +    int turbo;
    1.26  };
    1.27  
    1.28  static void transition_pstate(void *drvcmd)
    1.29 @@ -71,6 +73,15 @@ static void transition_pstate(void *drvc
    1.30      struct drv_cmd *cmd;
    1.31      cmd = (struct drv_cmd *) drvcmd;
    1.32  
    1.33 +    if (cmd->turbo != CPUFREQ_TURBO_UNSUPPORTED) {
    1.34 +        u32 lo, hi;
    1.35 +        rdmsr(MSR_K8_HWCR, lo, hi);
    1.36 +        if (cmd->turbo == CPUFREQ_TURBO_ENABLED)
    1.37 +            lo &= ~MSR_HWCR_CPBDIS_MASK;
    1.38 +        else
    1.39 +            lo |= MSR_HWCR_CPBDIS_MASK; 
    1.40 +        wrmsr(MSR_K8_HWCR, lo, hi);
    1.41 +    }
    1.42      wrmsr(MSR_PSTATE_CTRL, cmd->val, 0);
    1.43  }
    1.44  
    1.45 @@ -121,6 +132,7 @@ static int powernow_cpufreq_target(struc
    1.46      freqs.new = data->freq_table[next_state].frequency;
    1.47  
    1.48      cmd.val = next_perf_state;
    1.49 +    cmd.turbo = policy->turbo;
    1.50  
    1.51      on_selected_cpus(&cmd.mask, transition_pstate, &cmd, 0);
    1.52  
    1.53 @@ -159,6 +171,7 @@ static int powernow_cpufreq_cpu_init(str
    1.54      unsigned int result = 0;
    1.55      struct processor_performance *perf;
    1.56      u32 max_hw_pstate, hi = 0, lo = 0;
    1.57 +    struct cpuinfo_x86 *c = &cpu_data[policy->cpu];
    1.58  
    1.59      data = xmalloc(struct powernow_cpufreq_data);
    1.60      if (!data)
    1.61 @@ -234,6 +247,15 @@ static int powernow_cpufreq_cpu_init(str
    1.62      if (result)
    1.63          goto err_freqfree;
    1.64  
    1.65 +    if (c->cpuid_level >= 6) {
    1.66 +        unsigned int edx;
    1.67 +        edx = cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES);
    1.68 +        if ((edx & CPB_CAPABLE) == CPB_CAPABLE) {
    1.69 +            policy->turbo = CPUFREQ_TURBO_ENABLED;
    1.70 +            printk(XENLOG_INFO "Core Boost/Turbo detected and enabled\n");
    1.71 +        }
    1.72 +    }
    1.73 +      
    1.74      /*
    1.75       * the first call to ->target() should result in us actually
    1.76       * writing something to the appropriate registers.