From 7a5f6e1d639984bbe2b857920d94a49ca5ea5ebe Mon Sep 17 00:00:00 2001 From: Youngtae Lee Date: Thu, 14 Jun 2018 14:44:27 +0900 Subject: [PATCH] cpufreq: acme: Add exynos_cpufreq_get_locked. It is accompanied by a lock job to prevent reading frequency during frequency change Change-Id: Iaf163321dff7437ad215b200f10589225a73c4f7 Signed-off-by: Youngtae Lee --- drivers/cpufreq/exynos-acme.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/exynos-acme.c b/drivers/cpufreq/exynos-acme.c index 8bccc3485d99..5e2da3343feb 100644 --- a/drivers/cpufreq/exynos-acme.c +++ b/drivers/cpufreq/exynos-acme.c @@ -407,6 +407,16 @@ out: return ret; } +static unsigned int exynos_cpufreq_get(unsigned int cpu) +{ + struct exynos_cpufreq_domain *domain = find_domain(cpu); + + if (!domain) + return 0; + + return get_freq(domain); +} + static int exynos_cpufreq_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation) @@ -538,7 +548,6 @@ static struct notifier_block exynos_cpufreq_pm = { .notifier_call = exynos_cpufreq_pm_notifier, }; -unsigned int exynos_cpufreq_get(unsigned int cpu); static struct cpufreq_driver exynos_driver = { .name = "exynos_cpufreq", .flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY, @@ -778,15 +787,23 @@ unsigned int exynos_cpufreq_get_max_freq(struct cpumask *mask) } EXPORT_SYMBOL(exynos_cpufreq_get_max_freq); -unsigned int exynos_cpufreq_get(unsigned int cpu) +unsigned int exynos_cpufreq_get_locked(unsigned int cpu) { struct exynos_cpufreq_domain *domain = find_domain(cpu); if (!domain) return 0; + /* + * It is accompanied by a lock job to prevent + * reading frequency during frequency change + */ + mutex_lock(&domain->lock); + mutex_unlock(&domain->lock); + return get_freq(domain); } +EXPORT_SYMBOL(exynos_cpufreq_get_locked); /********************************************************************* * SYSFS INTERFACES * -- 2.20.1