From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_NEOMUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A48F9C10F11 for ; Wed, 10 Apr 2019 06:29:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 719252133D for ; Wed, 10 Apr 2019 06:29:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XlKSgBx4"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UCyfNCr5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 719252133D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MEiQppOLhy2DIPopkw8zeHJH69rhsa0Y+2ATLqP+ZAY=; b=XlKSgBx4n6nlTP 8vV8TmiftJh2zLMCqLmOMwgYZwW7k++10IhbsorB2KEN0E+scBSXnzxnqFXEas3KUmZA2bG2V6L+d cLhDcPwaiY4v1v/haV7F97joqdg2kjSJq9QfJhEfkbT+LdWStjHRGlrVJYltK7crVxQZP6QbwdfMQ eT41BHhtibay4Vf75FvMkPZHkcnoGAppfu0Bp1OXenSwwSr796lBwcUfwohvliwCoD2jHo6T4B2+8 aR5X8fjxO5wN2wtDwqdwVU9/rL2xOXdGZFW0GDIbHCHunYgz9eZXg0TvBMNabRMPgizkE+ySfnsat eOPig/jUVhpJipMu9lZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hE6jW-0006g8-3i; Wed, 10 Apr 2019 06:29:18 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hE6jS-0006fP-UK for linux-arm-kernel@lists.infradead.org; Wed, 10 Apr 2019 06:29:16 +0000 Received: by mail-pg1-x544.google.com with SMTP id k3so906907pga.6 for ; Tue, 09 Apr 2019 23:29:14 -0700 (PDT) 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=xwfoUJqPA7B1qNvVW6xqIft2TcTCZV15J00JP5m2zL0=; b=UCyfNCr519TJ50zJhOYOS3XKdK0WnZVYhD5rWWcwm5L+T5bcxT1LczBzkY6bHu6BbZ Mq6EKHOZYz8zBPDZC4PThzCQbbpvAZ75UJMy9XcVMRHyHe74YoH2niI771wWBOitsY5K RALtn2igb0aj1KJWqiveis3Tv0VroWV0Sc23h+mTdYuLUlOegjP+YOWxHvRL2GxjQbsI 1mSchPAZq4NEXqW8mc2GUZpr9sE10Sp1C92sSoKdis2uOvfOyfx/KbvCithIp7QY9Qn8 DF22GRECTU9827sKvmqsEYqKvpodXBM5CfuzB9EUJ0MEl/uWslrv7y8HJN3oQVBA4Bc8 p/ww== 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=xwfoUJqPA7B1qNvVW6xqIft2TcTCZV15J00JP5m2zL0=; b=rJub/hTr34lQKqRRWGxTc/6k1HMGXXLyMb4iuihU30AKbQKqndLMF7VlWpMjh77AR2 rQaBUGoK/s9z9oyxOuiNvfdI2bx6fLhTFqJ2dycrxBiL4l+pm85BRchBw5Z+qGnqCLbG INyJhBwwhKTx9i4mW0Spem+iqZMZsOVfm7lAsAGhS+Ic+nga+C/BlPYyIOD5c2D94ZhC 1SYWNe22aaINImhQN3ROwphC12FRtUcF3nKEB9FOjPCcwykdHFqrtLZd6PpD/QKW7dLE xLvh7PKdtGUWGUKaG0X7P5sqMePS32oPkDoGPwunichK2M+xC9WUR3HN1ePTS0gqoOK/ CMRA== X-Gm-Message-State: APjAAAVsubKX8pLd834xkQRN2B4xPe27kYmRvH5nzIXrw0zlgBQdkVr1 U3YzSnzNA3tZyP6lFX472tLplQ== X-Google-Smtp-Source: APXvYqwhCjnR8iyO0qw7uyNVRkxDrU991+dX+WGTKAyB0guZWqyPfl3YUsBqGPPZOoIM+eCh3ZxgIQ== X-Received: by 2002:a63:195f:: with SMTP id 31mr39424906pgz.116.1554877753878; Tue, 09 Apr 2019 23:29:13 -0700 (PDT) Received: from localhost ([122.166.139.136]) by smtp.gmail.com with ESMTPSA id a129sm79153601pfa.152.2019.04.09.23.29.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 23:29:11 -0700 (PDT) Date: Wed, 10 Apr 2019 11:59:09 +0530 From: Viresh Kumar To: "Andrew-sh.Cheng" Subject: Re: [PATCH v2 2/4] opp: add API which get max freq by voltage Message-ID: <20190410062909.6nkl4m4j5evrmqrl@vireshk-i7> References: <1553841972-19737-1-git-send-email-andrew-sh.cheng@mediatek.com> <1553841972-19737-3-git-send-email-andrew-sh.cheng@mediatek.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1553841972-19737-3-git-send-email-andrew-sh.cheng@mediatek.com> User-Agent: NeoMutt/20180323-120-3dd1ac X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190409_232915_000368_604D7920 X-CRM114-Status: GOOD ( 18.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, srv_heupstream@mediatek.com, linux-pm@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Rob Herring , Chanwoo Choi , Kyungmin Park , MyungJoo Ham , linux-mediatek@lists.infradead.org, Matthias Brugger , fan.chen@mediatek.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 29-03-19, 14:46, Andrew-sh.Cheng wrote: > This API will get voltage as input parameter. > Search all opp items for the item which with max frequency, > and the voltae is smaller than provided voltage. > > Signed-off-by: Andrew-sh.Cheng > --- > drivers/opp/core.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ > include/linux/pm_opp.h | 8 ++++++++ > 2 files changed, 63 insertions(+) I have applied this patch with some modifications, here is the diff: --- drivers/opp/core.c | 29 ++++++++++++++--------------- include/linux/pm_opp.h | 8 ++++---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 7323cd9aabf9..0e7703fe733f 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -527,31 +527,30 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); /** - * dev_pm_opp_find_max_freq_by_volt() - Search for a opp with max freq - * under provided voltage - * @dev: device for which we do this operation - * @u_volt: provided voltage + * dev_pm_opp_find_freq_ceil_by_volt() - Find OPP with highest frequency for + * target voltage. + * @dev: Device for which we do this operation. + * @u_volt: Target voltage. + * + * Search for OPP with highest (ceil) frequency and has voltage <= u_volt. * - * Search for the matching available OPP which provide voltage can support. + * Return: matching *opp, else returns ERR_PTR in case of error which should be + * handled using IS_ERR. * - * Return: matching *opp, else returns ERR_PTR in case of error - * and should be handled using IS_ERR. * Error return values can be: - * EINVAL: for bad pointer - * ERANGE: no match found for search - * ENODEV: if device not found in list of registered devices + * EINVAL: bad parameters * * The callers are required to call dev_pm_opp_put() for the returned OPP after * use. */ -struct dev_pm_opp *dev_pm_opp_find_max_freq_by_volt(struct device *dev, - unsigned long u_volt) +struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev, + unsigned long u_volt) { struct opp_table *opp_table; struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE); if (!dev || !u_volt) { - dev_err(dev, "%s: Invalid argument volt=%d\n", __func__, + dev_err(dev, "%s: Invalid argument volt=%lu\n", __func__, u_volt); return ERR_PTR(-EINVAL); } @@ -564,7 +563,6 @@ struct dev_pm_opp *dev_pm_opp_find_max_freq_by_volt(struct device *dev, list_for_each_entry(temp_opp, &opp_table->opp_list, node) { if (temp_opp->available) { - /* go to the next node, before choosing prev */ if (temp_opp->supplies[0].u_volt > u_volt) break; opp = temp_opp; @@ -574,12 +572,13 @@ struct dev_pm_opp *dev_pm_opp_find_max_freq_by_volt(struct device *dev, /* Increment the reference count of OPP */ if (!IS_ERR(opp)) dev_pm_opp_get(opp); + mutex_unlock(&opp_table->lock); dev_pm_opp_put_opp_table(opp_table); return opp; } -EXPORT_SYMBOL_GPL(dev_pm_opp_find_max_freq_by_volt); +EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil_by_volt); static int _set_opp_voltage(struct device *dev, struct regulator *reg, struct dev_pm_opp_supply *supply) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 57deef9cf5d3..b150fe97ce5a 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -102,8 +102,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq); -struct dev_pm_opp *dev_pm_opp_find_max_freq_by_volt(struct device *dev, - unsigned long u_volt); +struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev, + unsigned long u_volt); struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, unsigned long *freq); @@ -209,8 +209,8 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, return ERR_PTR(-ENOTSUPP); } -static inline struct dev_pm_opp *dev_pm_opp_find_max_freq_by_volt(struct device *dev, - unsigned long u_volt) +static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev, + unsigned long u_volt) { return ERR_PTR(-ENOTSUPP); } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel