From patchwork Tue May 12 12:53:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543129 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1AAAC92A for ; Tue, 12 May 2020 12:54:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 037902075E for ; Tue, 12 May 2020 12:54:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Xwqjy0RH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729842AbgELMx4 (ORCPT ); Tue, 12 May 2020 08:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729800AbgELMxz (ORCPT ); Tue, 12 May 2020 08:53:55 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E9B1C061A0C for ; Tue, 12 May 2020 05:53:55 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id m24so12021299wml.2 for ; Tue, 12 May 2020 05:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1SdYNVTNaFvyLINhitLbEPKE0p+9pMDxlpt3g6of/ns=; b=Xwqjy0RHnIb5Rvf3b47+nB0QUCnzZWaHwSCvbj+70eIdHcw5wWyuLhAWupxQ/fndsS IALkY3q+9pJGLILVNHxx2/yLm3U57RaI5QaqRtfNYq4MRf685W9K1GHEPJacRfrO+ozo g0gSkI6ShBTsk0pjMYkjAShUaBB5fNLACioo8oH5aJU0gzr5gFdv4cKWfdRJQYG401FS 04faqFc/R/Y1Mx4TL6Rrwb55RQn1XNjtJDPOzmkof58YmNnNkiYylrtXym/761g0hX+H 3piXVEeD41H9tJfeNEX34mDfsCPYtXpxsduPWvMgTFE5I8IFPxhLz/0MLZkqtVEySn+H EDGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1SdYNVTNaFvyLINhitLbEPKE0p+9pMDxlpt3g6of/ns=; b=inhLrgxhCmRhCZC0vfqUpGW4IS7SBMOwgfzgOj1U39OXHzcUhAiMv/eQmetPWgBDSH 4XDsiIVNh1h3YHwwga/NaDAvUa7C/XO6WfWoma/IB2nRdSFHM4+9qF5/g8Gx6IKvJ0eB 5f2YOnbYM8u8Pj276bVIhyBY3qYbfX/T1xogdPDdrCN+zxct0r0R48Yj0kZKjOEaz9Zs aSMLbBrCPswumRuaURYvSya8oD4n2A4EvFGdlTjywQa6XhBKG8U2marGIJ+LxiSRQJVW xe0EKhCujve3ohtrC4TQMl4I51twemcjfOOIAw/FDfaSU+JL/60DNlLiYck18fdsF5rL OPOA== X-Gm-Message-State: AGi0PuY/oLnlPHtZvGpfiaU5BVojCnw8ZL1Ukj2HkvZntWXdZWalm59J Q4x7jYy7pyZhjdrob8mXTBpEJA== X-Google-Smtp-Source: APiQypJwjvPGkayKcc1IbT12QaENm3WRCE4IZfuh0ZT1+eHBylHTrvlamxCMCr7VwP3NSbdPGDRvLw== X-Received: by 2002:a7b:ca53:: with SMTP id m19mr29619717wml.182.1589288033812; Tue, 12 May 2020 05:53:53 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.53.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:53:53 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org, Rob Herring Subject: [PATCH v8 01/10] dt-bindings: opp: Introduce opp-peak-kBps and opp-avg-kBps bindings Date: Tue, 12 May 2020 15:53:18 +0300 Message-Id: <20200512125327.1868-2-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Saravana Kannan Interconnects often quantify their performance points in terms of bandwidth. So, add opp-peak-kBps (required) and opp-avg-kBps (optional) to allow specifying Bandwidth OPP tables in DT. opp-peak-kBps is a required property that replaces opp-hz for Bandwidth OPP tables. opp-avg-kBps is an optional property that can be used in Bandwidth OPP tables. Signed-off-by: Saravana Kannan Reviewed-by: Sibi Sankar Reviewed-by: Rob Herring Signed-off-by: Georgi Djakov --- v8: * Picked reviewed-by tags. * Changes on wording. Documentation/devicetree/bindings/opp/opp.txt | 17 ++++++++++++++--- .../devicetree/bindings/property-units.txt | 4 ++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt index 68592271461f..9d16d417e9be 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, unless another "required" property to + uniquely identify the OPP nodes exists. Devices like power domains must have + another (implementation dependent) property. + +- opp-peak-kBps: Peak bandwidth in kilobytes per second, expressed as an array + of 32-bit big-endian integers. Each element of the array represents the + peak bandwidth value of each interconnect path. The number of elements should + match the number of interconnect paths. Optional properties: - opp-microvolt: voltage in micro Volts. @@ -132,6 +137,12 @@ 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 an array + of 32-bit big-endian integers. Each element of the array represents the + average bandwidth value of each interconnect path. The number of elements + should match the number of interconnect paths. This property is only + meaningful in OPP tables where opp-peak-kBps is present. + - clock-latency-ns: Specifies the maximum possible transition latency (in nanoseconds) for switching to this OPP from any other OPP. diff --git a/Documentation/devicetree/bindings/property-units.txt b/Documentation/devicetree/bindings/property-units.txt index e9b8360b3288..c80a110c1e26 100644 --- a/Documentation/devicetree/bindings/property-units.txt +++ b/Documentation/devicetree/bindings/property-units.txt @@ -41,3 +41,7 @@ Temperature Pressure ---------------------------------------- -kpascal : kilopascal + +Throughput +---------------------------------------- +-kBps : kilobytes per second From patchwork Tue May 12 12:53:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543111 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B37915E6 for ; Tue, 12 May 2020 12:54:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CB8420722 for ; Tue, 12 May 2020 12:54:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="v3E9oQtc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729896AbgELMx7 (ORCPT ); Tue, 12 May 2020 08:53:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729882AbgELMx7 (ORCPT ); Tue, 12 May 2020 08:53:59 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ACCEC061A0F for ; Tue, 12 May 2020 05:53:57 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id g12so23126928wmh.3 for ; Tue, 12 May 2020 05:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZY4SY3JUuu1zN9osT5fZKN1dv+hBkS+vG5Fe3GmSDvo=; b=v3E9oQtcC+LCZ7/WhfBUykWkmv1LrzfXOW8Go4K0HJKmIh7S/g17SWZU2LACfmJNNW Hu1ZUKGEZYUu6xetG2EWYE/5pulo3ZQX1O6CTM8bvmEp6jBIVGDmZI8BMithEOi5R1y4 NxbvLyzHKHUH4FuJBPcKdnu9ephambV1Yldk5SIoY1DwMdaa21OvzStgUkSqMXHdQiJj Awz2TkkNDze2JFkERz+lobgNUBBEL45Bp6xE3KRehkDSCB9SVngeAsFo8qO+ylsdBfmf hA//0IoDiwAPXvqWicYtem4cVemH7HLpH6OcBmtWRoxIGnlq9KjEiCiIjYgnXk5aE8Yg uniA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZY4SY3JUuu1zN9osT5fZKN1dv+hBkS+vG5Fe3GmSDvo=; b=b40JWUvBM16TFKm2tyKIV4SQIPohHteA1sPOKBtQzQ4GUkZwrh9rU+Vl0rO3B97RF0 n7YDfMmXMjU94oDkbTdQBlDLrWMww/CAkJCazBBbwPkAKzZYp7nfvUtivPmdQtnpYpDy ahMHt4yNJQn9kbWmXvNo+VQA/PNvp/ZOYwxuuJdHHWreO03Z6uqsUal/sMT1EKjXhy5k 7E5hHQ+NkTsJ7VX4Bof39Pdla4GQ9+9WdLie6eMMMnquvhSncrhPLJANRSBnSGriR3Pu B9+v7RZEYrWVPZNY4BVOMf0W6mAXQLC8NdL75jRnrLnuPHMN6zm5vr9/fSxIG2oFNm9U ta0g== X-Gm-Message-State: AOAM530EPeyP/N3rn1hW1j03Bn2YnB9eBySjISWiStdqP6LJgJlfDFtD YpgcVYOOEhTSJNmOEkCIt7nGCA== X-Google-Smtp-Source: ABdhPJxlJOzCKpVNgUT7Y/42Aplo7q1WWLy95KCQrQSQtnfI+tTP3G96a/0OkjNXPPCK96SQP8fBBA== X-Received: by 2002:a1c:444:: with SMTP id 65mr350110wme.21.1589288036006; Tue, 12 May 2020 05:53:56 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.53.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:53:55 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 02/10] OPP: Add helpers for reading the binding properties Date: Tue, 12 May 2020 15:53:19 +0300 Message-Id: <20200512125327.1868-3-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Saravana Kannan The opp-hz DT property is not mandatory and we may use another property as a key in the OPP table. Add helper functions to simplify the reading and comparing the keys. Signed-off-by: Saravana Kannan Reviewed-by: Matthias Kaehlcke Reviewed-by: Sibi Sankar Signed-off-by: Georgi Djakov --- v8: * Keep the existing behavior: goto free_opp only if !is_genpd * Picked reviewed-by tags. drivers/opp/core.c | 15 +++++++++++++-- drivers/opp/of.c | 45 +++++++++++++++++++++++++++------------------ drivers/opp/opp.h | 1 + 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index e4f01e7771a2..ce7e4103ec09 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1286,11 +1286,21 @@ static bool _opp_supported_by_regulators(struct dev_pm_opp *opp, return true; } +int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2) +{ + if (opp1->rate != opp2->rate) + return opp1->rate < opp2->rate ? -1 : 1; + if (opp1->level != opp2->level) + return opp1->level < opp2->level ? -1 : 1; + return 0; +} + static int _opp_is_duplicate(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table, struct list_head **head) { struct dev_pm_opp *opp; + int opp_cmp; /* * Insert new OPP in order of increasing frequency and discard if @@ -1301,12 +1311,13 @@ static int _opp_is_duplicate(struct device *dev, struct dev_pm_opp *new_opp, * loop. */ list_for_each_entry(opp, &opp_table->opp_list, node) { - if (new_opp->rate > opp->rate) { + opp_cmp = _opp_compare_key(new_opp, opp); + if (opp_cmp > 0) { *head = &opp->node; continue; } - if (new_opp->rate < opp->rate) + if (opp_cmp < 0) return 0; /* Duplicate OPPs */ diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 9cd8f0adacae..5179f034751a 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -521,6 +521,28 @@ 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, + bool *rate_not_available) +{ + u64 rate; + int ret; + + 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; + } + *rate_not_available = !!ret; + + of_property_read_u32(np, "opp-level", &new_opp->level); + + return ret; +} + /** * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings) * @opp_table: OPP table @@ -558,26 +580,13 @@ 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); - 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__); - goto free_opp; - } - - rate_not_available = true; - } else { - /* - * Rate is defined as an unsigned long in clk API, and so - * casting explicitly to its type. Must be fixed once rate is 64 - * bit guaranteed in clk API. - */ - new_opp->rate = (unsigned long)rate; + ret = _read_opp_key(new_opp, np, &rate_not_available); + /* The key is optional for devices like power domains. */ + if (ret < 0 && !opp_table->is_genpd) { + dev_err(dev, "%s: opp key field not found\n", __func__); + goto free_opp; } - of_property_read_u32(np, "opp-level", &new_opp->level); - /* Check if the OPP supports hardware's hierarchy of versions or not */ if (!_opp_is_supported(dev, opp_table, np)) { dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index d14e27102730..bcadb1e328a4 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -211,6 +211,7 @@ struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_ void _dev_pm_opp_find_and_remove_table(struct device *dev); struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table); void _opp_free(struct dev_pm_opp *opp); +int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2); int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table, bool rate_not_available); int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int last_cpu); From patchwork Tue May 12 12:53:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543127 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0480192A for ; Tue, 12 May 2020 12:54:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D66B72075E for ; Tue, 12 May 2020 12:54:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="R9bsk+7B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729921AbgELMyC (ORCPT ); Tue, 12 May 2020 08:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729901AbgELMx7 (ORCPT ); Tue, 12 May 2020 08:53:59 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84FBCC061A0F for ; Tue, 12 May 2020 05:53:59 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id g14so9313422wme.1 for ; Tue, 12 May 2020 05:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+rGKvfoFiAjDdQtTJ+6Vf7qeLWqTDG31CN5bbQtUQo8=; b=R9bsk+7Bfx6aoIZswCKHfN5y9yBMNHag58e4lfCBuVfHphfHNW9fb8fAa+v4hEOqHR jWKg8MG1csnW15D6ckwBgpCyyZtwk3rRq+T0DP6hrMm6FZmqP58jylNfhns/Pa4qDnfk OfFJHqXMukabQLkOuzbxfNYlfTQVCuWoOy0wTOhXRER6dIwsS6RETC6W1+Ua+jUnwZOU r/pOp2X0EgJaGApqO5iWRwEExGO5LXycsC8+b5gjb4bE4pGSfA5hPJAq+0M0YnxJ4WlH fero2AQKwoUddyP2V4V45egrl2kvvj19KEER8L0B5nmqccdJuPqgzW46McVZgvAVuhuQ ByJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+rGKvfoFiAjDdQtTJ+6Vf7qeLWqTDG31CN5bbQtUQo8=; b=GMft9NR7udemshT4QdleWqxJ2nV+1UQ6gtii99u8WaNEpHGGQT9cxhTdaoUZ0sMs4+ A6Y7df3eVsNhkHizDy7kzbI+B6Os66uLTdkuvABMEiE4C+B1vDunLXtP7lAJTVg+ODxU 5nUWEYR+q6bpkKKkkXPg4JlQfZjVtN0e6Lp/BoFhHQ7MmCmavjgrKWUR+6VBo0Jws4p2 PAPJcecRkZ1k5geXo9XHE0E2+J1Un/SrKLogZmGdwJLFhMskoKJj40obdk6Th6En/0jJ 4lrGVjzHc26rJLPaVXdewiN1O/4tUDUtUauY7lihvjBWoM3Zmqakm21ui7e3aob12Ae5 e4ew== X-Gm-Message-State: AGi0PuZuPKWSYcuUL6sAAKzs8XWg5cluMym6ob7cnIyxxX4q7LOQGvhy Vt2xYbdX4IThTcT3sITQiCxRhA== X-Google-Smtp-Source: APiQypLVCbH0uBXG8DFqpYqzRwWsWiqSkdNCTz/vDUVtGWJZXox+WKeuIqWoT6/6hqCEQhI68x/oSQ== X-Received: by 2002:a1c:c242:: with SMTP id s63mr27560918wmf.180.1589288038141; Tue, 12 May 2020 05:53:58 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.53.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:53:57 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 03/10] interconnect: Add of_icc_get_by_index() helper function Date: Tue, 12 May 2020 15:53:20 +0300 Message-Id: <20200512125327.1868-4-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This is the same as the traditional of_icc_get() function, but the difference is that it takes index as an argument, instead of name. Reviewed-by: Matthias Kaehlcke Reviewed-by: Sibi Sankar Signed-off-by: Georgi Djakov --- v8: * Dropped unneeded initializations. * Picked reviewed-by tags. drivers/interconnect/core.c | 72 +++++++++++++++++++++++++++--------- include/linux/interconnect.h | 6 +++ 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 2c6515e3ecf1..aba5d38ea9d1 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -351,9 +351,9 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec) } /** - * of_icc_get() - get a path handle from a DT node based on name + * of_icc_get_by_index() - get a path handle from a DT node based on index * @dev: device pointer for the consumer device - * @name: interconnect path name + * @idx: interconnect path index * * This function will search for a path between two endpoints and return an * icc_path handle on success. Use icc_put() to release constraints when they @@ -365,13 +365,12 @@ static struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec) * Return: icc_path pointer on success or ERR_PTR() on error. NULL is returned * when the API is disabled or the "interconnects" DT property is missing. */ -struct icc_path *of_icc_get(struct device *dev, const char *name) +struct icc_path *of_icc_get_by_index(struct device *dev, int idx) { - struct icc_path *path = ERR_PTR(-EPROBE_DEFER); + struct icc_path *path; struct icc_node *src_node, *dst_node; - struct device_node *np = NULL; + struct device_node *np; struct of_phandle_args src_args, dst_args; - int idx = 0; int ret; if (!dev || !dev->of_node) @@ -391,12 +390,6 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) * lets support only global ids and extend this in the future if needed * without breaking DT compatibility. */ - if (name) { - idx = of_property_match_string(np, "interconnect-names", name); - if (idx < 0) - return ERR_PTR(idx); - } - ret = of_parse_phandle_with_args(np, "interconnects", "#interconnect-cells", idx * 2, &src_args); @@ -439,12 +432,8 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) return path; } - if (name) - path->name = kstrdup_const(name, GFP_KERNEL); - else - path->name = kasprintf(GFP_KERNEL, "%s-%s", - src_node->name, dst_node->name); - + path->name = kasprintf(GFP_KERNEL, "%s-%s", + src_node->name, dst_node->name); if (!path->name) { kfree(path); return ERR_PTR(-ENOMEM); @@ -452,6 +441,53 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) return path; } +EXPORT_SYMBOL_GPL(of_icc_get_by_index); + +/** + * of_icc_get() - get a path handle from a DT node based on name + * @dev: device pointer for the consumer device + * @name: interconnect path name + * + * This function will search for a path between two endpoints and return an + * icc_path handle on success. Use icc_put() to release constraints when they + * are not needed anymore. + * 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: icc_path pointer on success or ERR_PTR() on error. NULL is returned + * when the API is disabled or the "interconnects" DT property is missing. + */ +struct icc_path *of_icc_get(struct device *dev, const char *name) +{ + struct device_node *np; + int idx = 0; + + if (!dev || !dev->of_node) + return ERR_PTR(-ENODEV); + + np = dev->of_node; + + /* + * When the consumer DT node do not have "interconnects" property + * return a NULL path to skip setting constraints. + */ + if (!of_find_property(np, "interconnects", NULL)) + return NULL; + + /* + * We use a combination of phandle and specifier for endpoint. For now + * lets support only global ids and extend this in the future if needed + * without breaking DT compatibility. + */ + if (name) { + idx = of_property_match_string(np, "interconnect-names", name); + if (idx < 0) + return ERR_PTR(idx); + } + + return of_icc_get_by_index(dev, idx); +} EXPORT_SYMBOL_GPL(of_icc_get); /** diff --git a/include/linux/interconnect.h b/include/linux/interconnect.h index d70a914cba11..34e97231a6ab 100644 --- a/include/linux/interconnect.h +++ b/include/linux/interconnect.h @@ -28,6 +28,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 icc_path *of_icc_get_by_index(struct device *dev, int idx); void icc_put(struct icc_path *path); int icc_set_bw(struct icc_path *path, u32 avg_bw, u32 peak_bw); void icc_set_tag(struct icc_path *path, u32 tag); @@ -46,6 +47,11 @@ static inline struct icc_path *of_icc_get(struct device *dev, return NULL; } +static inline struct icc_path *of_icc_get_by_index(struct device *dev, int idx) +{ + return NULL; +} + static inline void icc_put(struct icc_path *path) { } From patchwork Tue May 12 12:53:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543121 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 648D892A for ; Tue, 12 May 2020 12:54:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3EC4D20753 for ; Tue, 12 May 2020 12:54:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fb/gdTCq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729952AbgELMyG (ORCPT ); Tue, 12 May 2020 08:54:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729918AbgELMyC (ORCPT ); Tue, 12 May 2020 08:54:02 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C68AC061A0C for ; Tue, 12 May 2020 05:54:02 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id m12so16710167wmc.0 for ; Tue, 12 May 2020 05:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZNWwiClN9J9T7evLiY37kMNqf5NsweYzE/X+kyO+ICQ=; b=fb/gdTCqpL1JsDWySrHQAsWmzKLsAmNC8kb7AUayoG9sarsZqWcSb5Pk09D8XzqA1p IsxIzN3yujlsyaa+bNQmWFgFEuK9nOlaGXdECh5olK7XGlpiF7w6Hte+AJqqoo886rLL SEJn+f+0iQ2+LMgEo0qBmkb6aRQeJlSZFhGbAJp/JpMWK9LDqKKFDpq4CXSLD/kH6L/0 54ttqL/usJ56e8NsQjvtWa83yj1ADUg7pBeh2pvJi54MnE+ZtXZYjfdpZr0g41T2rABJ 6bzL+aP7tif3kP/EuNvDn09bSMtBYqwmW7ypia9NENet47814t4002slg077x9+65BoH +iyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZNWwiClN9J9T7evLiY37kMNqf5NsweYzE/X+kyO+ICQ=; b=IkpUAikPF1x8iQPWNNySjPUpA7cuIWKJNBATcAbrDv2Zy9bu1nd+bK5W3MBIQa96Tv 0EmYjsYzrzZRvUt++Ya5I3Jq2no4ZbLtvd0KaqJYSDlh10Y84g9Bpbvsre5dAsj2MW5g Rbyt54bJoMYDvhy2Ae4eh5CkBGXA5/ndk3+oQ0SZQzTeEtBrMV2a0OQtuqtxD/7RZNmR hX23m/p7G3FxoeLoQT89stNqAaToswU0FjVy1HUjWfIXBSbf+XKEQR18nzElvyz/IHzG 4vqiY5CbiYO+N9/dm3MJSgznHvJMgOOc7jfmEedjwZ861i4MmXLmI7SkksDvh/u8CNWr Hcrw== X-Gm-Message-State: AGi0Pub5X+Tqn2vt/24ma0+73M1o0Rt31ZsIvd6qgyT9KluUljCAL6JM GLVIY0kNKxoQVmW/aREo4bLvZQ== X-Google-Smtp-Source: APiQypKfiJNyaLR5mbA1viBAxBp1qaLv2saXkd4v32ycysK7Z5vjIfcAtFC7yiv/VWvW/sNNC78iFw== X-Received: by 2002:a7b:ca53:: with SMTP id m19mr29620199wml.182.1589288040687; Tue, 12 May 2020 05:54:00 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.53.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:54:00 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 04/10] OPP: Add support for parsing interconnect bandwidth Date: Tue, 12 May 2020 15:53:21 +0300 Message-Id: <20200512125327.1868-5-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The OPP bindings now support bandwidth values, so add support to parse it from device tree and store it into the new dev_pm_opp_icc_bw struct, which is part of the dev_pm_opp. Signed-off-by: Georgi Djakov Reviewed-by: Matthias Kaehlcke Reviewed-by: Sibi Sankar --- v8: * Drop bandwidth requests and free memory in _opp_table_kref_release. * Take into account the supply_count in struct size calculations. * Free the temporary arrays for peak and average bandwidth. * Fix the check for opp-level. * Use dev_warn insted of dev_dbg. * Rename _of_find_icc_paths to _of_find_icc_paths. * Rename the variable count to supply_count. drivers/opp/Kconfig | 1 + drivers/opp/core.c | 27 +++++++-- drivers/opp/of.c | 121 ++++++++++++++++++++++++++++++++++++++++- drivers/opp/opp.h | 9 +++ include/linux/pm_opp.h | 12 ++++ 5 files changed, 164 insertions(+), 6 deletions(-) diff --git a/drivers/opp/Kconfig b/drivers/opp/Kconfig index 35dfc7e80f92..230d2b84436c 100644 --- a/drivers/opp/Kconfig +++ b/drivers/opp/Kconfig @@ -2,6 +2,7 @@ config PM_OPP bool select SRCU + depends on INTERCONNECT || !INTERCONNECT ---help--- SOCs have a standard set of tuples consisting of frequency and voltage pairs that the device will support per voltage domain. This diff --git a/drivers/opp/core.c b/drivers/opp/core.c index ce7e4103ec09..a3dd0bc9b9f6 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -999,6 +999,12 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index) ret); } + /* Find interconnect path(s) for the device */ + ret = _of_find_icc_paths(opp_table, dev); + if (ret) + dev_warn(dev, "%s: Error finding interconnect paths: %d\n", + __func__, ret); + BLOCKING_INIT_NOTIFIER_HEAD(&opp_table->head); INIT_LIST_HEAD(&opp_table->opp_list); kref_init(&opp_table->kref); @@ -1057,6 +1063,7 @@ static void _opp_table_kref_release(struct kref *kref) { struct opp_table *opp_table = container_of(kref, struct opp_table, kref); struct opp_device *opp_dev, *temp; + int i; _of_clear_opp_table(opp_table); @@ -1064,6 +1071,12 @@ static void _opp_table_kref_release(struct kref *kref) if (!IS_ERR(opp_table->clk)) clk_put(opp_table->clk); + if (opp_table->paths) { + for (i = 0; i < opp_table->path_count; i++) + icc_put(opp_table->paths[i]); + kfree(opp_table->paths); + } + WARN_ON(!list_empty(&opp_table->opp_list)); list_for_each_entry_safe(opp_dev, temp, &opp_table->dev_list, node) { @@ -1243,19 +1256,22 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_remove_all_dynamic); struct dev_pm_opp *_opp_allocate(struct opp_table *table) { struct dev_pm_opp *opp; - int count, supply_size; + int supply_count, supply_size, icc_size; /* Allocate space for at least one supply */ - count = table->regulator_count > 0 ? table->regulator_count : 1; - supply_size = sizeof(*opp->supplies) * count; + supply_count = table->regulator_count > 0 ? table->regulator_count : 1; + supply_size = sizeof(*opp->supplies) * supply_count; + icc_size = sizeof(*opp->bandwidth) * table->path_count; /* allocate new OPP node and supplies structures */ - opp = kzalloc(sizeof(*opp) + supply_size, GFP_KERNEL); + opp = kzalloc(sizeof(*opp) + supply_size + icc_size, GFP_KERNEL); + if (!opp) return NULL; /* Put the supplies at the end of the OPP structure as an empty array */ opp->supplies = (struct dev_pm_opp_supply *)(opp + 1); + opp->bandwidth = (struct dev_pm_opp_icc_bw *)(opp->supplies + supply_count); INIT_LIST_HEAD(&opp->node); return opp; @@ -1290,6 +1306,9 @@ int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2) { if (opp1->rate != opp2->rate) return opp1->rate < opp2->rate ? -1 : 1; + if (opp1->bandwidth && opp2->bandwidth && + opp1->bandwidth[0].peak != opp2->bandwidth[0].peak) + return opp1->bandwidth[0].peak < opp2->bandwidth[0].peak ? -1 : 1; if (opp1->level != opp2->level) return opp1->level < opp2->level ? -1 : 1; return 0; diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 5179f034751a..d139ad8c8f4f 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -332,6 +332,58 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, return ret; } +int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) +{ + struct device_node *np; + int ret, i, count, num_paths; + + np = of_node_get(dev->of_node); + if (!np) + return 0; + + count = of_count_phandle_with_args(np, "interconnects", + "#interconnect-cells"); + of_node_put(np); + if (count < 0) + return 0; + + /* two phandles when #interconnect-cells = <1> */ + if (count % 2) { + dev_err(dev, "%s: Invalid interconnects values\n", __func__); + return -EINVAL; + } + + num_paths = count / 2; + opp_table->paths = kcalloc(num_paths, sizeof(*opp_table->paths), + GFP_KERNEL); + if (!opp_table->paths) + return -ENOMEM; + + for (i = 0; i < num_paths; i++) { + opp_table->paths[i] = of_icc_get_by_index(dev, i); + if (IS_ERR(opp_table->paths[i])) { + ret = PTR_ERR(opp_table->paths[i]); + if (ret != -EPROBE_DEFER) { + dev_err(dev, "%s: Unable to get path%d: %d\n", + __func__, i, ret); + } + goto err; + } + } + opp_table->path_count = num_paths; + + return 0; + +err: + while (i--) + icc_put(opp_table->paths[i]); + + kfree(opp_table->paths); + opp_table->paths = NULL; + + return ret; +} + static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, struct device_node *np) { @@ -524,8 +576,11 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np, bool *rate_not_available) { + struct property *peak, *avg; + u32 *peak_bw, *avg_bw; u64 rate; - int ret; + int ret, i, count; + bool found = false; ret = of_property_read_u64(np, "opp-hz", &rate); if (!ret) { @@ -535,10 +590,72 @@ static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np, * bit guaranteed in clk API. */ new_opp->rate = (unsigned long)rate; + found = true; } *rate_not_available = !!ret; - of_property_read_u32(np, "opp-level", &new_opp->level); + peak = of_find_property(np, "opp-peak-kBps", NULL); + if (peak) { + /* + * Bandwidth consists of peak and average (optional) values: + * opp-peak-kBps = ; + * opp-avg-kBps = ; + */ + count = peak->length / sizeof(u32); + peak_bw = kmalloc_array(count, sizeof(*peak_bw), GFP_KERNEL); + if (!peak_bw) + return -ENOMEM; + + ret = of_property_read_u32_array(np, "opp-peak-kBps", peak_bw, + count); + if (ret) { + pr_err("%s: Error parsing opp-peak-kBps: %d\n", + __func__, ret); + goto free_peak_bw; + } + + for (i = 0; i < count; i++) + new_opp->bandwidth[i].peak = kBps_to_icc(peak_bw[i]); + + found = true; + kfree(peak_bw); + } + + avg = of_find_property(np, "opp-avg-kBps", NULL); + if (peak && avg) { + count = avg->length / sizeof(u32); + avg_bw = kmalloc_array(count, sizeof(*avg_bw), GFP_KERNEL); + if (!avg_bw) { + ret = -ENOMEM; + goto free_peak_bw; + } + + ret = of_property_read_u32_array(np, "opp-avg-kBps", avg_bw, + count); + if (ret) { + pr_err("%s: Error parsing opp-avg-kBps: %d\n", + __func__, ret); + goto free_avg_bw; + } + + for (i = 0; i < count; i++) + new_opp->bandwidth[i].avg = kBps_to_icc(avg_bw[i]); + + kfree(avg_bw); + } + + if (!of_property_read_u32(np, "opp-level", &new_opp->level)) + found = true; + + if (found) + return 0; + + return ret; + +free_avg_bw: + kfree(avg_bw); +free_peak_bw: + kfree(peak_bw); return ret; } diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index bcadb1e328a4..17d45119d9bc 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -12,6 +12,7 @@ #define __DRIVER_OPP_H__ #include +#include #include #include #include @@ -59,6 +60,7 @@ extern struct list_head opp_tables; * @rate: Frequency in hertz * @level: Performance level * @supplies: Power supplies voltage/current values + * @bandwidth: Interconnect bandwidth values * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's * frequency from any other OPP's frequency. * @required_opps: List of OPPs that are required by this OPP. @@ -81,6 +83,7 @@ struct dev_pm_opp { unsigned int level; struct dev_pm_opp_supply *supplies; + struct dev_pm_opp_icc_bw *bandwidth; unsigned long clock_latency_ns; @@ -146,6 +149,8 @@ enum opp_table_access { * @regulator_count: Number of power supply regulators. Its value can be -1 * (uninitialized), 0 (no opp-microvolt property) or > 0 (has opp-microvolt * property). + * @paths: Interconnect path handles + * @path_count: Number of interconnect paths * @genpd_performance_state: Device's power domain support performance state. * @is_genpd: Marks if the OPP table belongs to a genpd. * @set_opp: Platform specific set_opp callback @@ -189,6 +194,8 @@ struct opp_table { struct clk *clk; struct regulator **regulators; int regulator_count; + struct icc_path **paths; + unsigned int path_count; bool genpd_performance_state; bool is_genpd; @@ -224,12 +231,14 @@ void _of_clear_opp_table(struct opp_table *opp_table); struct opp_table *_managed_opp(struct device *dev, int index); void _of_opp_free_required_opps(struct opp_table *opp_table, struct dev_pm_opp *opp); +int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev); #else static inline void _of_init_opp_table(struct opp_table *opp_table, struct device *dev, int index) {} static inline void _of_clear_opp_table(struct opp_table *opp_table) {} static inline struct opp_table *_managed_opp(struct device *dev, int index) { return NULL; } static inline void _of_opp_free_required_opps(struct opp_table *opp_table, struct dev_pm_opp *opp) {} +static inline int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) { return 0; } #endif #ifdef CONFIG_DEBUG_FS diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 747861816f4f..cfceb0290401 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -41,6 +41,18 @@ struct dev_pm_opp_supply { unsigned long u_amp; }; +/** + * struct dev_pm_opp_icc_bw - Interconnect bandwidth values + * @avg: Average bandwidth corresponding to this OPP (in icc units) + * @peak: Peak bandwidth corresponding to this OPP (in icc units) + * + * This structure stores the bandwidth values for a single interconnect path. + */ +struct dev_pm_opp_icc_bw { + u32 avg; + u32 peak; +}; + /** * struct dev_pm_opp_info - OPP freq/voltage/current values * @rate: Target clk rate in hz From patchwork Tue May 12 12:53:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543113 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB62992A for ; Tue, 12 May 2020 12:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D362B2078C for ; Tue, 12 May 2020 12:54:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Bp9y1iYj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729840AbgELMyG (ORCPT ); Tue, 12 May 2020 08:54:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729948AbgELMyE (ORCPT ); Tue, 12 May 2020 08:54:04 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B8DFC05BD09 for ; Tue, 12 May 2020 05:54:04 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id m12so16710306wmc.0 for ; Tue, 12 May 2020 05:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b24wWlVcAI5WtF67gfQ7lrjlIMYnj1RJeDLHmrXEYY0=; b=Bp9y1iYjiq7ye/soNQOoI0zgGM05UpR/YwVIWWyyEltiDcIOoAGDYxVDyrDRrvoh0O daBFFibX2WNQ2n4W5P7mhIcxYCnoHunw/ZHAgIJfRZeNwwKd/+4yY6j2RSUCcAO2oKcG SlfmAbhoI/WUOA16HyPwEuIj1qRrpMFdx/6fH+Dv5VKckYOsA70pKQD7sY6ocNbpEILX xIEK/cd4VbYgamr0IAvzmZgRzZEWeNyStR5Lyqvf7wpEZ/3sclOwgm73VYOhveGK1FZm Ocaj1mJlJ2z1Vu6Fid4ZF3lE7fTtiybksa2rITo9zqBwvMuPmmswX2vTdUeFj+9Na6YF ms/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b24wWlVcAI5WtF67gfQ7lrjlIMYnj1RJeDLHmrXEYY0=; b=kBl+VSpeIQly4tMdWOKAcj5n8N9S3Nejuu85sSBtpxrXDjPaYe+77b4YCaz3T9xhXv FMHMhsic6myLR51S2xHou7lgpjIQeF1W1Wok+0+E3tVd5V3b5/4+q3CpuQ3OMRbeqlID zmeR0MpIQgydGCAqwpeXL5bCTNcBoaax1HT+LIPXyOji650TGOi6pCrTiKXtK/BQ/BC3 8h1nWVGAkpUJdUZPZ+fGH7giSETtMdT+LsWW/hMjxPrbgiVTJE+t7mpblcwPZzwb5PDx bpxUTZuIMifPEk8D0fMM6hKQRyvsAHQgIl+ZZmf0+qPwLAI8D/R20GARnPMZ+ZS0DROI wsag== X-Gm-Message-State: AGi0PubYdFZREuPwoyUhLsP1RNTi7AQ4h8AB4ZIiovcix3HF6tsyWOO5 ii4O9aiGDydvL+YqWnkJyqiMMA== X-Google-Smtp-Source: APiQypImfYB5nyqvxvA2M9l1iE6rJd3+iWflg0lmI06ciJYbhnp3vcBubfm+gyg9hkqNQsFSQpHNSQ== X-Received: by 2002:a1c:3884:: with SMTP id f126mr39071056wma.91.1589288042966; Tue, 12 May 2020 05:54:02 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.54.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:54:02 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 05/10] OPP: Add sanity checks in _read_opp_key() Date: Tue, 12 May 2020 15:53:22 +0300 Message-Id: <20200512125327.1868-6-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org When we read the OPP keys, it would be nice to do some sanity checks of the values we get from DT and see if they match with the information that is populated in the OPP table. Let's pass a pointer of the table, so that we can do some validation. Reviewed-by: Matthias Kaehlcke Reviewed-by: Sibi Sankar Signed-off-by: Georgi Djakov --- v8: * Picked reviewed-by tags. drivers/opp/of.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index d139ad8c8f4f..3a64f2aa0f86 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -573,8 +573,8 @@ 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, - bool *rate_not_available) +static int _read_opp_key(struct dev_pm_opp *new_opp, struct opp_table *table, + struct device_node *np, bool *rate_not_available) { struct property *peak, *avg; u32 *peak_bw, *avg_bw; @@ -602,6 +602,12 @@ static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np, * opp-avg-kBps = ; */ count = peak->length / sizeof(u32); + if (table->path_count != count) { + pr_err("%s: Mismatch between opp-peak-kBps and paths (%d %d)\n", + __func__, count, table->path_count); + return -EINVAL; + } + peak_bw = kmalloc_array(count, sizeof(*peak_bw), GFP_KERNEL); if (!peak_bw) return -ENOMEM; @@ -624,6 +630,13 @@ static int _read_opp_key(struct dev_pm_opp *new_opp, struct device_node *np, avg = of_find_property(np, "opp-avg-kBps", NULL); if (peak && avg) { count = avg->length / sizeof(u32); + if (table->path_count != count) { + pr_err("%s: Mismatch between opp-avg-kBps and paths (%d %d)\n", + __func__, count, table->path_count); + ret = -EINVAL; + goto free_peak_bw; + } + avg_bw = kmalloc_array(count, sizeof(*avg_bw), GFP_KERNEL); if (!avg_bw) { ret = -ENOMEM; @@ -697,7 +710,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, if (!new_opp) return ERR_PTR(-ENOMEM); - ret = _read_opp_key(new_opp, np, &rate_not_available); + ret = _read_opp_key(new_opp, opp_table, np, &rate_not_available); /* The key is optional for devices like power domains. */ if (ret < 0 && !opp_table->is_genpd) { dev_err(dev, "%s: opp key field not found\n", __func__); From patchwork Tue May 12 12:53:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543123 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C33FC1668 for ; Tue, 12 May 2020 12:54:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABC0920736 for ; Tue, 12 May 2020 12:54:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="scW+/E3V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730070AbgELMyp (ORCPT ); Tue, 12 May 2020 08:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729962AbgELMyH (ORCPT ); Tue, 12 May 2020 08:54:07 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C09FC061A0C for ; Tue, 12 May 2020 05:54:06 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id e1so1293881wrt.5 for ; Tue, 12 May 2020 05:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3LiHGYQJdrfKidREPKcP85nvhchSzlTD7vf2JY+btAU=; b=scW+/E3VOhb7ANMkVGJAkt7I46OvXaM5bUd9N0yFWjWVfeIAu2lIjkgtUMGJUGqT2v o87Z65cKvS6wBr1IJmeiic/ITKuZXfTMO3Lrvxc+/WHFSUoyB3/mx0JGmHF+vOoXEUs2 rHpa0IRoHt2Epz3mA1yq70MMy1zH25WqxYc0aOfgnhc7UqNR8SVfQ2uPac0T6QUdzCGs PlYJ3NC9syl5LHu9dZstEPrZLF7cd70ILMfQDuoG1KDEUlQSpD7WVvDF3Yh7rF8t0Oc4 lnXedUVI+mIg2DOvSe5eL9UBRK16w9fSAzbzQ+nAG3nbu7hrkh8Fu5IvXKUNoKZCwCAN 4E/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3LiHGYQJdrfKidREPKcP85nvhchSzlTD7vf2JY+btAU=; b=G13O0lODbNnJTlHscExnFD+fX2SYGAw0tHaa9pEziyE0FndhvSla9VU1ckSwPIETwu ih3rU+7SLqWrs1Azo0pWVH3TNOHaQk16H0FWefdUOeIahUcI+CcTNNOfRPibBcRS2eqB 7u5wTib5KIlAuW3J2v1+pr9JzckHLOaFnloN84knbgvtgftpM5Hd0rFTYoo+U8Zo3qFi ijzLLcrk+asEsG/1+uGYG7UH9O+7jgRHh9uYpwyMAF92RgrmvIN1MZmt+Th0kLSMnZ8h gnYZ863ibtqsXT13JP/tITdbQAx+w/HEL8NNkF+Q/82HqT+zfYr30HjG8JcCVuekaaPG azow== X-Gm-Message-State: AGi0PubLJHTHap9h0P8VnTlz6KWpJmJM2V2x7xZ/6eS9bsrqxZssgv1p 2MS8HZNZYyBLVwBAi3cD5pkXcA== X-Google-Smtp-Source: APiQypLWnsIijAZkCoIPv0Yw0p6DgOwRj7KRO6OOZp0lKCb8xAu9CIukABYCZLAyYnm8VEBr1P0w2w== X-Received: by 2002:adf:b30f:: with SMTP id j15mr26775441wrd.394.1589288045298; Tue, 12 May 2020 05:54:05 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.54.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:54:04 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 06/10] OPP: Update the bandwidth on OPP frequency changes Date: Tue, 12 May 2020 15:53:23 +0300 Message-Id: <20200512125327.1868-7-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org If the OPP bandwidth values are populated, we want to switch also the interconnect bandwidth in addition to frequency and voltage. Reviewed-by: Matthias Kaehlcke Reviewed-by: Sibi Sankar Signed-off-by: Georgi Djakov --- v8: * Picked reviewed-by tags. drivers/opp/core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index a3dd0bc9b9f6..b4cc4b12d57b 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -808,7 +808,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) unsigned long freq, old_freq, temp_freq; struct dev_pm_opp *old_opp, *opp; struct clk *clk; - int ret; + int ret, i; opp_table = _find_opp_table(dev); if (IS_ERR(opp_table)) { @@ -909,6 +909,17 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) dev_err(dev, "Failed to set required opps: %d\n", ret); } + if (!ret && opp_table->paths) { + for (i = 0; i < opp_table->path_count; i++) { + ret = icc_set_bw(opp_table->paths[i], + opp->bandwidth[i].avg, + opp->bandwidth[i].peak); + if (ret) + dev_err(dev, "Failed to set bandwidth[%d]: %d\n", + i, ret); + } + } + put_opp: dev_pm_opp_put(opp); put_old_opp: From patchwork Tue May 12 12:53:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543125 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26DBC92A for ; Tue, 12 May 2020 12:54:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E31F20A8B for ; Tue, 12 May 2020 12:54:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hRQiCfER" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729645AbgELMyp (ORCPT ); Tue, 12 May 2020 08:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729982AbgELMyJ (ORCPT ); Tue, 12 May 2020 08:54:09 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2642C061A0F for ; Tue, 12 May 2020 05:54:08 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id e16so15231849wra.7 for ; Tue, 12 May 2020 05:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UrDz0VtEFIllRgR/SygMJHwSLsI5h5gjPBKpNjucqnU=; b=hRQiCfERNwcKeaXH+vBgWstpdhfVeFUqZ1HMM5gInNFUPCUmTIxlN+nW06ZqEyr1MT WJt82jfFMhSh3/RaGC13yJslFwkNU9IP5rTAXxevITstBNNe0Q0GqLiQ8X/4kMoTb5St 9DB5LdqtelZUdP4aOiA8r4r6CKfpEsAkHPc+1ZB0OvODMQGzdCislqEz/wGa5WTmLoY2 d/LAisGXl4ceWObzMaSX+TnByQmuW6rujCdNxrDyZktJU5cYwJDxyLT3uqKLbzHAA/zv 4Q+Skz9YusrYZTS4w02hgcM5lS0pRpHRcUHCIILUcGrWW36OTz9Rc638ZOyVZKUaow2B luIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UrDz0VtEFIllRgR/SygMJHwSLsI5h5gjPBKpNjucqnU=; b=J6lgp1hw77RLYT/jcdXXWoaCuU4GVLUWe8ORN5O6mE0iNoITYbC2vQ9TidUiLWtgJv h7BQlnwRx8vcDHg0LSMrgJK1bgAgoA00TWy9PIl49rYVia29wV5TxMUqF4WOTli0OCIt 4gbVW89xRQDMgpQDJ2UMQYThCN+hZ9PYbRe/zxa3bUi1PIXmmVU7rggexl1COvAKSHny JjMELNjyJxu6T8xh3+AeyHljZceNYEyme0flmBj49uPsQmDP9ezflaxhNo9MAdloZBEH 7knt9OoQNBIHeINxhrPmMrKYAYyBcVjP1v2KnBr4yYw7eym46aQGxIEBP6b9x5rL/3KD iFPA== X-Gm-Message-State: AGi0PuYT5EnQoh34i3hihrfwBZprQPk+6C2Ne+FxwkWlHT+RWFL2y+bm pLjjN7DmDZ5A9dogh2E2LAeTmA== X-Google-Smtp-Source: APiQypKf6IbOeOx+5EfHUUqCWzbaipquaePVOHE175HL0LBNU9ynasyUz/CcO62uWiKdOHOo00HWLA== X-Received: by 2002:a5d:614b:: with SMTP id y11mr26414026wrt.77.1589288047573; Tue, 12 May 2020 05:54:07 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.54.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:54:06 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 07/10] cpufreq: dt: Add support for interconnect bandwidth scaling Date: Tue, 12 May 2020 15:53:24 +0300 Message-Id: <20200512125327.1868-8-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In addition to clocks and regulators, some devices can scale the bandwidth of their on-chip interconnect - for example between CPU and DDR memory. Add support for that, so that platforms which support it can make use of it. Reviewed-by: Matthias Kaehlcke Signed-off-by: Georgi Djakov --- v8: * Picked reviewed-by tag. * Added a separate patch to check the number of paths in DT and validate each one of them. drivers/cpufreq/Kconfig | 1 + drivers/cpufreq/cpufreq-dt.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index c3e6bd59e920..db2ad54ee67f 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig @@ -217,6 +217,7 @@ config CPUFREQ_DT config CPUFREQ_DT_PLATDEV bool + depends on INTERCONNECT || !INTERCONNECT help This adds a generic DT based cpufreq platdev driver for frequency management. This creates a 'cpufreq-dt' platform device, on the diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 26fe8dfb9ce6..4ecef3257532 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ static int resources_available(void) struct device *cpu_dev; struct regulator *cpu_reg; struct clk *cpu_clk; + struct icc_path *cpu_path; int ret = 0; const char *name; @@ -121,6 +123,19 @@ static int resources_available(void) clk_put(cpu_clk); + cpu_path = of_icc_get(cpu_dev, NULL); + ret = PTR_ERR_OR_ZERO(cpu_path); + if (ret) { + if (ret == -EPROBE_DEFER) + dev_dbg(cpu_dev, "defer icc path: %d\n", ret); + else + dev_err(cpu_dev, "failed to get icc path: %d\n", ret); + + return ret; + } + + icc_put(cpu_path); + name = find_supply_name(cpu_dev); /* Platform doesn't require regulator */ if (!name) From patchwork Tue May 12 12:53:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543119 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22F2F15E6 for ; Tue, 12 May 2020 12:54:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 059A62075E for ; Tue, 12 May 2020 12:54:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sO7XfySX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728085AbgELMyb (ORCPT ); Tue, 12 May 2020 08:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729998AbgELMyM (ORCPT ); Tue, 12 May 2020 08:54:12 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A96FC05BD0C for ; Tue, 12 May 2020 05:54:11 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id y24so23175337wma.4 for ; Tue, 12 May 2020 05:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ajq1/CzNblXv+RM50/78rYUghtc/wnGS+X5x8yODyro=; b=sO7XfySXe80lnwqkM0HWalZ/ES2oFzxHC7xem4vOYv+YNGQ6ZdL81IDKCWGRDYfo0K AIuWbCIrg5La5wCRDU2tJVS4DgFc4wCRbB6qfTOAeTyqMYZlg2VZaW+copxuN+tcappx IuMRgLabKURL8TLvRpsSTyWAzjpVwbUMLwc0VPYo7NzOqGT1qcj5lQ6VT/ZlAltjSLbe FSBTGWNX19PpIanyCGJPjsAd/QKzg+8cSl7cg13/lrwi54mXTWI8SfsQ8zpneQZZBtdi 5FpDn2wm5oPgJImqxZQYO6p3LvBY/IvBBd3lsGCb7YLa0bMxREUTf1p5wqFbjpk6DEsd rjMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ajq1/CzNblXv+RM50/78rYUghtc/wnGS+X5x8yODyro=; b=T9lgoFCZNrbnrkuJoMGeRLGOuPOM/BdbbK6FiGoPaQGD/Cm0PLuTBB5eHZzhbd2Z6d 8AUQULZi3XBxNT4iIL4AKSeOK4Z6u+F3x9L+Clww+xNCI7ggfy405rFTnq+mxPYEWL7M h542rU1PA81L+GoEJG6okOakOVoxMaPORX8YQspJXT+lDaE4DAy+pba4QAygPxx8JySM VmajTnueuW7/nzRYkupV7aNQd8pLp2/TRHL8VZoZn+fMgiMtUijT5oPn6FABtZYkL8jS TPddiTmiAGQIeUE78icKBd4dysBfl8D15heULLFRYQjzmNEgF4s0hooFTurvDxhpP26/ wQqQ== X-Gm-Message-State: AGi0PuaJPGVSxaZ/pwCyCNbfpn+7F5QqpcKY/kEVMVvIE2pPt/R8icAp inMYsT6COeTHqsbsTxJTCavZ5Q== X-Google-Smtp-Source: APiQypI9T2ok8lrlawVLg9C+vh31VJV/7SAheVI1C66BCWNhBoiMINsaNb/Pq91MS1pb1eZXRFnVwg== X-Received: by 2002:a05:600c:21d6:: with SMTP id x22mr39074416wmj.95.1589288049805; Tue, 12 May 2020 05:54:09 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.54.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:54:09 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 08/10] cpufreq: dt: Validate all interconnect paths Date: Tue, 12 May 2020 15:53:25 +0300 Message-Id: <20200512125327.1868-9-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently when we check for the available resources, we assume that there is only one interconnect path, but in fact it could be more than one. Do some validation to determine the number of paths and verify if each one of them is available. Signed-off-by: Georgi Djakov --- v8: * New patch. drivers/cpufreq/cpufreq-dt.c | 49 ++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index 4ecef3257532..3dd28c2c1633 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -91,12 +91,54 @@ static const char *find_supply_name(struct device *dev) return name; } +static int find_icc_paths(struct device *dev) +{ + struct device_node *np; + struct icc_path **paths; + int i, count, num_paths; + int ret = 0; + + np = of_node_get(dev->of_node); + if (!np) + return 0; + + count = of_count_phandle_with_args(np, "interconnects", + "#interconnect-cells"); + of_node_put(np); + if (count < 0) + return 0; + + /* two phandles when #interconnect-cells = <1> */ + if (count % 2) { + dev_err(dev, "%s: Invalid interconnects values\n", __func__); + return -EINVAL; + } + + num_paths = count / 2; + paths = kcalloc(num_paths, sizeof(*paths), GFP_KERNEL); + if (!paths) + return -ENOMEM; + + for (i = 0; i < num_paths; i++) { + paths[i] = of_icc_get_by_index(dev, i); + ret = PTR_ERR_OR_ZERO(paths[i]); + if (ret) + break; + } + + while (i--) + icc_put(paths[i]); + + kfree(paths); + + return ret; +} + static int resources_available(void) { struct device *cpu_dev; struct regulator *cpu_reg; struct clk *cpu_clk; - struct icc_path *cpu_path; int ret = 0; const char *name; @@ -123,8 +165,7 @@ static int resources_available(void) clk_put(cpu_clk); - cpu_path = of_icc_get(cpu_dev, NULL); - ret = PTR_ERR_OR_ZERO(cpu_path); + ret = find_icc_paths(cpu_dev); if (ret) { if (ret == -EPROBE_DEFER) dev_dbg(cpu_dev, "defer icc path: %d\n", ret); @@ -134,8 +175,6 @@ static int resources_available(void) return ret; } - icc_put(cpu_path); - name = find_supply_name(cpu_dev); /* Platform doesn't require regulator */ if (!name) From patchwork Tue May 12 12:53:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543117 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E013992A for ; Tue, 12 May 2020 12:54:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C85242075E for ; Tue, 12 May 2020 12:54:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="lbhHhuyO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730017AbgELMyV (ORCPT ); Tue, 12 May 2020 08:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730014AbgELMyS (ORCPT ); Tue, 12 May 2020 08:54:18 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83242C05BD0F for ; Tue, 12 May 2020 05:54:13 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id j5so15248188wrq.2 for ; Tue, 12 May 2020 05:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DiGkcP4eFfexy4SQNg7ufjBEY09YfamROxya/IRuOvI=; b=lbhHhuyOPtBdd3q/gIrXbLMkzPLkug63EWPG7QItNwgksACc7MSj/9kF1UPQ8MLJqh unxRTRIW1DyZxi2DdzBndiS1VPS62K39G9g8zOpKDjNfZbU47NFi6qoTXe1K9wkyrUS/ DlJJxWVA3GKMxyWwBnDpZwuudkuOYYk762HkMYAvvUaso/D+8paTno94nFhGa/kn3FlL NcfHo42OmU9PCgj51w+Axe4g/w5EGoa69wsjmd0tSFkBF9ZCZpqaNqiD/+xJ8DDYSxbT XzMtZEv2QGvk8VdHoxSUgZOr9n5N6drn6eUY8W0MFprKVglnYkSkBnDkYDwm0998PhHQ uxlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DiGkcP4eFfexy4SQNg7ufjBEY09YfamROxya/IRuOvI=; b=dsN3+uiy1RE5CHvZiPK/iRzjJdlVlYC4H6iPP7u9Rs8fOuNrwwp0r3pqb8I4Jec5oB Ibtq9H3pMCTtdkDBN0faPig3bof9AkRGeAQjkKVT038H4UHOUIfBEoip+C5YCyImC1fg /n1kKnwjc86GA+soDztp+l8G8QYu1Dt3VzeXbtXJORtIXorI6uS4y2fyuW/PkYEjRbiG s2n2xrnj6Xv5l1UkHNnggbKsIXZpvqiJmxlOXgEANvt0nSEulvNw+meIgx4+9SXxP3o9 bb1h9e43uQ3P0+kbpMRk5vCWVQxHzmWcbHodtEl80ugwoW9nBR3rsK8Kj/nuFigR68z/ u+8A== X-Gm-Message-State: AOAM5304GVNFL+JTeKpIsZviur+qZ2AjVNz0tQl+I3cdccCsibKClTP7 g17Xzra13qoFl+1OKyBKHrC6ew== X-Google-Smtp-Source: ABdhPJxcybAIvGXBrRlxlNGIKrgxSDZXtYzJGmC8jFI2UV/YzTeoWr1beziqnC7jrJDlyfrzn/I/bQ== X-Received: by 2002:a5d:4491:: with SMTP id j17mr2147301wrq.41.1589288052058; Tue, 12 May 2020 05:54:12 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.54.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:54:11 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 09/10] dt-bindings: interconnect: Add interconnect-tags bindings Date: Tue, 12 May 2020 15:53:26 +0300 Message-Id: <20200512125327.1868-10-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Sibi Sankar Add interconnect-tags bindings to enable passing of optional tag information to the interconnect framework. Signed-off-by: Sibi Sankar Signed-off-by: Georgi Djakov --- v8: * New patch, picked from here: https://lore.kernel.org/r/20200504202243.5476-10-sibis@codeaurora.org .../devicetree/bindings/interconnect/interconnect.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/interconnect/interconnect.txt b/Documentation/devicetree/bindings/interconnect/interconnect.txt index 6f5d23a605b7..c1a226a934e5 100644 --- a/Documentation/devicetree/bindings/interconnect/interconnect.txt +++ b/Documentation/devicetree/bindings/interconnect/interconnect.txt @@ -55,6 +55,11 @@ 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-tags : List of interconnect path tags sorted in the same order as the + interconnects property. Consumers can append a specific tag to + the path and pass this information to the interconnect framework + to do aggregation based on the attached tag. + Example: sdhci@7864000 { From patchwork Tue May 12 12:53:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 11543115 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDEF492A for ; Tue, 12 May 2020 12:54:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A508B206D3 for ; Tue, 12 May 2020 12:54:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CtAO3vqc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730023AbgELMyV (ORCPT ); Tue, 12 May 2020 08:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730016AbgELMyS (ORCPT ); Tue, 12 May 2020 08:54:18 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3F73C05BD11 for ; Tue, 12 May 2020 05:54:15 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id k12so21578453wmj.3 for ; Tue, 12 May 2020 05:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fvKbAOWfl/knTZNX27VnXfewubIaPbz+/XetIklYZ7g=; b=CtAO3vqc/5ciyMQoZsCfVYtGsZMc+eGRSXx8OOoeAcTbEVI4XVBa71bqTsRSIHZ0gK cIoZxWJLoMHxPgfW90arxdJ8OlAjwSTl9umY/OPCe30eJ/bW7vTcQkNceICuv313oULW TOGrpVNZ9fr3FpbebaRAGuhnQhXb7jCQv3QOwonNO2kt4Ps1rNkm//Xwdg34qLqRAsiw ZF0XfOyfRoK6lhpW+QCop6SAla1XYxNLOWCXFpFzGfqvQkIGLdm42P0TaQuoqZBRveos tJhRidy4xOS3ok+vXCq8VghzXgIU1qoCXK7qMumPAlU/3O+ElEbAbTKGV5pfpG4mgQ0B 137Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fvKbAOWfl/knTZNX27VnXfewubIaPbz+/XetIklYZ7g=; b=RiqO7yOJkCYhi3s64vuFi4LqQD4QNdeSoijZBU+Xr2htjFZ9BH18POz19Z+snl4mUk cnJMh+uegeUt91d0m3eiG+eaxM5jWl/kKKOBP78ViR4bH47xGZqaq8ElrHSw4HZqTlbn W+wmWRg5ipkJCum6EfUCNHXCQk+ECAq9dZbUBqwxe7Bi6Y+KJZqTZeLtYUN9VOSsZZIy qzMFcMHldGBVOukl4SWpfCvRZrX/15sBg4e7bGwRDXi5UjZ5xiv5NVCMzioMKljDoDRd wbnqp5Ax8qVuM/uTEYmIh0+B+DLHf+cw9YtO7cjs8vSVe2wqmz2Y6iS0QK7PJMeYmQHR QDdA== X-Gm-Message-State: AOAM533qPP18/+SwucRZghVebDYpoDMCCRNiidVr/dW1XMdMXU+SANBf dwz7anJBuUIp1Yx1s4HK1LmTBQ== X-Google-Smtp-Source: ABdhPJwY/a0cn3q6lCGX60mZA2InAaE/IzVG1DBnCICgZqVoe54tj6ukY4c547zEb5HQfe3aDNwFYA== X-Received: by 2002:a1c:444:: with SMTP id 65mr351423wme.21.1589288054568; Tue, 12 May 2020 05:54:14 -0700 (PDT) Received: from localhost.localdomain (212-39-89-66.ip.btc-net.bg. [212.39.89.66]) by smtp.googlemail.com with ESMTPSA id n13sm2433938wrs.2.2020.05.12.05.54.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2020 05:54:13 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, rjw@rjwysocki.net, saravanak@google.com, sibis@codeaurora.org, mka@chromium.org Cc: robh+dt@kernel.org, rnayak@codeaurora.org, bjorn.andersson@linaro.org, vincent.guittot@linaro.org, jcrouse@codeaurora.org, evgreen@chromium.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v8 10/10] OPP: Add support for setting interconnect-tags Date: Tue, 12 May 2020 15:53:27 +0300 Message-Id: <20200512125327.1868-11-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512125327.1868-1-georgi.djakov@linaro.org> References: <20200512125327.1868-1-georgi.djakov@linaro.org> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Sibi Sankar Add support for setting tags on icc paths associated with the opp_table. Signed-off-by: Sibi Sankar Signed-off-by: Georgi Djakov --- v8: * New patch, picked from here: https://lore.kernel.org/r/20200504202243.5476-11-sibis@codeaurora.org drivers/opp/of.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 3a64f2aa0f86..fd148d54022f 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -336,6 +336,7 @@ int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) { struct device_node *np; int ret, i, count, num_paths; + u32 tag; np = of_node_get(dev->of_node); if (!np) @@ -344,20 +345,25 @@ int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) count = of_count_phandle_with_args(np, "interconnects", "#interconnect-cells"); of_node_put(np); - if (count < 0) - return 0; + if (count < 0) { + ret = 0; + goto put_np; + } /* two phandles when #interconnect-cells = <1> */ if (count % 2) { dev_err(dev, "%s: Invalid interconnects values\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto put_np; } num_paths = count / 2; opp_table->paths = kcalloc(num_paths, sizeof(*opp_table->paths), GFP_KERNEL); - if (!opp_table->paths) - return -ENOMEM; + if (!opp_table->paths) { + ret = -ENOMEM; + goto put_np; + } for (i = 0; i < num_paths; i++) { opp_table->paths[i] = of_icc_get_by_index(dev, i); @@ -369,8 +375,14 @@ int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) } goto err; } + + /* Set tag if present */ + if (!of_property_read_u32_index(np, "interconnect-tags", + i, &tag)) + icc_set_tag(opp_table->paths[i], tag); } opp_table->path_count = num_paths; + of_node_put(np); return 0; @@ -380,6 +392,8 @@ int _of_find_icc_paths(struct opp_table *opp_table, struct device *dev) kfree(opp_table->paths); opp_table->paths = NULL; +put_np: + of_node_put(np); return ret; }