summaryrefslogtreecommitdiff
path: root/drivers/cpufreq/cpufreq-cpu0.c
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2013-01-18 19:52:33 +0000
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-01-22 13:28:39 +0100
commit78e8eb8feab7d85f4cc215afe1457a228bf4eed9 (patch)
tree409aa5ca48b0ee458c5a55956ca4c73dc44d2819 /drivers/cpufreq/cpufreq-cpu0.c
parentf44d188acdca1a34e4439ca6a173f85086e0e655 (diff)
downloadlwn-78e8eb8feab7d85f4cc215afe1457a228bf4eed9.tar.gz
lwn-78e8eb8feab7d85f4cc215afe1457a228bf4eed9.zip
cpufreq: cpufreq-cpu0: use RCU locks around usage of OPP
OPP pointer is RCU protected, hence after finding it, de-reference also should be protected with the same RCU context else the OPP pointer may become invalid. Reported-by: Jack Mitchell <jack@embed.me.uk> Tested-by: Alexander Holler <holler@ahsoftware.de> Tested-by: Jack Mitchell <jack@embed.me.uk> Acked-by: Alexander Holler <holler@ahsoftware.de> Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq-cpu0.c')
-rw-r--r--drivers/cpufreq/cpufreq-cpu0.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index 52bf36d599f5..debc5a7c8db6 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -71,12 +71,15 @@ static int cpu0_set_target(struct cpufreq_policy *policy,
}
if (cpu_reg) {
+ rcu_read_lock();
opp = opp_find_freq_ceil(cpu_dev, &freq_Hz);
if (IS_ERR(opp)) {
+ rcu_read_unlock();
pr_err("failed to find OPP for %ld\n", freq_Hz);
return PTR_ERR(opp);
}
volt = opp_get_voltage(opp);
+ rcu_read_unlock();
tol = volt * voltage_tolerance / 100;
volt_old = regulator_get_voltage(cpu_reg);
}
@@ -236,12 +239,14 @@ static int cpu0_cpufreq_driver_init(void)
*/
for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++)
;
+ rcu_read_lock();
opp = opp_find_freq_exact(cpu_dev,
freq_table[0].frequency * 1000, true);
min_uV = opp_get_voltage(opp);
opp = opp_find_freq_exact(cpu_dev,
freq_table[i-1].frequency * 1000, true);
max_uV = opp_get_voltage(opp);
+ rcu_read_unlock();
ret = regulator_set_voltage_time(cpu_reg, min_uV, max_uV);
if (ret > 0)
transition_latency += ret * 1000;