ia64/xen-unstable

changeset 18747:1137464400a8

CPUIDLE: add idx field

This patch adds an idx field in the 'struct acpi_processor_cx'. It can
simplify some coding lines.

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
Signed-off-by: Wei Gang <gang.wei@intel.com>=
author Keir Fraser <keir.fraser@citrix.com>
date Thu Oct 30 13:33:17 2008 +0000 (2008-10-30)
parents e8f0e625e043
children 112e81ae5824
files xen/arch/x86/acpi/cpu_idle.c xen/include/xen/cpuidle.h
line diff
     1.1 --- a/xen/arch/x86/acpi/cpu_idle.c	Thu Oct 30 13:27:07 2008 +0000
     1.2 +++ b/xen/arch/x86/acpi/cpu_idle.c	Thu Oct 30 13:33:17 2008 +0000
     1.3 @@ -75,13 +75,14 @@ static void print_acpi_power(uint32_t cp
     1.4  
     1.5      printk("==cpu%d==\n", cpu);
     1.6      printk("active state:\t\tC%d\n",
     1.7 -           power->last_state ? (int)(power->last_state - power->states) : -1);
     1.8 +           power->last_state ? power->last_state->idx : -1);
     1.9      printk("max_cstate:\t\tC%d\n", max_cstate);
    1.10      printk("states:\n");
    1.11      
    1.12      for ( i = 1; i < power->count; i++ )
    1.13      {
    1.14 -        printk((power->last_state == &power->states[i]) ? "   *" : "    ");
    1.15 +        printk((power->last_state && power->last_state->idx == i) ?
    1.16 +               "   *" : "    ");
    1.17          printk("C%d:\t", i);
    1.18          printk("type[C%d] ", power->states[i].type);
    1.19          printk("latency[%03d] ", power->states[i].latency);
    1.20 @@ -222,7 +223,7 @@ static void acpi_processor_idle(void)
    1.21          if ( power->flags.bm_check && acpi_idle_bm_check()
    1.22               && cx->type == ACPI_STATE_C3 )
    1.23              cx = power->safe_state;
    1.24 -        if ( cx - &power->states[0] > max_cstate )
    1.25 +        if ( cx->idx > max_cstate )
    1.26              cx = &power->states[max_cstate];
    1.27      }
    1.28      if ( !cx )
    1.29 @@ -328,7 +329,7 @@ static void acpi_processor_idle(void)
    1.30          }
    1.31  
    1.32          /* Trace cpu idle entry */
    1.33 -        TRACE_1D(TRC_PM_IDLE_ENTRY, cx - &power->states[0]);
    1.34 +        TRACE_1D(TRC_PM_IDLE_ENTRY, cx->idx);
    1.35          /*
    1.36           * Before invoking C3, be aware that TSC/APIC timer may be 
    1.37           * stopped by H/W. Without carefully handling of TSC/APIC stop issues,
    1.38 @@ -349,7 +350,7 @@ static void acpi_processor_idle(void)
    1.39          /* recovering TSC */
    1.40          cstate_restore_tsc();
    1.41          /* Trace cpu idle exit */
    1.42 -        TRACE_1D(TRC_PM_IDLE_EXIT, cx - &power->states[0]);
    1.43 +        TRACE_1D(TRC_PM_IDLE_EXIT, cx->idx);
    1.44  
    1.45          if ( power->flags.bm_check && power->flags.bm_control )
    1.46          {
    1.47 @@ -387,8 +388,13 @@ static void acpi_processor_idle(void)
    1.48  
    1.49  static int init_cx_pminfo(struct acpi_processor_power *acpi_power)
    1.50  {
    1.51 +    int i;
    1.52 +
    1.53      memset(acpi_power, 0, sizeof(*acpi_power));
    1.54  
    1.55 +    for ( i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++ )
    1.56 +        acpi_power->states[i].idx = i;
    1.57 +
    1.58      acpi_power->states[ACPI_STATE_C1].type = ACPI_STATE_C1;
    1.59  
    1.60      acpi_power->states[ACPI_STATE_C0].valid = 1;
    1.61 @@ -761,8 +767,7 @@ int pmstat_get_cx_stat(uint32_t cpuid, s
    1.62          return 0;
    1.63      }
    1.64  
    1.65 -    stat->last = (power->last_state) ?
    1.66 -        (int)(power->last_state - &power->states[0]) : 0;
    1.67 +    stat->last = power->last_state ? power->last_state->idx : 0;
    1.68      stat->nr = power->count;
    1.69      stat->idle_time = v->runstate.time[RUNSTATE_running];
    1.70      if ( v->is_running )
     2.1 --- a/xen/include/xen/cpuidle.h	Thu Oct 30 13:27:07 2008 +0000
     2.2 +++ b/xen/include/xen/cpuidle.h	Thu Oct 30 13:33:17 2008 +0000
     2.3 @@ -32,6 +32,7 @@
     2.4  
     2.5  struct acpi_processor_cx
     2.6  {
     2.7 +    u8 idx;
     2.8      u8 valid;
     2.9      u8 type;
    2.10      u32 address;