diff options
| -rw-r--r-- | drivers/cpuidle/cpuidle.c | 42 | ||||
| -rw-r--r-- | drivers/cpuidle/cpuidle.h | 2 |
2 files changed, 31 insertions, 13 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 2f0083a51a9a..3e3e3e4d9581 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
| @@ -103,6 +103,34 @@ int cpuidle_play_dead(void) | |||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| 106 | * cpuidle_enter_state - enter the state and update stats | ||
| 107 | * @dev: cpuidle device for this cpu | ||
| 108 | * @drv: cpuidle driver for this cpu | ||
| 109 | * @next_state: index into drv->states of the state to enter | ||
| 110 | */ | ||
| 111 | int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, | ||
| 112 | int next_state) | ||
| 113 | { | ||
| 114 | int entered_state; | ||
| 115 | |||
| 116 | entered_state = cpuidle_enter_ops(dev, drv, next_state); | ||
| 117 | |||
| 118 | if (entered_state >= 0) { | ||
| 119 | /* Update cpuidle counters */ | ||
| 120 | /* This can be moved to within driver enter routine | ||
| 121 | * but that results in multiple copies of same code. | ||
| 122 | */ | ||
| 123 | dev->states_usage[entered_state].time += | ||
| 124 | (unsigned long long)dev->last_residency; | ||
| 125 | dev->states_usage[entered_state].usage++; | ||
| 126 | } else { | ||
| 127 | dev->last_residency = 0; | ||
| 128 | } | ||
| 129 | |||
| 130 | return entered_state; | ||
| 131 | } | ||
| 132 | |||
| 133 | /** | ||
| 106 | * cpuidle_idle_call - the main idle loop | 134 | * cpuidle_idle_call - the main idle loop |
| 107 | * | 135 | * |
| 108 | * NOTE: no locks or semaphores should be used here | 136 | * NOTE: no locks or semaphores should be used here |
| @@ -143,23 +171,11 @@ int cpuidle_idle_call(void) | |||
| 143 | trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu); | 171 | trace_power_start_rcuidle(POWER_CSTATE, next_state, dev->cpu); |
| 144 | trace_cpu_idle_rcuidle(next_state, dev->cpu); | 172 | trace_cpu_idle_rcuidle(next_state, dev->cpu); |
| 145 | 173 | ||
| 146 | entered_state = cpuidle_enter_ops(dev, drv, next_state); | 174 | entered_state = cpuidle_enter_state(dev, drv, next_state); |
| 147 | 175 | ||
| 148 | trace_power_end_rcuidle(dev->cpu); | 176 | trace_power_end_rcuidle(dev->cpu); |
| 149 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); | 177 | trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu); |
| 150 | 178 | ||
| 151 | if (entered_state >= 0) { | ||
| 152 | /* Update cpuidle counters */ | ||
| 153 | /* This can be moved to within driver enter routine | ||
| 154 | * but that results in multiple copies of same code. | ||
| 155 | */ | ||
| 156 | dev->states_usage[entered_state].time += | ||
| 157 | (unsigned long long)dev->last_residency; | ||
| 158 | dev->states_usage[entered_state].usage++; | ||
| 159 | } else { | ||
| 160 | dev->last_residency = 0; | ||
| 161 | } | ||
| 162 | |||
| 163 | /* give the governor an opportunity to reflect on the outcome */ | 179 | /* give the governor an opportunity to reflect on the outcome */ |
| 164 | if (cpuidle_curr_governor->reflect) | 180 | if (cpuidle_curr_governor->reflect) |
| 165 | cpuidle_curr_governor->reflect(dev, entered_state); | 181 | cpuidle_curr_governor->reflect(dev, entered_state); |
diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h index 7db186685c27..d8a3ccce8281 100644 --- a/drivers/cpuidle/cpuidle.h +++ b/drivers/cpuidle/cpuidle.h | |||
| @@ -14,6 +14,8 @@ extern struct list_head cpuidle_detected_devices; | |||
| 14 | extern struct mutex cpuidle_lock; | 14 | extern struct mutex cpuidle_lock; |
| 15 | extern spinlock_t cpuidle_driver_lock; | 15 | extern spinlock_t cpuidle_driver_lock; |
| 16 | extern int cpuidle_disabled(void); | 16 | extern int cpuidle_disabled(void); |
| 17 | extern int cpuidle_enter_state(struct cpuidle_device *dev, | ||
| 18 | struct cpuidle_driver *drv, int next_state); | ||
| 17 | 19 | ||
| 18 | /* idle loop */ | 20 | /* idle loop */ |
| 19 | extern void cpuidle_install_idle_handler(void); | 21 | extern void cpuidle_install_idle_handler(void); |
