[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] CPUIDLE: add idx field



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1225373597 0
# Node ID 1137464400a81bbfe7a5093a07102b2ded7a4684
# Parent  e8f0e625e043cd71e61dc6fb6124a3367298bbfe
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@xxxxxxxxx>
Signed-off-by: Wei Gang <gang.wei@xxxxxxxxx>=
---
 xen/arch/x86/acpi/cpu_idle.c |   19 ++++++++++++-------
 xen/include/xen/cpuidle.h    |    1 +
 2 files changed, 13 insertions(+), 7 deletions(-)

diff -r e8f0e625e043 -r 1137464400a8 xen/arch/x86/acpi/cpu_idle.c
--- a/xen/arch/x86/acpi/cpu_idle.c      Thu Oct 30 13:27:07 2008 +0000
+++ b/xen/arch/x86/acpi/cpu_idle.c      Thu Oct 30 13:33:17 2008 +0000
@@ -75,13 +75,14 @@ static void print_acpi_power(uint32_t cp
 
     printk("==cpu%d==\n", cpu);
     printk("active state:\t\tC%d\n",
-           power->last_state ? (int)(power->last_state - power->states) : -1);
+           power->last_state ? power->last_state->idx : -1);
     printk("max_cstate:\t\tC%d\n", max_cstate);
     printk("states:\n");
     
     for ( i = 1; i < power->count; i++ )
     {
-        printk((power->last_state == &power->states[i]) ? "   *" : "    ");
+        printk((power->last_state && power->last_state->idx == i) ?
+               "   *" : "    ");
         printk("C%d:\t", i);
         printk("type[C%d] ", power->states[i].type);
         printk("latency[%03d] ", power->states[i].latency);
@@ -222,7 +223,7 @@ static void acpi_processor_idle(void)
         if ( power->flags.bm_check && acpi_idle_bm_check()
              && cx->type == ACPI_STATE_C3 )
             cx = power->safe_state;
-        if ( cx - &power->states[0] > max_cstate )
+        if ( cx->idx > max_cstate )
             cx = &power->states[max_cstate];
     }
     if ( !cx )
@@ -328,7 +329,7 @@ static void acpi_processor_idle(void)
         }
 
         /* Trace cpu idle entry */
-        TRACE_1D(TRC_PM_IDLE_ENTRY, cx - &power->states[0]);
+        TRACE_1D(TRC_PM_IDLE_ENTRY, cx->idx);
         /*
          * Before invoking C3, be aware that TSC/APIC timer may be 
          * stopped by H/W. Without carefully handling of TSC/APIC stop issues,
@@ -349,7 +350,7 @@ static void acpi_processor_idle(void)
         /* recovering TSC */
         cstate_restore_tsc();
         /* Trace cpu idle exit */
-        TRACE_1D(TRC_PM_IDLE_EXIT, cx - &power->states[0]);
+        TRACE_1D(TRC_PM_IDLE_EXIT, cx->idx);
 
         if ( power->flags.bm_check && power->flags.bm_control )
         {
@@ -387,7 +388,12 @@ static void acpi_processor_idle(void)
 
 static int init_cx_pminfo(struct acpi_processor_power *acpi_power)
 {
+    int i;
+
     memset(acpi_power, 0, sizeof(*acpi_power));
+
+    for ( i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++ )
+        acpi_power->states[i].idx = i;
 
     acpi_power->states[ACPI_STATE_C1].type = ACPI_STATE_C1;
 
@@ -761,8 +767,7 @@ int pmstat_get_cx_stat(uint32_t cpuid, s
         return 0;
     }
 
-    stat->last = (power->last_state) ?
-        (int)(power->last_state - &power->states[0]) : 0;
+    stat->last = power->last_state ? power->last_state->idx : 0;
     stat->nr = power->count;
     stat->idle_time = v->runstate.time[RUNSTATE_running];
     if ( v->is_running )
diff -r e8f0e625e043 -r 1137464400a8 xen/include/xen/cpuidle.h
--- a/xen/include/xen/cpuidle.h Thu Oct 30 13:27:07 2008 +0000
+++ b/xen/include/xen/cpuidle.h Thu Oct 30 13:33:17 2008 +0000
@@ -32,6 +32,7 @@
 
 struct acpi_processor_cx
 {
+    u8 idx;
     u8 valid;
     u8 type;
     u32 address;

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.