aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2017-09-21 13:44:36 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-09-25 18:44:32 -0400
commite4d8ae00169f7686e1da5a62e5cf797d12bf8822 (patch)
tree259c6369f13b73c0e5ed857f0cd6e289f96bac7c
parente19b205be43d11bff638cad4487008c48d21c103 (diff)
PM / OPP: Call notifier without holding opp_table->lock
The notifier callbacks may want to call some OPP helper routines which may try to take the same opp_table->lock again and cause a deadlock. One such usecase was reported by Chanwoo Choi, where calling dev_pm_opp_disable() leads us to the devfreq's OPP notifier handler, which further calls dev_pm_opp_find_freq_floor() and it deadlocks. We don't really need the opp_table->lock to be held across the notifier call though, all we want to make sure is that the 'opp' doesn't get freed while being used from within the notifier chain. We can do it with help of dev_pm_opp_get/put() as well. Let's do it. Cc: 4.11+ <stable@vger.kernel.org> # 4.11+ Fixes: 5b650b388844 "PM / OPP: Take kref from _find_opp_table()" Reported-by: Chanwoo Choi <cw00.choi@samsung.com> Tested-by: Chanwoo Choi <cw00.choi@samsung.com> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/base/power/opp/core.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index a8cc14fd8ae4..a6de32530693 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -1581,6 +1581,9 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
1581 1581
1582 opp->available = availability_req; 1582 opp->available = availability_req;
1583 1583
1584 dev_pm_opp_get(opp);
1585 mutex_unlock(&opp_table->lock);
1586
1584 /* Notify the change of the OPP availability */ 1587 /* Notify the change of the OPP availability */
1585 if (availability_req) 1588 if (availability_req)
1586 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, 1589 blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE,
@@ -1589,8 +1592,12 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
1589 blocking_notifier_call_chain(&opp_table->head, 1592 blocking_notifier_call_chain(&opp_table->head,
1590 OPP_EVENT_DISABLE, opp); 1593 OPP_EVENT_DISABLE, opp);
1591 1594
1595 dev_pm_opp_put(opp);
1596 goto put_table;
1597
1592unlock: 1598unlock:
1593 mutex_unlock(&opp_table->lock); 1599 mutex_unlock(&opp_table->lock);
1600put_table:
1594 dev_pm_opp_put_opp_table(opp_table); 1601 dev_pm_opp_put_opp_table(opp_table);
1595 return r; 1602 return r;
1596} 1603}