From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755361AbbFBDbE (ORCPT ); Mon, 1 Jun 2015 23:31:04 -0400 Received: from mailout3.w1.samsung.com ([210.118.77.13]:45245 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754880AbbFBDaz (ORCPT ); Mon, 1 Jun 2015 23:30:55 -0400 X-AuditID: cbfec7f5-f794b6d000001495-10-556d236cb066 Message-id: <556D2369.2000603@samsung.com> Date: Tue, 02 Jun 2015 12:30:49 +0900 From: Krzysztof Kozlowski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-version: 1.0 To: Stephen Boyd , linux-arm-msm@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nishanth Menon , Viresh Kumar , Srinivas Kandagatla , Andy Gross , linux-pm@vger.kernel.org, Mark Brown , David Collins Subject: Re: [RFC/PATCH 4/6] OPP: Allow notifiers to call dev_pm_opp_get_{voltage,freq} RCU-free References: <1433209679-31389-1-git-send-email-sboyd@codeaurora.org> <1433209679-31389-5-git-send-email-sboyd@codeaurora.org> In-reply-to: <1433209679-31389-5-git-send-email-sboyd@codeaurora.org> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRmVeSWpSXmKPExsVy+t/xa7o5yrmhBhP/i1js/NDNZDH14RM2 i642IYvXLwwtNj2+xmoxcf9ZdovLu+awWXzuPcJo8ebHWSaLH2e6WSzajh1jtdj41cOBx+Ny Xy+Tx6ZVnWwed67tYfPYvKTeo2/LKkaP4ze2M3l83iQXwB7FZZOSmpNZllqkb5fAlbF/+gOm giOCFZ1dk5gaGPv5uhg5OSQETCR2velnhrDFJC7cW8/WxcjFISSwlFHi8KvdUM5TRom1E7+z gFTxCmhJPNz4GKyDRUBVYuH0DawgNpuAscTm5UvYQGxRgQiJt5dPMkHUC0r8mHwPrFdEwE1i Xd8XFpChzAIXmCRmbF0GlhAWSJLY+HM52CAhgXqJnvO/wQZxCrhK9HU/ZOxi5ABq0JO4f1EL JMwsIC+xec1b5gmMArOQrJiFUDULSdUCRuZVjKKppckFxUnpuUZ6xYm5xaV56XrJ+bmbGCEx 8nUH49JjVocYBTgYlXh4GT7lhAqxJpYVV+YeYpTgYFYS4b3MlxsqxJuSWFmVWpQfX1Sak1p8 iFGag0VJnHfmrvchQgLpiSWp2ampBalFMFkmDk6pBsZ1TlGvfUz0hRvzl8qy64ZYHk54zf2S s/NNTt2/M14nl/eorPz2xcF87o9/6rxCey1NHjVIJWYWnQiLMyz8eJ47svB4DPODrQduZyzT 7y27uSZk5f757Hv5pxTfPmP2cqJI/+OVt/YrRUcqpGy9MNeM03Crz7c4FpP3U2esklnS97+0 p5CZ8bsSS3FGoqEWc1FxIgAZJZ1DjQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02.06.2015 10:47, Stephen Boyd wrote: > We pass the dev_pm_opp structure to OPP notifiers but the users > of the notifier need to surround calls to dev_pm_opp_get_*() with > RCU read locks to avoid lockdep warnings. The notifier is already > called with the dev_opp's srcu lock held, so it should be safe to > assume the devm_pm_opp structure is already protected inside the > notifier. Update the lockdep check for this. > > Cc: Krzysztof Kozlowski > Signed-off-by: Stephen Boyd > --- > > This is probably wrong, but it's what I had to hack up > to be able to use the OPP functions from within the notifier > to figure out the new values of the OPP without having to take > an RCU read lock. > > drivers/base/power/opp.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) > > diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c > index b997a7eabcd4..6d75022c6a0e 100644 > --- a/drivers/base/power/opp.c > +++ b/drivers/base/power/opp.c > @@ -108,9 +108,10 @@ static LIST_HEAD(dev_opp_list); > /* Lock to allow exclusive modification to the device and opp lists */ > static DEFINE_MUTEX(dev_opp_list_lock); > > -#define opp_rcu_lockdep_assert() \ > +#define opp_rcu_lockdep_assert(s) \ > do { \ > rcu_lockdep_assert(rcu_read_lock_held() || \ > + (s && srcu_read_lock_held(s)) || \ > lockdep_is_held(&dev_opp_list_lock), \ > "Missing rcu_read_lock() or " \ > "dev_opp_list_lock protection"); \ > @@ -169,9 +170,10 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) > struct dev_pm_opp *tmp_opp; > unsigned long v = 0; > > - opp_rcu_lockdep_assert(); > + opp_rcu_lockdep_assert(&opp->dev_opp->srcu_head.srcu); > > - tmp_opp = rcu_dereference(opp); > + tmp_opp = srcu_dereference_check(opp, &opp->dev_opp->srcu_head.srcu, > + rcu_read_lock_held()); It looks strange. The notifier's SRCU is part of device_opp but here we want to protect the dev_pm_opp. Because of this difference I am not sure that it is safe having around this a srcu_read_lock() from notifiers instead of rcu_read_lock(). Best regards, Krzysztof