Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp862866pxb; Wed, 3 Feb 2021 21:52:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1qYhWoxm/tiujYmXA6b35oZF/6uISmpQqHuI3jFhUj0C4VXAL8IQ4L3on/PP/83yYLu5a X-Received: by 2002:aa7:c2c7:: with SMTP id m7mr6472411edp.134.1612417934750; Wed, 03 Feb 2021 21:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612417934; cv=none; d=google.com; s=arc-20160816; b=L5D3ktKbJXk5NF5L/GdZUVrkvrqo5loBO0UEPIftzqKybLm+ybdIJxJbmEDK0HWwIQ 8qMYIBMyTX1LR55cFsw91X/xRP/tZBnFRhR3llGD5U/RilLkqLjrCW5GoPhgPFeVk0im lemYW6A5f+3Z0oXlY4GSDb/pu5BrlCp7RxQCvZSMlQjU/P8BvkADV3dzAb7MgmMqyEwA N4AmySOU14FeG28XytOCpT5njIsW1odqzZOVoDg/fwcppWNjsnzzcMchothiaxXjSm2m m6EwacBC4oBH4mX/ivYcEa26xuumrQvJfBEdMxVB67zgzg5JIRmfbCUugxcnbvNP0nZW 254Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KyojcS0OuJamrwyKsNSmnu2upiRPh0xOegZncnEILlM=; b=k5JtwcmJDNfkA7bVeQsUUy49lVNKm/ACs8HmiINxzvtar7PojICael5CGzXMushOpm nRMLPzkK+owZgrPtuRoF+ecxKWxarOAyXjSppGWlF4fhfWJsjynCiREI+NaTbmz64Gyv 9Oh4+7Nc8MCXrj7ByFHx3BmQ4dIOi8QdIpugcxDEVII5vhSI2MOdDmvANuHdD7+xN2Ny 6bO2U6f5v8YKWQsXlhFrSI5reLJTLgrYM+eHaCX5TsYpBjnozoB7DSPf4MGSIZ7SG9eg VBTpPyllpeOb2lVEXlIJQufNC2iTrnjCBgZEmcaxL7+vyxsssNw5dsFlwZZezH83vb4h M9Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rps3pL2i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sa7si2723272ejb.28.2021.02.03.21.51.48; Wed, 03 Feb 2021 21:52:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rps3pL2i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231791AbhBDFro (ORCPT + 99 others); Thu, 4 Feb 2021 00:47:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230263AbhBDFrm (ORCPT ); Thu, 4 Feb 2021 00:47:42 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F2E1C0613ED for ; Wed, 3 Feb 2021 21:47:02 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id lw17so4522784pjb.0 for ; Wed, 03 Feb 2021 21:47:02 -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=KyojcS0OuJamrwyKsNSmnu2upiRPh0xOegZncnEILlM=; b=Rps3pL2i1mnueKuQdus5KbOfSZ48aSMWFXDPs/Lm8FDW42pAdWx2J+RlEODeCuoPl6 XUnAECdOyiInABbGe6jy2qhTW8zBJWo3xk3G97wMzGER5JsimF3g9GNtz2OQ0H+M93Z+ oQ/OalyZF76Nx2n8+hC2mO5xieOYo3uWIOEpuoB1cDz89sPeuUKDWEhPE9M8TRMwzqCx zAamPPHk2C0+6XJ2B22uI4InfP2rLNHt5ljw9DIk35K64jVozhRo7oeT7k9plAtfWaPP Pu+e6dK6V7oVuDqKZzDiZdTKbgj9YpI5599Wj8SOwgQ+wENig6y2+k/WUvKeVVJ0bub7 Ee3A== 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=KyojcS0OuJamrwyKsNSmnu2upiRPh0xOegZncnEILlM=; b=FCAwjDo8ROCCsAMTC8o0J3G3o1+GAJFHhvgsY1yklFzzwPtU7uJuYScd/Oiqr53j4T 7xR/Kkv743K31gvVdlly4gHUTI8w41nmvM4s7vM1iA4LzxB521Vzrv2svf7Ed2MJukY5 yEy53VI+Z4+S/EtiPmYiOdPM5fI1dn1niK2fOHI1j3R8LYH+BVfa7IpifEEgM/B1gFsJ i0px2n1M+mbyG7D0VC5s68MJIB6Did9j+Padp+xCr4n1+H8vUxq8XPMi2AJ27636tZ5v qSvpTrDa5V8VG+qH85PZ10kLPlzM/gau/cFdT/hEvNR5jCGIXpZbien7jmx2Hnud7JFd F3OA== X-Gm-Message-State: AOAM531iDL0GgAV+dMi+f7Vp0CY67OyhFJWtLijzGHtdSXqV9iSMW1at Kzo5aqM7knDNS82rc1or1wTnmA== X-Received: by 2002:a17:902:b190:b029:df:fff2:c345 with SMTP id s16-20020a170902b190b02900dffff2c345mr6402458plr.17.1612417621764; Wed, 03 Feb 2021 21:47:01 -0800 (PST) Received: from localhost ([122.172.59.240]) by smtp.gmail.com with ESMTPSA id z11sm4270598pfk.97.2021.02.03.21.47.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Feb 2021 21:47:00 -0800 (PST) Date: Thu, 4 Feb 2021 11:16:58 +0530 From: Viresh Kumar To: Hsin-Yi Wang Cc: Viresh Kumar , linux-pm@vger.kernel.org, Nishanth Menon , Stephen Boyd , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, "MyungJoo Ham )" , Kyungmin Park , Chanwoo Choi , Saravana Kannan Subject: Re: [PATCH v5 1/3] OPP: Add function to look up required OPP's for a given OPP Message-ID: <20210204054658.aujpukq657ziabde@vireshk-i7> References: <20210203092400.1791884-1-hsinyi@chromium.org> <20210203092400.1791884-2-hsinyi@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203092400.1791884-2-hsinyi@chromium.org> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03-02-21, 17:23, Hsin-Yi Wang wrote: > From: Saravana Kannan > > Add a function that allows looking up required OPPs given a source OPP > table, destination OPP table and the source OPP. > > Signed-off-by: Saravana Kannan > Signed-off-by: Hsin-Yi Wang > --- > drivers/opp/core.c | 58 ++++++++++++++++++++++++++++++++++++++++++ > include/linux/pm_opp.h | 11 ++++++++ > 2 files changed, 69 insertions(+) > > diff --git a/drivers/opp/core.c b/drivers/opp/core.c > index dc95d29e94c1b..878f066b972cc 100644 > --- a/drivers/opp/core.c > +++ b/drivers/opp/core.c > @@ -2398,6 +2398,64 @@ devm_pm_opp_attach_genpd(struct device *dev, const char **names, > } > EXPORT_SYMBOL_GPL(devm_pm_opp_attach_genpd); > > +/** > + * dev_pm_opp_xlate_required_opp() - Find required OPP for @src_table OPP. > + * @src_table: OPP table which has @dst_table as one of its required OPP table. > + * @dst_table: Required OPP table of the @src_table. > + * > + * This function returns the OPP (present in @dst_table) pointed out by the > + * "required-opps" property of the OPP (present in @src_table). > + * > + * The callers are required to call dev_pm_opp_put() for the returned OPP after > + * use. > + * > + * Return: destination table OPP on success, otherwise NULL on errors. > + */ > +struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, > + struct opp_table *dst_table, > + struct dev_pm_opp *src_opp) > +{ > + struct dev_pm_opp *opp, *dest_opp = NULL; > + int i; > + > + if (!src_table || !dst_table || !src_opp || > + !src_table->required_opp_tables) > + return NULL; > + > + /* required-opps not fully initialized yet */ > + if (lazy_linking_pending(src_table)) > + return NULL; > + > + for (i = 0; i < src_table->required_opp_count; i++) { > + if (src_table->required_opp_tables[i] == dst_table) > + break; > + } > + > + if (unlikely(i == src_table->required_opp_count)) { > + pr_err("%s: Couldn't find matching OPP table (%p: %p)\n", > + __func__, src_table, dst_table); > + return NULL; > + } > + > + mutex_lock(&src_table->lock); > + > + list_for_each_entry(opp, &src_table->opp_list, node) { > + if (opp == src_opp) { > + dest_opp = opp->required_opps[i]; > + dev_pm_opp_get(dest_opp); > + goto unlock; > + } > + } > + > + pr_err("%s: Couldn't find matching OPP (%p: %p)\n", __func__, src_table, > + dst_table); > + > +unlock: > + mutex_unlock(&src_table->lock); > + > + return dest_opp; > +} > + > /** > * dev_pm_opp_xlate_performance_state() - Find required OPP's pstate for src_table. > * @src_table: OPP table which has dst_table as one of its required OPP table. > diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h > index ab1d15ce559db..6f5f72a7f601c 100644 > --- a/include/linux/pm_opp.h > +++ b/include/linux/pm_opp.h > @@ -156,6 +156,9 @@ struct opp_table *devm_pm_opp_register_set_opp_helper(struct device *dev, int (* > struct opp_table *dev_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); > void dev_pm_opp_detach_genpd(struct opp_table *opp_table); > struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, const char **names, struct device ***virt_devs); > +struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_table, > + struct opp_table *dst_table, > + struct dev_pm_opp *src_opp); > int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); > int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); > int dev_pm_opp_set_opp(struct device *dev, struct dev_pm_opp *opp); > @@ -367,6 +370,14 @@ static inline struct opp_table *devm_pm_opp_attach_genpd(struct device *dev, > return ERR_PTR(-EOPNOTSUPP); > } > > +static inline struct dev_pm_opp *dev_pm_opp_xlate_required_opp( > + struct opp_table *src_table, > + struct opp_table *dst_table, > + struct dev_pm_opp *src_opp) > +{ > + return NULL; > +} Like other routines that return opp *, don't return NULL on errors but a valid error number instead. And follow the declaration format of other routines from this file, don't break lines etc.. > + > static inline int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate) > { > return -EOPNOTSUPP; > -- > 2.30.0.365.g02bc693789-goog -- viresh