diff mbox

[2/3] cpuidle: check for pm qos constraint override

Message ID 1385508011-26914-3-git-send-email-jacob.jun.pan@linux.intel.com (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Jacob Pan Nov. 26, 2013, 11:20 p.m. UTC
If a QOS class is disabled due to platform thermal or power capping
needs, idle governor shall pick the deepest idle state to conserve power.

Power saving should be prioritized over QOS in this case in that
hardware based catastrophic measure is more intrusive than
managed idle.

Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
---
 drivers/cpuidle/governors/ladder.c |  4 ++++
 drivers/cpuidle/governors/menu.c   | 13 +++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index 9f08e8c..40161d3 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -71,6 +71,10 @@  static int ladder_select_state(struct cpuidle_driver *drv,
 	int last_residency, last_idx = ldev->last_state_idx;
 	int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
 
+	/* qos ignored, pick the deepest idle state */
+	if (unlikely(latency_req == PM_QOS_DEFAULT_VALUE))
+		return drv->state_count - 1;
+
 	/* Special case when user has set very strict latency requirement */
 	if (unlikely(latency_req == 0)) {
 		ladder_do_selection(ldev, last_idx, 0);
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index cf7f2f0..afa0088 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -297,12 +297,21 @@  static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 		data->needs_update = 0;
 	}
 
+	/* qos ignored, pick the deepest idle state */
+	if (unlikely(latency_req == PM_QOS_DEFAULT_VALUE)) {
+		struct cpuidle_state *s = &drv->states[drv->state_count - 1];
+
+		data->last_state_idx = drv->state_count - 1;
+		data->exit_us = s->exit_latency;
+		goto exit_done;
+	}
+
 	data->last_state_idx = 0;
 	data->exit_us = 0;
 
 	/* Special case when user has set very strict latency requirement */
 	if (unlikely(latency_req == 0))
-		return 0;
+		goto exit_done;
 
 	/* determine the expected residency time, round up */
 	t = ktime_to_timespec(tick_nohz_get_sleep_length());
@@ -361,7 +370,7 @@  static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 		data->last_state_idx = i;
 		data->exit_us = s->exit_latency;
 	}
-
+exit_done:
 	return data->last_state_idx;
 }