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: 200750 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17B83C54E4A for ; Tue, 12 May 2020 12:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA8F220722 for ; Tue, 12 May 2020 12:53: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 S1729836AbgELMx4 (ORCPT ); Tue, 12 May 2020 08:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727859AbgELMxz (ORCPT ); Tue, 12 May 2020 08:53:55 -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 20625C061A0F for ; Tue, 12 May 2020 05:53:55 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id g12so23126795wmh.3 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=VMV4FaOesNwc1MoXadZT4O0sza/1/zkSQmhH3DLGpNLbAM7Q/+Sks6XLsRuo3hKZPH 2qRWxWqhvvX6qcVFRLhm2G8b2ni+UAPaq52gqfgdQEksAQ9AuFPHlJKh8qLHdCUV7c5B RZTjdKi9PjF1BWA7dIYnvE4+q3aO7FPQ2mQ7YpuaS6KZ6ZLUFmU2GJ+l65Ce6zML7FyV HWQ/Gi6BdB0L1HyOYWWlI/swIemiML59UMDmiVSR3UCOOcRsL/J+RZG0ZwVqsTmoZb/V CIcptGXarLjReJQSTnSDzk1xvksXydKoIostVu9D+Zid7oUMgNKFbqraEKLy68HOQlC7 Vbrw== X-Gm-Message-State: AGi0PuYX41XnuC9G3HqHzy06qEYK6Pc98RLBWCLgv8TaHRrmf1HN8CkV Y66dsQLNL7IrUxGnvwHD99lQRQ== 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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: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: 200749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06C75C54E4A for ; Tue, 12 May 2020 12:54:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D302D20747 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 S1729948AbgELMyG (ORCPT ); Tue, 12 May 2020 08:54:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729947AbgELMyE (ORCPT ); Tue, 12 May 2020 08:54:04 -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 5262BC061A0F for ; Tue, 12 May 2020 05:54:04 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id g14so9313554wme.1 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=DKRwq9pB8PeX5HnAcy4VSO3MXY4h5hW04lrupgBWNZEQRzlAJac6UMxrLEdH3aVVsv Y51KeUcRrBL4LsdWLnsX6sjzykGXGnUkiGSfrPMIO78No6xunL6ld30yu+apvTLGL+jH 972Zl1RyzJYVjNDG+Kp/sIU/mw3hbaCS5OwTTwEVcGmY99esMR8HBdtOtSUszI+1j2O/ AaIEnzZkWZIq9ExVJzPV2+JzCIJ0JQbuZw7BQFTdZNwbFz+OWSWZ59aD2GujDtLLGmfD f6KMHPZ11yM7jsz43i6Xu+zqXdVghLCDHsOpOUdUiX422vMWx5qtFiX+VxBqbRnyiC+c 5gPA== X-Gm-Message-State: AGi0PubrleoFI9BgAzKp24sKrcU1+tpc/lCL1A0UMnMOoOHzTIPkp2ky UA2gx7lMr5WySv3sDb3M36ZG3Q== 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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: 200748 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A13B4C54E8F for ; Tue, 12 May 2020 12:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 80358206D3 for ; Tue, 12 May 2020 12:54:10 +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 S1729972AbgELMyI (ORCPT ); Tue, 12 May 2020 08:54:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729970AbgELMyI (ORCPT ); Tue, 12 May 2020 08:54:08 -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 A0E5BC061A0E for ; Tue, 12 May 2020 05:54:06 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id h17so6342852wrc.8 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=pPt9HIsLN7CuXIcVpREVi1uTJRJN/QiWC1fHd/e2FkAF4QMY39nHfjfOJmk1iM2VoP Gxjbg1a/p6zleqqB449UOYHKhLR7xlsT7MCl+f+Vhv9kIokG7KVDoQz6IurWTUQykX95 QaZXKxK75gO4LNSjS9wJmQ7YLM2JBG8psi4AUttr9Ebxbk2weYeAmhei/QHCWCUo98tc lxhtRgLJNouCVopDMizVeU4bf9N8EXxCNg6oA5ggLb/HXMYThPAuisEGwYzO2geXVrga ZLONROD9NVm/v5LqzaWX906eEbHkGvAIhmkTSdSyCumGLTy4mk947WIxs2yrkhgBy+2R IkEQ== X-Gm-Message-State: AGi0PuYrfT9NRl6ix7aVHVeLOkPdLacBL25m8G5/S+XOiyHOHCgvkser yQfOFbOOmPIsGCbtsiGHFESobA== 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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: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: 200746 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F58AC54E8E for ; Tue, 12 May 2020 12:54:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D970206D3 for ; Tue, 12 May 2020 12:54:45 +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 S1730039AbgELMyb (ORCPT ); Tue, 12 May 2020 08:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729994AbgELMyL (ORCPT ); Tue, 12 May 2020 08:54:11 -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 17515C05BD0B for ; Tue, 12 May 2020 05:54:11 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id m12so16710803wmc.0 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=rKtCltULs75bU6WwQ4TM91IZPe89yweJIW6ek0mJYp8ywgeeYHxlYoIsUyvunf8sOa hKrrHmyqAe3GtbESXRxleSgML3+JdZsr8hcVIA0LlXZNX+1pg1RT0YrCI55PDV8u4wnR NxuG9p077u099PeFbBgZC42NsiB50juMcY5gNQZm2AWB5/8q1KTAWl7iAstVMge4Xo4X qmo1WeKVd4Dto5N+7pc0a7WwN4K9X6M+OB+mTrFtGFQrsHG8uhaVHjuHb/rKPnhgSAa0 MDKp9cNKAjjGE47aVl1dL8hj/CWjJO8WTywPRSDwagBatJuzybbWZXrjUdYHvxIL30FI Dj3g== X-Gm-Message-State: AGi0PuYamwIPLqawwgAyACagQp3c6uXWl6fgkrMisDDwZO8CiFgb6vsh Op6x/1yoT/tr4YM1TA5XszCYrQ== 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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: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: 200747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E662EC54E4A 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 BC81E206D3 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="CtAO3vqc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730011AbgELMyV (ORCPT ); Tue, 12 May 2020 08:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730013AbgELMyR (ORCPT ); Tue, 12 May 2020 08:54:17 -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 D9EA3C05BD12 for ; Tue, 12 May 2020 05:54:15 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id g12so23128114wmh.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=uZ5kzvRrcW/iqmb0MRgAY3/yR40moqTUDa7uv4AAKSCnCsvN90ClbpSbqQPx2n6sh4 /3j3qn2q1QwOBXkPuXLVbTEdmvdr4tP91RedYpTzUa4MTT6waNHYL4C6Sv5FkiY8A3yW Mp7vGGrqWHe5ahIFgd0oCmXg8EUeGr5tiUuNbk7vNjl4i8b4gWQUdVHm274iEjxbS+AV ysDf5J9A/YT7uDUk7cBgfvj6Bk4FkWYFVs/q87/dB4WySleZ5YxP6ixbZucL4gM505Yv EwjY8rlSEM3G3TUPOzQCI9c3ThA1O9Ar0bVj4p7bq7NS6X3kWAmTfeZPqXSldGe21YVh WZaw== X-Gm-Message-State: AOAM533Yh/dVXRMHlt3Bdw617umrNpJ1SU8gYseQtJG2jcklV4LmHC5U PJDbJfls76a5zI16vsJ1saEZ4Q== 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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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; }