mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
cpuidle: Move dev->last_residency update to driver enter routine; remove dev->last_state
Cpuidle governor only suggests the state to enter using the governor->select() interface, but allows the low level driver to override the recommended state. The actual entered state may be different because of software or hardware demotion. Software demotion is done by the back-end cpuidle driver and can be accounted correctly. Current cpuidle code uses last_state field to capture the actual state entered and based on that updates the statistics for the state entered. Ideally the driver enter routine should update the counters, and it should return the state actually entered rather than the time spent there. The generic cpuidle code should simply handle where the counters live in the sysfs namespace, not updating the counters. Reference: https://lkml.org/lkml/2011/3/25/52 Signed-off-by: Deepthi Dharwar <[email protected]> Signed-off-by: Trinabh Gupta <[email protected]> Tested-by: Jean Pihet <[email protected]> Reviewed-by: Kevin Hilman <[email protected]> Acked-by: Arjan van de Ven <[email protected]> Acked-by: Kevin Hilman <[email protected]> Signed-off-by: Len Brown <[email protected]>
This commit is contained in:
parent
c3b92c8787
commit
e978aa7d7d
12 changed files with 164 additions and 99 deletions
|
|
@ -62,7 +62,7 @@ int cpuidle_idle_call(void)
|
|||
{
|
||||
struct cpuidle_device *dev = __this_cpu_read(cpuidle_devices);
|
||||
struct cpuidle_state *target_state;
|
||||
int next_state;
|
||||
int next_state, entered_state;
|
||||
|
||||
if (off)
|
||||
return -ENODEV;
|
||||
|
|
@ -102,26 +102,27 @@ int cpuidle_idle_call(void)
|
|||
|
||||
target_state = &dev->states[next_state];
|
||||
|
||||
/* enter the state and update stats */
|
||||
dev->last_state = target_state;
|
||||
|
||||
trace_power_start(POWER_CSTATE, next_state, dev->cpu);
|
||||
trace_cpu_idle(next_state, dev->cpu);
|
||||
|
||||
dev->last_residency = target_state->enter(dev, target_state);
|
||||
entered_state = target_state->enter(dev, next_state);
|
||||
|
||||
trace_power_end(dev->cpu);
|
||||
trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);
|
||||
|
||||
if (dev->last_state)
|
||||
target_state = dev->last_state;
|
||||
|
||||
target_state->time += (unsigned long long)dev->last_residency;
|
||||
target_state->usage++;
|
||||
if (entered_state >= 0) {
|
||||
/* Update cpuidle counters */
|
||||
/* This can be moved to within driver enter routine
|
||||
* but that results in multiple copies of same code.
|
||||
*/
|
||||
dev->states[entered_state].time +=
|
||||
(unsigned long long)dev->last_residency;
|
||||
dev->states[entered_state].usage++;
|
||||
}
|
||||
|
||||
/* give the governor an opportunity to reflect on the outcome */
|
||||
if (cpuidle_curr_governor->reflect)
|
||||
cpuidle_curr_governor->reflect(dev);
|
||||
cpuidle_curr_governor->reflect(dev, entered_state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -172,11 +173,10 @@ void cpuidle_resume_and_unlock(void)
|
|||
EXPORT_SYMBOL_GPL(cpuidle_resume_and_unlock);
|
||||
|
||||
#ifdef CONFIG_ARCH_HAS_CPU_RELAX
|
||||
static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)
|
||||
static int poll_idle(struct cpuidle_device *dev, int index)
|
||||
{
|
||||
ktime_t t1, t2;
|
||||
s64 diff;
|
||||
int ret;
|
||||
|
||||
t1 = ktime_get();
|
||||
local_irq_enable();
|
||||
|
|
@ -188,8 +188,9 @@ static int poll_idle(struct cpuidle_device *dev, struct cpuidle_state *st)
|
|||
if (diff > INT_MAX)
|
||||
diff = INT_MAX;
|
||||
|
||||
ret = (int) diff;
|
||||
return ret;
|
||||
dev->last_residency = (int) diff;
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
static void poll_idle_init(struct cpuidle_device *dev)
|
||||
|
|
@ -248,7 +249,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev)
|
|||
dev->states[i].time = 0;
|
||||
}
|
||||
dev->last_residency = 0;
|
||||
dev->last_state = NULL;
|
||||
|
||||
smp_wmb();
|
||||
|
||||
|
|
|
|||
|
|
@ -153,11 +153,24 @@ static int ladder_enable_device(struct cpuidle_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* ladder_reflect - update the correct last_state_idx
|
||||
* @dev: the CPU
|
||||
* @index: the index of actual state entered
|
||||
*/
|
||||
static void ladder_reflect(struct cpuidle_device *dev, int index)
|
||||
{
|
||||
struct ladder_device *ldev = &__get_cpu_var(ladder_devices);
|
||||
if (index > 0)
|
||||
ldev->last_state_idx = index;
|
||||
}
|
||||
|
||||
static struct cpuidle_governor ladder_governor = {
|
||||
.name = "ladder",
|
||||
.rating = 10,
|
||||
.enable = ladder_enable_device,
|
||||
.select = ladder_select_state,
|
||||
.reflect = ladder_reflect,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -310,14 +310,17 @@ static int menu_select(struct cpuidle_device *dev)
|
|||
/**
|
||||
* menu_reflect - records that data structures need update
|
||||
* @dev: the CPU
|
||||
* @index: the index of actual entered state
|
||||
*
|
||||
* NOTE: it's important to be fast here because this operation will add to
|
||||
* the overall exit latency.
|
||||
*/
|
||||
static void menu_reflect(struct cpuidle_device *dev)
|
||||
static void menu_reflect(struct cpuidle_device *dev, int index)
|
||||
{
|
||||
struct menu_device *data = &__get_cpu_var(menu_devices);
|
||||
data->needs_update = 1;
|
||||
data->last_state_idx = index;
|
||||
if (index >= 0)
|
||||
data->needs_update = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue