From 6037f89cac3105f071567f02b328d9865ffda0cd Mon Sep 17 00:00:00 2001 From: Johnlay Park Date: Fri, 8 Jun 2018 20:41:00 +0900 Subject: [PATCH] cpufreq: acme: optimize the clock handling when buck off Change-Id: I661307b7c2045111166bbb269f675c8ba691841b Signed-off-by: Johnlay Park --- drivers/cpufreq/exynos-acme.c | 23 +++++++++++++++-------- drivers/soc/samsung/exynos-cpupm.c | 6 +++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/exynos-acme.c b/drivers/cpufreq/exynos-acme.c index a5e205534f73..c6d73cf19acf 100644 --- a/drivers/cpufreq/exynos-acme.c +++ b/drivers/cpufreq/exynos-acme.c @@ -134,6 +134,7 @@ static unsigned int index_to_freq(struct cpufreq_frequency_table *table, return table[index].frequency; } + /********************************************************************* * FREQUENCY SCALING * *********************************************************************/ @@ -144,10 +145,16 @@ static unsigned int index_to_freq(struct cpufreq_frequency_table *table, */ static unsigned int get_freq(struct exynos_cpufreq_domain *domain) { + int wakeup_flag = 0; unsigned int freq; - if (domain->need_awake) + if (domain->need_awake) { + if (likely(domain->old)) + return domain->old; + + wakeup_flag = 1; disable_power_mode(cpumask_any(&domain->cpus), POWERMODE_TYPE_CLUSTER); + } freq = (unsigned int)cal_dfs_get_rate(domain->cal_id); if (!freq) { @@ -155,7 +162,7 @@ static unsigned int get_freq(struct exynos_cpufreq_domain *domain) freq = domain->old; } - if (domain->need_awake) + if (unlikely(wakeup_flag)) enable_power_mode(cpumask_any(&domain->cpus), POWERMODE_TYPE_CLUSTER); return freq; @@ -166,23 +173,23 @@ static int set_freq(struct exynos_cpufreq_domain *domain, { int err; - if (domain->need_awake) - disable_power_mode(cpumask_any(&domain->cpus), POWERMODE_TYPE_CLUSTER); - dbg_snapshot_printk("ID %d: %d -> %d (%d)\n", domain->id, domain->old, target_freq, DSS_FLAG_IN); + if (domain->need_awake) + disable_power_mode(cpumask_any(&domain->cpus), POWERMODE_TYPE_CLUSTER); + err = cal_dfs_set_rate(domain->cal_id, target_freq); if (err < 0) pr_err("failed to scale frequency of domain%d (%d -> %d)\n", domain->id, domain->old, target_freq); - dbg_snapshot_printk("ID %d: %d -> %d (%d)\n", - domain->id, domain->old, target_freq, DSS_FLAG_OUT); - if (domain->need_awake) enable_power_mode(cpumask_any(&domain->cpus), POWERMODE_TYPE_CLUSTER); + dbg_snapshot_printk("ID %d: %d -> %d (%d)\n", + domain->id, domain->old, target_freq, DSS_FLAG_OUT); + return err; } diff --git a/drivers/soc/samsung/exynos-cpupm.c b/drivers/soc/samsung/exynos-cpupm.c index 6f20c33194c8..3754df21b463 100644 --- a/drivers/soc/samsung/exynos-cpupm.c +++ b/drivers/soc/samsung/exynos-cpupm.c @@ -508,8 +508,12 @@ void enable_power_mode(int cpu, int type) if (IS_NULL(mode)) break; - if (mode->type == type) + if (mode->type == type) { atomic_dec(&mode->disable); + spin_unlock(&cpupm_lock); + awake_cpus(&mode->siblings); + return; + } } spin_unlock(&cpupm_lock); } -- 2.20.1