From patchwork Wed Jul 3 01:10:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11028813 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 3407E14F6 for ; Wed, 3 Jul 2019 01:10:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30C1D2883F for ; Wed, 3 Jul 2019 01:10:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2411428949; Wed, 3 Jul 2019 01:10:56 +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 B8F572883F for ; Wed, 3 Jul 2019 01:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727400AbfGCBK3 (ORCPT ); Tue, 2 Jul 2019 21:10:29 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:44685 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727355AbfGCBK2 (ORCPT ); Tue, 2 Jul 2019 21:10:28 -0400 Received: by mail-pf1-f201.google.com with SMTP id j22so394298pfe.11 for ; Tue, 02 Jul 2019 18:10:28 -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=e9kTi24uB4qma1DS6GLfEd66OjyUuGvajWKOikD47Aw=; b=Gke0wMis6E54EMbeMX51d1b4DLg3NQl068tRf9JRRwoyEiiec/5boft2FQO/E182cW uoGbqSDHrEW0BfxIj4OxChLfIrwGIcJ/IziKnOHCXvLp36E4FOuiR10Gfrexqp83BIBG k2KWFMwUE5pztZQsHB5U1kpLIQ636P5rYZ+iSo+I1q4LGS+u8VlCzht1pOUpr28+RacL 3bsNezsZYmq9SdcXbeVtcyMwZ6w5XuvSEam+c0LGKZUBTAfwag33F2ozP7CmvpZoAa3l 8v6gShBaUpRw04xZAmgd8KpxH8XqQ+yC9ZD31FLirq2K0FjF661IsWc8zLppc9P5nWsx zIfw== 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=e9kTi24uB4qma1DS6GLfEd66OjyUuGvajWKOikD47Aw=; b=PO5+dNbjk/1v4DpFQuNDEbxAU24RLhB4SreLgwPfTFHeDbhuzkWtQjHhx64SnMX8BQ GjkUtrIveecF+qrd5FcRc/w9aD5HZJhpPEEhJtjAkF/+HN8of5sqp92fDVz1J244kzX3 dCXQEBToNgjSvtPNJMQ5sJagPrk4t/qbrtCrZhzC9TpeCDkgH15MPppQVlT3cN3Qh36S LcnUoC14Z9MOCkHytFX816RdVyvY5WNsABN7mCW/ZdUv5f4vVhvVt7bmMBQ8P6tTSV2Y EwGh+bJ8iYFzn2R4Acakxc7eBgo0iyFq3/5bBmk6Y4oC6tnKnKksUrmr780V8W2sIv/I vBKQ== X-Gm-Message-State: APjAAAXfRS7yRmSEbHiF1efiiSTY4yM6zlX7d2fW7yW46kD+UGNan29r pmL/DYrxX5Spr7RDGSBMf3EIuRmI9Cx0Uas= X-Google-Smtp-Source: APXvYqyhZ6ewKAXFIwQJJhA1AgdyM3RtUJbdz/u8xIi1sWGVsqHDJ1zCwj5Y4C/wLIAnD3LEbng6V6B5cGYzL9Y= X-Received: by 2002:a63:6ec4:: with SMTP id j187mr15725095pgc.420.1562116227470; Tue, 02 Jul 2019 18:10:27 -0700 (PDT) Date: Tue, 2 Jul 2019 18:10:15 -0700 In-Reply-To: <20190703011020.151615-1-saravanak@google.com> Message-Id: <20190703011020.151615-2-saravanak@google.com> Mime-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v3 1/6] 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 , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@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 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 Wed Jul 3 01:10:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11028811 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 7D59813B1 for ; Wed, 3 Jul 2019 01:10:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BF522883F for ; Wed, 3 Jul 2019 01:10:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 708382894E; Wed, 3 Jul 2019 01:10:55 +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 0EB1728917 for ; Wed, 3 Jul 2019 01:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727436AbfGCBKc (ORCPT ); Tue, 2 Jul 2019 21:10:32 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:52151 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727395AbfGCBKb (ORCPT ); Tue, 2 Jul 2019 21:10:31 -0400 Received: by mail-pg1-f202.google.com with SMTP id o16so490197pgk.18 for ; Tue, 02 Jul 2019 18:10:31 -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=Dy7IdBEhW7jfMC6O06J1yeWm8DJoUAt+P2F38lOHIKQ=; b=C+5g3BYbxc2d5v4pLP/1xtwd+gYW5qoY5iVHn3hvWw7WT8h7YVWVxHxfRmoJZQ+3s6 hffBFFZ4zf6A+TQkyNDSMed/hkUv/4u1jzgsPMyyvLb8hk0B2xE21Z86qEbY9tJHH5oR GfYN6NWShZj/4lMx+s+3v/qGTLx+NmsrdLLR6Cdq1pKbrTdMgKnwRQDBVMM48asgS0+R /AYTF6Nm7JTPNsl33trsxoyKPIqWP9Y2TgHdjTQKk54a5F0nlHR49OKuBTRcQ7BXh/+q hSR7Y5Che5UPvZGgOcNebRoL4ySDoTiY3d1LLbAWX5xLnPfcS16Q2qDmzcKnrBnPNlKo fcVA== 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=Dy7IdBEhW7jfMC6O06J1yeWm8DJoUAt+P2F38lOHIKQ=; b=X7ZThSHNi3JISAQ13CimtFZdBGFfRE5U+B7Z9cMOe6gnUH0nrWU4Or0hErOLOJN2xJ Ve/mMUpJLQ6lXT6OdROW6QFBEZzJn41Wxd9eDs9xmp9p13RjzDRurxTwUlQ91VooUomn qteHx7NFvaf3ddTxvRG5Bj3an7QssKzsgC1J0vDUnisiKW/gllZHrpJKkZ8lGb1qkVRv ik5+azD4z8lW8AwNX3qhO8/nUK75+JIQsxxhEpev93lZBs2bfobnTOzfe3mfjiSXcP7k eXAA9WYU4DmGs3K0tyP47dtzhmM+hU/YtQiH5iARQNrzcQoy0vz/dL51d7eYzxXz6awo aCWQ== X-Gm-Message-State: APjAAAXF/s0B59aXJylai/B3q4jXuYDzJO9ebGdMy0fey2B9YaDgwVN0 T/TH8ebDE92iS7GP1Kj5V53k8m48I97ks+o= X-Google-Smtp-Source: APXvYqyZ5SvXkZiJtN4AUVK0TG4NbXUnITz/8Rd9BjbL8Dw8vo+ZHuPMPIdAlkE6UzLY/jK4QL5YPQ5Wylc+8rU= X-Received: by 2002:a65:4786:: with SMTP id e6mr25216266pgs.448.1562116230898; Tue, 02 Jul 2019 18:10:30 -0700 (PDT) Date: Tue, 2 Jul 2019 18:10:16 -0700 In-Reply-To: <20190703011020.151615-1-saravanak@google.com> Message-Id: <20190703011020.151615-3-saravanak@google.com> Mime-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v3 2/6] 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 , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@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 | 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 Wed Jul 3 01:10:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11028803 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 1998F13B1 for ; Wed, 3 Jul 2019 01:10:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1770F288E1 for ; Wed, 3 Jul 2019 01:10:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BA2428900; Wed, 3 Jul 2019 01:10:41 +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 7EA58288E6 for ; Wed, 3 Jul 2019 01:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbfGCBKg (ORCPT ); Tue, 2 Jul 2019 21:10:36 -0400 Received: from mail-ot1-f73.google.com ([209.85.210.73]:34724 "EHLO mail-ot1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727478AbfGCBKf (ORCPT ); Tue, 2 Jul 2019 21:10:35 -0400 Received: by mail-ot1-f73.google.com with SMTP id 20so457457otv.1 for ; Tue, 02 Jul 2019 18:10:34 -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=BIB5A9ngYQ21e4UWwpxGoaLXwuW8tNl9DCFK747Sb4o=; b=XwTMOg1R7C9eWoppaFTrTaFBZmQOj8k2Yscg00eIPwDaQoRQYl7ee8Qc2FlcNMASXT 1EitN34YZe7NVLEzs82LisWVDqKQy3jLsFxUO0uikI4SF6BZitqw2zXRhjS8YN2s+EEH DTVmz86oZ+kv4UxmbIlgT741QhfKU3533HE0LDTdUjzqPbSSemPADj6FHkPjibGEOTqt /wYNZe5Ce+ftw0C6V2HsMcbWTO7VQ4n0U7UXUpNm9tlzN5qVVmXxMeTAC/Fp/9poRVRq PoFPVgzZpBoPlKdeDPtTWp5fpymHNxlMeTr1TRpDnaSrTCOSnEfxyYjpDwapfjanHwkb 5Ufw== 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=BIB5A9ngYQ21e4UWwpxGoaLXwuW8tNl9DCFK747Sb4o=; b=oTfT4D9PljSiNoehFoMDwwfoya3bMfzo+8rsPvCBs1w/ebpvoMG2/IGJzFr7GBpZUD VgFL+3nOwU8ohpFndin8kt6LN/MKUh01ZrW69H66qY7Q2yQRf78mf0dPYqY/owgIvNS8 m7da/6hdenmumGJdZPXyF9+JhNh4JEQFZxVq5szE2QOU1bmsYD1fslu6U0haa6Xv9+qw naoStVZjHNFoLvmyYvmVDqr3ECB1pguVwNBvu3t/InEEmYnrkIAIsBSwt7YwbN7NVE0H Un2RV9FY1M/kW8WVY0eesT1TT0s8Lg4KnKveZiZA+XaySjiiPnXEWXN9vOw7YMds/0KX B6VQ== X-Gm-Message-State: APjAAAX3l3YPrzFeCv8cYguX9+Y6koFnLV5FEuRRxVNjj3MtgYeaVp15 kHaLyRDnf1o1CZlH2b9wrYIZeWEr3+hnrzQ= X-Google-Smtp-Source: APXvYqzPIXzYYdzVqfphJDXQq8xQWI4gZvxXm7m36ULqwEMX1J38/YQsNoWLJJCp7fu+IZQfcrZEqEkXz+SZMDQ= X-Received: by 2002:aca:6ccc:: with SMTP id h195mr4897756oic.163.1562116234188; Tue, 02 Jul 2019 18:10:34 -0700 (PDT) Date: Tue, 2 Jul 2019 18:10:17 -0700 In-Reply-To: <20190703011020.151615-1-saravanak@google.com> Message-Id: <20190703011020.151615-4-saravanak@google.com> Mime-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v3 3/6] 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 , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@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 0e7703fe733f..0168862579f1 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..d4d79ac0b5b2 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 Wed Jul 3 01:10:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11028809 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 823C313B1 for ; Wed, 3 Jul 2019 01:10:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DD6128749 for ; Wed, 3 Jul 2019 01:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 679C02883F; Wed, 3 Jul 2019 01:10:54 +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 EBE0828900 for ; Wed, 3 Jul 2019 01:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727501AbfGCBKk (ORCPT ); Tue, 2 Jul 2019 21:10:40 -0400 Received: from mail-ot1-f73.google.com ([209.85.210.73]:46396 "EHLO mail-ot1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727479AbfGCBKi (ORCPT ); Tue, 2 Jul 2019 21:10:38 -0400 Received: by mail-ot1-f73.google.com with SMTP id m16so436574otq.13 for ; Tue, 02 Jul 2019 18:10:37 -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=yFXfbR6wa0Ur/jSZ6VNfgLJznw66VBn59W3yxqCW7NM=; b=vwv84SdZLnvN4EmOeqy22YxzbmFmKouwa0nzBFOwmxta9hlsJT0H3QFXCuy5t777YN FjNrPeaCRamOIDNLfHaCdvn+Cv7d4uzH2Xgtar+yJTKor7GRaURomcBbJN49yNiPSiTc 9aCQcC00dtNqUOnuB/4syiHqjno4Xb5t8LGnKcUtXKbhX1rGhy/S0MKjRtGJNWa28KUE ZgoJGZZS0d0lI8qLSPBe1RoQyutcB2VLpy7YkvTV38IePnyBD3nl+3iaP3x7skzksJ1g 6HxhRqmBSesa8mVVinWZyyUJu22aSHoFC6GACyqtYa76BjBb33Q9mtiBfphneTFq0D4l rReg== 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=yFXfbR6wa0Ur/jSZ6VNfgLJznw66VBn59W3yxqCW7NM=; b=VnKBVdFtFH5Y1wTQrxbKo2zmP5AGCacUjl0EEW43OyEyOGOxZHZUmpWRcvNDwAHF16 I18ngFkJ1RzRIB8POz2kwN4Xd1Irnde7Kv7PnE4BJMSmMbp2WPToz0+9uz9vr/Ed6ZSe Jb9EtQgz9R+JtMWt6PKMLfbLeCh6TlJK9fT3mTw0Tjxh2PUV4+h2Da9kUG0amRozx2qD 5RRx5GQXHhEBX1t4ZB3ndmeC2kNtrXeJ/YsBD+k9xEZbtWS5laUy8HgP3gr9ffujLGKL HCI6KJIFI6X7RXeQVlBwDYtih0LLbs8rDiw2jEkRKG6kvYPBQSxqC33E92/F5VbDVuve 5xgA== X-Gm-Message-State: APjAAAXku/4kDSDIttJwPGA7isnzsHTpSMIj40BDv2aPum4I9TgmwnYR 3k+jL5zDfXyYRYrbsahy7Hr1oYERs+vKwD0= X-Google-Smtp-Source: APXvYqy/kO7fXs12HqbjkZVqApk+Z3KfTpViPx35W4gf2H71u487pYhcO8yqWOR8+YLawhr6iW9vzVIQEUtt+SM= X-Received: by 2002:a9d:6c17:: with SMTP id f23mr16508610otq.174.1562116237315; Tue, 02 Jul 2019 18:10:37 -0700 (PDT) Date: Tue, 2 Jul 2019 18:10:18 -0700 In-Reply-To: <20190703011020.151615-1-saravanak@google.com> Message-Id: <20190703011020.151615-5-saravanak@google.com> Mime-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v3 4/6] 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 , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@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 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 d4d79ac0b5b2..d80c59bcd50b 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 Wed Jul 3 01:10:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11028805 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 7559A14F6 for ; Wed, 3 Jul 2019 01:10:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66DE528949 for ; Wed, 3 Jul 2019 01:10:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56A7628917; Wed, 3 Jul 2019 01:10:45 +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 0907928917 for ; Wed, 3 Jul 2019 01:10:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727508AbfGCBKo (ORCPT ); Tue, 2 Jul 2019 21:10:44 -0400 Received: from mail-oi1-f202.google.com ([209.85.167.202]:34919 "EHLO mail-oi1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727509AbfGCBKl (ORCPT ); Tue, 2 Jul 2019 21:10:41 -0400 Received: by mail-oi1-f202.google.com with SMTP id i132so370905oif.2 for ; Tue, 02 Jul 2019 18:10:41 -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=/i4EXGtPCOjTtUn8OcmQPQhLaKRhMOHErmPbV67RSQU=; b=km/RUnXQsmM11f9u6Vj6KLdcm6YNGFElnIVjDftfoR/IS3uki7O8YPAX7hSwR6929j x51ouFZg/um6bBKoBAY0YdKBqXpWk+IqgLewMKa92kH07Ada5NO+GkfFpUDoYheX8XJl 9bwzLgVwPNJ8Jmfq0GNodUvpY7vhnKK1tjThNpdWyMW7gkM4ReRiv0XFoM5PeklWDhJh Wtfj3qWG/TfEolzalTHU2AbJlUtyU2LfjZKCtDt1KHzdh3GaANn3/7NXwh7aNKAoWFb3 JdKlsRtBZWE13avukcxGZZsOwmlEkx5nBOnAjj26Sfq5NB9b5tWkWtbEkYLCY/7phx3e /fJw== 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=/i4EXGtPCOjTtUn8OcmQPQhLaKRhMOHErmPbV67RSQU=; b=uJDQTB9iSHny5d5lGBlfw3a6lYSbRJVB/TIMblbrRHmd+/YCfTEWAzMX6D9Qx/6M48 BN4EvVcQ+MNuT3hRTC0QJk+gPdedV7p1fcL1MvbTThmhPUlEOAmnPVTvZzYNj8PA0SfG 1+vNorIO5Cn5cqns1134Qhj1z08nR93K25GipTAPL+qf1uE3b8bRW81AfWMqIj9TEfXE uYIwJLlfTWzWQ92PbV+ZEVT4YJJbMYGQ+58iwtc3MowK7VlVMMD74ZfkiTXJZShlVlwE 0jA84dPXRosk2zFB8DYkWRq3G8kev0YvmLI/S1gKVrsbZlsZQxnOylyOmQ5dhuvxt7fr OX4A== X-Gm-Message-State: APjAAAXOYK0freOW7DCJ836mHkpKS8ZLE3YVFAtNUilXyUXi9Vn+cyEU gE/gR4DARMeYTg4oV6Ww+y/Y8fGSTOH4yuc= X-Google-Smtp-Source: APXvYqzR1Jl6EGogA5bw9waCkseQkalNsyNyWGljAV6SnmdbV7yJAuwfhPQ/T+V5l9xBaAIX1pXO6niIfMhaSkU= X-Received: by 2002:a05:6808:656:: with SMTP id z22mr4715089oih.79.1562116240529; Tue, 02 Jul 2019 18:10:40 -0700 (PDT) Date: Tue, 2 Jul 2019 18:10:19 -0700 In-Reply-To: <20190703011020.151615-1-saravanak@google.com> Message-Id: <20190703011020.151615-6-saravanak@google.com> Mime-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v3 5/6] 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 , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@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 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 Wed Jul 3 01:10:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 11028807 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 489FC13B1 for ; Wed, 3 Jul 2019 01:10:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4658D288E1 for ; Wed, 3 Jul 2019 01:10:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A46E28949; Wed, 3 Jul 2019 01:10:50 +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 B7D7E288E1 for ; Wed, 3 Jul 2019 01:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727504AbfGCBKp (ORCPT ); Tue, 2 Jul 2019 21:10:45 -0400 Received: from mail-pg1-f201.google.com ([209.85.215.201]:44425 "EHLO mail-pg1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727519AbfGCBKo (ORCPT ); Tue, 2 Jul 2019 21:10:44 -0400 Received: by mail-pg1-f201.google.com with SMTP id a21so498653pgh.11 for ; Tue, 02 Jul 2019 18:10:44 -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=dWSTEB7RleZh8XkGrKFTJOfmQbdpdA8YvLb6+yLjiBI=; b=GQP3lyPaiOWVdY7hddYL/HQhNvDTl81zOg4nL0V/I6lx5L0cBJkii5mqEgmUSkDIaU O3U9k5/hTnRIvVzHZX+BxSQA9Ul3gei1PEJdwTf5irvmc5BlbteZ+in5aiHi+OQUzltL jqzY6gGgQoYasy92jwTiE/fnngT4SR5BthJWETwbYHfwo0pHvmR8ECVWdg8cfU/w8bJN GeKuJk4Am5G9A1ZIAw/ic9QKTksdAMWj2qfn/ALIhP1LrFBEJVmahjxY3vL+3lHh3wpv B0bqCyOr87MhKPN/hTBrsgtaHUjc5OU/5L5P6SqNN07sN9O2KGy7rf9ONme5RwQk81sQ sIZQ== 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=dWSTEB7RleZh8XkGrKFTJOfmQbdpdA8YvLb6+yLjiBI=; b=ZpC+oV0m+JudMR3PPuV/OSArOydoJ8aMmFellqljILSMcwnxfw6oy0VGBkJkSpTV87 xJhKPIASCW2Ot4ugUKdBdVFtAGNE8C+nQVz0vmk1YvYg2Cto+Ft6PHxrZrQjOE+mY1KM H5aB9a92ixIQ1mcMaLtozf9sw7lnuUw8MKZC3K4Qy8fI4c1vGVAu7H9cKIZy8ZhdDS9V iYnqMZw/IdQsTCcmz8rnC50E61Pt6AX435x2Z0Q12Q528ueBNFAlz5qJC2HK1JDxCCKN zvDS4x/DRFmBw1oaipKeQynk82Extjn6jhxRL4LEYs8E42Vlpu4R6+zNLIiaFL2WzFpO EBMQ== X-Gm-Message-State: APjAAAVEfF3G4rnwamUIgK9eUF3a7MVCiKHpNApHmGKWbVfWYkRAMKUA JO73QkFeor/o3ZAYB7Vzw8y4qN2PI8hkLOw= X-Google-Smtp-Source: APXvYqzWDTUputAqKDd6ILTyuM86jYoIJkzu7BT12HhgBGatoUR02aCN152bsgijRYOJekQeK0A37JZDsLThSyw= X-Received: by 2002:a65:62c2:: with SMTP id m2mr34089166pgv.413.1562116243633; Tue, 02 Jul 2019 18:10:43 -0700 (PDT) Date: Tue, 2 Jul 2019 18:10:20 -0700 In-Reply-To: <20190703011020.151615-1-saravanak@google.com> Message-Id: <20190703011020.151615-7-saravanak@google.com> Mime-Version: 1.0 References: <20190703011020.151615-1-saravanak@google.com> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog Subject: [PATCH v3 6/6] 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 , vincent.guittot@linaro.org, seansw@qti.qualcomm.com, daidavid1@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 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;