cpufreq: acme: optimize the clock handling when buck off
authorJohnlay Park <jonglae.park@samsung.com>
Fri, 8 Jun 2018 11:41:00 +0000 (20:41 +0900)
committerlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 23 Jul 2018 05:58:41 +0000 (14:58 +0900)
Change-Id: I661307b7c2045111166bbb269f675c8ba691841b
Signed-off-by: Johnlay Park <jonglae.park@samsung.com>
drivers/cpufreq/exynos-acme.c
drivers/soc/samsung/exynos-cpupm.c

index a5e205534f7378cdaab4a20e17e50353ce9c38cb..c6d73cf19acf188530e754c864ecf3cfdc264c7a 100644 (file)
@@ -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;
 }
 
index 6f20c33194c8dbb376b660399a5c3f894aae625d..3754df21b463daf8953996faf8893e292f18daed 100644 (file)
@@ -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);
 }