Commit 5b02b779 authored by Arve Hjønnevåg's avatar Arve Hjønnevåg Committed by Dave Jones

[CPUFREQ] S5PV210: Lock a mutex while changing the cpu frequency

Without this lock the call to change the frequency for suspend could
switch to a new frequency while another thread was still changing the
cpu voltage.
Signed-off-by: default avatarArve Hjønnevåg <arve@android.com>
Signed-off-by: default avatarJonghwan Choi <jhbird.choi@samsung.com>
Signed-off-by: default avatarKukjin Kim <kgene.kim@samsung.com>
Signed-off-by: default avatarDave Jones <davej@redhat.com>
parent 405e6d6d
...@@ -26,6 +26,7 @@ static struct clk *cpu_clk; ...@@ -26,6 +26,7 @@ static struct clk *cpu_clk;
static struct clk *dmc0_clk; static struct clk *dmc0_clk;
static struct clk *dmc1_clk; static struct clk *dmc1_clk;
static struct cpufreq_freqs freqs; static struct cpufreq_freqs freqs;
static DEFINE_MUTEX(set_freq_lock);
/* APLL M,P,S values for 1G/800Mhz */ /* APLL M,P,S values for 1G/800Mhz */
#define APLL_VAL_1000 ((1 << 31) | (125 << 16) | (3 << 8) | 1) #define APLL_VAL_1000 ((1 << 31) | (125 << 16) | (3 << 8) | 1)
...@@ -199,6 +200,8 @@ static int s5pv210_target(struct cpufreq_policy *policy, ...@@ -199,6 +200,8 @@ static int s5pv210_target(struct cpufreq_policy *policy,
int arm_volt, int_volt; int arm_volt, int_volt;
int ret = 0; int ret = 0;
mutex_lock(&set_freq_lock);
if (relation & ENABLE_FURTHER_CPUFREQ) if (relation & ENABLE_FURTHER_CPUFREQ)
no_cpufreq_access = false; no_cpufreq_access = false;
...@@ -207,7 +210,8 @@ static int s5pv210_target(struct cpufreq_policy *policy, ...@@ -207,7 +210,8 @@ static int s5pv210_target(struct cpufreq_policy *policy,
pr_err("%s:%d denied access to %s as it is disabled" pr_err("%s:%d denied access to %s as it is disabled"
"temporarily\n", __FILE__, __LINE__, __func__); "temporarily\n", __FILE__, __LINE__, __func__);
#endif #endif
return -EINVAL; ret = -EINVAL;
goto exit;
} }
if (relation & DISABLE_FURTHER_CPUFREQ) if (relation & DISABLE_FURTHER_CPUFREQ)
...@@ -218,19 +222,23 @@ static int s5pv210_target(struct cpufreq_policy *policy, ...@@ -218,19 +222,23 @@ static int s5pv210_target(struct cpufreq_policy *policy,
freqs.old = s5pv210_getspeed(0); freqs.old = s5pv210_getspeed(0);
if (cpufreq_frequency_table_target(policy, s5pv210_freq_table, if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
target_freq, relation, &index)) target_freq, relation, &index)) {
return -EINVAL; ret = -EINVAL;
goto exit;
}
freqs.new = s5pv210_freq_table[index].frequency; freqs.new = s5pv210_freq_table[index].frequency;
freqs.cpu = 0; freqs.cpu = 0;
if (freqs.new == freqs.old) if (freqs.new == freqs.old)
return 0; goto exit;
/* Finding current running level index */ /* Finding current running level index */
if (cpufreq_frequency_table_target(policy, s5pv210_freq_table, if (cpufreq_frequency_table_target(policy, s5pv210_freq_table,
freqs.old, relation, &priv_index)) freqs.old, relation, &priv_index)) {
return -EINVAL; ret = -EINVAL;
goto exit;
}
arm_volt = dvs_conf[index].arm_volt; arm_volt = dvs_conf[index].arm_volt;
int_volt = dvs_conf[index].int_volt; int_volt = dvs_conf[index].int_volt;
...@@ -239,12 +247,12 @@ static int s5pv210_target(struct cpufreq_policy *policy, ...@@ -239,12 +247,12 @@ static int s5pv210_target(struct cpufreq_policy *policy,
ret = regulator_set_voltage(arm_regulator, ret = regulator_set_voltage(arm_regulator,
arm_volt, arm_volt_max); arm_volt, arm_volt_max);
if (ret) if (ret)
return ret; goto exit;
ret = regulator_set_voltage(int_regulator, ret = regulator_set_voltage(int_regulator,
int_volt, int_volt_max); int_volt, int_volt_max);
if (ret) if (ret)
return ret; goto exit;
} }
cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
...@@ -471,7 +479,9 @@ static int s5pv210_target(struct cpufreq_policy *policy, ...@@ -471,7 +479,9 @@ static int s5pv210_target(struct cpufreq_policy *policy,
printk(KERN_DEBUG "Perf changed[L%d]\n", index); printk(KERN_DEBUG "Perf changed[L%d]\n", index);
return 0; exit:
mutex_unlock(&set_freq_lock);
return ret;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment