From: Youngtae Lee Date: Fri, 27 Apr 2018 06:28:58 +0000 (+0900) Subject: samsung: emc: Add function to check target_freq is available X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=49bbb5aacc5f0df38210e566f1a30ad5a44a2cc3;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git samsung: emc: Add function to check target_freq is available Change-Id: Ie957e3d0c8064f5d8b2fa324fb1205d373554cf6 Signed-off-by: Youngtae Lee --- diff --git a/drivers/soc/samsung/exynos-emc.c b/drivers/soc/samsung/exynos-emc.c index 6587596be32c..dfddd59a8db2 100644 --- a/drivers/soc/samsung/exynos-emc.c +++ b/drivers/soc/samsung/exynos-emc.c @@ -174,6 +174,30 @@ exit: return 0; } +void emc_check_available_freq(struct cpumask *cpus, unsigned int target_freq) +{ + unsigned int max_freq; + struct emc_domain *domain = emc_get_boost_domain(); + int cpu = cpumask_first(cpus); + struct cpumask online_mask; + struct emc_mode *mode; + + cpumask_copy(&online_mask, cpu_online_mask); + mode = emc_find_mode(&online_mask); + + if (!cpumask_equal(cpus, &domain->cpus)) + return; + + if (mode) + max_freq = mode->max_freq; + else + max_freq = emc_get_base_mode()->max_freq; + + if (target_freq > max_freq) + panic("cpu%d target_freq(%d) is higher than max_freq(%d, mode %s)\n", + cpu, target_freq, max_freq, mode->name); +} + /* check policy->max constaints and real clock violation according to mask */ int emc_verify_constraints(struct cpumask *mask) { diff --git a/include/soc/samsung/exynos-emc.h b/include/soc/samsung/exynos-emc.h index 7dcf0fb3126b..15812fba3307 100644 --- a/include/soc/samsung/exynos-emc.h +++ b/include/soc/samsung/exynos-emc.h @@ -16,10 +16,12 @@ void exynos_emc_update(int cpu); int exynos_emc_update_cpu_pwr(unsigned int cpu, bool on); int emc_get_boost_freq(int cpu); +void emc_check_available_freq(struct cpumask *cpus, unsigned int target_freq); #else static inline void exynos_emc_update(int cpu) {}; static inline int exynos_emc_update_cpu_pwr(unsigned int cpu, bool on) { return 0; }; static inline int emc_get_boost_freq(int cpu) { return 0; }; +static inline void emc_check_available_freq(struct cpumask *cpus, unsigned int target_freq) { return; }; #endif #endif /* __EXYNOS_MODE_CHANGER_H */