samsung: emc: Fix bug that max_constraints violation bug.
authorYoungtae Lee <yt0729.lee@samsung.com>
Thu, 14 Jun 2018 05:47:16 +0000 (14:47 +0900)
committerlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 23 Jul 2018 05:59:33 +0000 (14:59 +0900)
This fxixes bug that current and real frequency is higher than
max frequency.

Change-Id: I3d488b642cea350e6dcc7d84eab9389d34639555
Signed-off-by: Youngtae Lee <yt0729.lee@samsung.com>
drivers/soc/samsung/exynos-emc.c
include/soc/samsung/exynos-emc.h

index 0e8ed77f5cc9f7c593120738da9e08b273cd5969..19ba035a96aa663c90ba8cc24bfd9d05e00bf9e0 100644 (file)
@@ -210,7 +210,7 @@ int emc_verify_constraints(void)
 {
        struct cpufreq_policy *policy;
        struct emc_domain *domain;
-       unsigned int cpu;
+       unsigned int cpu, cur_freq;
 
        domain = emc_get_boost_domain();
        cpu = cpumask_first(&domain->cpus);
@@ -224,7 +224,7 @@ int emc_verify_constraints(void)
        /* check policy max */
        if (policy->max > emc.max_freq) {
                cpufreq_cpu_put(policy);
-               pr_warn("EMC: max constraints is not yet applyied(emc_max(%d) < cur_max(%d)\n",
+               pr_warn("EMC: constraints isn't yet applyied(emc_max(%lu) < cur_max(%d)\n",
                                emc.max_freq, policy->max);
                return 0;
        }
@@ -232,9 +232,12 @@ int emc_verify_constraints(void)
 
 check_real_freq:
        /* check whether real cpu freq within max constraints or not */
-       if (exynos_cpufreq_get(cpu) > emc.max_freq)
-               panic("EMC(%s): real frequency(%d) is higher than max(%d)\n",
-                       __func__, exynos_cpufreq_get(cpu), emc.max_freq);
+       cur_freq = exynos_cpufreq_get_locked(cpu);
+       if (cur_freq > emc.max_freq) {
+               pr_warn("EMC(%s: cur freq(%d) is higher than max(%lu), retring...\n",
+                       __func__, cur_freq, emc.max_freq);
+               return 0;
+       }
 
        return 1;
 }
@@ -816,7 +819,7 @@ static int emc_cpu_on_callback(unsigned int cpu)
 }
 int emc_cpu_pre_on_callback(unsigned int cpu)
 {
-       emc_update_pre_mask(cpu, false);
+       emc_update_pre_mask(cpu, true);
        return 0;
 }
 
@@ -1280,7 +1283,7 @@ static void emc_print_inform(void)
                scnprintf(buf, sizeof(buf), "%*pbl",
                                cpumask_pr_args(&mode->boost_cpus));
                pr_info("mode%d boost_cpus: %s\n", i, buf);
-               pr_info("mode%d ldsum_thr: %u\n", mode->ldsum_thr);
+               pr_info("mode%d ldsum_thr: %u\n", i, mode->ldsum_thr);
                pr_info("mode%d cal-id: %u\n", i, mode->cal_id);
                pr_info("mode%d max_freq: %u\n", i, mode->max_freq);
                pr_info("mode%d change_latency: %u\n", i, mode->change_latency);
index 595d934c6312043251a8f605a2a12ea9407033ca..e666a6663898163c3254fe66534b8b27cd7a334b 100644 (file)
@@ -26,7 +26,7 @@ static inline void emc_check_available_freq(struct cpumask *cpus, unsigned int t
 static inline int emc_cpu_pre_off_callback(unsigned int cpu) { return 0; };
 #endif
 
-unsigned int exynos_cpufreq_get(unsigned int cpu);
+unsigned int exynos_cpufreq_get_locked(unsigned int cpu);
 
 #endif /* __EXYNOS_MODE_CHANGER_H */