From e93d34d9256e3823f75cca0051234afdd6eb85b5 Mon Sep 17 00:00:00 2001 From: "tao.zeng" Date: Tue, 2 Sep 2014 03:20:12 +0000 Subject: [PATCH] PD #98831(97021): fit cpu frequent out of avaliable table to proper cooling state When you set a value scaling_max_freq of cpu frequent which is not in scaling_avaliable_table, thermal governor will got a wrong cooling_state when doing step_wise and force update state of each trip point.This will cause scaling_max_freq loop between each trip point limitation. Change-Id: I8d04761474b02868db824157e0d549ed76341c80 --- drivers/thermal/cpu_cooling.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 9cc8e26a55b0..94ace6b66e63 100755 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -195,10 +195,21 @@ static int get_property(unsigned int cpu, unsigned long input, /* now we have a valid frequency entry */ freq = table[i].frequency; - if (property == GET_LEVEL && (unsigned int)input == freq) { + if (property == GET_LEVEL) { /* get level by frequency */ - *output = descend ? j : (max_level - j - 1); - return 0; + if (descend && input >= freq) { + *output = (j - 1); + if (input != freq) { + pr_debug("descend, fit %ld to level:%d, next freq:%d\n", input, *output, freq); + } + return 0; + } else if (!descend && input <= freq) { + *output = (max_level - j - 1); + if (input != freq) { + pr_debug("ascend, fit %ld to level:%d, next freq:%d\n", input, *output, freq); + } + return 0; + } } if (property == GET_FREQ && level == j) { /* get frequency by level */