From patchwork Tue Apr 23 13:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 10912989 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE1E51390 for ; Tue, 23 Apr 2019 13:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A06D2286F2 for ; Tue, 23 Apr 2019 13:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9477D2873A; Tue, 23 Apr 2019 13:29:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38E1F286F2 for ; Tue, 23 Apr 2019 13:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728056AbfDWN3J (ORCPT ); Tue, 23 Apr 2019 09:29:09 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44413 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727754AbfDWN2b (ORCPT ); Tue, 23 Apr 2019 09:28:31 -0400 Received: by mail-lj1-f194.google.com with SMTP id h16so959719ljg.11 for ; Tue, 23 Apr 2019 06:28:29 -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=3r+b8+ekNVHte2QeCZMZAWdkAU7CdygGrtvnF2S4meU=; b=lfCNfDiQGJnwV59072TgSQ/QI0Z22D8koaXNkdIjyMEzEPlQgEmHSAJSJkTSafGn/5 giGeB/hmkrFAmAPPNycokb+0Ds1tdk66Bbbdt5LDNso09R37cP9YqBmcqN4pg3ExcM7O rrOnBQLJT/B/auJOE/0fAjshwXn+mN0IHe22TUkmKy6MQHLE9HOfKLEqwnz44Fd9mhhY FFHUbj8SN6LXo4m51LYKVmGdaqLDbFFlYarUWbUQ6tXdFywNb7hIyfwTT7K8eVyRE8l4 NG60sR2bSizrP7APx+c31+9Sax/MyyYkRLHimkZoBkdm6OjnoHSuU55AhNquY90FDcTJ juJg== 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=3r+b8+ekNVHte2QeCZMZAWdkAU7CdygGrtvnF2S4meU=; b=jqVxIFDjoctmHQ5jwAkKuPeGdOWBFKSkER0m4B56H3DsoVtDWz8fIo3yOV/NA9Mkg8 I5UBjlxncN22pRKTDn/V2rIi6Lw/ILvAK5tKGT6QtZJgnAB2FjHch6sCsSX8Kxk3A0qI 1JXpt+fhHWza7nKj6TUQ970oGMqRIj3lNHKkZ9vHyScA/sLM63xEH7SirgHJTw6BDUW6 XSTRT8VrR/SMrW19zrRFe7OW3Rh7c4Ts9KX4Uye/O8l0Qt4O7gyGlo5/gkxdaQkK+Amd GDIGSV+RgZwBhxemDpMKU7vUye48tAkFn7j/wbnLAiSX5GG+tRdOejugAS/AG+UaiBep wnlw== X-Gm-Message-State: APjAAAV0o2dVdCOvE8nYK6wrdsP7kOr3GTE/Yaxr8YcfFn1T5J/Bnbuy qCH6hY4foWao+MWdD8w86PjxAA== X-Google-Smtp-Source: APXvYqxcThCJ9co/aWID+yA6D6uqJUhZ5RwV+8mms/Umltv4wn/p5ZH/93HikDYzo6iztlgRRsk5fw== X-Received: by 2002:a2e:9348:: with SMTP id m8mr14019864ljh.23.1556026108454; Tue, 23 Apr 2019 06:28:28 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y206sm4617107lfc.72.2019.04.23.06.28.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 06:28:27 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, sboyd@kernel.org, nm@ti.com, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net Cc: jcrouse@codeaurora.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v2 1/5] dt-bindings: opp: Introduce bandwidth-MBps bindings Date: Tue, 23 Apr 2019 16:28:19 +0300 Message-Id: <20190423132823.7915-2-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423132823.7915-1-georgi.djakov@linaro.org> References: <20190423132823.7915-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 X-Virus-Scanned: ClamAV using ClamSMTP In addition to frequency and voltage, some devices may have bandwidth requirements for their interconnect throughput - for example a CPU or GPU may also need to increase or decrease their bandwidth to DDR memory based on the current operating performance point. Extend the OPP tables with additional property to describe the bandwidth needs of a device. The average and peak bandwidth values depend on the hardware and its properties. Signed-off-by: Georgi Djakov --- Documentation/devicetree/bindings/opp/opp.txt | 38 +++++++++++++++++++ .../devicetree/bindings/property-units.txt | 4 ++ 2 files changed, 42 insertions(+) diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt index 76b6c79604a5..830f0206aea7 100644 --- a/Documentation/devicetree/bindings/opp/opp.txt +++ b/Documentation/devicetree/bindings/opp/opp.txt @@ -132,6 +132,9 @@ Optional properties: - opp-level: A value representing the performance level of the device, expressed as a 32-bit integer. +- bandwidth-MBps: The interconnect bandwidth is specified with an array containing + the two integer values for average and peak bandwidth in megabytes per second. + - clock-latency-ns: Specifies the maximum possible transition latency (in nanoseconds) for switching to this OPP from any other OPP. @@ -546,3 +549,38 @@ Example 6: opp-microvolt-, opp-microamp-: }; }; }; + +Example 7: bandwidth-MBps: +Average and peak bandwidth values for the interconnects between CPU and DDR +memory and also between CPU and L3 are defined per each OPP. Bandwidth of both +interconnects is scaled together with CPU frequency. + +/ { + cpus { + CPU0: cpu@0 { + compatible = "arm,cortex-a53", "arm,armv8"; + ... + operating-points-v2 = <&cpu_opp_table>; + /* path between CPU and DDR memory and CPU and L3 */ + interconnects = <&noc MASTER_CPU &noc SLAVE_DDR>, + <&noc MASTER_CPU &noc SLAVE_L3>; + }; + }; + + cpu_opp_table: cpu_opp_table { + compatible = "operating-points-v2"; + opp-shared; + + opp-200000000 { + opp-hz = /bits/ 64 <200000000>; + /* CPU<->DDR bandwidth: 457 MB/s average, 1525 MB/s peak */ + * CPU<->L3 bandwidth: 914 MB/s average, 3050 MB/s peak */ + bandwidth-MBps = <457 1525>, <914 3050>; + }; + opp-400000000 { + opp-hz = /bits/ 64 <400000000>; + /* CPU<->DDR bandwidth: 915 MB/s average, 3051 MB/s peak */ + * CPU<->L3 bandwidth: 1828 MB/s average, 6102 MB/s peak */ + bandwidth-MBps = <915 3051>, <1828 6102>; + }; + }; diff --git a/Documentation/devicetree/bindings/property-units.txt b/Documentation/devicetree/bindings/property-units.txt index bfd33734faca..9c3dbefcdae8 100644 --- a/Documentation/devicetree/bindings/property-units.txt +++ b/Documentation/devicetree/bindings/property-units.txt @@ -41,3 +41,7 @@ Temperature Pressure ---------------------------------------- -kpascal : kiloPascal + +Throughput +---------------------------------------- +-MBps : megabytes per second From patchwork Tue Apr 23 13:28:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 10912983 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F33DB1390 for ; Tue, 23 Apr 2019 13:29:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3DFB28733 for ; Tue, 23 Apr 2019 13:29:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D810228880; Tue, 23 Apr 2019 13:29:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65B5228733 for ; Tue, 23 Apr 2019 13:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727959AbfDWN2f (ORCPT ); Tue, 23 Apr 2019 09:28:35 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:45146 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbfDWN2d (ORCPT ); Tue, 23 Apr 2019 09:28:33 -0400 Received: by mail-lj1-f196.google.com with SMTP id y6so13483316ljd.12 for ; Tue, 23 Apr 2019 06:28:31 -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=TmzrLG0HhMUllGPErHueXstJu/wyUlmgrIkCuicVsiY=; b=pjyiAvWpRnfInL1U8vVm5G28PPwIa7vHVRINhbLFwD7Hh8RLqG1XBvcg6uhiz5Q7I/ oDN/v1CW3tmWtHRBfdLsTUhN3j1Ez8EdsbehRXTSLKgBkdXvWs6FxQ/neadA2MdMxyCv /T86u/ZwKidHvmiwKNAiXKqlT6ADVxSxocN6dT4P477jUUBupKtT35G3+nr8vkHzgvWd +6GveAO2cO7rhe58ZHp0+Kgisl4ilC3MIdSjLoHz7+E1PvM3J4aYUIFnfv5nb5ygA7N5 5dlcgCZuU9fe0qw3ewVCgh0ZKTnuzxJOcl7hkfXbZa6WVywG4g0j32gsnzFs0ERahaVm My7g== 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=TmzrLG0HhMUllGPErHueXstJu/wyUlmgrIkCuicVsiY=; b=MsdsKJISdukJKvRuiYJzftOZ0VTpNXDYIrefBpThtEvnlT+whSFQ6paDxYspvGmL9F 3bAdhm8mYdLR4t7WhrlTI5/kkAVPTOb+FjUzCiUnoZGPod0hXTGWN3xqGu7cpciyRirp /sYsKalr54M8wXlyVOpw7DH7oYj8bjn3yHEJz+KZ5MzO2ce+dRJ3Bh1/Ha0f1bX51lfL aU8OtVR+HshScle/KvjzUTlaEhO4IXm30gAu7IW2F3Yq8eChGIyxFm7LUlmxKFtURrjY XxbfQt/oZypjV98VgDbiadBVJPb4eIMiturnUCzLlBl9Q2cvRV3wH4eHyP16wQJQ7NKg qIGQ== X-Gm-Message-State: APjAAAXNRrsOAB5YyxD3thInNr1oZ1Cy7SZTI8He7nfGa+IfvWJ1bZb7 2WaBG2VsZ7EnMQzD+iY88ksIQQ== X-Google-Smtp-Source: APXvYqxYn5AHIWe8NubgPi748hbhffjSbR78lCUgeNHQmIJgIs0nNxYDkCygfXs7mEYHaYNwQVCsrQ== X-Received: by 2002:a2e:500d:: with SMTP id e13mr13748245ljb.169.1556026110607; Tue, 23 Apr 2019 06:28:30 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y206sm4617107lfc.72.2019.04.23.06.28.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 06:28:29 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, sboyd@kernel.org, nm@ti.com, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net Cc: jcrouse@codeaurora.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v2 2/5] interconnect: Add of_icc_get_by_index() helper function Date: Tue, 23 Apr 2019 16:28:20 +0300 Message-Id: <20190423132823.7915-3-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423132823.7915-1-georgi.djakov@linaro.org> References: <20190423132823.7915-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 X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Georgi Djakov --- drivers/interconnect/core.c | 45 ++++++++++++++++++++++++++++-------- include/linux/interconnect.h | 6 +++++ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/drivers/interconnect/core.c b/drivers/interconnect/core.c index 871eb4bc4efc..a7c3c262c974 100644 --- a/drivers/interconnect/core.c +++ b/drivers/interconnect/core.c @@ -295,9 +295,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 @@ -309,13 +309,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_node *src_node, *dst_node; struct device_node *np = NULL; struct of_phandle_args src_args, dst_args; - int idx = 0; int ret; if (!dev || !dev->of_node) @@ -335,12 +334,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); @@ -383,6 +376,38 @@ struct icc_path *of_icc_get(struct device *dev, const char *name) return path; } + +/** + * 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) +{ + int idx = 0; + + if (!dev || !dev->of_node) + return ERR_PTR(-ENODEV); + + if (name) { + idx = of_property_match_string(dev->of_node, + "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 dc25864755ba..0e430b3b6519 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); @@ -45,6 +46,11 @@ static inline struct icc_path *of_icc_get(struct device *dev, return NULL; } +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 Apr 23 13:28:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 10912971 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19FBA112C for ; Tue, 23 Apr 2019 13:28:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A46E286F2 for ; Tue, 23 Apr 2019 13:28:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F20512873A; Tue, 23 Apr 2019 13:28:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0928A286F2 for ; Tue, 23 Apr 2019 13:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727925AbfDWN2h (ORCPT ); Tue, 23 Apr 2019 09:28:37 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35538 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727954AbfDWN2g (ORCPT ); Tue, 23 Apr 2019 09:28:36 -0400 Received: by mail-lj1-f195.google.com with SMTP id t4so13508466ljc.2 for ; Tue, 23 Apr 2019 06:28:33 -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=QtHDB3QMogv515ITSyvJXMA+IzhZoNxGiv5NT5h1biw=; b=pFONKqXyBmUDG4wQo07YI3Wbdza5aMEyIASoDSFX6o8AcxMLF6619lBuscNbCsqJvB p2JTMAdUlew+S99HAcKB+uoxUm0qYmzo7ESgwwJMLJjrQ33GweVt+eNFpiURepbvGhym 9n9J7H6WkH2EJc4fjiX5IQC6wb3jOLTdCEZCCokb8qol1sQT4/x2RytS/0jzzkNSX+YL B9zXytaOQ2hMXoEeeX1OK39hUhxqBVp8ke0S6ejVkQVka9fRxpw4iYmtnGaRAP3x6Y6v k/Nd4rPgF5A3w8bWt3iRW4SnGnpcL6qpid8/Psn3Qjwd6soR+zOq1XJ3QMf9v0fQdNA4 ptuQ== 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=QtHDB3QMogv515ITSyvJXMA+IzhZoNxGiv5NT5h1biw=; b=SrZR7LeKAHeqNh2IcK7H6PY+L4870jbhGws/DI28cONQOhoVrFmsSHjSQs06kZ1mRD E6vEkcmTeZqUTM4PI8YSyBBNGf3lQKX9TgDubYceSvNpLaNRUfMAbuIAgSXv0LGbt+2/ bCfvYrjRcxQ6UJI5uQA9E+2yajAnCeWlB4ro6Ou5rdePEUngEPHDbbutyGgOc6z7CUrk iJok3+so7LEQRnczGEIK+HP/MI7aJ+LYaqMFG2ogPKz0GIpxKPVICLrhEYTgCOaXYJAX 1MMNYnN+4jcvcz99LaQOdHj/ugbWDy1wVpG4S0ipwLH1eIgZK5r1rpRS8zbe1c18bKqt ez/Q== X-Gm-Message-State: APjAAAW8pgsjAL0pt4WCWQNxHc9xAPyzSxeW7qGlXuFMBXqjLU3NApB3 nJKoseVob5o5psSjmYyimVg5NQ== X-Google-Smtp-Source: APXvYqy0XJIbuwvem78ICkHllbYavZe5S7u7nhzcgk+bOirZg0VOKGzw1i6QGcAoOm1+gDGWVPnU6g== X-Received: by 2002:a2e:9ac3:: with SMTP id p3mr14664445ljj.109.1556026112981; Tue, 23 Apr 2019 06:28:32 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y206sm4617107lfc.72.2019.04.23.06.28.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 06:28:32 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, sboyd@kernel.org, nm@ti.com, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net Cc: jcrouse@codeaurora.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v2 3/5] OPP: Add support for parsing the interconnect bandwidth Date: Tue, 23 Apr 2019 16:28:21 +0300 Message-Id: <20190423132823.7915-4-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423132823.7915-1-georgi.djakov@linaro.org> References: <20190423132823.7915-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 X-Virus-Scanned: ClamAV using ClamSMTP 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. Also add and export the dev_pm_opp_set_paths() and dev_pm_opp_put_paths() helpers, to set (and release) an interconnect paths to a device. The bandwidth of these paths will be updated when the OPPs are switched. Signed-off-by: Georgi Djakov --- drivers/opp/core.c | 87 ++++++++++++++++++++++++++++++++++- drivers/opp/of.c | 102 +++++++++++++++++++++++++++++++++++++++++ drivers/opp/opp.h | 9 ++++ include/linux/pm_opp.h | 14 ++++++ 4 files changed, 210 insertions(+), 2 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0420f7e8ad5b..97ee39ecdebd 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -876,6 +877,8 @@ static struct opp_table *_allocate_opp_table(struct device *dev, int index) ret); } + _of_find_paths(opp_table, dev); + BLOCKING_INIT_NOTIFIER_HEAD(&opp_table->head); INIT_LIST_HEAD(&opp_table->opp_list); kref_init(&opp_table->kref); @@ -1129,11 +1132,12 @@ 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 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; + icc_size = sizeof(*opp->bandwidth) * table->path_count; /* allocate new OPP node and supplies structures */ opp = kzalloc(sizeof(*opp) + supply_size, GFP_KERNEL); @@ -1141,7 +1145,8 @@ struct dev_pm_opp *_opp_allocate(struct opp_table *table) 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 + 1); + opp->supplies = (struct dev_pm_opp_supply *)(opp + icc_size + 1); INIT_LIST_HEAD(&opp->node); return opp; @@ -1637,6 +1642,84 @@ void dev_pm_opp_put_clkname(struct opp_table *opp_table) } EXPORT_SYMBOL_GPL(dev_pm_opp_put_clkname); +/** + * dev_pm_opp_set_paths() - Set interconnect path for a device + * @dev: Device for which interconnect path is being set. + * + * This must be called before any OPPs are initialized for the device. + */ +struct opp_table *dev_pm_opp_set_paths(struct device *dev) +{ + struct opp_table *opp_table; + int ret, i; + + opp_table = dev_pm_opp_get_opp_table(dev); + if (!opp_table) + return ERR_PTR(-ENOMEM); + + /* This should be called before OPPs are initialized */ + if (WARN_ON(!list_empty(&opp_table->opp_list))) { + ret = -EBUSY; + goto err; + } + + /* Another CPU that shares the OPP table has set the path */ + if (opp_table->paths) + return opp_table; + + opp_table->paths = kmalloc_array(opp_table->path_count, + sizeof(*opp_table->paths), GFP_KERNEL); + + /* Find interconnect path(s) for the device */ + for (i = 0; i < opp_table->path_count; 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: Couldn't find path%d: %d\n", + __func__, i, ret); + goto err; + } + } + + return opp_table; + +err: + dev_pm_opp_put_opp_table(opp_table); + + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_set_paths); + +/** + * dev_pm_opp_put_paths() - Release interconnect path resources + * @opp_table: OPP table returned from dev_pm_opp_set_paths(). + */ +void dev_pm_opp_put_paths(struct opp_table *opp_table) +{ + int i; + + if (!opp_table->paths) { + pr_err("%s: Doesn't have paths set\n", __func__); + return; + } + + /* Make sure there are no concurrent readers while updating opp_table */ + WARN_ON(!list_empty(&opp_table->opp_list)); + + for (i = opp_table->path_count - 1; i >= 0; i--) + icc_put(opp_table->paths[i]); + + _free_set_opp_data(opp_table); + + kfree(opp_table->paths); + opp_table->paths = NULL; + opp_table->path_count = 0; + + dev_pm_opp_put_opp_table(opp_table); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_put_paths); + /** * dev_pm_opp_register_set_opp_helper() - Register custom set OPP helper * @dev: Device for which the helper is getting registered. diff --git a/drivers/opp/of.c b/drivers/opp/of.c index c10c782d15aa..00af23280bc6 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -363,6 +364,45 @@ static int _of_opp_alloc_required_opps(struct opp_table *opp_table, return ret; } +int _of_find_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) { + count = of_count_phandle_with_args(np, "interconnects", + "#interconnect-cells"); + if (count % 2) { + dev_err(dev, "%s: Invalid interconnects values\n", + __func__); + ret = -EINVAL; + goto put_of_node; + } + + num_paths = count / 2; + opp_table->paths = kcalloc(num_paths, sizeof(*opp_table->paths), + GFP_KERNEL); + if (!opp_table->paths) { + ret = -ENOMEM; + goto put_of_node; + } + + for (i = 0; i < num_paths; i++) + opp_table->paths[i] = of_icc_get_by_index(dev, i); + + opp_table->path_count = num_paths; + of_node_put(np); + } + + return 0; + +put_of_node: + of_node_put(np); + + return ret; +} + static bool _opp_is_supported(struct device *dev, struct opp_table *opp_table, struct device_node *np) { @@ -539,6 +579,64 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, return ret; } +static int opp_parse_icc_bw(struct dev_pm_opp *opp, struct device *dev, + struct opp_table *opp_table) +{ + struct property *prop = NULL; + u32 *bandwidth; + char name[] = "bandwidth-MBps"; + int count, i, j, ret; + + /* Search for "bandwidth-MBps" */ + prop = of_find_property(opp->np, name, NULL); + + /* Missing property is not a problem */ + if (!prop) { + dev_dbg(dev, "%s: Missing %s property\n", __func__, name); + return 0; + } + + if (!prop->value) { + dev_dbg(dev, "%s: Missing %s value\n", __func__, name); + return -ENODATA; + } + + /* + * Bandwidth consists of average and peak values like: + * bandwidth-MBps = + */ + count = prop->length / sizeof(u32); + if (count % 2) { + dev_err(dev, "%s: Invalid %s values\n", __func__, name); + return -EINVAL; + } + + if (opp_table->path_count != count / 2) { + dev_err(dev, "%s Mismatch between values and paths (%d %d)\n", + __func__, opp_table->path_count, count / 2); + return -EINVAL; + } + + bandwidth = kmalloc_array(count, sizeof(*bandwidth), GFP_KERNEL); + if (!bandwidth) + return -ENOMEM; + + ret = of_property_read_u32_array(opp->np, name, bandwidth, count); + if (ret) { + dev_err(dev, "%s: Error parsing %s: %d\n", __func__, name, ret); + goto free_bandwidth; + } + for (i = 0, j = 0; i < count; i++) { + opp->bandwidth[i].avg = MBps_to_icc(bandwidth[j++]); + opp->bandwidth[i].peak = MBps_to_icc(bandwidth[j++]); + } + +free_bandwidth: + kfree(bandwidth); + + return ret; +} + /** * dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT * entries @@ -635,6 +733,10 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, if (opp_table->is_genpd) new_opp->pstate = pm_genpd_opp_to_performance_state(dev, new_opp); + ret = opp_parse_icc_bw(new_opp, dev, opp_table); + if (ret) + goto free_opp; + ret = _opp_add(dev, new_opp, opp_table, rate_not_available); if (ret) { /* Don't return error for duplicate OPPs */ diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 569b3525aa67..70a537f2dbd3 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -24,6 +24,7 @@ struct clk; struct regulator; +struct icc_path; /* Lock to allow exclusive modification to the device and opp lists */ extern struct mutex opp_table_lock; @@ -62,6 +63,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. @@ -84,6 +86,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; @@ -150,6 +153,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 @@ -194,6 +199,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; @@ -228,12 +235,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_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_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 24c757a32a7b..dabee09a92b8 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -43,6 +43,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 @@ -127,6 +139,8 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, const char * con void dev_pm_opp_put_regulators(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_clkname(struct device *dev, const char * name); void dev_pm_opp_put_clkname(struct opp_table *opp_table); +struct opp_table *dev_pm_opp_set_paths(struct device *dev); +void dev_pm_opp_put_paths(struct opp_table *opp_table); struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev, int (*set_opp)(struct dev_pm_set_opp_data *data)); void dev_pm_opp_unregister_set_opp_helper(struct opp_table *opp_table); struct opp_table *dev_pm_opp_set_genpd_virt_dev(struct device *dev, struct device *virt_dev, int index); From patchwork Tue Apr 23 13:28:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 10912975 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7EFA1390 for ; Tue, 23 Apr 2019 13:28:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8751286F2 for ; Tue, 23 Apr 2019 13:28:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC86A28706; Tue, 23 Apr 2019 13:28:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6284C28715 for ; Tue, 23 Apr 2019 13:28:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727953AbfDWN2i (ORCPT ); Tue, 23 Apr 2019 09:28:38 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36678 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727978AbfDWN2h (ORCPT ); Tue, 23 Apr 2019 09:28:37 -0400 Received: by mail-lj1-f193.google.com with SMTP id l23so2931900lja.3 for ; Tue, 23 Apr 2019 06:28:36 -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=tPf6o+4Fx6BNBg9gjLd55OiV879tfPNqQcVlMqs6y0g=; b=jHmFr0Ji3NPCs6KScyG5QEgqkd/ZNlX5zGr23YkTpGO2to5XJsMw+hLNB1ZuPWG0g8 wiShsf0tLLH/TtyfTemrRboVDLC56NOsDUPkb5xH3oufJ4oNE64DyhfI/BW3RHF2jz7a yuoIcNqZrrcVzG/ulGq+Lx3VilqGfm2VLptYSwEiCbmVqiuXJCeQ8T25URw4xMo1D0gv ErRGrCLMoMJ2qD9B8QPBJh1IBMfijYAGqSAJqWTEyDfDVDr1PL2RnT7EwEhRb5nM89YM DWJ9gWe6C1ZRe5cB+GCy/GJniYisxNZifkud7+fxxQ2ZNwNH/f3s415udFVd9qqjieBC wwig== 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=tPf6o+4Fx6BNBg9gjLd55OiV879tfPNqQcVlMqs6y0g=; b=suzuJR3LqP2NZnO+VvHn29DyCFJBLGDqfGPgT//POi9kR3cOKyGTEm8NwVANGSjYNv 9JnBbwmj2Fsiddo/C3oWumIvuz3YzkOEPLuHxUoPBkOewVCnRph212SC/Hrou1GHJ4UK 1QwFfboMM/i4OUw4LucLZ20lXyYoo0FepHjOCE/dHsJvRxpvZZJYT5cU7Kx3dBcfC1AH IXm38NWjZo6sZDUNq4a5so06X4zvlSx/Drrwx0QPB+vwJOfjpWFkZVCe7UNO1GB9ViLF fOGeNqX6+PxFNDZNtUpgAr6DJQeRXRwHFCa1YLskPxWoO6d6RUyeOuQsRlgofVaBM4Zc Q+ZQ== X-Gm-Message-State: APjAAAUB7HsW5u+zvaJiRNWxNiSgENl2mNywAgXUfPrB9vZSOiRuQW9d zBzMZQH/8lcHZAXjzSwPHGjWig== X-Google-Smtp-Source: APXvYqxJBaGcY+Di1m9z+nyzZSyjRVq/y3HxdVMb8Y8nJx9/QbBtvSZgIZcPmYZ+R+o4V12dtvM85Q== X-Received: by 2002:a2e:998d:: with SMTP id w13mr13886812lji.110.1556026115286; Tue, 23 Apr 2019 06:28:35 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y206sm4617107lfc.72.2019.04.23.06.28.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 06:28:34 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, sboyd@kernel.org, nm@ti.com, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net Cc: jcrouse@codeaurora.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v2 4/5] OPP: Update the bandwidth on OPP frequency changes Date: Tue, 23 Apr 2019 16:28:22 +0300 Message-Id: <20190423132823.7915-5-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423132823.7915-1-georgi.djakov@linaro.org> References: <20190423132823.7915-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 X-Virus-Scanned: ClamAV using ClamSMTP If the OPP bandwidth values are populated, we want to switch also the interconnect bandwidth in addition to frequency and voltage. Signed-off-by: Georgi Djakov --- drivers/opp/core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 97ee39ecdebd..91d1c2abfb3e 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -707,7 +707,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) unsigned long freq, old_freq; struct dev_pm_opp *old_opp, *opp; struct clk *clk; - int ret; + int ret, i; if (unlikely(!target_freq)) { dev_err(dev, "%s: Invalid target frequency %lu\n", __func__, @@ -780,6 +780,13 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) ret = _generic_set_opp_clk_only(dev, clk, freq); } + if (!ret && !IS_ERR_OR_NULL(opp_table->paths)) { + for (i = 0; i < opp_table->path_count; i++) { + icc_set_bw(opp_table->paths[i], opp->bandwidth[i].avg, + opp->bandwidth[i].peak); + } + } + /* Scaling down? Configure required OPPs after frequency */ if (!ret && freq < old_freq) { ret = _set_required_opps(dev, opp_table, opp); From patchwork Tue Apr 23 13:28:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgi Djakov X-Patchwork-Id: 10912981 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DA96112C for ; Tue, 23 Apr 2019 13:28:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F6AE286F2 for ; Tue, 23 Apr 2019 13:28:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 833862873A; Tue, 23 Apr 2019 13:28:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32D68286F2 for ; Tue, 23 Apr 2019 13:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbfDWN2w (ORCPT ); Tue, 23 Apr 2019 09:28:52 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41133 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727978AbfDWN2j (ORCPT ); Tue, 23 Apr 2019 09:28:39 -0400 Received: by mail-lj1-f194.google.com with SMTP id k8so979445lja.8 for ; Tue, 23 Apr 2019 06:28:38 -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=WBZVH8tY60kvdDXDwV8aJHdGVIEg5lBCBmcPhKf9y2Y=; b=mx7tfKFCrLM+my8sDW7dzzb2SBOnGloSVzmUgLj2SrdsqiYsq+Uq1lnU07zY7h6C5e y0YhFrKkNWfdkTfdMdlbNuKmiaMApa4h+ey7j9Jz639toJrjKFCByOrQXzoM/XHNorPX XJxuAJhHm0Tv57dwC1lVcrZvp1gxj1OPAsHwveMyKCONalWR2wAGlI6E1Q94EM+yggSP XsQNCgnxVz1nZZPTFmuMjHl8RLk2dSsx/7CxPZg8ylVSR+MMKw2rAlrD8vOBAYJhThDL taL/1wBYpNLKnmLsVnUxn7DEHk9MjQ3LCh0f9wXjbuB6Jk14ibwh/E24H+FkhD6mc00m s6xw== 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=WBZVH8tY60kvdDXDwV8aJHdGVIEg5lBCBmcPhKf9y2Y=; b=D5jrBTXoA5qKtz0YMp8on8u2xKHaDL8KqLjegC5Qc9RW3ta3VyQu1YzAoh87ICa7DZ 0CRyld+dUcf+sAxlvkurVsy49gTA/gHlonsl3DiUbmmGcrK2OPQKPTUcn/hjOy7xXJXs jn2YSAaXNx/4NPa2rv3y6mnT0hOFshifF3SXHkIhjWuEgtGs7xiHYBVkQp3mWTfTbqOg +8n33HUXRF1IqbHU9vUpKg48PA0FtpjSswIvO11ge6BpG5MzfOWl/yEb5qKzNlziRVeE a/Yxdan8wu7ZI77fsUTXNS0cvZ52v16esrNivLnn27IX3xnkBlctMetWRzvmc22NLBWb XHTg== X-Gm-Message-State: APjAAAWzLKBmrUB69KKLUph1J4L2uk1DaNcTfg+5gs9cp/60Wipti/uh PDbgTYubHDMKpuWlXH5W7Q3RGA== X-Google-Smtp-Source: APXvYqzNAQqhTw6N2yoD4Bz5LuIxZwqCEb1c1WFtTJ4PtefGrEYIIRNvEmZZ8vqvnt1FgOHQdMxjbA== X-Received: by 2002:a2e:1203:: with SMTP id t3mr3028829lje.180.1556026117559; Tue, 23 Apr 2019 06:28:37 -0700 (PDT) Received: from localhost.localdomain ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id y206sm4617107lfc.72.2019.04.23.06.28.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 06:28:36 -0700 (PDT) From: Georgi Djakov To: vireshk@kernel.org, sboyd@kernel.org, nm@ti.com, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net Cc: jcrouse@codeaurora.org, vincent.guittot@linaro.org, bjorn.andersson@linaro.org, amit.kucheria@linaro.org, seansw@qti.qualcomm.com, daidavid1@codeaurora.org, evgreen@chromium.org, sibis@codeaurora.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, georgi.djakov@linaro.org Subject: [PATCH v2 5/5] cpufreq: dt: Add support for interconnect bandwidth scaling Date: Tue, 23 Apr 2019 16:28:23 +0300 Message-Id: <20190423132823.7915-6-georgi.djakov@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423132823.7915-1-georgi.djakov@linaro.org> References: <20190423132823.7915-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 X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Georgi Djakov --- drivers/cpufreq/cpufreq-dt.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index bde28878725b..8a20f4d0243e 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -98,6 +99,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; @@ -124,6 +126,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) @@ -203,10 +218,18 @@ static int cpufreq_init(struct cpufreq_policy *policy) } } + opp_table = dev_pm_opp_set_paths(cpu_dev); + if (IS_ERR(opp_table)) { + ret = PTR_ERR(opp_table); + dev_err(cpu_dev, "Failed to set interconnect path for cpu%d: %d\n", + policy->cpu, ret); + goto out_put_regulator; + } + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) { ret = -ENOMEM; - goto out_put_regulator; + goto out_put_path; } priv->reg_name = name; @@ -288,6 +311,8 @@ static int cpufreq_init(struct cpufreq_policy *policy) if (priv->have_static_opps) dev_pm_opp_of_cpumask_remove_table(policy->cpus); kfree(priv); +out_put_path: + dev_pm_opp_put_paths(opp_table); out_put_regulator: if (name) dev_pm_opp_put_regulators(opp_table);