aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/opp/core.c
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2016-11-30 05:51:25 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-06 04:40:15 -0500
commitc7a8a0ac8fee26d3c20402da306a17bcbbbb367b (patch)
tree3bc42f9ceb956d26100eae2cc148c34eeee18fe6 /drivers/base/power/opp/core.c
parenteab1c4e2d0ad4509ccb8476a604074547dc202e0 (diff)
PM / OPP: Pass opp_table to dev_pm_opp_put_regulator()
commit 91291d9ad92faa65a56a9a19d658d8049b78d3d4 upstream. Joonyoung Shim reported an interesting problem on his ARM octa-core Odoroid-XU3 platform. During system suspend, dev_pm_opp_put_regulator() was failing for a struct device for which dev_pm_opp_set_regulator() is called earlier. This happened because an earlier call to dev_pm_opp_of_cpumask_remove_table() function (from cpufreq-dt.c file) removed all the entries from opp_table->dev_list apart from the last CPU device in the cpumask of CPUs sharing the OPP. But both dev_pm_opp_set_regulator() and dev_pm_opp_put_regulator() routines get CPU device for the first CPU in the cpumask. And so the OPP core failed to find the OPP table for the struct device. This patch attempts to fix this problem by returning a pointer to the opp_table from dev_pm_opp_set_regulator() and using that as the parameter to dev_pm_opp_put_regulator(). This ensures that the dev_pm_opp_put_regulator() doesn't fail to find the opp table. Note that similar design problem also exists with other dev_pm_opp_put_*() APIs, but those aren't used currently by anyone and so we don't need to update them for now. Reported-by: Joonyoung Shim <jy0922.shim@samsung.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> [ Viresh: Wrote commit log and tested on exynos 5250 ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/power/opp/core.c')
-rw-r--r--drivers/base/power/opp/core.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index 4c7c6da7a989..2824d3a5e9f0 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -1316,7 +1316,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_put_prop_name);
1316 * that this function is *NOT* called under RCU protection or in contexts where 1316 * that this function is *NOT* called under RCU protection or in contexts where
1317 * mutex cannot be locked. 1317 * mutex cannot be locked.
1318 */ 1318 */
1319int dev_pm_opp_set_regulator(struct device *dev, const char *name) 1319struct opp_table *dev_pm_opp_set_regulator(struct device *dev, const char *name)
1320{ 1320{
1321 struct opp_table *opp_table; 1321 struct opp_table *opp_table;
1322 struct regulator *reg; 1322 struct regulator *reg;
@@ -1354,20 +1354,20 @@ int dev_pm_opp_set_regulator(struct device *dev, const char *name)
1354 opp_table->regulator = reg; 1354 opp_table->regulator = reg;
1355 1355
1356 mutex_unlock(&opp_table_lock); 1356 mutex_unlock(&opp_table_lock);
1357 return 0; 1357 return opp_table;
1358 1358
1359err: 1359err:
1360 _remove_opp_table(opp_table); 1360 _remove_opp_table(opp_table);
1361unlock: 1361unlock:
1362 mutex_unlock(&opp_table_lock); 1362 mutex_unlock(&opp_table_lock);
1363 1363
1364 return ret; 1364 return ERR_PTR(ret);
1365} 1365}
1366EXPORT_SYMBOL_GPL(dev_pm_opp_set_regulator); 1366EXPORT_SYMBOL_GPL(dev_pm_opp_set_regulator);
1367 1367
1368/** 1368/**
1369 * dev_pm_opp_put_regulator() - Releases resources blocked for regulator 1369 * dev_pm_opp_put_regulator() - Releases resources blocked for regulator
1370 * @dev: Device for which regulator was set. 1370 * @opp_table: OPP table returned from dev_pm_opp_set_regulator().
1371 * 1371 *
1372 * Locking: The internal opp_table and opp structures are RCU protected. 1372 * Locking: The internal opp_table and opp structures are RCU protected.
1373 * Hence this function internally uses RCU updater strategy with mutex locks 1373 * Hence this function internally uses RCU updater strategy with mutex locks
@@ -1375,22 +1375,12 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_set_regulator);
1375 * that this function is *NOT* called under RCU protection or in contexts where 1375 * that this function is *NOT* called under RCU protection or in contexts where
1376 * mutex cannot be locked. 1376 * mutex cannot be locked.
1377 */ 1377 */
1378void dev_pm_opp_put_regulator(struct device *dev) 1378void dev_pm_opp_put_regulator(struct opp_table *opp_table)
1379{ 1379{
1380 struct opp_table *opp_table;
1381
1382 mutex_lock(&opp_table_lock); 1380 mutex_lock(&opp_table_lock);
1383 1381
1384 /* Check for existing table for 'dev' first */
1385 opp_table = _find_opp_table(dev);
1386 if (IS_ERR(opp_table)) {
1387 dev_err(dev, "Failed to find opp_table: %ld\n",
1388 PTR_ERR(opp_table));
1389 goto unlock;
1390 }
1391
1392 if (IS_ERR(opp_table->regulator)) { 1382 if (IS_ERR(opp_table->regulator)) {
1393 dev_err(dev, "%s: Doesn't have regulator set\n", __func__); 1383 pr_err("%s: Doesn't have regulator set\n", __func__);
1394 goto unlock; 1384 goto unlock;
1395 } 1385 }
1396 1386