[PATCH 3/6] cpuidle: teo: Don't always stop tick on one state

Christian Loehle posted 6 patches 1 year, 6 months ago
[PATCH 3/6] cpuidle: teo: Don't always stop tick on one state
Posted by Christian Loehle 1 year, 6 months ago
Even if we have only one state, we unfortunately still need to query
expected sleep length if state0 is a proper sleep state like WFI.
This enables teo to save energy even in that scenario.

Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
 drivers/cpuidle/governors/teo.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index 2c427dd4cac0..216d34747e3b 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -403,7 +403,14 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
 	/* Check if there is any choice in the first place. */
 	if (drv->state_count < 2) {
 		idx = 0;
-		goto out_tick;
+		if (drv->states[0].flags & CPUIDLE_FLAG_POLLING)
+			goto out_tick;
+		/*
+		 * If we only have one state and it is a proper one, check if
+		 * disabling the tick would be worth it.
+		 */
+		duration_ns = tick_nohz_get_sleep_length(&delta_tick);
+		goto end;
 	}

 	if (!dev->states_usage[0].disable)
--
2.34.1