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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 D6DCCC388F7 for ; Wed, 28 Oct 2020 14:10:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 5AC2224726 for ; Wed, 28 Oct 2020 14:10:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TkKL2BAH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AC2224726 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rgTH0KvkdbPWTU36VetMOR6hkc4fV0tZBpUOKfn1O+A=; b=TkKL2BAHHaybiuoJGPOAmTMiK7 utId6DZ8FvVQVVGR6UQ1f+YXo/sFkhGTxo0KsqBJgtqpwD0OSm2LjN8Ki9A8NnaPF2De9wo9//K8F hzVYc6vrYm1Z6p61z2gIr4tr/0eybdindY41T7tCkfV1BebMSKzbH3eHfLdRqx56TQi7BAsqg0+RN 84anrsl/v5I77++gk7gih1sslrB3SsdcsaM5AqW1AZGxgd1p0fgwSELwELc9ktHDRokNM0NT3Cr1I vbnb3vOtvOynRt/DwjrKxJHNKszUWJQ2u6CCsUXnSjxTCroQdb9pF7WXOCL8RzMBK2rUsMfqosZNH sgLyRYeQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXm8u-00086V-Ks; Wed, 28 Oct 2020 14:09:36 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXm8j-00083L-Cw for linux-arm-kernel@lists.infradead.org; Wed, 28 Oct 2020 14:09:27 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21ABC19BF; Wed, 28 Oct 2020 07:09:23 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.12.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6FE6B3F66E; Wed, 28 Oct 2020 07:09:20 -0700 (PDT) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, vireshk@kernel.org, robh+dt@kernel.org Subject: [PATCH 2/4] OPP: Add support for parsing the 'opp-sustainable' property Date: Wed, 28 Oct 2020 14:08:45 +0000 Message-Id: <20201028140847.1018-3-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201028140847.1018-1-lukasz.luba@arm.com> References: <20201028140847.1018-1-lukasz.luba@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201028_100925_984508_FB773649 X-CRM114-Status: GOOD ( 18.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, rafael@kernel.org, sboyd@kernel.org, daniel.lezcano@linaro.org, sudeep.holla@arm.com, Dietmar.Eggemann@arm.com, lukasz.luba@arm.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that the OPP bindings are updated to include an optional 'opp-sustainable' property, add support to parse it from device tree and store it as part of dev_pm_opp structure. Also add and export an helper 'dev_pm_opp_get_sustainable()' that can be used to get the sustainable OPP when present. Signed-off-by: Lukasz Luba --- drivers/opp/core.c | 26 ++++++++++++++++++++++++++ drivers/opp/of.c | 14 ++++++++++++++ drivers/opp/opp.h | 3 +++ include/linux/pm_opp.h | 6 ++++++ 4 files changed, 49 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 9915e8487f0b..bb1e68b96d0e 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -299,6 +299,32 @@ unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp_freq); +/** + * dev_pm_opp_get_sustainable_opp_freq() - Get frequency of sustainable opp + * in Hz + * @dev: device for which we do this operation + * + * Return: This function returns the frequency of the OPP marked as + * sustainable_opp if one is available, else returns 0; + */ +unsigned long dev_pm_opp_get_sustainable_opp_freq(struct device *dev) +{ + struct opp_table *opp_table; + unsigned long freq = 0; + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) + return 0; + + if (opp_table->sustainable_opp && opp_table->sustainable_opp->available) + freq = dev_pm_opp_get_freq(opp_table->sustainable_opp); + + dev_pm_opp_put_opp_table(opp_table); + + return freq; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_sustainable_opp_freq); + int _get_opp_count(struct opp_table *opp_table) { struct dev_pm_opp *opp; diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 9faeb83e4b32..1f6b19bb1a95 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -815,6 +815,20 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, } } + if (of_property_read_bool(np, "opp-sustainable")) { + if (opp_table->sustainable_opp) { + /* Pick the OPP with higher rate as sustainable OPP */ + if (new_opp->rate > opp_table->sustainable_opp->rate) { + opp_table->sustainable_opp->sustainable = false; + new_opp->sustainable = true; + opp_table->sustainable_opp = new_opp; + } + } else { + new_opp->sustainable = true; + opp_table->sustainable_opp = new_opp; + } + } + if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index ebd930e0b3ca..45288ccbb295 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -56,6 +56,7 @@ extern struct list_head opp_tables; * @dynamic: not-created from static DT entries. * @turbo: true if turbo (boost) OPP * @suspend: true if suspend OPP + * @sustainable: true if sustainable OPP * @pstate: Device's power domain's performance state. * @rate: Frequency in hertz * @level: Performance level @@ -78,6 +79,7 @@ struct dev_pm_opp { bool dynamic; bool turbo; bool suspend; + bool sustainable; unsigned int pstate; unsigned long rate; unsigned int level; @@ -183,6 +185,7 @@ struct opp_table { unsigned int parsed_static_opps; enum opp_table_access shared_opp; struct dev_pm_opp *suspend_opp; + struct dev_pm_opp *sustainable_opp; struct mutex genpd_virt_dev_lock; struct device **genpd_virt_devs; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index dbb484524f82..363d5a2c1ef3 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -106,6 +106,7 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev); unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev); unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev); +unsigned long dev_pm_opp_get_sustainable_opp_freq(struct device *dev); struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, @@ -215,6 +216,11 @@ static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) return 0; } +static inline unsigned long dev_pm_opp_get_sustainable_opp_freq(struct device *dev) +{ + return 0; +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available) { -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel