ia64/xen-unstable

changeset 18520:9cc4cebee50b

CPUIDLE: Support multiple C3 states

There may be multiple ACPI C3 states reported by BIOS. Those C3 states
may be different on latency & power. So made some modification to
support this case.

Signed-off-by: Wei Gang <gang.wei@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Sep 22 11:21:31 2008 +0100 (2008-09-22)
parents ad79f7af3916
children e61c7833dc9d
files xen/arch/x86/acpi/cpu_idle.c
line diff
     1.1 --- a/xen/arch/x86/acpi/cpu_idle.c	Mon Sep 22 11:16:56 2008 +0100
     1.2 +++ b/xen/arch/x86/acpi/cpu_idle.c	Mon Sep 22 11:21:31 2008 +0100
     1.3 @@ -61,7 +61,7 @@ extern u32 pmtmr_ioport;
     1.4  extern void (*pm_idle) (void);
     1.5  
     1.6  static void (*pm_idle_save) (void) __read_mostly;
     1.7 -unsigned int max_cstate __read_mostly = 2;
     1.8 +unsigned int max_cstate __read_mostly = ACPI_PROCESSOR_MAX_POWER - 1;
     1.9  integer_param("max_cstate", max_cstate);
    1.10  
    1.11  static struct acpi_processor_power processor_powers[NR_CPUS];
    1.12 @@ -72,17 +72,13 @@ static void print_acpi_power(uint32_t cp
    1.13  
    1.14      printk("==cpu%d==\n", cpu);
    1.15      printk("active state:\t\tC%d\n",
    1.16 -           (power->last_state) ? power->last_state->type : -1);
    1.17 +           power->last_state ? (int)(power->last_state - power->states) : -1);
    1.18      printk("max_cstate:\t\tC%d\n", max_cstate);
    1.19      printk("states:\n");
    1.20      
    1.21      for ( i = 1; i < power->count; i++ )
    1.22      {
    1.23 -        if ( power->last_state && 
    1.24 -             power->states[i].type == power->last_state->type )
    1.25 -            printk("   *");
    1.26 -        else
    1.27 -            printk("    ");
    1.28 +        printk((power->last_state == &power->states[i]) ? "   *" : "    ");
    1.29          printk("C%d:\t\t", i);
    1.30          printk("type[C%d] ", power->states[i].type);
    1.31          printk("latency[%03d] ", power->states[i].latency);
    1.32 @@ -222,7 +218,7 @@ static void acpi_processor_idle(void)
    1.33          if ( power->flags.bm_check && acpi_idle_bm_check()
    1.34               && cx->type == ACPI_STATE_C3 )
    1.35              cx = power->safe_state;
    1.36 -        if ( cx->type > max_cstate )
    1.37 +        if ( cx - &power->states[0] > max_cstate )
    1.38              cx = &power->states[max_cstate];
    1.39      }
    1.40      if ( !cx )
    1.41 @@ -565,7 +561,11 @@ static void set_cx(
    1.42      if ( check_cx(acpi_power, xen_cx) != 0 )
    1.43          return;
    1.44  
    1.45 -    cx = &acpi_power->states[xen_cx->type];
    1.46 +    if ( xen_cx->type == ACPI_STATE_C1 )
    1.47 +        cx = &acpi_power->states[1];
    1.48 +    else
    1.49 +        cx = &acpi_power->states[acpi_power->count];
    1.50 +
    1.51      if ( !cx->valid )
    1.52          acpi_power->count++;
    1.53  
    1.54 @@ -718,7 +718,8 @@ int pmstat_get_cx_stat(uint32_t cpuid, s
    1.55      uint64_t usage;
    1.56      int i;
    1.57  
    1.58 -    stat->last = (power->last_state) ? power->last_state->type : 0;
    1.59 +    stat->last = (power->last_state) ?
    1.60 +        (int)(power->last_state - &power->states[0]) : 0;
    1.61      stat->nr = processor_powers[cpuid].count;
    1.62      stat->idle_time = v->runstate.time[RUNSTATE_running];
    1.63      if ( v->is_running )