ia64/xen-unstable

changeset 19195:999c465f94f9

x86: cpufreq get_cur_val adjustment

c/s 19149 update cpufreq get_cur_val logic to avoid cross processor
call. However, to avoid null drv_data pointer, we adjust some logic in
this patch to keep advantage of c/s 19149 and at same time to avoid
null drv_data pointer.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Feb 11 13:07:45 2009 +0000 (2009-02-11)
parents ce391986ce35
children bf9cdbec516a
files xen/arch/x86/acpi/cpufreq/cpufreq.c
line diff
     1.1 --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c	Wed Feb 11 10:47:24 2009 +0000
     1.2 +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c	Wed Feb 11 13:07:45 2009 +0000
     1.3 @@ -183,7 +183,7 @@ static void drv_read(struct drv_cmd *cmd
     1.4      ASSERT(cpus_weight(cmd->mask) == 1);
     1.5  
     1.6      /* to reduce IPI for the sake of performance */
     1.7 -    if (cpu_isset(smp_processor_id(), cmd->mask))
     1.8 +    if (likely(cpu_isset(smp_processor_id(), cmd->mask)))
     1.9          do_drv_read((void *)cmd);
    1.10      else
    1.11          on_selected_cpus( cmd->mask, do_drv_read, (void *)cmd, 0, 1);
    1.12 @@ -196,6 +196,7 @@ static void drv_write(struct drv_cmd *cm
    1.13  
    1.14  static u32 get_cur_val(cpumask_t mask)
    1.15  {
    1.16 +    struct cpufreq_policy *policy;
    1.17      struct processor_performance *perf;
    1.18      struct drv_cmd cmd;
    1.19      unsigned int cpu = smp_processor_id();
    1.20 @@ -205,18 +206,19 @@ static u32 get_cur_val(cpumask_t mask)
    1.21  
    1.22      if (!cpu_isset(cpu, mask))
    1.23          cpu = first_cpu(mask);
    1.24 +    policy = cpufreq_cpu_policy[cpu];
    1.25  
    1.26 -    if (cpu >= NR_CPUS || !drv_data[cpu])
    1.27 +    if (cpu >= NR_CPUS || !policy || !drv_data[policy->cpu])
    1.28          return 0;    
    1.29  
    1.30 -    switch (drv_data[cpu]->cpu_feature) {
    1.31 +    switch (drv_data[policy->cpu]->cpu_feature) {
    1.32      case SYSTEM_INTEL_MSR_CAPABLE:
    1.33          cmd.type = SYSTEM_INTEL_MSR_CAPABLE;
    1.34          cmd.addr.msr.reg = MSR_IA32_PERF_STATUS;
    1.35          break;
    1.36      case SYSTEM_IO_CAPABLE:
    1.37          cmd.type = SYSTEM_IO_CAPABLE;
    1.38 -        perf = drv_data[cpu]->acpi_data;
    1.39 +        perf = drv_data[policy->cpu]->acpi_data;
    1.40          cmd.addr.io.port = perf->control_register.address;
    1.41          cmd.addr.io.bit_width = perf->control_register.bit_width;
    1.42          break;