Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751673AbdITRAG (ORCPT ); Wed, 20 Sep 2017 13:00:06 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55028 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751175AbdITRAE (ORCPT ); Wed, 20 Sep 2017 13:00:04 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D1812602A9 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sboyd@codeaurora.org Date: Wed, 20 Sep 2017 10:00:00 -0700 From: Stephen Boyd To: Viresh Kumar Cc: Rafael Wysocki , cw00.choi@samsung.com, Viresh Kumar , Nishanth Menon , linux-pm@vger.kernel.org, Vincent Guittot , myungjoo.ham@samsung.com, inki.dae@samsung.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] PM / OPP: Call notifier without holding opp_table->lock Message-ID: <20170920170000.GA457@codeaurora.org> References: <59C2414E.6020803@samsung.com> <45c7e892a69c4936993c65c9987981dbe4433148.1505920911.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45c7e892a69c4936993c65c9987981dbe4433148.1505920911.git.viresh.kumar@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1557 Lines: 39 On 09/20, Viresh Kumar wrote: > 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. s/Lets/Let's/ > > Reported-by: Chanwoo Choi > Signed-off-by: Viresh Kumar > --- > 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); Does this prevent the OPP from changing while the lock is released? That would be the only difference from before. It's possible that nobody cares about this situation though. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project