From d630b488a5c17565ecfb8eb566f6d2f77dc28469 Mon Sep 17 00:00:00 2001 From: Liang Chen Date: Thu, 13 Dec 2018 16:18:56 +0800 Subject: [PATCH] drivers: cpufreq_interactive: recover tunables when switch governor Android will switch governor between different applications, so we must recover tunables for interactive governor. Change-Id: Ieb3d1f46ec628bf0a70d2656b63dd255f36770e0 Signed-off-by: Liang Chen --- drivers/cpufreq/cpufreq_interactive.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index 3886b39c5861..2792e0836e0a 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -129,6 +129,9 @@ struct cpufreq_interactive_tunables { /* For cases where we have single governor instance for system */ static struct cpufreq_interactive_tunables *common_tunables; +#ifdef CONFIG_ARCH_ROCKCHIP +static struct cpufreq_interactive_tunables backup_tunables[2]; +#endif static struct attribute_group *get_sysfs_attr(void); @@ -1280,6 +1283,7 @@ static struct input_handler cpufreq_interactive_input_handler = { static void rockchip_cpufreq_policy_init(struct cpufreq_policy *policy) { struct cpufreq_interactive_tunables *tunables = policy->governor_data; + int index; tunables->min_sample_time = 40 * USEC_PER_MSEC; tunables->boostpulse_duration_val = 40 * USEC_PER_MSEC; @@ -1290,6 +1294,12 @@ static void rockchip_cpufreq_policy_init(struct cpufreq_policy *policy) } else { tunables->hispeed_freq = 816000; } + + index = (policy->cpu == 0) ? 0 : 1; + if (!backup_tunables[index].usage_count) + backup_tunables[index] = *tunables; + else + *tunables = backup_tunables[index]; } #endif @@ -1388,6 +1398,15 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy, sysfs_remove_group(get_governor_parent_kobj(policy), get_sysfs_attr()); +#ifdef CONFIG_ARCH_ROCKCHIP + if (policy->cpu == 0) { + backup_tunables[0] = *tunables; + backup_tunables[0].usage_count = 1; + } else { + backup_tunables[1] = *tunables; + backup_tunables[1].usage_count = 1; + } +#endif kfree(tunables); common_tunables = NULL; }