From patchwork Wed Aug 7 22:31:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11082783 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E597114DB for ; Wed, 7 Aug 2019 22:31:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D746428A5C for ; Wed, 7 Aug 2019 22:31:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB58C28ABA; Wed, 7 Aug 2019 22:31:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A45228A5C for ; Wed, 7 Aug 2019 22:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389471AbfHGWbU (ORCPT ); Wed, 7 Aug 2019 18:31:20 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:42364 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389284AbfHGWbT (ORCPT ); Wed, 7 Aug 2019 18:31:19 -0400 Received: by mail-qk1-f202.google.com with SMTP id p18so7026011qke.9 for ; Wed, 07 Aug 2019 15:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=ckpmb+TNBKBpyxo3hmHEyu4vxqKi6Nk6GzLW2/f2keU=; b=BSiqMpq6HoHNp0p49Nzkyt13lkHVX/6GuQpF8Kr8KnGBApx+sMX49a0LJvr8MGIUjS EdPDbkfgrECeizFLqhMGngAXCxcAZ0cTnWpnR65ROBYXP/G7QR3LGE2rbLw2Cra4ThiM 7rrCINPrbNFIOy+XrgB+T0lBNam/8Wac5k3l2IFjBBu8MdAwOmsgFSWKndSDyYHrO1Xh TtHur7MsUe0HOzKF/E4BPURvDt23OGElVYq5r9NgKsaDuiEsW3bR35MH3nXQTNGrTwwV sFaHapXc6X2Nv71ho23ujXWOM4Y10idK1WOQOJmoGP/BzLFZzboUCloJTqNyBnSILmLE VprQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ckpmb+TNBKBpyxo3hmHEyu4vxqKi6Nk6GzLW2/f2keU=; b=iuC5hj/DsPo1iJ2J9olIHFuIybgn/N+CB8J+Ziv894eBprnYwe+TqFM/F36oIVkAEI aW93/ut+xuaqdfQPSzVWqrc5JLtcNWc69tQaO8BN9wiiIblrer96wrJ1bFsWFKVfRUee zlh4+F0U9dzwpJzDC3Ll9RMV5KUTV0QqiBx6iBbpgjlwqwmQAEJEqJfwcSvUNb9IbGJ/ ymVhAEsdqilZqAVJ+a/+Qw2cRTtPQa1GBxGFuoR+Nn85CiOtMnGug3UWrQXWwAiGc6AO y7hHS8/A9jUTBcbmytzbR1f+CVTWsoD9IVOueBnzYxTdrO0Rq+dMA8ub8yKccZlCxSZv WMFg== X-Gm-Message-State: APjAAAXia0oEbKFYWS0u685637HAwWXGF4ATMxwvpoF3ufMIseGsKu7a oi3UsD8uZ7mZP2/JZT8m4yS2U+Ei3lh7zBs= X-Google-Smtp-Source: APXvYqxDhQTeMZ27YhUXhV335PAv5RzZgLceI6C81MqWo0wkCxeUetGuTCa6PoXaTHbL84zYlcM32MoiII/dMXk= X-Received: by 2002:a37:be87:: with SMTP id o129mr10537574qkf.31.1565217078090; Wed, 07 Aug 2019 15:31:18 -0700 (PDT) Date: Wed, 7 Aug 2019 15:31:09 -0700 In-Reply-To: <20190807223111.230846-1-saravanak@google.com> Message-Id: <20190807223111.230846-2-saravanak@google.com> Mime-Version: 1.0 References: <20190807223111.230846-1-saravanak@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v5 1/3] dt-bindings: opp: Introduce opp-peak-kBps and opp-avg-kBps bindings From: Saravana Kannan To: Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Georgi Djakov , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, adharmap@codeaurora.org, Rajendra Nayak , sibis@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Interconnects often quantify their performance points in terms of bandwidth. So, add opp-peak-kBps (required) and opp-avg-kBps (optional) to allow specifying Bandwidth OPP tables in DT. opp-peak-kBps is a required property that replaces opp-hz for Bandwidth OPP tables. opp-avg-kBps is an optional property that can be used in Bandwidth OPP tables. Signed-off-by: Saravana Kannan Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/opp/opp.txt | 15 ++++++++++++--- .../devicetree/bindings/property-units.txt | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt index 68592271461f..dbad8eb6c746 100644 --- a/Documentation/devicetree/bindings/opp/opp.txt +++ b/Documentation/devicetree/bindings/opp/opp.txt @@ -83,9 +83,14 @@ properties. Required properties: - opp-hz: Frequency in Hz, expressed as a 64-bit big-endian integer. This is a - required property for all device nodes but devices like power domains. The - power domain nodes must have another (implementation dependent) property which - uniquely identifies the OPP nodes. + required property for all device nodes except for devices like power domains + or bandwidth opp tables. The power domain nodes must have another + (implementation dependent) property which uniquely identifies the OPP nodes. + The interconnect opps are required to have the opp-peak-kBps property. + +- opp-peak-kBps: Peak bandwidth in kilobytes per second, expressed as a 32-bit + big-endian integer. This is a required property for all devices that don't + have opp-hz. For example, bandwidth OPP tables for interconnect paths. Optional properties: - opp-microvolt: voltage in micro Volts. @@ -132,6 +137,10 @@ Optional properties: - opp-level: A value representing the performance level of the device, expressed as a 32-bit integer. +- opp-avg-kBps: Average bandwidth in kilobytes per second, expressed as a + 32-bit big-endian integer. This property is only meaningful in OPP tables + where opp-peak-kBps is present. + - clock-latency-ns: Specifies the maximum possible transition latency (in nanoseconds) for switching to this OPP from any other OPP. diff --git a/Documentation/devicetree/bindings/property-units.txt b/Documentation/devicetree/bindings/property-units.txt index e9b8360b3288..c80a110c1e26 100644 --- a/Documentation/devicetree/bindings/property-units.txt +++ b/Documentation/devicetree/bindings/property-units.txt @@ -41,3 +41,7 @@ Temperature Pressure ---------------------------------------- -kpascal : kilopascal + +Throughput +---------------------------------------- +-kBps : kilobytes per second From patchwork Wed Aug 7 22:31:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11082785 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 381001709 for ; Wed, 7 Aug 2019 22:31:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25A3328A5C for ; Wed, 7 Aug 2019 22:31:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19E9B28AB8; Wed, 7 Aug 2019 22:31:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A475528A75 for ; Wed, 7 Aug 2019 22:31:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389519AbfHGWbX (ORCPT ); Wed, 7 Aug 2019 18:31:23 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:54587 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389465AbfHGWbW (ORCPT ); Wed, 7 Aug 2019 18:31:22 -0400 Received: by mail-qt1-f201.google.com with SMTP id t5so83571771qtd.21 for ; Wed, 07 Aug 2019 15:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=f/5iyKYNpppjBF3zdaFLWaB9mtwpqzd2AKaKjPJxAWs=; b=oG/h5CSE4Vl8m9nJpZKL2XmKPaShpcaKcKIvjDfvwRS9zUFnoyEJ3iouLQdGeCZq+E hf9dKIkpZb9iIuxITVcANYzlRy6K7U+DS0F6TsUJOUjUBN39vlI6rEFj7nwKYnjH1jnX 6aSKpaBVNOrDAU8lFkxwVB4padlrh79dFWccl81oByzfLMik8LcjrwAAATm0E9k+bbVs eKzqRFY+EYl5uV2uMKPbKLCMo93gdvytxJvjedgKr3PGKLN/s5CP10TvgN1jHHWZ58dc VFrHN/eoabKXS5bZ03G+2CTZZeJfUJacXEtg2vO+jIsZWRl1Enxs5vUieQ0d0zVf+S+g sIAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=f/5iyKYNpppjBF3zdaFLWaB9mtwpqzd2AKaKjPJxAWs=; b=mr8QeeXg+KZNosyhHLpOqud3LTbbMNNrM0XlJ7B5/auzevZOJllGEbqOYBKtl8Jv4K 8Ub8gH+y8+u3ZR+H/rbGvQAPuixAP4ttOztHLhvYkw5NKsBNzsp/KdvVgaEJj1M2TP2+ fmQLbvNhkrCpKJPYKsbQwAcJPEd7OvJyUMaM4SiHxmQfOwsiA5fQVLYE9gnKbKVkoyul QBeQUUneg3k0pVKVN4t5HCWvy+Gr1ZgNaaD9BzuO9XZ6Bu+QI/wJw61goh2/bogFbFbO FAN1rgXWg0a9+BebNaLVYLrWg0OcAHfh9OceXj8nIlj280kcnC02A4c3KC3DBCxdWnCs NFmg== X-Gm-Message-State: APjAAAW1S7e+4JsmZ2LYvGVOf8jLbi/JzNHgmJwLIhfln49qOi0rlmiC PVKbEVbnSH9WxIQ5u4kmc8NBE2TYiTQVo78= X-Google-Smtp-Source: APXvYqz0a1du6BAb2n9zOY1TKTVI9Gg9OvB/aNzpeonZWxzlN/oxlG5fY68P9FEOHHUsq2e6wy1iV98PD6FTBF8= X-Received: by 2002:a0c:df12:: with SMTP id g18mr10126912qvl.34.1565217081340; Wed, 07 Aug 2019 15:31:21 -0700 (PDT) Date: Wed, 7 Aug 2019 15:31:10 -0700 In-Reply-To: <20190807223111.230846-1-saravanak@google.com> Message-Id: <20190807223111.230846-3-saravanak@google.com> Mime-Version: 1.0 References: <20190807223111.230846-1-saravanak@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v5 2/3] OPP: Add support for bandwidth OPP tables From: Saravana Kannan To: Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Georgi Djakov , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, adharmap@codeaurora.org, Rajendra Nayak , sibis@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Not all devices quantify their performance points in terms of frequency. Devices like interconnects quantify their performance points in terms of bandwidth. We need a way to represent these bandwidth levels in OPP. So, add support for parsing bandwidth OPPs from DT. Signed-off-by: Saravana Kannan --- drivers/opp/of.c | 41 ++++++++++++++++++++++++++++++++--------- drivers/opp/opp.h | 4 +++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 1813f5ad5fa2..e1750033fef9 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -523,6 +523,35 @@ void dev_pm_opp_of_remove_table(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); +static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np) +{ + int ret; + u64 rate; + u32 bw; + + ret = of_property_read_u64(np, "opp-hz", &rate); + if (!ret) { + /* + * Rate is defined as an unsigned long in clk API, and so + * casting explicitly to its type. Must be fixed once rate is 64 + * bit guaranteed in clk API. + */ + new_opp->rate = (unsigned long)rate; + return 0; + } + + ret = of_property_read_u32(np, "opp-peak-kBps", &bw); + if (ret) + return ret; + new_opp->rate = (unsigned long) bw; + + ret = of_property_read_u32(np, "opp-avg-kBps", &bw); + if (!ret) + new_opp->avg_bw = (unsigned long) bw; + + return 0; +} + /** * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings) * @opp_table: OPP table @@ -560,22 +589,16 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, if (!new_opp) return ERR_PTR(-ENOMEM); - ret = of_property_read_u64(np, "opp-hz", &rate); + ret = _read_opp_key(new_opp, np); if (ret < 0) { /* "opp-hz" is optional for devices like power domains. */ if (!opp_table->is_genpd) { - dev_err(dev, "%s: opp-hz not found\n", __func__); + dev_err(dev, "%s: opp-hz or opp-peak-kBps not found\n", + __func__); goto free_opp; } rate_not_available = true; - } else { - /* - * Rate is defined as an unsigned long in clk API, and so - * casting explicitly to its type. Must be fixed once rate is 64 - * bit guaranteed in clk API. - */ - new_opp->rate = (unsigned long)rate; } of_property_read_u32(np, "opp-level", &new_opp->level); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 01a500e2c40a..6bb238af9cac 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -56,7 +56,8 @@ extern struct list_head opp_tables; * @turbo: true if turbo (boost) OPP * @suspend: true if suspend OPP * @pstate: Device's power domain's performance state. - * @rate: Frequency in hertz + * @rate: Frequency in hertz OR Peak bandwidth in kilobytes per second + * @avg_bw: Average bandwidth in kilobytes per second * @level: Performance level * @supplies: Power supplies voltage/current values * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's @@ -78,6 +79,7 @@ struct dev_pm_opp { bool suspend; unsigned int pstate; unsigned long rate; + unsigned long avg_bw; unsigned int level; struct dev_pm_opp_supply *supplies; From patchwork Wed Aug 7 22:31:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11082787 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D5851399 for ; Wed, 7 Aug 2019 22:31:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A8AF28A5C for ; Wed, 7 Aug 2019 22:31:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D08828AB8; Wed, 7 Aug 2019 22:31:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEB6328A5C for ; Wed, 7 Aug 2019 22:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389553AbfHGWb0 (ORCPT ); Wed, 7 Aug 2019 18:31:26 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:34178 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389544AbfHGWb0 (ORCPT ); Wed, 7 Aug 2019 18:31:26 -0400 Received: by mail-pf1-f202.google.com with SMTP id i2so57675123pfe.1 for ; Wed, 07 Aug 2019 15:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DWjpwGhlXJQyl9FQAlOupUp/l9PizFz1wErEWTwJlag=; b=hcqK1rm2Kc81+PcpjarLbrP8P4J7ecqPay/pLa2ERjLIRU6yaHy83GRzwH5twgmz77 p6ZlJr/qRukqde30IsHj5KuzdQD1+nQbX6inahTdo+X9XUkKQKQAxeRMNTPIh4uf+PKe qGbHD86j7Qx3tpSx8Z/YKJ18+uSJXxnSMqkRxH41MDNar18DnUwL7cKQ6ANn7wa/rwPj c0l7uSoYS6zqTeEr/4qNtDEOtZX1eVO/p6LpbU9jkd+99x2d5iwz4Uwj9RJWdBNSZ/LU 0a4XqqsHxy0B4SUTTVPu/R3tdbcI+WpwFbgGAskVzLsXhIYf2naq9yFuR5HNsF4448om Z37w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DWjpwGhlXJQyl9FQAlOupUp/l9PizFz1wErEWTwJlag=; b=LEwDhyEdUD/TIa90rEWdRC7pU84nLt2c8R7KkkcjabKkCuBMs9KVM2pRrMQLVVTbct TQwABjksZAgxrKJQ8VU0RbWJ6Tj3rA/uQi/OFQKUXMc/RYRzq+HICW3wu3d5spGolyuW ieEA0FypQRU5RDDzGdlcC2uddymjdEoGKjTqMnaolMNoxS7WitpCmFjz+yiwAMOnicDr cW7d/4sQb2oSdZYdevj1k+pzBH3h623eDusccL+QmxvG0n47jomO1VcwQMoEV7E2feiB PY3T79j8omzeF2GF6et4Xp8zEbbjD7WNaBHMVUXyiZlhnjYmK7fQ3XcUZhwuf0jzHJlp lQKQ== X-Gm-Message-State: APjAAAW2yAAmj48pd8C0/go8uF6vU/lAMKGO1tRlOQPe9rVGvHSw47TB +M3zlTv5n19RdwAcbyhVKyqgKMWMnhbfjws= X-Google-Smtp-Source: APXvYqy/1aDhWc3+HFfJ/c7HXcYAOyJ1I9KCDVFdyCtC5/D4WfVyr1uqw90aRy9Chmq3OSW6+nY2hoQfBFxyOEw= X-Received: by 2002:a63:b102:: with SMTP id r2mr9553166pgf.370.1565217084491; Wed, 07 Aug 2019 15:31:24 -0700 (PDT) Date: Wed, 7 Aug 2019 15:31:11 -0700 In-Reply-To: <20190807223111.230846-1-saravanak@google.com> Message-Id: <20190807223111.230846-4-saravanak@google.com> Mime-Version: 1.0 References: <20190807223111.230846-1-saravanak@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH v5 3/3] OPP: Add helper function for bandwidth OPP tables From: Saravana Kannan To: Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Georgi Djakov , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, adharmap@codeaurora.org, Rajendra Nayak , sibis@codeaurora.org, bjorn.andersson@linaro.org, evgreen@chromium.org, kernel-team@android.com, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The frequency OPP tables have helper functions to search for entries in the table based on frequency and get the frequency values for a given (or suspend) OPP entry. Add similar helper functions for bandwidth OPP tables to search for entries in the table based on peak bandwidth and to get the peak and average bandwidth for a given (or suspend) OPP entry. Signed-off-by: Saravana Kannan --- drivers/opp/core.c | 51 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 19 ++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 3b7ffd0234e9..22dcf22f908f 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -127,6 +127,29 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); +/** + * dev_pm_opp_get_bw() - Gets the bandwidth corresponding to an available opp + * @opp: opp for which frequency has to be returned for + * @avg_bw: Pointer where the corresponding average bandwidth is stored. + * Can be NULL. + * + * Return: Peak bandwidth in kBps corresponding to the opp, else + * return 0 + */ +unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, unsigned long *avg_bw) +{ + if (IS_ERR_OR_NULL(opp) || !opp->available) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + if (avg_bw) + *avg_bw = opp->avg_bw; + + return opp->rate; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_bw); + /** * dev_pm_opp_get_level() - Gets the level corresponding to an available opp * @opp: opp for which level value has to be returned for @@ -299,6 +322,34 @@ 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_suspend_opp_bw() - Get peak bandwidth of suspend opp in kBps + * @dev: device for which we do this operation + * @avg_bw: Pointer where the corresponding average bandwidth is stored. + * Can be NULL. + * + * Return: This function returns the peak bandwidth of the OPP marked as + * suspend_opp if one is available, else returns 0; + */ +unsigned long dev_pm_opp_get_suspend_opp_bw(struct device *dev, + unsigned long *avg_bw) +{ + struct opp_table *opp_table; + unsigned long peak_bw = 0; + + opp_table = _find_opp_table(dev); + if (IS_ERR(opp_table)) + return 0; + + if (opp_table->suspend_opp && opp_table->suspend_opp->available) + peak_bw = dev_pm_opp_get_bw(opp_table->suspend_opp, avg_bw); + + dev_pm_opp_put_opp_table(opp_table); + + return peak_bw; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp_bw); + int _get_opp_count(struct opp_table *opp_table) { struct dev_pm_opp *opp; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index b8197ab014f2..f4e900f36414 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -82,6 +82,7 @@ void dev_pm_opp_put_opp_table(struct opp_table *opp_table); unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); +unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, unsigned long *avg_bw); unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); @@ -92,6 +93,8 @@ 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_suspend_opp_bw(struct device *dev, + unsigned long *avg_bw); struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, @@ -160,6 +163,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) { return 0; } +static inline unsigned long dev_pm_opp_get_bw(struct dev_pm_opp *opp, + unsigned long *avg_bw) +{ + return 0; +} static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) { @@ -196,6 +204,12 @@ static inline unsigned long dev_pm_opp_get_suspend_opp_freq(struct device *dev) return 0; } +static inline unsigned long dev_pm_opp_get_suspend_opp_bw(struct device *dev, + unsigned long *avg_bw) +{ + return 0; +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available) { @@ -337,6 +351,11 @@ static inline void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask #endif /* CONFIG_PM_OPP */ +#define dev_pm_opp_find_peak_bw_exact dev_pm_opp_find_freq_exact +#define dev_pm_opp_find_peak_bw_floor dev_pm_opp_find_freq_floor +#define dev_pm_opp_find_peak_bw_ceil_by_volt dev_pm_opp_find_freq_ceil_by_volt +#define dev_pm_opp_find_peak_bw_ceil dev_pm_opp_find_freq_ceil + #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF) int dev_pm_opp_of_add_table(struct device *dev); int dev_pm_opp_of_add_table_indexed(struct device *dev, int index);