From patchwork Tue Jan 10 04:39:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 90624 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp426987qgi; Mon, 9 Jan 2017 20:39:48 -0800 (PST) X-Received: by 10.84.233.133 with SMTP id l5mr1985382plk.129.1484023188763; Mon, 09 Jan 2017 20:39:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si790993pgj.1.2017.01.09.20.39.48; Mon, 09 Jan 2017 20:39:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1764779AbdAJEjq (ORCPT + 13 others); Mon, 9 Jan 2017 23:39:46 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:34403 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1764774AbdAJEjp (ORCPT ); Mon, 9 Jan 2017 23:39:45 -0500 Received: by mail-pf0-f172.google.com with SMTP id 127so39896975pfg.1 for ; Mon, 09 Jan 2017 20:39:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6kDqQUFi3lmLStWi0/tcIbkDAeZq16WKLo+LyDa84tw=; b=ZJ2baZGCJLTXbZYsGS496BLs3xHhT1uYYygkJwYZ/LMLEAMnHBuzmg2m2rb/35fy8S QXsbM/Z0eHE/0THvvxcZYajVtsPBTZ75XrqH3qzzBrNMKFOpC27vkNszlzrKaAvhKzC9 oLHf4NGR+LxivSbL9dhUEV4xSle27Km2dHNQU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6kDqQUFi3lmLStWi0/tcIbkDAeZq16WKLo+LyDa84tw=; b=fuesf7GUnysUFst+uYLxm4I4YDyi71xC8RQDHQp5nzJltQVdQbcplT9CARhmabjwBI 2V6XRDc/zAo07MQZBNjBUUxA71Vf14erd9OAnm7F0ZRD6oMlaWb8n66zjRWRmb5GSdes +Qmvt0jsEOQAo4uqtt+d6JhQvLMfSuub9M8SHII5IhMDmt4vVLsNbe2Bn3leTsQCrSGz VHqNHJY6W+CrdUkTyLP/ba5/snc8DnqGUt/ZJFjemujHdCCnrHk6budxjm6t77C2sDmQ h8upPNRS71yG/9xabIhuywjVpoZC6950gHheKvTTKChpYdb5M4LC5jVZ3khrIGsDnFDa KhEw== X-Gm-Message-State: AIkVDXJIUiOggkJjk/LmZA7ROeXQq9TaW57LjTsSUQc57GMaPSQq23gCr/Kb+Pp1WfxHiOVJ X-Received: by 10.99.204.81 with SMTP id q17mr1672300pgi.168.1484023184406; Mon, 09 Jan 2017 20:39:44 -0800 (PST) Received: from localhost ([122.171.77.55]) by smtp.gmail.com with ESMTPSA id 18sm1127133pgf.28.2017.01.09.20.39.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 20:39:43 -0800 (PST) Date: Tue, 10 Jan 2017 10:09:41 +0530 From: Viresh Kumar To: Stephen Boyd Cc: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Len Brown , Pavel Machek , linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: Re: [PATCH 12/12] PM / OPP: Update Documentation to remove RCU specific bits Message-ID: <20170110043941.GE6332@vireshk-i7> References: <164ad6c0c6a5200eae99a7ac23554f33542f465b.1481106919.git.viresh.kumar@linaro.org> <20170109223937.GR17126@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170109223937.GR17126@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 09-01-17, 14:39, Stephen Boyd wrote: > On 12/07, Viresh Kumar wrote: > > @@ -137,15 +121,18 @@ functions return the matching pointer representing the opp if a match is > > found, else returns error. These errors are expected to be handled by standard > > error checks such as IS_ERR() and appropriate actions taken by the caller. > > > > +Callers of these functions shall call dev_pm_opp_put() after they have used the > > +OPP. Otherwise the memory for the OPP will never get freed and result in > > +memleak. > > + > > dev_pm_opp_find_freq_exact - Search for an OPP based on an *exact* frequency and > > availability. This function is especially useful to enable an OPP which > > is not available by default. > > Example: In a case when SoC framework detects a situation where a > > higher frequency could be made available, it can use this function to > > find the OPP prior to call the dev_pm_opp_enable to actually make it available. > > - rcu_read_lock(); > > opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false); > > - rcu_read_unlock(); > > + dev_pm_opp_put(opp); > > /* dont operate on the pointer.. just do a sanity check.. */ > > if (IS_ERR(opp)) { > > pr_err("frequency not disabled!\n"); > > @@ -163,9 +150,8 @@ dev_pm_opp_find_freq_floor - Search for an available OPP which is *at most* the > > frequency. > > Example: To find the highest opp for a device: > > freq = ULONG_MAX; > > - rcu_read_lock(); > > dev_pm_opp_find_freq_floor(dev, &freq); > > - rcu_read_unlock(); > > + dev_pm_opp_put(opp); > > opp doesn't exist in the scope here. Missing an assignment during > the dev_pm_opp_find_freq_floor() call? Thanks for noticing this. Following is the diff I am adding to this patch: Please add your RBY if it looks fine to you now. -- viresh -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Stephen Boyd diff --git a/Documentation/power/opp.txt b/Documentation/power/opp.txt index be895e32022d..0c007e250cd1 100644 --- a/Documentation/power/opp.txt +++ b/Documentation/power/opp.txt @@ -150,7 +150,7 @@ dev_pm_opp_find_freq_floor - Search for an available OPP which is *at most* the frequency. Example: To find the highest opp for a device: freq = ULONG_MAX; - dev_pm_opp_find_freq_floor(dev, &freq); + opp = dev_pm_opp_find_freq_floor(dev, &freq); dev_pm_opp_put(opp); dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the @@ -159,7 +159,7 @@ dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the frequency. Example 1: To find the lowest opp for a device: freq = 0; - dev_pm_opp_find_freq_ceil(dev, &freq); + opp = dev_pm_opp_find_freq_ceil(dev, &freq); dev_pm_opp_put(opp); Example 2: A simplified implementation of a SoC cpufreq_driver->target: soc_cpufreq_target(..) @@ -252,6 +252,7 @@ dev_pm_opp_get_freq - Retrieve the freq represented by the opp pointer. if (!IS_ERR(max_opp) && !IS_ERR(requested_opp)) r = soc_test_validity(max_opp, requested_opp); dev_pm_opp_put(max_opp); + dev_pm_opp_put(requested_opp); /* do other things */ } soc_test_validity(..)