]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
cpuidle: use last_state which can reflect the actual state entered
authorVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Tue, 27 Jan 2009 16:38:45 +0000 (17:38 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 6 Feb 2009 22:00:40 +0000 (14:00 -0800)
commit 887e301aa1105326f1412a98749024263b1031c7 upstream

cpuidle accounts the idle time for the C-state it was trying to enter and
not to the actual state that the driver eventually entered. The driver may
select a different state than the one chosen by cpuidle due to
constraints like bus-mastering, etc.

Change the time acounting code to look at the dev->last_state after
returning from target_state->enter(). Driver can modify dev->last_state
internally, inside the enter routine to reflect the actual C-state
entered.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Tested-by: Kevin Hilman <khilman@deeprootsystems.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Cc: Thomas Renninger <trenn@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/cpuidle/cpuidle.c

index 19e746a7a0f764cb0a9ca93e5ba6813a1eaede38..bb6e3b338043e13e8e87bc8fceaad67e8f6a9dcc 100644 (file)
@@ -71,8 +71,11 @@ static void cpuidle_idle_call(void)
        target_state = &dev->states[next_state];
 
        /* enter the state and update stats */
-       dev->last_residency = target_state->enter(dev, target_state);
        dev->last_state = target_state;
+       dev->last_residency = target_state->enter(dev, target_state);
+       if (dev->last_state)
+               target_state = dev->last_state;
+
        target_state->time += (unsigned long long)dev->last_residency;
        target_state->usage++;