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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 E4D79C3526B for ; Thu, 17 Dec 2020 18:13:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A46A92396F for ; Thu, 17 Dec 2020 18:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730335AbgLQSMu (ORCPT ); Thu, 17 Dec 2020 13:12:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730216AbgLQSIo (ORCPT ); Thu, 17 Dec 2020 13:08:44 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B7C4C0611CF; Thu, 17 Dec 2020 10:07:35 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id o13so36631787lfr.3; Thu, 17 Dec 2020 10:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=ChchZyVri0yi/O25dvPeSHNQEk3sLXfZVskKc7CN57GBdMMTmWURalf2IM6i2rgvhh qfcMtU+PS/OCGaJjeaVHDM2wBUNa8Tg9f7+ONq/dSM6byM/Y8iogLVMrfOj4dNFwy2Xm Ps6rz8w/7z9Mz8vRMGfOZ86sU3M3S0FpRWA4hoISaf7GtzBRBYpB/pOJM78wLmrasMEr /gb3uNc548kJHGE9V2DfBbDDkAnqUyLpzfbxhrKpEumO23OdI8D7by5pViVe1cJ16DXd 4yhnxob5KSGfDuhxWiH1oLSuAV4B7pIQHOcN3N/ZWY1erLsW1JFmbo1HRGSDSIF6T5LI wT3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=SknprHSEzF813dbEmKVR1JbvWnI34zRa9YWnAE7c0uFxk6I0GkBc24q2CvBtc511J5 WlZ34fOn5+MLmtHiM648i8FkRNBi1axD8aup8S4PUG5fptuol1cSBWmV77hwYAl6eAn9 g3Bznq0myyO0LD2d/DLgJa35rTZSTTS7GC2LYHCHDSHErA0rVou6ZQVAdv+l4gGALfaL +Hrt47Vb1vSHIpWMudUTGAVhDZ2RjqvoSCbvG8scoUJPlkL13STEGhK+Ejela91U85yb wC2/D5aITrX42+Zmvhsu4kZCqPtp4Z4yz0pgS/C249UPgKUr3BsjZxgAaHVzbAZ/KYSL 7bVw== X-Gm-Message-State: AOAM530pXJl6ZcpKPpybxC+WNrHEcx1AT4GSh/og57XtKJpLbjYKmwsQ WqhyPMvakO2BCGUEszECrNQ= X-Google-Smtp-Source: ABdhPJzFSNM0TMMoSxcYKoyhk7r0wzOQ4M8gA685Cb16wgK+4tnur3IzXUR06VdXp1ulyFqi9mnu/A== X-Received: by 2002:a2e:a404:: with SMTP id p4mr220062ljn.260.1608228453811; Thu, 17 Dec 2020 10:07:33 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id u5sm655596lff.78.2020.12.17.10.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:07:33 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Mauro Carvalho Chehab , Rob Herring , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Michael Turquette Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH v2 12/48] opp: Add dev_pm_opp_get_required_pstate() Date: Thu, 17 Dec 2020 21:06:02 +0300 Message-Id: <20201217180638.22748-13-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201217180638.22748-1-digetx@gmail.com> References: <20201217180638.22748-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Add dev_pm_opp_get_required_pstate() which allows OPP users to retrieve required performance state of a given OPP. Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0783a4ac819a..4774701ec82d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -145,6 +145,28 @@ unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_level); +/** + * dev_pm_opp_get_required_pstate() - Gets the required performance state + * corresponding to an available opp + * @opp: opp for which performance state has to be returned for + * @index: index of the required opp + * + * Return: performance state read from device tree corresponding to the + * required opp, else return 0. + */ +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available || + index >= opp->opp_table->required_opp_count) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->required_opps[index]->pstate; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate); + /** * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not * @opp: opp for which turbo mode is being verified diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a17d92d923cc..0298b426fba3 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -98,6 +98,9 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index); + bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); int dev_pm_opp_get_opp_count(struct device *dev); @@ -188,6 +191,13 @@ static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) return 0; } +static inline +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + return 0; +} + static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) { return false; -- 2.29.2 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 EEFEBC2BBCD for ; Thu, 17 Dec 2020 18:07:38 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.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 B3C55238EF for ; Thu, 17 Dec 2020 18:07:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3C55238EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8173987A99; Thu, 17 Dec 2020 18:07:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z3XRFUNRek8b; Thu, 17 Dec 2020 18:07:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 17B5587A8A; Thu, 17 Dec 2020 18:07:38 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 651DC1BF477 for ; Thu, 17 Dec 2020 18:07:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 61B7287A95 for ; Thu, 17 Dec 2020 18:07:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EPQ7PwezNXu7 for ; Thu, 17 Dec 2020 18:07:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by hemlock.osuosl.org (Postfix) with ESMTPS id 7E91F87A8A for ; Thu, 17 Dec 2020 18:07:35 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id 23so59802237lfg.10 for ; Thu, 17 Dec 2020 10:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=ChchZyVri0yi/O25dvPeSHNQEk3sLXfZVskKc7CN57GBdMMTmWURalf2IM6i2rgvhh qfcMtU+PS/OCGaJjeaVHDM2wBUNa8Tg9f7+ONq/dSM6byM/Y8iogLVMrfOj4dNFwy2Xm Ps6rz8w/7z9Mz8vRMGfOZ86sU3M3S0FpRWA4hoISaf7GtzBRBYpB/pOJM78wLmrasMEr /gb3uNc548kJHGE9V2DfBbDDkAnqUyLpzfbxhrKpEumO23OdI8D7by5pViVe1cJ16DXd 4yhnxob5KSGfDuhxWiH1oLSuAV4B7pIQHOcN3N/ZWY1erLsW1JFmbo1HRGSDSIF6T5LI wT3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=bpiuhduXVwgD7TNS/WgvqXQFmtg15JwJhsPS6GBu2SSmVHB79+NFjltaiUhGq8QPUF 88qW7oMpvRXWU7qy3p7nj4BcJEIDbn7ThuMHYUSoax34U3cLfYgxXW7S+epIPCGZ52Fn 3xqLBDtwPfnSHto73d0bETuRTOmm/zVp3GbMFSKJTATULGDUV4AIq6itFIQ+Di7GcQQR 7cRnsfaCZ+EM9P/XDILE2lT1ibjH0vcklzSRntPfK4awmcS8MOUSbpZhPLpJarCQgne6 9OeujI6gMHgDHNUF/a9rZBEDRsPmq+TvDBUm/w5WTvF7EiMSXAp2YeZ1UWrZzNbbSFdg 2D2Q== X-Gm-Message-State: AOAM531ADULLJNNG8LuMJ33ujeq6twegwOoxhGLMk6tnnyuh8267BH49 JjW31FT9V9l+tkpAFtO6Ow4= X-Google-Smtp-Source: ABdhPJzFSNM0TMMoSxcYKoyhk7r0wzOQ4M8gA685Cb16wgK+4tnur3IzXUR06VdXp1ulyFqi9mnu/A== X-Received: by 2002:a2e:a404:: with SMTP id p4mr220062ljn.260.1608228453811; Thu, 17 Dec 2020 10:07:33 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id u5sm655596lff.78.2020.12.17.10.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:07:33 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Mauro Carvalho Chehab , Rob Herring , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Michael Turquette Subject: [PATCH v2 12/48] opp: Add dev_pm_opp_get_required_pstate() Date: Thu, 17 Dec 2020 21:06:02 +0300 Message-Id: <20201217180638.22748-13-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201217180638.22748-1-digetx@gmail.com> References: <20201217180638.22748-1-digetx@gmail.com> MIME-Version: 1.0 X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" Add dev_pm_opp_get_required_pstate() which allows OPP users to retrieve required performance state of a given OPP. Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0783a4ac819a..4774701ec82d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -145,6 +145,28 @@ unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_level); +/** + * dev_pm_opp_get_required_pstate() - Gets the required performance state + * corresponding to an available opp + * @opp: opp for which performance state has to be returned for + * @index: index of the required opp + * + * Return: performance state read from device tree corresponding to the + * required opp, else return 0. + */ +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available || + index >= opp->opp_table->required_opp_count) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->required_opps[index]->pstate; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate); + /** * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not * @opp: opp for which turbo mode is being verified diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a17d92d923cc..0298b426fba3 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -98,6 +98,9 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index); + bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); int dev_pm_opp_get_opp_count(struct device *dev); @@ -188,6 +191,13 @@ static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) return 0; } +static inline +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + return 0; +} + static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) { return false; -- 2.29.2 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 D1BA4C4361B for ; Fri, 18 Dec 2020 08:31:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 8A75B20936 for ; Fri, 18 Dec 2020 08:31:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A75B20936 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E3CB89812; Fri, 18 Dec 2020 08:31:49 +0000 (UTC) Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 56F2A6E1D3 for ; Thu, 17 Dec 2020 18:07:35 +0000 (UTC) Received: by mail-lf1-x136.google.com with SMTP id y19so59727802lfa.13 for ; Thu, 17 Dec 2020 10:07:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=ChchZyVri0yi/O25dvPeSHNQEk3sLXfZVskKc7CN57GBdMMTmWURalf2IM6i2rgvhh qfcMtU+PS/OCGaJjeaVHDM2wBUNa8Tg9f7+ONq/dSM6byM/Y8iogLVMrfOj4dNFwy2Xm Ps6rz8w/7z9Mz8vRMGfOZ86sU3M3S0FpRWA4hoISaf7GtzBRBYpB/pOJM78wLmrasMEr /gb3uNc548kJHGE9V2DfBbDDkAnqUyLpzfbxhrKpEumO23OdI8D7by5pViVe1cJ16DXd 4yhnxob5KSGfDuhxWiH1oLSuAV4B7pIQHOcN3N/ZWY1erLsW1JFmbo1HRGSDSIF6T5LI wT3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vPD7hQ8b5N25hcZTdVSAqhZrBeZE9ONbNkTdFW8v87g=; b=i94ww2Y3XQvb54tzS6353ohi5mBX9dzKBg4RJTJzk6d3mmB8aQ+srERzHmTDhn79h4 ystjX1Tqm++LzCFpT+D/CfekX4oRwEuW9sb4tRYy1+cpm5QKoKaVZKAW+6fG8f9CHB78 FcMRsMS882YqP2eDmif2jIHqU+Z9TfXhyWIhNdyB5N6phJwGEE26svAX1Hj7kIL7simt qzzaNK+vlNpl0KWo97A5xtpHewpZd4oMz1Hq2hAmX5QO+BhBc2MlgCsKrE6ZdtS3tKMN FZADe4tXgb6ZP16mthQ87Fi4GNnSDa3zrY6eFrgOlT9Plf8rgzudnjJ8RbCAyv6Xhz3H fj6w== X-Gm-Message-State: AOAM533rxHOhbjM9QeeK/a2KiziYxFHtJ5ejT25PzSFDFsRmdVrGfJlr OHDwqyRZ769Bf2t6xjHcGt8= X-Google-Smtp-Source: ABdhPJzFSNM0TMMoSxcYKoyhk7r0wzOQ4M8gA685Cb16wgK+4tnur3IzXUR06VdXp1ulyFqi9mnu/A== X-Received: by 2002:a2e:a404:: with SMTP id p4mr220062ljn.260.1608228453811; Thu, 17 Dec 2020 10:07:33 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id u5sm655596lff.78.2020.12.17.10.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 10:07:33 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Liam Girdwood , Ulf Hansson , Mauro Carvalho Chehab , Rob Herring , Peter Geis , Nicolas Chauvet , Krzysztof Kozlowski , "Rafael J. Wysocki" , Kevin Hilman , Peter De Schrijver , Viresh Kumar , Stephen Boyd , Michael Turquette Subject: [PATCH v2 12/48] opp: Add dev_pm_opp_get_required_pstate() Date: Thu, 17 Dec 2020 21:06:02 +0300 Message-Id: <20201217180638.22748-13-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201217180638.22748-1-digetx@gmail.com> References: <20201217180638.22748-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 18 Dec 2020 08:31:48 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add dev_pm_opp_get_required_pstate() which allows OPP users to retrieve required performance state of a given OPP. Signed-off-by: Dmitry Osipenko --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0783a4ac819a..4774701ec82d 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -145,6 +145,28 @@ unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_level); +/** + * dev_pm_opp_get_required_pstate() - Gets the required performance state + * corresponding to an available opp + * @opp: opp for which performance state has to be returned for + * @index: index of the required opp + * + * Return: performance state read from device tree corresponding to the + * required opp, else return 0. + */ +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available || + index >= opp->opp_table->required_opp_count) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->required_opps[index]->pstate; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_required_pstate); + /** * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not * @opp: opp for which turbo mode is being verified diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index a17d92d923cc..0298b426fba3 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -98,6 +98,9 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index); + bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); int dev_pm_opp_get_opp_count(struct device *dev); @@ -188,6 +191,13 @@ static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) return 0; } +static inline +unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, + unsigned int index) +{ + return 0; +} + static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) { return false; -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel