summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-02-20 08:22:50 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-02-20 08:22:50 -0500
commit64f758a07a8cdb5c2a08e0d3dfec323af1d2bac3 (patch)
tree1eeae3c431523b85076884c4b893cf3337314fb2 /drivers/thermal
parent7089db84e356562f8ba737c29e472cc42d530dbc (diff)
parent0764c604c8128f17fd740ff8b1701d0a1301eb7e (diff)
Merge branch 'pm-opp'
* pm-opp: (24 commits) PM / OPP: Expose _of_get_opp_desc_node as dev_pm_opp API PM / OPP: Make _find_opp_table_unlocked() static PM / OPP: Update Documentation to remove RCU specific bits PM / OPP: Simplify dev_pm_opp_get_max_volt_latency() PM / OPP: Simplify _opp_set_availability() PM / OPP: Move away from RCU locking PM / OPP: Take kref from _find_opp_table() PM / OPP: Update OPP users to put reference PM / OPP: Add 'struct kref' to struct dev_pm_opp PM / OPP: Use dev_pm_opp_get_opp_table() instead of _add_opp_table() PM / OPP: Take reference of the OPP table while adding/removing OPPs PM / OPP: Return opp_table from dev_pm_opp_set_*() routines PM / OPP: Add 'struct kref' to OPP table PM / OPP: Add per OPP table mutex PM / OPP: Split out part of _add_opp_table() and _remove_opp_table() PM / OPP: Don't expose srcu_head to register notifiers PM / OPP: Rename dev_pm_opp_get_suspend_opp() and return OPP rate PM / OPP: Don't allocate OPP table from _opp_allocate() PM / OPP: Rename and split _dev_pm_opp_remove_table() PM / OPP: Add light weight _opp_free() routine ...
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/cpu_cooling.c11
-rw-r--r--drivers/thermal/devfreq_cooling.c15
2 files changed, 6 insertions, 20 deletions
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 9ce0e9eef923..85fdbf762fa0 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -297,8 +297,6 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
297 if (!power_table) 297 if (!power_table)
298 return -ENOMEM; 298 return -ENOMEM;
299 299
300 rcu_read_lock();
301
302 for (freq = 0, i = 0; 300 for (freq = 0, i = 0;
303 opp = dev_pm_opp_find_freq_ceil(dev, &freq), !IS_ERR(opp); 301 opp = dev_pm_opp_find_freq_ceil(dev, &freq), !IS_ERR(opp);
304 freq++, i++) { 302 freq++, i++) {
@@ -306,13 +304,13 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
306 u64 power; 304 u64 power;
307 305
308 if (i >= num_opps) { 306 if (i >= num_opps) {
309 rcu_read_unlock();
310 ret = -EAGAIN; 307 ret = -EAGAIN;
311 goto free_power_table; 308 goto free_power_table;
312 } 309 }
313 310
314 freq_mhz = freq / 1000000; 311 freq_mhz = freq / 1000000;
315 voltage_mv = dev_pm_opp_get_voltage(opp) / 1000; 312 voltage_mv = dev_pm_opp_get_voltage(opp) / 1000;
313 dev_pm_opp_put(opp);
316 314
317 /* 315 /*
318 * Do the multiplication with MHz and millivolt so as 316 * Do the multiplication with MHz and millivolt so as
@@ -328,8 +326,6 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_device,
328 power_table[i].power = power; 326 power_table[i].power = power;
329 } 327 }
330 328
331 rcu_read_unlock();
332
333 if (i != num_opps) { 329 if (i != num_opps) {
334 ret = PTR_ERR(opp); 330 ret = PTR_ERR(opp);
335 goto free_power_table; 331 goto free_power_table;
@@ -433,13 +429,10 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_device,
433 return 0; 429 return 0;
434 } 430 }
435 431
436 rcu_read_lock();
437
438 opp = dev_pm_opp_find_freq_exact(cpufreq_device->cpu_dev, freq_hz, 432 opp = dev_pm_opp_find_freq_exact(cpufreq_device->cpu_dev, freq_hz,
439 true); 433 true);
440 voltage = dev_pm_opp_get_voltage(opp); 434 voltage = dev_pm_opp_get_voltage(opp);
441 435 dev_pm_opp_put(opp);
442 rcu_read_unlock();
443 436
444 if (voltage == 0) { 437 if (voltage == 0) {
445 dev_warn_ratelimited(cpufreq_device->cpu_dev, 438 dev_warn_ratelimited(cpufreq_device->cpu_dev,
diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 5a737fd5f1aa..ba7a5cd994dc 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -113,15 +113,15 @@ static int partition_enable_opps(struct devfreq_cooling_device *dfc,
113 unsigned int freq = dfc->freq_table[i]; 113 unsigned int freq = dfc->freq_table[i];
114 bool want_enable = i >= cdev_state ? true : false; 114 bool want_enable = i >= cdev_state ? true : false;
115 115
116 rcu_read_lock();
117 opp = dev_pm_opp_find_freq_exact(dev, freq, !want_enable); 116 opp = dev_pm_opp_find_freq_exact(dev, freq, !want_enable);
118 rcu_read_unlock();
119 117
120 if (PTR_ERR(opp) == -ERANGE) 118 if (PTR_ERR(opp) == -ERANGE)
121 continue; 119 continue;
122 else if (IS_ERR(opp)) 120 else if (IS_ERR(opp))
123 return PTR_ERR(opp); 121 return PTR_ERR(opp);
124 122
123 dev_pm_opp_put(opp);
124
125 if (want_enable) 125 if (want_enable)
126 ret = dev_pm_opp_enable(dev, freq); 126 ret = dev_pm_opp_enable(dev, freq);
127 else 127 else
@@ -221,15 +221,12 @@ get_static_power(struct devfreq_cooling_device *dfc, unsigned long freq)
221 if (!dfc->power_ops->get_static_power) 221 if (!dfc->power_ops->get_static_power)
222 return 0; 222 return 0;
223 223
224 rcu_read_lock();
225
226 opp = dev_pm_opp_find_freq_exact(dev, freq, true); 224 opp = dev_pm_opp_find_freq_exact(dev, freq, true);
227 if (IS_ERR(opp) && (PTR_ERR(opp) == -ERANGE)) 225 if (IS_ERR(opp) && (PTR_ERR(opp) == -ERANGE))
228 opp = dev_pm_opp_find_freq_exact(dev, freq, false); 226 opp = dev_pm_opp_find_freq_exact(dev, freq, false);
229 227
230 voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */ 228 voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */
231 229 dev_pm_opp_put(opp);
232 rcu_read_unlock();
233 230
234 if (voltage == 0) { 231 if (voltage == 0) {
235 dev_warn_ratelimited(dev, 232 dev_warn_ratelimited(dev,
@@ -412,18 +409,14 @@ static int devfreq_cooling_gen_tables(struct devfreq_cooling_device *dfc)
412 unsigned long power_dyn, voltage; 409 unsigned long power_dyn, voltage;
413 struct dev_pm_opp *opp; 410 struct dev_pm_opp *opp;
414 411
415 rcu_read_lock();
416
417 opp = dev_pm_opp_find_freq_floor(dev, &freq); 412 opp = dev_pm_opp_find_freq_floor(dev, &freq);
418 if (IS_ERR(opp)) { 413 if (IS_ERR(opp)) {
419 rcu_read_unlock();
420 ret = PTR_ERR(opp); 414 ret = PTR_ERR(opp);
421 goto free_tables; 415 goto free_tables;
422 } 416 }
423 417
424 voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */ 418 voltage = dev_pm_opp_get_voltage(opp) / 1000; /* mV */
425 419 dev_pm_opp_put(opp);
426 rcu_read_unlock();
427 420
428 if (dfc->power_ops) { 421 if (dfc->power_ops) {
429 power_dyn = get_dynamic_power(dfc, freq, voltage); 422 power_dyn = get_dynamic_power(dfc, freq, voltage);