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 <cl@rock-chips.com>
This commit is contained in:
Liang Chen
2018-12-13 16:18:56 +08:00
committed by Tao Huang
parent cb38ae649b
commit d630b488a5

View File

@@ -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;
}