From 20ecb229c5b2aa9b87bbcd42b37a0ee523ae0fa7 Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Tue, 25 Jul 2023 16:38:34 +0000 Subject: [PATCH] ANDROID: cpuidle: teo: Export a function that allows modifying util_threshold There are some corner cases where we do worse in power because the threshold is too low. Until these cases are better understood and addressed upstream, provide a function for vendors to override this value with something more suitable in their modules. Bug: 289293494 Signed-off-by: Qais Yousef Change-Id: I95dd36718a317f3fcb2a9f4bc87dd3390a4f7d7d --- drivers/cpuidle/governors/teo.c | 13 +++++++++++++ include/linux/cpuidle.h | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c index 987fc5f3997d..356ffc41d284 100644 --- a/drivers/cpuidle/governors/teo.c +++ b/drivers/cpuidle/governors/teo.c @@ -202,6 +202,19 @@ struct teo_cpu { static DEFINE_PER_CPU(struct teo_cpu, teo_cpus); +unsigned long teo_cpu_get_util_threshold(int cpu) +{ + struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, cpu); + return cpu_data->util_threshold; +} +EXPORT_SYMBOL_GPL(teo_cpu_get_util_threshold); +void teo_cpu_set_util_threshold(int cpu, unsigned long util) +{ + struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, cpu); + cpu_data->util_threshold = util; +} +EXPORT_SYMBOL_GPL(teo_cpu_set_util_threshold); + /** * teo_cpu_is_utilized - Check if the CPU's util is above the threshold * @cpu: Target CPU diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 1035cb423fc1..c223ca3eebaa 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -314,4 +314,12 @@ extern s64 cpuidle_governor_latency_req(unsigned int cpu); #define CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM(low_level_idle_enter, idx, state) \ __CPU_PM_CPU_IDLE_ENTER(low_level_idle_enter, idx, state, 1) +#ifdef CONFIG_CPU_IDLE_GOV_TEO +unsigned long teo_cpu_get_util_threshold(int cpu); +void teo_cpu_set_util_threshold(int cpu, unsigned long util); +#else +static inline unsigned long teo_cpu_get_util_threshold(int cpu) {return -1;} +static inline void teo_cpu_set_util_threshold(int cpu, unsigned long util) {} +#endif + #endif /* _LINUX_CPUIDLE_H */