From patchwork Sat Jun 8 04:43:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982981 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 89A7D76 for ; Sat, 8 Jun 2019 04:44:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 731C228B70 for ; Sat, 8 Jun 2019 04:44:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 673A928BE0; Sat, 8 Jun 2019 04:44:03 +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 0838828B70 for ; Sat, 8 Jun 2019 04:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726252AbfFHEnu (ORCPT ); Sat, 8 Jun 2019 00:43:50 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:38407 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727520AbfFHEnu (ORCPT ); Sat, 8 Jun 2019 00:43:50 -0400 Received: by mail-vk1-f202.google.com with SMTP id u202so975734vku.5 for ; Fri, 07 Jun 2019 21:43:49 -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=yAz3k7OzPjxwzR5iBZENxEm1ewgrxin9ITMqtF0yTXk=; b=h16Y4HD/UPQ8Qdd8puBUJX6swjYiLioJGWRuDvWtjxgSH5taeUQyhOx79lWt1tEXh9 WP5jLzggF4W2BJI+QMCOkRsdE+R1jjdoA/MyslRnGDBrarPhPv3O8V8nQTinkxBX78O2 1u0gp3xytA+oINw+NizDSVapwgPCn8UIlQOweBTlg/DxloT62xhbeR2/KfYcCT+CR5n5 FoD1m0WGw4gEanoi/kzNuz3zX9MzXvrhLeBaEwvfiV/uRWD+3BXr7MVff/SrZVEp99DR PApeHHYPaL01eGLGrhz5jFMOkLLYRpS4qdRTDJpXZ3wAWpZH4ZBZ7YEA8XQwMnCpnccL 1ZNw== 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=yAz3k7OzPjxwzR5iBZENxEm1ewgrxin9ITMqtF0yTXk=; b=o4lh1VKS7KErTvz019/HUigkZUM0arL3owcFW4dDgOaO88kTgjG/Z851OdXp/e4YQd MudIs9g8N/aS385En7+Q9YzIctOP2PMM2ODePGPY86edkvDJtWvdvM05YGzWnqOEPfao UmWte4atkVKd0DTxYZilPziVJFwsn6X0MAOLtZen3dcwdyc/MlYWSrfnENURNFVy+Qy/ l2ofzNUEbeRZBuPZBzYQE7DoHt1eGThsb8JFNc0m53pBmUeahQ2dgJPnhNFeaMe5PHZk d1TDVcS7VaLOSGumG98uGRnXiYGaXApIpaox/Slt+sZNVdH8xHgjcpxBYgglJPqg8YMA h6uA== X-Gm-Message-State: APjAAAXGV3CzTwWBppjD88W5HsuSShxyoCKI2m+s2JuWWr5oupX0tMDn I/hsUgIqG8LcYmSD19/wAdmGSr99NIuW8dw= X-Google-Smtp-Source: APXvYqzgoCdbmtERP8lXY/RLG0ooX+4jcXs9QIN2JZHB94tDUDQbpKEPFjga7MoFGI0pHJDoAp7O7S8tT1TDM6M= X-Received: by 2002:a67:1ec1:: with SMTP id e184mr19214210vse.83.1559969029067; Fri, 07 Jun 2019 21:43:49 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:31 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-2-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 1/9] dt-bindings: opp: Introduce opp-peak-KBps and opp-avg-KBps bindings From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 replace 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 --- Documentation/devicetree/bindings/opp/opp.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt index 76b6c79604a5..c869e87caa2a 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 but 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-bw 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. From patchwork Sat Jun 8 04:43:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982997 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 A991876 for ; Sat, 8 Jun 2019 04:44:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92FDB28B70 for ; Sat, 8 Jun 2019 04:44:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86E2828BDD; Sat, 8 Jun 2019 04:44:38 +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 23C0F28B70 for ; Sat, 8 Jun 2019 04:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728051AbfFHEnx (ORCPT ); Sat, 8 Jun 2019 00:43:53 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:47964 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728045AbfFHEnx (ORCPT ); Sat, 8 Jun 2019 00:43:53 -0400 Received: by mail-qk1-f201.google.com with SMTP id l185so3387734qkd.14 for ; Fri, 07 Jun 2019 21:43:52 -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=VsGMjkGOZPFGkhCwCfPMuPNJvsOcLeFFhKH7B9SWhJo=; b=p3N7H7bH0nuAEuJTu/oq9x4clbJ/yyYk/4oia3UFTq0FSnZKiXsRnP55OG528RX6ae 3btwG3ecPZludSJG38saLdVAO3lzqWB4ZMTBoZdb8NFnD90Evo0eKLGU7qi+DS4a3Uy9 GNg7bYSnq0mhVOfnvqloXrHxZY+0wtD5Xv1JE4+mNM9gBtN2YSrULrqdad4VvML8YGfq Rnb3KzQlsTkYhJ+UWqrPVviuA2wMotbsq4hTaUP2yGRisweIID2Qmvcge8SYAskIgr54 sVgQrmYeDXzRM6YS+03hZQsEIm2eAWCKQ0gVQsGk586guRd+ud8wsc1H6y/nVEQ9eFiC IKpA== 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=VsGMjkGOZPFGkhCwCfPMuPNJvsOcLeFFhKH7B9SWhJo=; b=eikIY+row4l1wb2ktT3lxb+n63InUOlIJsLlSt01mBq2Dd8/60b3zPqDbsmWvWLQq8 Fc6/Df/GYmoxtJfmqui34tStobnX1hil72dL9XnyYAwXRyxr5GXXVyqyXbueWVECYPnh ew2bO4QLqEvW1ALTmZfE6gFtckjk0atUKvzaWe/g8bVL767PNW9ljdTT+6O9XQDFqP5t HF/6jmtkLlYLpOCUVSNPCgqHNHRzOVsJ8fqgb8JkFsYj6exTF4sciEWilWUQu7AIggL4 +gADprn+xuYH1caMxaooSLd+6bS6gKvVIhndIq474Lx2gcVGYkQD9sywMotqnQfQZnWO La0A== X-Gm-Message-State: APjAAAV8mYYNv7FP7L+zvVU7Xs0edSieAlVMNHU51EPX3fcq/Uyt0HY2 2LA6/xPo/0GmfZK+P5YncVKu6YvoRAJCiLI= X-Google-Smtp-Source: APXvYqxowEVj/16yFHu5u5M+Hh+OsPObpHW4eaANvRfQI2X4XmPpgTOnRXKsjSiYUE5FMSOmVTkt55wGBlGC8bE= X-Received: by 2002:ac8:2c17:: with SMTP id d23mr17659580qta.385.1559969032137; Fri, 07 Jun 2019 21:43:52 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:32 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-3-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 2/9] OPP: Add support for bandwidth OPP tables From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 | 34 ++++++++++++++++++++++++++++++++-- drivers/opp/opp.h | 4 +++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index c10c782d15aa..54fa70ed2adc 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -552,6 +552,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 @@ -589,11 +618,12 @@ 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-bw not found\n", + __func__); goto free_opp; } diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 569b3525aa67..ead2cdafe957 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -59,7 +59,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 @@ -81,6 +82,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 Sat Jun 8 04:43:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982983 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 C5E6517D2 for ; Sat, 8 Jun 2019 04:44:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE3D728B70 for ; Sat, 8 Jun 2019 04:44:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2B0428BDD; Sat, 8 Jun 2019 04:44:03 +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 28A0728BAF for ; Sat, 8 Jun 2019 04:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730325AbfFHEn4 (ORCPT ); Sat, 8 Jun 2019 00:43:56 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:55334 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727534AbfFHEn4 (ORCPT ); Sat, 8 Jun 2019 00:43:56 -0400 Received: by mail-pg1-f201.google.com with SMTP id g38so2719928pgl.22 for ; Fri, 07 Jun 2019 21:43:55 -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=9TRFnG9Pa4xihjbLr7RAzObBFSHpSGvF+wx+CoYHe04=; b=o0y7GGh8l3VL4MUBhV0b37+P5uxmTWR3hOCHXucOM+gGogO9VRqImq1BjnHjjqczVX CdmCQQP0td9an3P2JHgXjledRwCGknTgFr2DWH9+yeSUE0Iz9sfF0k6VXodhYKfleFfI 8676yQcSxMPTkd7jkxoI5YJj88ct6YkCz+U1FPW/0KPOxEovCSuBVs5Qk0LlYp9raI5j qPsnP8KtSbPSKFCCTaV44dMbk7+Z35vGfg5hhKYqSzkR/OtFTb/WQ4REUvrZ6Uh558H5 2Xs3pvwT7B0oQOY59w5zmROT28hofI6YfJa2aJYJaB6d3/XDxUlbk7FuC8TLHYPH2rau RJ/Q== 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=9TRFnG9Pa4xihjbLr7RAzObBFSHpSGvF+wx+CoYHe04=; b=X8zn6Oq0buhXjoRAKNC6K5M5XGbbiv55AXcBPFDWUzL/HqdG3dwPL2lP4KC60NmXsN 8PelIjzmXkiJhCbwW2RbNokwHJCaI10sRCcHxHPOLHwQrQpsualrBvXRsgz109dePr5q Mah0laJTri4kdhXzq0telT96J6PTZf1AkPBmrfOkqqGtI+MH3nsHwe80gtGEb1F+URq8 xDNWmD2Lybg8ukeUxp88RzhamYS0QkXRIG2cPi/tAI61rQDu/M6VUSOGLW6faWCEF2Hu iDBIsTzsjDmiBUkhODnILRfYk3MELu/CBboYPmBSbICkGTJS8yIxTWQ1qGUhYdFcjeeR T4dA== X-Gm-Message-State: APjAAAVv4xl1FG3LHk6dCpq6vi+QEibu7rd9CMTsmdepylyuOSn+9yA+ VcShTHlAQtDmkIqOzBhfnL5h0nlaTw8xsuA= X-Google-Smtp-Source: APXvYqwB3pJhgw3FEqCmaUjeAEEeT2g7UFlbBPH/9ouyGNfYMh2IC0TwNiylyTg/Jrax1O5b3gwzoyWOxiPsIFs= X-Received: by 2002:a63:1c16:: with SMTP id c22mr6276558pgc.333.1559969035102; Fri, 07 Jun 2019 21:43:55 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:33 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-4-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 3/9] OPP: Add helper function for bandwidth OPP tables From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 0e7703fe733f..89a2ece88480 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -130,6 +130,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 @@ -302,6 +325,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 b150fe97ce5a..7f040cc20daf 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -85,6 +85,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); @@ -95,6 +96,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, @@ -161,6 +164,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) { @@ -197,6 +205,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) { @@ -332,6 +346,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); From patchwork Sat Jun 8 04:43:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982985 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 5885A14B6 for ; Sat, 8 Jun 2019 04:44:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42A4B28B70 for ; Sat, 8 Jun 2019 04:44:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3658E28BAF; Sat, 8 Jun 2019 04:44:05 +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 47D9228BDC for ; Sat, 8 Jun 2019 04:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730533AbfFHEoB (ORCPT ); Sat, 8 Jun 2019 00:44:01 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:34332 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730471AbfFHEn7 (ORCPT ); Sat, 8 Jun 2019 00:43:59 -0400 Received: by mail-qk1-f202.google.com with SMTP id h198so3411702qke.1 for ; Fri, 07 Jun 2019 21:43:58 -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=AQaL/PGq4V0DuXs35/Wx+s7nNXc5+qEy/Os9W/iGFYA=; b=cHfi3CnTUcT1n2hmhkaz7Mg9O1ojtQBcEgDon17GIJ7rAI2DCEokMLnia6lX2ELmA1 xmRYRLLSFDWkW4AbAza2SAuDM8uNw1ML5WBrgCxz53AKgWu/5e+V67Og3J/KXliXlq9P viieHIuJgf2Q43PHgfe3i6Fb5VuUmOFwzOVJbWLcZiEPXqpJUgqbbHKzcs6gTTSDnHAI SQog4t282FQWBS+PPYN8Lem/9034ox8YIearSEgBN8nVVXVXuApsd3tOcr/HXp73U9Fh yLdkzE4F2D7baTtK4XvCFfhGbigKyDViR63AutM8OLXSitJshAKEhifKe4m0FQgJm7Xu ujpQ== 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=AQaL/PGq4V0DuXs35/Wx+s7nNXc5+qEy/Os9W/iGFYA=; b=e/80DUwFKBlOSX6yPDqBvmOrsbldg6WNZGHzSuN3IUIbK5lyP00t90sa0Cn5OU4e6a s2bBpnEDKi5tpnxUs02pJ/CfEtdZDXf9XpEzQoF8w54HmQJ/wsILW/vAljpUCyuDrUjU uRIstUXXmg8x9GhC47cvlENaB2nJ3S2SlcEtiCaaqsRcAUex50jb7IRQHZl6m/V5VyIx n+oqfKOuKj85zx7i7ST2OO4lC3toml8WF11hdr4jIODBFoGdDzKbUDjewZT8c2cFJsuW kJy0vY7TWE40zLevdSBgtHm89lxJrYqyKW+MpnHYfjb2UfURqW+dPBPwl7fHbJ0UcwuX sCHg== X-Gm-Message-State: APjAAAV+9RGH356f/LehLKsB3EfSZRXPVUcPhB8k5+qKM+y5IJ+QKwnX 9NvnqZkZd2xCw1N3Bs3PaY6yKnMfUlID508= X-Google-Smtp-Source: APXvYqzDiL0bLzrWM4BPLbZ4rXoIgduk46Uiyp6JQp8vO+GfSBOMdB0GFp36bFyZrGIsx1NIsnvnzMRXmsbPiuI= X-Received: by 2002:a0c:d047:: with SMTP id d7mr45723029qvh.64.1559969038459; Fri, 07 Jun 2019 21:43:58 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:34 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-5-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 4/9] OPP: Add API to find an OPP table from its DT node From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 This allows finding a device's OPP table (when it has multiple) from a phandle to the OPP table in DT. Signed-off-by: Saravana Kannan --- drivers/opp/of.c | 42 ++++++++++++++++++++++++++++++++++-------- include/linux/pm_opp.h | 7 +++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 54fa70ed2adc..34c51905f56d 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -42,14 +42,9 @@ struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_opp_desc_node); -struct opp_table *_managed_opp(struct device *dev, int index) +struct opp_table *_find_opp_table_from_node(struct device_node *np) { struct opp_table *opp_table, *managed_table = NULL; - struct device_node *np; - - np = _opp_of_get_opp_desc_node(dev->of_node, index); - if (!np) - return NULL; list_for_each_entry(opp_table, &opp_tables, node) { if (opp_table->np == np) { @@ -69,11 +64,42 @@ struct opp_table *_managed_opp(struct device *dev, int index) } } - of_node_put(np); - return managed_table; } +/** + * dev_pm_opp_of_find_table_from_node() - Find OPP table from its DT node + * @np: DT node used for finding the OPP table + * + * Return: OPP table corresponding to the DT node, else NULL on failure. + * + * The caller needs to put the node with of_node_put() after using it. + */ +struct opp_table *dev_pm_opp_of_find_table_from_node(struct device_node *np) +{ + struct opp_table *opp_table; + + mutex_lock(&opp_table_lock); + opp_table = _find_opp_table_from_node(np); + mutex_unlock(&opp_table_lock); + return opp_table; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_of_find_table_from_node); + +struct opp_table *_managed_opp(struct device *dev, int index) +{ + struct device_node *np; + struct opp_table *opp_table; + + np = _opp_of_get_opp_desc_node(dev->of_node, index); + if (!np) + return NULL; + + opp_table = _find_opp_table_from_node(np); + of_node_put(np); + return opp_table; +} + /* The caller must call dev_pm_opp_put() after the OPP is used */ static struct dev_pm_opp *_find_opp_of_np(struct opp_table *opp_table, struct device_node *opp_np) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 7f040cc20daf..3f30ce55e8eb 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -359,6 +359,7 @@ int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); +struct opp_table *dev_pm_opp_of_find_table_from_node(struct device_node *np); struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); int of_get_required_opp_performance_state(struct device_node *np, int index); void dev_pm_opp_of_register_em(struct cpumask *cpus); @@ -396,6 +397,12 @@ static inline struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device return NULL; } +static inline struct opp_table *dev_pm_opp_of_find_table_from_node( + struct device_node *np) +{ + return NULL; +} + static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) { return NULL; From patchwork Sat Jun 8 04:43:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982995 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 ED8A976 for ; Sat, 8 Jun 2019 04:44:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D75DC28B70 for ; Sat, 8 Jun 2019 04:44:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA75A28BDD; Sat, 8 Jun 2019 04:44:36 +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 7654828B70 for ; Sat, 8 Jun 2019 04:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730819AbfFHEof (ORCPT ); Sat, 8 Jun 2019 00:44:35 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:47440 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730542AbfFHEoC (ORCPT ); Sat, 8 Jun 2019 00:44:02 -0400 Received: by mail-vk1-f202.google.com with SMTP id a2so256495vkg.14 for ; Fri, 07 Jun 2019 21:44:02 -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=nYfthp2AfyfO7B9ZHl8Ammgshm5FNB69pWC4uzGdWTs=; b=dMmIR9zPNKZhyMj3vydkxUzXcQ5Wm+QYdCizczZFkIvzDmfPxqciSkaELIvEK5Uxih os7R+Bfrvx8ppB4h9Lehrkkyr2hNrBpZKz6KUgLW7eikgchAjWmW4brCbz0GESrD4gUr KOAldARNoWDFkH7M/X3DYcnyEkQPOyyDbzaEWpozSS9vPYGmeMVbHWJLv8MS6mZ9vYZT 8xkMnreKVikDXYWgfZ17GA+fWtZb03Hvs75yvGestNhmk5AGCRmflDoCC7BqhIYAtYS8 dwkJlIxMDIjq8xH6AY1NCud6bFT+S6W56c3l8qUPrOnJpQKyKa/GjyD+LZjJ5UP8C01A wuIw== 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=nYfthp2AfyfO7B9ZHl8Ammgshm5FNB69pWC4uzGdWTs=; b=lHhgTr2FBFybeacPPq7qo/wutnqpCEN40wHZBJZXF46Rs2ESLQ/xcb2s21URqg7qZR JTkRBfpo4UaRAkvwocCUweF+WTvLmahSOr0HnoF5w+Am5/Urmr4AGpkAU5HmPQj4IBy+ skZzbK4Gd78tENIMGN2K4tCm/AFqMruIOGONWofoNNOmiv+w0ZVrXxy/MsO0NgqO9Dz9 WmQoNOOiyQo09XNir559UrX28NWlKgE7DmL3IW+n0OBwy8K/6hkA4076/ouaeP+6dTZ9 zCIb/oIEKqMRYXSjYcqwys5xtBtL76rNKI3NYPGvFQh8EFga8JUv4ZBkn9jRhRLxSOeS NBHA== X-Gm-Message-State: APjAAAW/KI+pPCwPnJu8xe2f85J/Yv96KLSjeJ6U1TA5K04cJxbP23xK KPFKqht131SQPhRjpahtFYqVuQX4chzBUh8= X-Google-Smtp-Source: APXvYqwiuDqsREIBPM5HcBRZmU9ocdAtwS9Xwtx0WfII9zeKP5yslJnw2HWFvQ3SRyhjeXZMrdRFC3gLD1HglW4= X-Received: by 2002:ab0:30a3:: with SMTP id b3mr571866uam.3.1559969041487; Fri, 07 Jun 2019 21:44:01 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:35 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-6-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 5/9] dt-bindings: interconnect: Add interconnect-opp-table property From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 Add support for listing bandwidth OPP tables for each interconnect path listed using the interconnects property. Signed-off-by: Saravana Kannan --- .../devicetree/bindings/interconnect/interconnect.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/interconnect/interconnect.txt b/Documentation/devicetree/bindings/interconnect/interconnect.txt index 6f5d23a605b7..fc5b75b76a2c 100644 --- a/Documentation/devicetree/bindings/interconnect/interconnect.txt +++ b/Documentation/devicetree/bindings/interconnect/interconnect.txt @@ -55,10 +55,18 @@ interconnect-names : List of interconnect path name strings sorted in the same * dma-mem: Path from the device to the main memory of the system +interconnect-opp-table: List of phandles to OPP tables (bandwidth OPP tables) + that specify the OPPs for the interconnect paths listed + in the interconnects property. This property can only + point to OPP tables that belong to the device and are + listed in the device's operating-points-v2 property. + Example: sdhci@7864000 { + operating-points-v2 = <&sdhc_opp_table>, <&sdhc_mem_opp_table>; ... interconnects = <&pnoc MASTER_SDCC_1 &bimc SLAVE_EBI_CH0>; interconnect-names = "sdhc-mem"; + interconnect-opp-table = <&sdhc_mem_opp_table>; }; From patchwork Sat Jun 8 04:43:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982987 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 457EF14B6 for ; Sat, 8 Jun 2019 04:44:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EA2D28B70 for ; Sat, 8 Jun 2019 04:44:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 228AF28BDC; Sat, 8 Jun 2019 04:44:10 +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 A2DD628B70 for ; Sat, 8 Jun 2019 04:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730458AbfFHEoH (ORCPT ); Sat, 8 Jun 2019 00:44:07 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:44645 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730714AbfFHEoF (ORCPT ); Sat, 8 Jun 2019 00:44:05 -0400 Received: by mail-qt1-f202.google.com with SMTP id p15so3685626qti.11 for ; Fri, 07 Jun 2019 21:44:05 -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=qdT885hM1gH99LBPR29/QhPlOeEng+ZQVjJx3w/T2/A=; b=u4I58YoPay1wIV0iUGWNilJCvSvIVXTL1/ci8b1Wjy1sm8vMfzaHLznZpwJzX//Rph ttgkgbKpAFClv5uX/X/41cZzhnEUO/g/rlcKS9fYx+PTRXpRCP8TNbRaD1DvJrF/j/y3 tgmBde4zGp31x0CDivMs+UIvYHGUxOiEig9Fi7FlulgpoytiqiyJIEiVtvIe64im3Had Yx//ZCG2LVsaWnL+r4lFVQhbV8d1aLk8a+YaEyJEDHDBJVQnw5HRHSuyjKHtMPDm0p3z tVCiE/66D13o+CzXql9II+Xk/wQo1n2rezQTAgA1+3Up520E+RgpsscP7xPh9p4Gh7y8 WXYA== 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=qdT885hM1gH99LBPR29/QhPlOeEng+ZQVjJx3w/T2/A=; b=fWLeVShllA/pV9096+onFyEQipENgMuEUF87reAwP5H5p4w8kP2zGicTOF9McRdN5l 4V3fcofgFzzFGDc0leMmvfBCSY9andytzYCKbBrvph12qo8jDiWMkfbMS4vBFWYAc0TA opiMBA+jhWOmjhNSUliOZW7lGFXYragBWaRESX7gOLmfWLqGPud/PasFvk8Oev7AZUlP 1RL5B5VjTYLy926rz4JdjcOihW4bd6LL9joh8rrxKLyooUgAamcnS3mm7L4CTGEY4jv2 rgfM/Tkh9a1Jqalsv7qHFgsAt59g57onWec+aMP+ReYs7JlOyMk1fyIsDFAByYmPO7ON gz1Q== X-Gm-Message-State: APjAAAUa14Q6kxIXrwxC3tT5DSO1PgMo4e+aKXCsaEMIxaCxZ8tmxZ3v ZJB2SIwrHoYFSac1r3noJXVf7+zpQYB1Lhc= X-Google-Smtp-Source: APXvYqwj1cOP4RzT//I83dw4bKyy7KpftJsqRPBOzjTNZla/XLUxIXycPdwubPfAFYw0aw/lx47k+naEi+2zJ1o= X-Received: by 2002:a37:bd42:: with SMTP id n63mr47852920qkf.262.1559969044588; Fri, 07 Jun 2019 21:44:04 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:36 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-7-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 6/9] interconnect: Add OPP table support for interconnects From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 Interconnect paths can have different performance points. Now that OPP framework supports bandwidth OPP tables, add OPP table support for interconnects. Devices can use the interconnect-opp-table DT property to specify OPP tables for interconnect paths. And the driver can obtain the OPP table for an interconnect path by calling icc_get_opp_table(). Signed-off-by: Saravana Kannan --- drivers/interconnect/core.c | 27 ++++++++++++++++++++++++++- include/linux/interconnect.h | 7 +++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 871eb4bc4efc..881bac80bc1e 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -47,6 +47,7 @@ struct icc_req { */ struct icc_path { size_t num_nodes; + struct opp_table *opp_table; struct icc_req reqs[]; }; @@ -313,7 +314,7 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) { struct icc_path *path = ERR_PTR(-EPROBE_DEFER); struct icc_node *src_node, *dst_node; - struct device_node *np = NULL; + struct device_node *np = NULL, *opp_node; struct of_phandle_args src_args, dst_args; int idx = 0; int ret; @@ -381,10 +382,34 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path)); mutex_unlock(&icc_lock); + opp_node = of_parse_phandle(np, "interconnect-opp-table", idx); + if (opp_node) { + path->opp_table = dev_pm_opp_of_find_table_from_node(opp_node); + of_node_put(opp_node); + } + + return path; } EXPORT_SYMBOL_GPL(of_icc_get); +/** + * icc_get_opp_table() - Get the OPP table that corresponds to a path + * @path: reference to the path returned by icc_get() + * + * This function will return the OPP table that corresponds to a path handle. + * If the interconnect API is disabled, NULL is returned and the consumer + * drivers will still build. Drivers are free to handle this specifically, but + * they don't have to. + * + * Return: opp_table pointer on success. NULL is returned when the API is + * disabled or the OPP table is missing. + */ +struct opp_table *icc_get_opp_table(struct icc_path *path) +{ + return path->opp_table; +} + /** * icc_set_bw() - set bandwidth constraints on an interconnect path * @path: reference to the path returned by icc_get() diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h index dc25864755ba..0c0bc55f0e89 100644 --- a/include/linux/interconnect.h +++ b/include/linux/interconnect.h @@ -9,6 +9,7 @@ #include #include +#include /* macros for converting to icc units */ #define Bps_to_icc(x) ((x) / 1000) @@ -28,6 +29,7 @@ struct device; struct icc_path *icc_get(struct device *dev, const int src_id, const int dst_id); struct icc_path *of_icc_get(struct device *dev, const char *name); +struct opp_table *icc_get_opp_table(struct icc_path *path); void icc_put(struct icc_path *path); int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); @@ -49,6 +51,11 @@ static inline void icc_put(struct icc_path *path) { } +static inline struct opp_table *icc_get_opp_table(struct icc_path *path) +{ + return NULL; +} + static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) { return 0; From patchwork Sat Jun 8 04:43:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982993 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 6155114B6 for ; Sat, 8 Jun 2019 04:44:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB9428B70 for ; Sat, 8 Jun 2019 04:44:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E16B28BDD; Sat, 8 Jun 2019 04:44:34 +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 24EC528B70 for ; Sat, 8 Jun 2019 04:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731142AbfFHEo2 (ORCPT ); Sat, 8 Jun 2019 00:44:28 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:54342 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730823AbfFHEoI (ORCPT ); Sat, 8 Jun 2019 00:44:08 -0400 Received: by mail-qt1-f201.google.com with SMTP id r57so3664761qtj.21 for ; Fri, 07 Jun 2019 21:44:08 -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=l7frD8AwQb/664vV6b+eE1fM0p32UKK11iOjCpsV3ZE=; b=rCSnOT9kVTQ4zHlkjz/xjtzstPLwTuZJEpaaMJS61bIu3uWnlOAh8wLABGTIsTwBFg xm7pMtTt0ypdAcPWZrlIfxGY0FfWBGVRMBwf3jrEwOWI1/JN/wTnSTlN5i1cd56sRXsm KAWvWRqDo9/WfmsLrTKeS95TdKlXcGsZ07leJWoYaQiQ/2BftBUQW1pxZhCPELKiQmuO 2Fm7TvoK3DNvdkM7JRvRZ9dDxlFbZ47rMp3+MReBwsfI/rWbwYCOlkcPWCOuvJCY6fxw l+4DTin711JaMkrgqfd0/DsaXe1oWQsh5t0rFqsbtM52XkGYDnq8DSzsuiSHApUJK/KB C1iQ== 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=l7frD8AwQb/664vV6b+eE1fM0p32UKK11iOjCpsV3ZE=; b=qNEoHHs1Y8F9KID08y9ALD1k0us5vDdD7Hg6Yxizg44aIiilt3c+lFniCbf4TRXui7 pSSzICW1rx/gLZ23b2Q3BAYrsld+mKn1bUf/6WgN3QhUVJFjVok+S8GI9vxvnT9PZ0NC ROaBzcbDchhlK0Znbwyd5ro2rAjnk9ZEPlYDdT6Rc1wqLhUiMmU9SBNRxY6wB3GzvPXT aSQvUfDs2pMPr0aoayADNPgtWJNHGqjUBOrjBWTEI/lHO8V22wFGPN0zWnRrgz5OLVFH XFScB/jlTyVDSmnqRw3KNMt1E5VQ6Oq24rQrvLNGpu2g343bI5vVFrsQHmHpXXX0vQz0 nO4w== X-Gm-Message-State: APjAAAWnkrmaI4tNuvpzatUj2Mbg0zjsLEVHKnBjnBRw9ZqimR/0X4Uo S08gZgk5Y1NNjdE+u7vwlQ3LahXA6ICiXvE= X-Google-Smtp-Source: APXvYqwud8Aypv8gLILj91JHYUlSsreuVUJCq0h7diIstQL9qUtPn0pHHpuSFkdUqf0cnEy7NX6jcTlT8ggl5z8= X-Received: by 2002:ac8:7c7:: with SMTP id m7mr45776276qth.28.1559969047755; Fri, 07 Jun 2019 21:44:07 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:37 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-8-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 7/9] OPP: Add function to look up required OPP's for a given OPP From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 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 --- drivers/opp/core.c | 50 ++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 11 ++++++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 89a2ece88480..d96d5746eb47 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1881,6 +1881,56 @@ void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, dev_err(virt_dev, "Failed to find required device entry\n"); } +/** + * dev_pm_opp_xlate_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. + * @pstate: OPP 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). + * + * Return: destination table OPP on success, otherwise NULL on errors. + */ +struct dev_pm_opp *dev_pm_opp_xlate_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) + return NULL; + + for (i = 0; i < src_table->required_opp_count; i++) { + if (src_table->required_opp_tables[i]->np == dst_table->np) + 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]; + 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 3f30ce55e8eb..13381dc3dd39 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -137,6 +137,9 @@ void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev, struct device *virt_dev, int index); void dev_pm_opp_put_genpd_virt_dev(struct opp_table *opp_table, struct device *virt_dev); int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct opp_table *dst_table, unsigned int pstate); +struct dev_pm_opp *dev_pm_opp_xlate_opp(struct opp_table *src_table, + struct opp_table *dst_table, + struct dev_pm_opp *src_opp); int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq); int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const struct cpumask *cpumask); int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); @@ -321,6 +324,14 @@ static inline int dev_pm_opp_xlate_performance_state(struct opp_table *src_table return -ENOTSUPP; } +static inline struct dev_pm_opp *dev_pm_opp_xlate_opp( + struct opp_table *src_table, + struct opp_table *dst_table, + struct dev_pm_opp *src_opp) +{ + return NULL; +} + static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) { return -ENOTSUPP; From patchwork Sat Jun 8 04:43:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982991 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 029BD14B6 for ; Sat, 8 Jun 2019 04:44:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E01A028B70 for ; Sat, 8 Jun 2019 04:44:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D20E828BDD; Sat, 8 Jun 2019 04:44:27 +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 7AD8128B70 for ; Sat, 8 Jun 2019 04:44:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731119AbfFHEoX (ORCPT ); Sat, 8 Jun 2019 00:44:23 -0400 Received: from mail-ot1-f74.google.com ([209.85.210.74]:43555 "EHLO mail-ot1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730910AbfFHEoL (ORCPT ); Sat, 8 Jun 2019 00:44:11 -0400 Received: by mail-ot1-f74.google.com with SMTP id w110so1941517otb.10 for ; Fri, 07 Jun 2019 21:44:11 -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=AmlnQxdhHxhgaUE+upN643FVBvwEIISLpUNhemfIGlM=; b=JL5TWljI4VDEsVSrJSrPNzCX/VIAWb2fbHLcrGTXg2NQX5riYvqM7uVswYbzT/EEIy djd3AV+RJB9gvVahixYEtpThuyB3VVlVmFDDq1q4B9h3ijMYAPCKfE0nk4RoHstinSwx c/R9Pg82bRVid8j95hPh+O3ygphRRVx49n/4u3GIvaAN3C0B+dBOwvqdlm4rSCAstLr7 QkLCiAB4f29eEWdyvpz0T8IDux78ly13crISVGWjBxWAo/Kbu+0XLJFfmT1XIIdKtPZl 86fMZcAYwDzqag6dAnzFYm22f8WETD3fmEbtrfW4u453VQ+8v26rZpQt5DhyAP9cb9Gh DfKw== 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=AmlnQxdhHxhgaUE+upN643FVBvwEIISLpUNhemfIGlM=; b=ACP5prTzCDmo2H+oI64iyuw+02xyD/vTZ4YNDe9tEcZsfle/+tF2drMI89cxiD1cg9 pGVoD6fT4mnldKH9fhdLEb317MillZfLscvR1s8+fhyeMAZvyqfJvcJ3KUWgwCStuwUg mY+e1eMoJK4C5TBICNeIKy6xZutIx6EaY415VHTCnJUESnP2sAIkQwmfio52nQMv4LAB bfsu6wePJ33MgP3VgLnoeUhMg2eEjAZ7GbCZr3TDNMkKf6UVvADcC5HntV/+iR+iHFJb Noaemo3xwbOU0YtR6d/Sj7Rb6WmCOI7SFJ+qo4fpjQwG36demY2z8uDzSa4N15eNZee/ v5ig== X-Gm-Message-State: APjAAAUCO7bit2oQqPHtjR8swFWe5X2eVBRp50BRnpgx68yPjzV/p5ae GWFc6me7uGJIiLF0QsAkdGiIv0/WRxQD2P8= X-Google-Smtp-Source: APXvYqz9I03qq1fo0EbBYhFp6pczS0prAvgt/qQK+tiBjETZmeye60HIskMRhLyeg6qLcL8rLOIIuIvMoSD2BCs= X-Received: by 2002:aca:d88b:: with SMTP id p133mr6059786oig.3.1559969050745; Fri, 07 Jun 2019 21:44:10 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:38 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-9-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 8/9] OPP: Allow copying OPPs tables between devices From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 Some hardware devices might create multiple children devices to manage different components of the hardware. In these cases, it might be necessary for the original hardware device to copy specific OPP tables to a specific the new child device. Add dev_pm_opp_add_opp_table() to do that. Signed-off-by: Saravana Kannan --- drivers/opp/core.c | 8 ++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index d96d5746eb47..9d49aee2c3ef 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -943,6 +943,14 @@ struct opp_device *_add_opp_dev(const struct device *dev, return opp_dev; } +int dev_pm_opp_add_opp_table(struct device *dev, struct opp_table *opp_table) +{ + if (!dev || !opp_table) + return -EINVAL; + + return _add_opp_dev(dev, opp_table) ? 0 : -ENOMEM; +} + static struct opp_table *_allocate_opp_table(struct device *dev, int index) { struct opp_table *opp_table; diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 13381dc3dd39..31acc617fda3 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -81,6 +81,7 @@ struct dev_pm_set_opp_data { struct opp_table *dev_pm_opp_get_opp_table(struct device *dev); struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device *dev, int index); void dev_pm_opp_put_opp_table(struct opp_table *opp_table); +int dev_pm_opp_add_opp_table(struct device *dev, struct opp_table *opp_table); unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); @@ -158,6 +159,12 @@ static inline struct opp_table *dev_pm_opp_get_opp_table_indexed(struct device * static inline void dev_pm_opp_put_opp_table(struct opp_table *opp_table) {} +static int dev_pm_opp_add_opp_table(struct device *dev, + struct opp_table *opp_table) +{ + return -ENOTSUPP; +} + static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp) { return 0; From patchwork Sat Jun 8 04:43:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 10982989 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 0182E76 for ; Sat, 8 Jun 2019 04:44:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE28028B70 for ; Sat, 8 Jun 2019 04:44:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE60A28BDD; Sat, 8 Jun 2019 04:44:21 +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 2752628B70 for ; Sat, 8 Jun 2019 04:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731032AbfFHEoP (ORCPT ); Sat, 8 Jun 2019 00:44:15 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:52495 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731017AbfFHEoP (ORCPT ); Sat, 8 Jun 2019 00:44:15 -0400 Received: by mail-pf1-f202.google.com with SMTP id i123so2859351pfb.19 for ; Fri, 07 Jun 2019 21:44:14 -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=X/0NqtCGqUmOq4nLYX8jL0qKKJXqxo5c/Ras/XYEZ30=; b=sGxRHU9J6/WBdSx6fV4lvlmqJRkCIBhCKnkxlP2A6WFEW+TPmoxuIwxU/QxhjV/fg7 /FoAmfZkNcSjdPpmL5ehNppf/RPEpMu0zP+H3qTyZTFQLtYGYa8y9/Ylk1PwUiPttEco lwGacdhFHJIokJjrbPKkwNQJjMWfzhYycY8tHrP85QZrBvaiHmFyrLLJd7TvDUI3JXd1 ho5vXJdBfwyx9tMUZix67KP4mtoXuru6aeevvUzt5m7m5/GVT0sxGkzfu5NLHE1/J9e+ FG6nbS1fhDfHQpgtpwYdj/fRGdojh9ogJBjijzfbAxOa5i6kF0OKgg9sJdm+F9Qm+oLk stOQ== 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=X/0NqtCGqUmOq4nLYX8jL0qKKJXqxo5c/Ras/XYEZ30=; b=oy+SITIBftnLNgOhPx4x8TEgNgp5LSAQlzE4B5LnE6z8L2RFxQtRpaLft6ATwxITy0 CHLx0szw3Pj+bbFJ0c8a3mKyrxWCohn6kRlIcftxTBLNP206kavQpo37OQzfy0ofbvyj eelqHMhxdFWYlLmfkRGZoKVl2U5WRpa1e5j2Evz7vHHpFo/W43CtI7vFKRIZppBU6cXw DN28Aeuc54ra3KbUHIY84UQjp+ba/Gaf9sj+dALQrA9C6xI/JEN2ZMqU9aM2/hADDUTH YUuCKj3xEHHVhn2pS1YYyCA25w7exDmrCs69k98JX/vR7GaDCuKV5esNt7N/8PjGqRVx e+XA== X-Gm-Message-State: APjAAAUFlhnvEIRWhzBcKrDPWQ+vHLMW8cFYJ762fQf0TQ+kGX6fdPh3 HvNNWi3fzCuuymmiuflEx/4c/lqIUk8iDIE= X-Google-Smtp-Source: APXvYqw+aLvw6BhTGdaOngx8+WAxudDKeQuk6uRkUc6lti20wsGbVu9yrVV0Sa5OuwKBTg9T03aHut5pp6KUHxY= X-Received: by 2002:a65:6104:: with SMTP id z4mr5999890pgu.319.1559969054138; Fri, 07 Jun 2019 21:44:14 -0700 (PDT) Date: Fri, 7 Jun 2019 21:43:39 -0700 In-Reply-To: <20190608044339.115026-1-saravanak@google.com> Message-Id: <20190608044339.115026-10-saravanak@google.com> Mime-Version: 1.0 References: <20190608044339.115026-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.rc2.383.gf4fbbf30c2-goog Subject: [PATCH v1 9/9] interconnect: Add devfreq support From: Saravana Kannan To: Georgi Djakov , Rob Herring , Mark Rutland , Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Saravana Kannan , Rajendra Nayak , Jordan Crouse , vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.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 Add a icc_create_devfreq() and icc_remove_devfreq() to create and remove devfreq devices for interconnect paths. A driver can create/remove devfreq devices for the interconnects needed for its device by calling these APIs. This would allow various devfreq governors to work with interconnect paths and the device driver itself doesn't have to actively manage the bandwidth votes for the interconnects. Signed-off-by: Saravana Kannan --- drivers/interconnect/Makefile | 2 +- drivers/interconnect/icc-devfreq.c | 145 +++++++++++++++++++++++++++++ include/linux/interconnect.h | 11 +++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 drivers/interconnect/icc-devfreq.c diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile index 28f2ab0824d5..ddfb65b7fa55 100644 --- a/drivers/interconnect/Makefile +++ b/drivers/interconnect/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -icc-core-objs := core.o +icc-core-objs := core.o icc-devfreq.o obj-$(CONFIG_INTERCONNECT) += icc-core.o obj-$(CONFIG_INTERCONNECT_QCOM) += qcom/ diff --git a/drivers/interconnect/icc-devfreq.c b/drivers/interconnect/icc-devfreq.c new file mode 100644 index 000000000000..f88b267d281e --- /dev/null +++ b/drivers/interconnect/icc-devfreq.c @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * A devfreq device driver for interconnect paths + * + * Copyright (C) 2019 Google, Inc + */ + +#include +#include +#include +#include +#include +#include +#include + +struct icc_devfreq { + struct device icc_dev; + struct icc_path *path; + struct devfreq_dev_profile dp; + struct devfreq *df; + unsigned long peak_bw; + unsigned long avg_bw; +}; + +static int icc_target(struct device *dev, unsigned long *freq, + u32 flags) +{ + struct icc_devfreq *d = dev_get_drvdata(dev); + struct dev_pm_opp *opp; + unsigned long peak_bw, avg_bw; + + opp = devfreq_recommended_opp(dev, &peak_bw, flags); + if (IS_ERR(opp)) { + dev_err(dev, "Failed to find opp for %lu KHz\n", *freq); + return PTR_ERR(opp); + } + peak_bw = dev_pm_opp_get_bw(opp, &avg_bw); + dev_pm_opp_put(opp); + + if (!icc_set_bw(d->path, avg_bw, peak_bw)) { + *freq = peak_bw; + d->peak_bw = peak_bw; + d->avg_bw = avg_bw; + } + + return 0; +} + +static int icc_get_dev_status(struct device *dev, + struct devfreq_dev_status *stat) +{ + struct icc_devfreq *d = dev_get_drvdata(dev); + + stat->current_frequency = d->peak_bw; + return 0; +} + +#define icc_dev_to_data(DEV) container_of((DEV), struct icc_devfreq, icc_dev) +static void icc_dev_release(struct device *dev) +{ + struct icc_devfreq *d = icc_dev_to_data(dev); + + kfree(d); +} + +struct icc_devfreq *icc_create_devfreq(struct device *dev, char *name) +{ + struct icc_devfreq *d; + struct icc_path *path; + struct opp_table *opp_table; + struct dev_pm_opp *opp; + unsigned long peak_bw = U32_MAX, avg_bw = U32_MAX; + int err; + + if (!name) + return ERR_PTR(-EINVAL); + + path = of_icc_get(dev, name); + if (IS_ERR(path)) + return (void *) path; + + opp_table = icc_get_opp_table(path); + if (!opp_table) { + err = -EINVAL; + goto out_path; + } + + d = kzalloc(sizeof(*d), GFP_KERNEL); + if (!d) { + err = -ENOMEM; + goto out_path; + } + d->path = path; + + d->icc_dev.parent = dev; + d->icc_dev.release = icc_dev_release; + dev_set_name(&d->icc_dev, "%s-icc-%s", dev_name(dev), name); + err = device_register(&d->icc_dev); + if (err) { + put_device(&d->icc_dev); + goto out_path; + } + + dev_pm_opp_add_opp_table(&d->icc_dev, opp_table); + opp = dev_pm_opp_find_peak_bw_floor(dev, &peak_bw); + peak_bw = dev_pm_opp_get_bw(opp, &avg_bw); + dev_pm_opp_put(opp); + + if (!icc_set_bw(d->path, avg_bw, peak_bw)) { + d->peak_bw = peak_bw; + d->avg_bw = avg_bw; + } + + d->dp.initial_freq = peak_bw; + d->dp.polling_ms = 0; + d->dp.target = icc_target; + d->dp.get_dev_status = icc_get_dev_status; + d->df = devm_devfreq_add_device(&d->icc_dev, + &d->dp, + "performance", + NULL); + if (IS_ERR(d->df)) { + err = PTR_ERR(d->df); + goto out_dev; + } + + return d; +out_dev: + put_device(&d->icc_dev); +out_path: + icc_put(path); + return ERR_PTR(err); +} +EXPORT_SYMBOL_GPL(icc_create_devfreq); + +void icc_remove_devfreq(struct icc_devfreq *d) +{ + icc_put(d->path); + put_device(&d->icc_dev); +} +EXPORT_SYMBOL_GPL(icc_remove_devfreq); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("interconnect devfreq device driver"); +MODULE_AUTHOR("Saravana Kannan "); diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h index 0c0bc55f0e89..cb166cbcdf88 100644 --- a/include/linux/interconnect.h +++ b/include/linux/interconnect.h @@ -23,6 +23,7 @@ struct icc_path; struct device; +struct icc_devfreq; #if IS_ENABLED(CONFIG_INTERCONNECT) @@ -32,6 +33,8 @@ struct icc_path *of_icc_get(struct device *dev, const char *name); struct opp_table *icc_get_opp_table(struct icc_path *path); void icc_put(struct icc_path *path); int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); +struct icc_devfreq *icc_create_devfreq(struct device *dev, char *name); +void icc_remove_devfreq(struct icc_devfreq *d); #else @@ -61,6 +64,14 @@ static inline int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw) return 0; } +static inline struct icc_devfreq *icc_create_devfreq(struct device *dev, + char *name) +{ + return NULL; +} + +void icc_remove_devfreq(struct icc_devfreq *d) {} + #endif /* CONFIG_INTERCONNECT */ #endif /* __LINUX_INTERCONNECT_H */