aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/devfreq/devfreq.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2017-01-22 23:41:47 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-01-30 03:22:21 -0500
commit8a31d9d94297b1ecae3012069d35d78c959693c2 (patch)
tree97bc7ee54340bea61c32cc3cf102054ca30f0174 /drivers/devfreq/devfreq.c
parent7034764a1e4a6edbb60914e89aad8384e3fe5d17 (diff)
PM / OPP: Update OPP users to put reference
This patch updates dev_pm_opp_find_freq_*() routines to get a reference to the OPPs returned by them. Also updates the users of dev_pm_opp_find_freq_*() routines to call dev_pm_opp_put() after they are done using the OPPs. As it is guaranteed the that OPPs wouldn't get freed while being used, the RCU read side locking present with the users isn't required anymore. Drop it as well. This patch also updates all users of devfreq_recommended_opp() which was returning an OPP received from the OPP core. Note that some of the OPP core routines have gained rcu_read_{lock|unlock}() calls, as those still use RCU specific APIs within them. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> [Devfreq] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r--drivers/devfreq/devfreq.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index a545c0fee6e1..253525ea17af 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -111,18 +111,16 @@ static void devfreq_set_freq_table(struct devfreq *devfreq)
111 return; 111 return;
112 } 112 }
113 113
114 rcu_read_lock();
115 for (i = 0, freq = 0; i < profile->max_state; i++, freq++) { 114 for (i = 0, freq = 0; i < profile->max_state; i++, freq++) {
116 opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq); 115 opp = dev_pm_opp_find_freq_ceil(devfreq->dev.parent, &freq);
117 if (IS_ERR(opp)) { 116 if (IS_ERR(opp)) {
118 devm_kfree(devfreq->dev.parent, profile->freq_table); 117 devm_kfree(devfreq->dev.parent, profile->freq_table);
119 profile->max_state = 0; 118 profile->max_state = 0;
120 rcu_read_unlock();
121 return; 119 return;
122 } 120 }
121 dev_pm_opp_put(opp);
123 profile->freq_table[i] = freq; 122 profile->freq_table[i] = freq;
124 } 123 }
125 rcu_read_unlock();
126} 124}
127 125
128/** 126/**
@@ -1112,17 +1110,16 @@ static ssize_t available_frequencies_show(struct device *d,
1112 ssize_t count = 0; 1110 ssize_t count = 0;
1113 unsigned long freq = 0; 1111 unsigned long freq = 0;
1114 1112
1115 rcu_read_lock();
1116 do { 1113 do {
1117 opp = dev_pm_opp_find_freq_ceil(dev, &freq); 1114 opp = dev_pm_opp_find_freq_ceil(dev, &freq);
1118 if (IS_ERR(opp)) 1115 if (IS_ERR(opp))
1119 break; 1116 break;
1120 1117
1118 dev_pm_opp_put(opp);
1121 count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), 1119 count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
1122 "%lu ", freq); 1120 "%lu ", freq);
1123 freq++; 1121 freq++;
1124 } while (1); 1122 } while (1);
1125 rcu_read_unlock();
1126 1123
1127 /* Truncate the trailing space */ 1124 /* Truncate the trailing space */
1128 if (count) 1125 if (count)
@@ -1224,11 +1221,8 @@ subsys_initcall(devfreq_init);
1224 * @freq: The frequency given to target function 1221 * @freq: The frequency given to target function
1225 * @flags: Flags handed from devfreq framework. 1222 * @flags: Flags handed from devfreq framework.
1226 * 1223 *
1227 * Locking: This function must be called under rcu_read_lock(). opp is a rcu 1224 * The callers are required to call dev_pm_opp_put() for the returned OPP after
1228 * protected pointer. The reason for the same is that the opp pointer which is 1225 * use.
1229 * returned will remain valid for use with opp_get_{voltage, freq} only while
1230 * under the locked area. The pointer returned must be used prior to unlocking
1231 * with rcu_read_unlock() to maintain the integrity of the pointer.
1232 */ 1226 */
1233struct dev_pm_opp *devfreq_recommended_opp(struct device *dev, 1227struct dev_pm_opp *devfreq_recommended_opp(struct device *dev,
1234 unsigned long *freq, 1228 unsigned long *freq,