diff options
Diffstat (limited to 'drivers/cpuidle/governors/ladder.c')
| -rw-r--r-- | drivers/cpuidle/governors/ladder.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c index ba7b9a6b17a1..a4bec3f919aa 100644 --- a/drivers/cpuidle/governors/ladder.c +++ b/drivers/cpuidle/governors/ladder.c | |||
| @@ -67,10 +67,17 @@ static int ladder_select_state(struct cpuidle_device *dev) | |||
| 67 | struct ladder_device *ldev = &__get_cpu_var(ladder_devices); | 67 | struct ladder_device *ldev = &__get_cpu_var(ladder_devices); |
| 68 | struct ladder_device_state *last_state; | 68 | struct ladder_device_state *last_state; |
| 69 | int last_residency, last_idx = ldev->last_state_idx; | 69 | int last_residency, last_idx = ldev->last_state_idx; |
| 70 | int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY); | ||
| 70 | 71 | ||
| 71 | if (unlikely(!ldev)) | 72 | if (unlikely(!ldev)) |
| 72 | return 0; | 73 | return 0; |
| 73 | 74 | ||
| 75 | /* Special case when user has set very strict latency requirement */ | ||
| 76 | if (unlikely(latency_req == 0)) { | ||
| 77 | ladder_do_selection(ldev, last_idx, 0); | ||
| 78 | return 0; | ||
| 79 | } | ||
| 80 | |||
| 74 | last_state = &ldev->states[last_idx]; | 81 | last_state = &ldev->states[last_idx]; |
| 75 | 82 | ||
| 76 | if (dev->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) | 83 | if (dev->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID) |
| @@ -81,8 +88,7 @@ static int ladder_select_state(struct cpuidle_device *dev) | |||
| 81 | /* consider promotion */ | 88 | /* consider promotion */ |
| 82 | if (last_idx < dev->state_count - 1 && | 89 | if (last_idx < dev->state_count - 1 && |
| 83 | last_residency > last_state->threshold.promotion_time && | 90 | last_residency > last_state->threshold.promotion_time && |
| 84 | dev->states[last_idx + 1].exit_latency <= | 91 | dev->states[last_idx + 1].exit_latency <= latency_req) { |
| 85 | pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) { | ||
| 86 | last_state->stats.promotion_count++; | 92 | last_state->stats.promotion_count++; |
| 87 | last_state->stats.demotion_count = 0; | 93 | last_state->stats.demotion_count = 0; |
| 88 | if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) { | 94 | if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) { |
| @@ -92,7 +98,19 @@ static int ladder_select_state(struct cpuidle_device *dev) | |||
| 92 | } | 98 | } |
| 93 | 99 | ||
| 94 | /* consider demotion */ | 100 | /* consider demotion */ |
| 95 | if (last_idx > 0 && | 101 | if (last_idx > CPUIDLE_DRIVER_STATE_START && |
| 102 | dev->states[last_idx].exit_latency > latency_req) { | ||
| 103 | int i; | ||
| 104 | |||
| 105 | for (i = last_idx - 1; i > CPUIDLE_DRIVER_STATE_START; i--) { | ||
| 106 | if (dev->states[i].exit_latency <= latency_req) | ||
| 107 | break; | ||
| 108 | } | ||
| 109 | ladder_do_selection(ldev, last_idx, i); | ||
| 110 | return i; | ||
| 111 | } | ||
| 112 | |||
| 113 | if (last_idx > CPUIDLE_DRIVER_STATE_START && | ||
| 96 | last_residency < last_state->threshold.demotion_time) { | 114 | last_residency < last_state->threshold.demotion_time) { |
| 97 | last_state->stats.demotion_count++; | 115 | last_state->stats.demotion_count++; |
| 98 | last_state->stats.promotion_count = 0; | 116 | last_state->stats.promotion_count = 0; |
| @@ -117,7 +135,7 @@ static int ladder_enable_device(struct cpuidle_device *dev) | |||
| 117 | struct ladder_device_state *lstate; | 135 | struct ladder_device_state *lstate; |
| 118 | struct cpuidle_state *state; | 136 | struct cpuidle_state *state; |
| 119 | 137 | ||
| 120 | ldev->last_state_idx = 0; | 138 | ldev->last_state_idx = CPUIDLE_DRIVER_STATE_START; |
| 121 | 139 | ||
| 122 | for (i = 0; i < dev->state_count; i++) { | 140 | for (i = 0; i < dev->state_count; i++) { |
| 123 | state = &dev->states[i]; | 141 | state = &dev->states[i]; |
