From patchwork Tue Dec 16 23:09:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 5504181 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B658C9F1CD for ; Tue, 16 Dec 2014 23:11:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E71B720A16 for ; Tue, 16 Dec 2014 23:11:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 14F89209E5 for ; Tue, 16 Dec 2014 23:11:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582AbaLPXJy (ORCPT ); Tue, 16 Dec 2014 18:09:54 -0500 Received: from mail-ig0-f181.google.com ([209.85.213.181]:49373 "EHLO mail-ig0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbaLPXJx (ORCPT ); Tue, 16 Dec 2014 18:09:53 -0500 Received: by mail-ig0-f181.google.com with SMTP id l13so8559730iga.2 for ; Tue, 16 Dec 2014 15:09:52 -0800 (PST) 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; bh=xy/TJXmBf/CCFnjXLpaar735p8d9eiNJeg35RkaaybY=; b=DmVCVqET/xYd+K2tFMy8KViIF6/jif5yBqw+OebercG4ayP/c7j/EwcpmotN3y66ge F+ojgWNYH9yYye9yoEnhwkiD6uVyKlU+doZSjlxdCZZJ3gfBI6hbHuaMZ13hnwgPMGwM 091p0RYYmmQZdJZxKFweETYgSthqli5UZeNHGredt0qDKAF+Hfum5r9OcqFz3ksuH6q5 f564WX5BiGn7HPpZ67Z6j71/mE2FYZIjO7OFVm+yNdQBVtKdFo0gQHoHb3SPUb+iKD/Q ECLHhM+Ak0wevJethVRA8iGFQ2QY3/ctZgrHI6GmnB2NMbVxey2uX55eQ82SgdTLx/0E P/Zg== X-Gm-Message-State: ALoCoQkRLSMLVOkCGstUyZiBM41/FxWHdwyXr0wa/5PqbOfTInQif4JXUA8mY0pNjk54IewsBXZE X-Received: by 10.42.94.14 with SMTP id z14mr33500141icm.59.1418771392832; Tue, 16 Dec 2014 15:09:52 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.64.149]) by mx.google.com with ESMTPSA id s10sm1424817igr.2.2014.12.16.15.09.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Dec 2014 15:09:52 -0800 (PST) From: Dmitry Torokhov To: "Rafael J. Wysocki" , Viresh Kumar Cc: Thomas Petazzoni , Geert Uytterhoeven , Stefan Wahren , Paul Gortmaker , Nishanth Menon , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] PM / OPP: add some lockdep annotations Date: Tue, 16 Dec 2014 15:09:36 -0800 Message-Id: <1418771379-24369-2-git-send-email-dtor@chromium.org> X-Mailer: git-send-email 2.2.0.rc0.207.ga3a616c In-Reply-To: <1418771379-24369-1-git-send-email-dtor@chromium.org> References: <1418771379-24369-1-git-send-email-dtor@chromium.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Certain OPP APIs need to be called under RCU lock; let's add a few rcu_lockdep_assert() calls to warn about potential misuse. Signed-off-by: Dmitry Torokhov Acked-by: Viresh Kumar --- drivers/base/power/opp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index d24dd614a..b78c14d 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -108,6 +108,14 @@ 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() \ +do { \ + rcu_lockdep_assert(rcu_read_lock_held() || \ + lockdep_is_held(&dev_opp_list_lock), \ + "Missing rcu_read_lock() or " \ + "dev_opp_list_lock protection"); \ +} while (0) + /** * find_device_opp() - find device_opp struct using device pointer * @dev: device pointer used to lookup device OPPs @@ -218,6 +226,8 @@ int dev_pm_opp_get_opp_count(struct device *dev) struct dev_pm_opp *temp_opp; int count = 0; + opp_rcu_lockdep_assert(); + dev_opp = find_device_opp(dev); if (IS_ERR(dev_opp)) { int r = PTR_ERR(dev_opp); @@ -267,6 +277,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, struct device_opp *dev_opp; struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); + opp_rcu_lockdep_assert(); + dev_opp = find_device_opp(dev); if (IS_ERR(dev_opp)) { int r = PTR_ERR(dev_opp); @@ -313,6 +325,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, struct device_opp *dev_opp; struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); + opp_rcu_lockdep_assert(); + if (!dev || !freq) { dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); return ERR_PTR(-EINVAL); @@ -361,6 +375,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, struct device_opp *dev_opp; struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); + opp_rcu_lockdep_assert(); + if (!dev || !freq) { dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); return ERR_PTR(-EINVAL);