From patchwork Tue Dec 16 00:42:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 5498751 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 46352BEEA8 for ; Tue, 16 Dec 2014 00:42:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C5842037B for ; Tue, 16 Dec 2014 00:42:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 820F52008F for ; Tue, 16 Dec 2014 00:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567AbaLPAmT (ORCPT ); Mon, 15 Dec 2014 19:42:19 -0500 Received: from mail-yk0-f180.google.com ([209.85.160.180]:41499 "EHLO mail-yk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752506AbaLPAmR (ORCPT ); Mon, 15 Dec 2014 19:42:17 -0500 Received: by mail-yk0-f180.google.com with SMTP id 9so5496547ykp.11 for ; Mon, 15 Dec 2014 16:42:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=dCv82PzRZkHk031wAywH5LZAVXjxbES9uocaY1w3ZiM=; b=lM9yoR4L6ocuYljaJo2BD2svvKfk3GagGgB9xU97puPHtOPmAZfYArN3PeYubW5XSh 02bSEgOwjYBASk7dTjCKay6tH5i+PCC+RhAgkAcbBOXw/saRXK+J3Dov0TLIdS6RmFan DlgjVJH5J00WvRGWSJHV3Uv+BqSX2FAikdGK5wx/zXjhO/E0JBh+dt26rtU1oxznNRQx ntwpCxuGvy/ouGSkrhciS/tpKuc5ygeceCutprn3QVKEMGBSwT4Zw5RSzV3sB4m54MdS dSDfMlmZG93YNpVN1Xxn7LFtBFMNk4UP9CuE7YVlgkCB1lltIB+bVrfDeHCuGTMD1IDv 0qjg== X-Gm-Message-State: ALoCoQnKsiMipNo9T0jaIbF85/kLuJbrNQyIb/4QTjO/T9OIig+uthLeYLIokr27KzI53WlLYrkx X-Received: by 10.236.27.4 with SMTP id d4mr14392070yha.73.1418690536549; Mon, 15 Dec 2014 16:42:16 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1301:edc3:4b7a:3f05:ce06]) by mx.google.com with ESMTPSA id c63sm6904335yhc.24.2014.12.15.16.42.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 15 Dec 2014 16:42:15 -0800 (PST) Date: Mon, 15 Dec 2014 16:42:04 -0800 From: Dmitry Torokhov To: "Rafael J. Wysocki" Cc: Pavel Machek , Len Brown , Greg Kroah-Hartman , Viresh Kumar , Nishanth Menon , Chander Kashyap , Inderpal Singh , Paul Gortmaker , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PM / OPP: add some lockdep annotations Message-ID: <20141216004204.GA30467@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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=ham 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 --- drivers/base/power/opp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index d24dd614a..852eebf 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -218,6 +218,11 @@ int dev_pm_opp_get_opp_count(struct device *dev) struct dev_pm_opp *temp_opp; int count = 0; + rcu_lockdep_assert(rcu_read_lock_held() || + lockdep_is_held(&dev_opp_list_lock), + "dev_pm_opp_get_opp_count() needs rcu_read_lock() " + "or dev_opp_list_lock protection"); + dev_opp = find_device_opp(dev); if (IS_ERR(dev_opp)) { int r = PTR_ERR(dev_opp); @@ -267,6 +272,11 @@ 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); + rcu_lockdep_assert(rcu_read_lock_held() || + lockdep_is_held(&dev_opp_list_lock), + "dev_pm_opp_find_freq_exact() needs rcu_read_lock() " + "or dev_opp_list_lock protection"); + dev_opp = find_device_opp(dev); if (IS_ERR(dev_opp)) { int r = PTR_ERR(dev_opp); @@ -313,6 +323,11 @@ 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); + rcu_lockdep_assert(rcu_read_lock_held() || + lockdep_is_held(&dev_opp_list_lock), + "dev_pm_opp_find_freq_ceil() needs rcu_read_lock() " + "or dev_opp_list_lock protection"); + if (!dev || !freq) { dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); return ERR_PTR(-EINVAL); @@ -361,6 +376,11 @@ 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); + rcu_lockdep_assert(rcu_read_lock_held() || + lockdep_is_held(&dev_opp_list_lock), + "dev_pm_opp_find_freq_floor() needs rcu_read_lock() " + "or dev_opp_list_lock protection"); + if (!dev || !freq) { dev_err(dev, "%s: Invalid argument freq=%p\n", __func__, freq); return ERR_PTR(-EINVAL);