Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1735853
| Path | csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Viresh Kumar <viresh.kumar@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | [PATCH] PM / OPP: Call notifier without holding opp_table->lock |
| Date | Wed, 20 Sep 2017 17:40:02 +0200 |
| Message-ID | <urPgu-4TY-29@gated-at.bofh.it> (permalink) |
| References | <urPgu-4TY-31@gated-at.bofh.it> |
| X-Original-To | Rafael Wysocki <rjw@rjwysocki.net>, cw00.choi@samsung.com, Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>, Stephen Boyd <sboyd@codeaurora.org> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dWyYJlxHptaWzRM0hTG2IF4Xl5yaYudfXCxHCVvIciU=; b=CebhZvovcODguKl3GGHdEwwK3fjSw6sSPW0CFFxJl/02BfxEkzA4A/8+B8SDYfvze0 KykNFemGfAP7XJUO6yX39yWd79E3YPVHPR024BjhNWm8JGqiKdR96ZkN0e5b8KVZg9O6 QU/UzM6faR1avZ9roxTX968tv0/KAUdDKxeY4= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dWyYJlxHptaWzRM0hTG2IF4Xl5yaYudfXCxHCVvIciU=; b=RWzyVg3648va74WLQqJEZgLX0VkQ+k1z6lHsISOIV6M8CvGOpHpGnTsIZFjl6l13jP LjoLUFgQS4y0r9QJBoLlsRon2Q6UnWl/MZUJ3mAyu4WGwp1H50y4oOo/YC5MA4STDtaT jwgYFTG26oploc6nyX5sHhmgor3lNGOlOhagiDiYYegAf7tN7dU7FVYgsPsywxBhLNby cDsaL0mDksp6FM5ZMLNdv2Q2hRawAmfih1ZPYlMuebjXJnwfHgtV19QrgfJMlx5aAFmR H6uoY1hr3VF0AT4Z4VUArP12vFaSQfVjnCrOqIvtpPb3sIKtknblq9UFqTQ7VGwt4mtO T9/A== |
| X-Gm-Message-State | AHPjjUhhdEzkwM5s/YCylmTRLBW1EX6M+C7Yl4+xo8FraHtCtfKlF97N 6kot+uRpqJH+ss6ZtAI/idr4cWoTmC0= |
| X-Google-SMTP-Source | AOwi7QAlE//115IsrDUSq2lRo17y+aesr0Sy1de+CAUeC3nkmJSgNXA3rdGHRjf2R1c5wS7blsh1sw== |
| X-Received | by 10.101.68.65 with SMTP id e1mr2664012pgq.134.1505921703001; Wed, 20 Sep 2017 08:35:03 -0700 (PDT) |
| X-Mailer | git-send-email 2.7.4 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 46 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Viresh Kumar <viresh.kumar@linaro.org>, linux-pm@vger.kernel.org, Vincent Guittot <vincent.guittot@linaro.org>, myungjoo.ham@samsung.com, inki.dae@samsung.com, linux-kernel@vger.kernel.org |
| X-Original-Date | Wed, 20 Sep 2017 08:34:51 -0700 |
| X-Original-Message-ID | <45c7e892a69c4936993c65c9987981dbe4433148.1505920911.git.viresh.kumar@linaro.org> |
| X-Original-References | <59C2414E.6020803@samsung.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1735853 |
Show key headers only | View raw
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. Lets do it. Reported-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> --- drivers/base/power/opp/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 4360b4efcd4c..668fd940d362 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -1627,6 +1627,9 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, opp->available = availability_req; + dev_pm_opp_get(opp); + mutex_unlock(&opp_table->lock); + /* Notify the change of the OPP availability */ if (availability_req) blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ENABLE, @@ -1635,8 +1638,12 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_DISABLE, opp); + dev_pm_opp_put(opp); + goto put_table; + unlock: mutex_unlock(&opp_table->lock); +put_table: dev_pm_opp_put_opp_table(opp_table); return r; } -- 2.7.4
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] PM / OPP: Call notifier without holding opp_table->lock Viresh Kumar <viresh.kumar@linaro.org> - 2017-09-20 17:40 +0200
Re: [PATCH] PM / OPP: Call notifier without holding opp_table->lock Viresh Kumar <viresh.kumar@linaro.org> - 2017-09-20 19:10 +0200
Re: [PATCH] PM / OPP: Call notifier without holding opp_table->lock Stephen Boyd <sboyd@codeaurora.org> - 2017-09-20 21:50 +0200
Re: [PATCH] PM / OPP: Call notifier without holding opp_table->lock Stephen Boyd <sboyd@codeaurora.org> - 2017-09-20 19:10 +0200
csiph-web