[RAMEN9610-8149] [COMMON] cpufreq: acme: Use policy_update_with_DM_CALL
authorHyeonseong Gil <hs.gil@samsung.com>
Mon, 21 May 2018 04:08:27 +0000 (13:08 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:23:07 +0000 (20:23 +0300)
Race condition occurs betwwen policy_update and DM_CALL.
To prevent the problem, we changed to use policy_upate_with_DM_CALL()
to update all at once.

Change-Id: Ic8442c103db13ed56f6c0497d79e0974c6af5413
Signed-off-by: Hyeonseong Gil <hs.gil@samsung.com>
drivers/cpufreq/exynos-acme.c

index 1163a24dfe39238328511e2b665a25955a0a6b58..e9339354afc9e5c08baf929862aec68e802411f3 100644 (file)
@@ -412,6 +412,8 @@ static int exynos_cpufreq_target(struct cpufreq_policy *policy,
        struct exynos_cpufreq_domain *domain = find_domain(policy->cpu);
        unsigned long freq;
        unsigned int index;
+       unsigned int policy_min, policy_max;
+       unsigned int pm_qos_min, pm_qos_max;
 
        if (!domain)
                return -EINVAL;
@@ -435,7 +437,15 @@ static int exynos_cpufreq_target(struct cpufreq_policy *policy,
        }
        mutex_unlock(&domain->lock);
 
-       return DM_CALL(domain->dm_type, &freq);
+       policy_min = policy->min;
+       policy_max = policy->max;
+
+       pm_qos_min = pm_qos_request(domain->pm_qos_min_class);
+       pm_qos_max = pm_qos_request(domain->pm_qos_max_class);
+
+       freq = (unsigned long)target_freq;
+       return policy_update_with_DM_CALL(domain->dm_type, max(policy_min, pm_qos_min),
+                               min(policy_max, pm_qos_max), &freq);
 }
 
 static int __exynos_cpufreq_suspend(struct exynos_cpufreq_domain *domain)
@@ -553,36 +563,6 @@ static struct cpufreq_driver exynos_driver = {
 /*********************************************************************
  *                      SUPPORT for DVFS MANAGER                     *
  *********************************************************************/
-static void update_dm_constraint(struct exynos_cpufreq_domain *domain,
-                                       struct cpufreq_policy *new_policy)
-{
-       struct cpufreq_policy *policy;
-       unsigned int policy_min, policy_max;
-       unsigned int pm_qos_min, pm_qos_max;
-
-       if (new_policy) {
-               policy_min = new_policy->min;
-               policy_max = new_policy->max;
-       } else {
-               struct cpumask mask;
-               cpumask_and(&mask, &domain->cpus, cpu_online_mask);
-               if (cpumask_empty(&mask))
-                       return;
-               policy = cpufreq_cpu_get(cpumask_first(&mask));
-               if (!policy)
-                       return;
-
-               policy_min = policy->min;
-               policy_max = policy->max;
-               cpufreq_cpu_put(policy);
-       }
-
-       pm_qos_min = pm_qos_request(domain->pm_qos_min_class);
-       pm_qos_max = pm_qos_request(domain->pm_qos_max_class);
-
-       policy_update_call_to_DM(domain->dm_type, max(policy_min, pm_qos_min),
-                                                 min(policy_max, pm_qos_max));
-}
 
 static int dm_scaler(int dm_type, void *devdata, unsigned int target_freq,
                                                unsigned int relation)
@@ -663,8 +643,6 @@ static int exynos_cpufreq_pm_qos_callback(struct notifier_block *nb,
        if (!policy)
                return NOTIFY_BAD;
 
-       update_dm_constraint(domain, NULL);
-
        ret = need_update_freq(domain, pm_qos_class, val);
        if (ret < 0)
                return NOTIFY_BAD;
@@ -691,7 +669,6 @@ static int exynos_cpufreq_policy_callback(struct notifier_block *nb,
 
        switch (event) {
        case CPUFREQ_NOTIFY:
-               update_dm_constraint(domain, policy);
                arch_set_freq_scale(&domain->cpus, domain->old, policy->max);
                break;
        }