From patchwork Thu Nov 5 08:51:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 56028 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp278904lbr; Thu, 5 Nov 2015 00:52:34 -0800 (PST) X-Received: by 10.50.49.46 with SMTP id r14mr1604513ign.71.1446713553944; Thu, 05 Nov 2015 00:52:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ks1si22784811igb.23.2015.11.05.00.52.33; Thu, 05 Nov 2015 00:52:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033167AbbKEIwb (ORCPT + 28 others); Thu, 5 Nov 2015 03:52:31 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:32940 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032923AbbKEIwG (ORCPT ); Thu, 5 Nov 2015 03:52:06 -0500 Received: by pabfh17 with SMTP id fh17so81617737pab.0 for ; Thu, 05 Nov 2015 00:52:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=75+qZH30GIxB2JwFoIH37D59ey7LF169u2E3M47M4Ok=; b=skYTB2HxmbRYBg3y8lAbbfCCAECRVvj8oFVabyd4sgrzyIRkmJ0obA87A0EvX93yZM tGexQFXg+GNgWZws7rl7Fy/KNgONCEdE4w3wP5phf9TS6D9IA1vioDoKnQZ43qWOCeUn 7TRs15u/izDsGDOpbXqlIbp9VNo6e05i/09KAq2WIBMy9vsnlzeRgUgwXX0r8CQ91oMz HBy166JVGHqNc5EXQKo8KECbgiq/Qv0UEeXueDtUNgjX1Bl8lQwekr+ROr3CpEKg4mRI GcF9V2w1hgoBe2c5pQZE73qmk//eMaXVli590oKPYADO+TuJgQDwxgPqGJZsTT4XArlw r7/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=75+qZH30GIxB2JwFoIH37D59ey7LF169u2E3M47M4Ok=; b=TEbCeAQSGGnNVsIFAGvpn9r9/14yF9cSDRVf5ZLae0XxQ49eCBq7uFGCgyjBm6mKBv l48LqveIw58hUubpHZ/SmCfoSmZzOE2lrNdktbG0528xXAFDhOjtri6U0vrFTL6sQLzr exQP1t+Ycy4rRD0kzEErd8+q9lCAuQlg2C6ypDY5sTqGXifJCqX5+Fv6X0OKb/y+cbO2 2NtBrYhADkt+44ZjPu+dF8DlB4gpE0WJ4h3hy1xZZ/DSllirsehWegUthu1MenmfbEA6 SQaTxNfv0R9Os1I82wb7IucDOwJEG92d4PP647DXmDDzxdjuM2owCXqZKJ8+63Ys795T Jyjg== X-Gm-Message-State: ALoCoQnmjl4KmtexyhYLyv8EP+cmXjowBLmD0Mj7URq6wsuMjXm1ZhwEoYJsPpzswZ6TTHm2aYf0 X-Received: by 10.66.172.6 with SMTP id ay6mr8091477pac.44.1446713525885; Thu, 05 Nov 2015 00:52:05 -0800 (PST) Received: from localhost ([122.172.111.169]) by smtp.gmail.com with ESMTPSA id ix1sm6536107pbd.40.2015.11.05.00.52.04 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Nov 2015 00:52:05 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , "4 . 3 # 4 . 3" , Bartlomiej Zolnierkiewicz , Dmitry Torokhov , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Nishanth Menon , Pavel Machek Subject: [PATCH V2 4/4] PM / OPP: Add opp_rcu_lockdep_assert() to _find_device_opp() Date: Thu, 5 Nov 2015 14:21:21 +0530 Message-Id: <6f78bb732c54ff35c4adfc0de256f20fe7cd39ba.1446713282.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.6.2.198.g614a2ac In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org _find_device_opp() should be called with rcu-read lock or dev_opp_list_lock held. Add the opp_rcu_lockdep_assert() check to make sure caller have taken appropriate locks. Fix comment over the routine as well. Cc: 4.3 # 4.3 Suggested-by: Stephen Boyd Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.6.2.198.g614a2ac -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 7a395f5ba5f9..5e4b1d82b2f8 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -81,14 +81,18 @@ static struct device_opp *_managed_opp(const struct device_node *np) * Return: pointer to 'struct device_opp' if found, otherwise -ENODEV or * -EINVAL based on type of error. * - * Locking: This function must be called under rcu_read_lock(). device_opp - * is a RCU protected pointer. This means that device_opp is valid as long - * as we are under RCU lock. + * Locking: For readers, this function must be called under rcu_read_lock(). + * device_opp is a RCU protected pointer, which means that device_opp is valid + * as long as we are under RCU lock. + * + * For Writers, this function must be called with dev_opp_list_lock held. */ struct device_opp *_find_device_opp(struct device *dev) { struct device_opp *dev_opp; + opp_rcu_lockdep_assert(); + if (IS_ERR_OR_NULL(dev)) { pr_err("%s: Invalid parameters\n", __func__); return ERR_PTR(-EINVAL);