Commit 4a3a1353 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

PM / OPP: Hold dev_opp_list_lock for writers

Writers need to update OPP device and their list with dev_opp_list_lock
mutex held, which was missed at few places. Fix it.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Cc: 4.3 <stable@vger.kernel.org> # 4.3
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 87b4115d
...@@ -1168,13 +1168,17 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) ...@@ -1168,13 +1168,17 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
struct device_opp *dev_opp; struct device_opp *dev_opp;
int ret = 0, count = 0; int ret = 0, count = 0;
mutex_lock(&dev_opp_list_lock);
dev_opp = _managed_opp(opp_np); dev_opp = _managed_opp(opp_np);
if (dev_opp) { if (dev_opp) {
/* OPPs are already managed */ /* OPPs are already managed */
if (!_add_list_dev(dev, dev_opp)) if (!_add_list_dev(dev, dev_opp))
ret = -ENOMEM; ret = -ENOMEM;
mutex_unlock(&dev_opp_list_lock);
return ret; return ret;
} }
mutex_unlock(&dev_opp_list_lock);
/* We have opp-list node now, iterate over it and add OPPs */ /* We have opp-list node now, iterate over it and add OPPs */
for_each_available_child_of_node(opp_np, np) { for_each_available_child_of_node(opp_np, np) {
...@@ -1192,15 +1196,20 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) ...@@ -1192,15 +1196,20 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
if (WARN_ON(!count)) if (WARN_ON(!count))
return -ENOENT; return -ENOENT;
mutex_lock(&dev_opp_list_lock);
dev_opp = _find_device_opp(dev); dev_opp = _find_device_opp(dev);
if (WARN_ON(IS_ERR(dev_opp))) { if (WARN_ON(IS_ERR(dev_opp))) {
ret = PTR_ERR(dev_opp); ret = PTR_ERR(dev_opp);
mutex_unlock(&dev_opp_list_lock);
goto free_table; goto free_table;
} }
dev_opp->np = opp_np; dev_opp->np = opp_np;
dev_opp->shared_opp = of_property_read_bool(opp_np, "opp-shared"); dev_opp->shared_opp = of_property_read_bool(opp_np, "opp-shared");
mutex_unlock(&dev_opp_list_lock);
return 0; return 0;
free_table: free_table:
......
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