Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4571445ybl; Wed, 22 Jan 2020 00:12:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxooYGqH6O/TTdBJ+VONsIPRnBdyaTxOVIHrDE7LcW8h/YSNmrAmx6003kRG1ESqzQ47UWy X-Received: by 2002:aca:f20b:: with SMTP id q11mr5793913oih.78.1579680736540; Wed, 22 Jan 2020 00:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579680736; cv=none; d=google.com; s=arc-20160816; b=Gvrsruj+m84hs6bItiYjS71go2ksubdFBrH3v0y8FobGt+eNbUJ3Qli0fMpoImf3NA Po9tuAFJtj3S2VzVmtrBJ+xY4wkU3MmpEUJCN2PEL4amIg8OH7xpGb9o+TiQE9IF3pQw uaWw2r7LTwiXp6Q9rSD9MKlkczSRRXntwL6YT2fu02mfLQ1dffT8OhPUf8HVJWwvMkfq 48yHRGnYJY8kkLO3kxYvtRjDn1xGZwBD1Rp4hv1+0O3eDMZK9k4Wi1y9MDzeY7lst218 0k9YYwz66rGJCqOHltQkNwMK5TIrT6JnYRr2NeASkdm6RzzmodC5oqEHWYyRobSB3/90 i0Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:autocrypt :openpgp:from:references:cc:to:subject:dkim-signature; bh=yzwUgPfTsZjNhbzkAMeFUhcszle/0vrYiw5ZjCc0qF4=; b=PdNNDFAkW8HwSfgfxCQOREVdZv1EAfSWSUAS6cALt9jMPskxnvdukYBkHMGMIZhfbX MLI47UTlSLI8kz3K7d080Hg4pwbP9+CddJHpM8tMnBHDDWpzt6zA+owJgxAOV00G+YC+ 4qf9RcYF1sxo/kSxjNXn4QTfQEhxJvEmScC0VQTW1qyvjxI6mAffJd/4xd/K67SqfLJS i1iy9LWd58saIJzAIgIwB8BgR4f8ugB3GTml8PhZYYIf39w/YwjE61zBPQNkCjjn0DAs ONMnkm6ihR+F8lorGkQdhe3oAi6KJK5fjcvATfL2TOxRkqFIKoe1pBQILEXry28J1+qN cQaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TnzHga9S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g138si21922290oib.190.2020.01.22.00.12.03; Wed, 22 Jan 2020 00:12:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TnzHga9S; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726054AbgAVILF (ORCPT + 99 others); Wed, 22 Jan 2020 03:11:05 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33101 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbgAVILE (ORCPT ); Wed, 22 Jan 2020 03:11:04 -0500 Received: by mail-wm1-f68.google.com with SMTP id d139so3803273wmd.0 for ; Wed, 22 Jan 2020 00:11:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=yzwUgPfTsZjNhbzkAMeFUhcszle/0vrYiw5ZjCc0qF4=; b=TnzHga9S8h9Be3FoO1XWiv2DIzQOGFACQRd/yosgjSomuSRrdsUstes76PRPXV3SXa lPpZVH/VQVCSFumMyVuxJ+sj0AJi6QS3t1SNnynz5KV1aRgUnTiooAID1E5jY+Jr/Nco 6J5N3+JDV6lmdl37FTwvPbcDNXDe5c5ud8XHGmniqTO1JQCteJVUMxSs/fm/0f38AEtH kmEscUWZa169QPhWsZBGusDalxGDNLC9SYLysnov7GYfFnakaP/bXli0ISTfKEtKOscE sxksTJP3Uub69bRrC8BEiwBqcIq6j/AbthaYwg6gh/KIRQP5H4FBXy/HKVALdEw1XYvi 8S0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=yzwUgPfTsZjNhbzkAMeFUhcszle/0vrYiw5ZjCc0qF4=; b=O/u6dFBznm0fYAwFZmsWksr4FI07v337rAt3P5GBO6RL16FX2QCtRlSnu+mozIqiix N2BgD8Xe64uXO+jYc+u94l3qO/3LBlBHoE9FYVC8ShmcugLagUmq/61bOlU7YD1IsXv4 ANHhDRNQ4sJrf13jZWr8NlCGahnQ9wcHBR9Z53JvzsgUiDNZyhSO/QKUQTkYbTOANpir s8saM43TiJH0tWn+J8QMNA3Z8tRE1LubxRwmoWowpQhY+XM18q8K4D0OYkzN88mLqH3K OordJeKKoeL35ercEsHZfghTlbhHcMblD8oSn19Z0HdM7akCys5QYJKfTlR5d7IT1Ud2 YZOA== X-Gm-Message-State: APjAAAV+9oUuyTH9oJ8O6ad5bLlxtcvxReDsy2R/qRbFT2LqlyJHAUo4 rrcoF+CjO7PK69uCv+96KZflOQ== X-Received: by 2002:a7b:ce8b:: with SMTP id q11mr1622019wmj.100.1579680661316; Wed, 22 Jan 2020 00:11:01 -0800 (PST) Received: from [10.44.66.8] ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id o4sm56013442wrw.97.2020.01.22.00.11.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jan 2020 00:11:00 -0800 (PST) Subject: Re: [PATCH v4 2/4] interconnect: qcom: Add OSM L3 interconnect provider support To: Sibi Sankar , robh+dt@kernel.org, evgreen@chromium.org Cc: bjorn.andersson@linaro.org, agross@kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, mark.rutland@arm.com, daidavid1@codeaurora.org, saravanak@google.com, viresh.kumar@linaro.org References: <20200109211215.18930-1-sibis@codeaurora.org> <20200109211215.18930-3-sibis@codeaurora.org> From: Georgi Djakov Openpgp: preference=signencrypt Autocrypt: addr=georgi.djakov@linaro.org; prefer-encrypt=mutual; keydata= mQINBFjTuRcBEACyAOVzghvyN19Sa/Nit4LPBWkICi5W20p6bwiZvdjhtuh50H5q4ktyxJtp 1+s8dMSa/j58hAWhrc2SNL3fttOCo+MM1bQWwe8uMBQJP4swgXf5ZUYkSssQlXxGKqBSbWLB uFHOOBTzaQBaNgsdXo+mQ1h8UCgM0zQOmbs2ort8aHnH2i65oLs5/Xgv/Qivde/FcFtvEFaL 0TZ7odM67u+M32VetH5nBVPESmnEDjRBPw/DOPhFBPXtal53ZFiiRr6Bm1qKVu3dOEYXHHDt nF13gB+vBZ6x5pjl02NUEucSHQiuCc2Aaavo6xnuBc3lnd4z/xk6GLBqFP3P/eJ56eJv4d0B 0LLgQ7c1T3fU4/5NDRRCnyk6HJ5+HSxD4KVuluj0jnXW4CKzFkKaTxOp7jE6ZD/9Sh74DM8v etN8uwDjtYsM07I3Szlh/I+iThxe/4zVtUQsvgXjwuoOOBWWc4m4KKg+W4zm8bSCqrd1DUgL f67WiEZgvN7tPXEzi84zT1PiUOM98dOnmREIamSpKOKFereIrKX2IcnZn8jyycE12zMkk+Sc ASMfXhfywB0tXRNmzsywdxQFcJ6jblPNxscnGMh2VlY2rezmqJdcK4G4Lprkc0jOHotV/6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hQXKe99a5+eHNhtZJcMAIO89wZmj 7ayYJIXFqjl/X0KBcCbiAl4vbdBw1bqFnO4zd1lMXKVoa29UHqby4MPbQhjWNVv9kqp8A39+ E9xw890l1xdERkjVKX6IEJu2hf7X3MMl9tOjBK6MvdOUxvh1bNNmXh7OlBL1MpJYY/ydIm3B KEmKjLDvB0pePJkdTw== Message-ID: <543ac242-236a-ead9-c2fb-4e3b47544c5b@linaro.org> Date: Wed, 22 Jan 2020 10:10:59 +0200 MIME-Version: 1.0 In-Reply-To: <20200109211215.18930-3-sibis@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sibi, Thanks for working on this! On 1/9/20 23:12, Sibi Sankar wrote: > On some Qualcomm SoCs, Operating State Manager (OSM) controls the > resources of scaling L3 caches. Add a driver to handle bandwidth > requests to OSM L3 from CPU on SDM845 SoCs. > > Signed-off-by: Sibi Sankar > --- > drivers/interconnect/qcom/Kconfig | 7 + > drivers/interconnect/qcom/Makefile | 2 + > drivers/interconnect/qcom/osm-l3.c | 267 +++++++++++++++++++++++++++++ > 3 files changed, 276 insertions(+) > create mode 100644 drivers/interconnect/qcom/osm-l3.c > > diff --git a/drivers/interconnect/qcom/Kconfig b/drivers/interconnect/qcom/Kconfig > index a9bbbdf7400f9..b94d28e7bf700 100644 > --- a/drivers/interconnect/qcom/Kconfig > +++ b/drivers/interconnect/qcom/Kconfig > @@ -14,6 +14,13 @@ config INTERCONNECT_QCOM_MSM8974 > This is a driver for the Qualcomm Network-on-Chip on msm8974-based > platforms. > > +config INTERCONNECT_QCOM_OSM_L3 > + tristate "Qualcomm OSM L3 interconnect driver" > + depends on INTERCONNECT_QCOM || COMPILE_TEST > + help > + Say y here to support the Operating State Manager (OSM) interconnect > + driver which controls the scaling of L3 caches on Qualcomm SoCs. > + > config INTERCONNECT_QCOM_QCS404 > tristate "Qualcomm QCS404 interconnect driver" > depends on INTERCONNECT_QCOM > diff --git a/drivers/interconnect/qcom/Makefile b/drivers/interconnect/qcom/Makefile > index 55ec3c5c89dbd..89fecbd1257c7 100644 > --- a/drivers/interconnect/qcom/Makefile > +++ b/drivers/interconnect/qcom/Makefile > @@ -1,5 +1,6 @@ > # SPDX-License-Identifier: GPL-2.0 > > +icc-osm-l3-objs := osm-l3.o > qnoc-msm8974-objs := msm8974.o > qnoc-qcs404-objs := qcs404.o > qnoc-sc7180-objs := sc7180.o > @@ -12,6 +13,7 @@ icc-smd-rpm-objs := smd-rpm.o > obj-$(CONFIG_INTERCONNECT_QCOM_BCM_VOTER) += icc-bcm-voter.o > obj-$(CONFIG_INTERCONNECT_QCOM_MSM8916) += qnoc-msm8916.o > obj-$(CONFIG_INTERCONNECT_QCOM_MSM8974) += qnoc-msm8974.o > +obj-$(CONFIG_INTERCONNECT_QCOM_OSM_L3) += icc-osm-l3.o > obj-$(CONFIG_INTERCONNECT_QCOM_QCS404) += qnoc-qcs404.o > obj-$(CONFIG_INTERCONNECT_QCOM_RPMH) += icc-rpmh.o > obj-$(CONFIG_INTERCONNECT_QCOM_SC7180) += qnoc-sc7180.o > diff --git a/drivers/interconnect/qcom/osm-l3.c b/drivers/interconnect/qcom/osm-l3.c > new file mode 100644 > index 0000000000000..7fde53c70081e > --- /dev/null > +++ b/drivers/interconnect/qcom/osm-l3.c > @@ -0,0 +1,267 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2019, The Linux Foundation. All rights reserved. You will need to update the year. > + * > + */ > + > +#include Please move this below the other linux/ headers. > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include Is this used? > +#include > + > +#define LUT_MAX_ENTRIES 40U > +#define LUT_SRC GENMASK(31, 30) > +#define LUT_L_VAL GENMASK(7, 0) > +#define LUT_ROW_SIZE 32 > +#define CLK_HW_DIV 2 > + > +/* Register offsets */ > +#define REG_ENABLE 0x0 > +#define REG_FREQ_LUT 0x110 > +#define REG_PERF_STATE 0x920 > + > +#define OSM_L3_MAX_LINKS 1 > +#define SDM845_MAX_RSC_NODES 130 This looks fragile. > + > +#define to_qcom_provider(_provider) \ > + container_of(_provider, struct qcom_osm_l3_icc_provider, provider) > + > +enum { > + SDM845_MASTER_OSM_L3_APPS = SDM845_MAX_RSC_NODES + 1, > + SDM845_SLAVE_OSM_L3, > +}; > + > +struct qcom_osm_l3_icc_provider { > + void __iomem *base; > + unsigned int max_state; > + unsigned long lut_tables[LUT_MAX_ENTRIES]; > + struct icc_provider provider; > +}; > + > +/** > + * struct qcom_icc_node - Qualcomm specific interconnect nodes > + * @name: the node name used in debugfs > + * @links: an array of nodes where we can go next while traversing > + * @id: a unique node identifier > + * @num_links: the total number of @links > + * @buswidth: width of the interconnect between a node and the bus > + */ > +struct qcom_icc_node { > + const char *name; > + u16 links[OSM_L3_MAX_LINKS]; > + u16 id; > + u16 num_links; > + u16 buswidth; > +}; > + > +struct qcom_icc_desc { > + struct qcom_icc_node **nodes; > + size_t num_nodes; > +}; > + > +#define DEFINE_QNODE(_name, _id, _buswidth, ...) \ > + static struct qcom_icc_node _name = { \ > + .name = #_name, \ > + .id = _id, \ > + .buswidth = _buswidth, \ > + .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \ > + .links = { __VA_ARGS__ }, \ > + } > + > +DEFINE_QNODE(sdm845_osm_apps_l3, SDM845_MASTER_OSM_L3_APPS, 16, SDM845_SLAVE_OSM_L3); > +DEFINE_QNODE(sdm845_osm_l3, SDM845_SLAVE_OSM_L3, 16); > + > +static struct qcom_icc_node *sdm845_osm_l3_nodes[] = { > + [MASTER_OSM_L3_APPS] = &sdm845_osm_apps_l3, > + [SLAVE_OSM_L3] = &sdm845_osm_l3, > +}; > + > +static struct qcom_icc_desc sdm845_icc_osm_l3 = { > + .nodes = sdm845_osm_l3_nodes, > + .num_nodes = ARRAY_SIZE(sdm845_osm_l3_nodes), > +}; > + > +static int qcom_icc_set(struct icc_node *src, struct icc_node *dst) > +{ > + struct qcom_osm_l3_icc_provider *qp; > + struct icc_provider *provider; > + struct qcom_icc_node *qn; > + struct icc_node *n; > + unsigned int index; > + u32 agg_peak = 0; > + u32 agg_avg = 0; > + u64 rate; > + > + qn = src->data; > + provider = src->provider; > + qp = to_qcom_provider(provider); > + > + list_for_each_entry(n, &provider->nodes, node_list) > + provider->aggregate(n, 0, n->avg_bw, n->peak_bw, > + &agg_avg, &agg_peak); > + > + rate = max(agg_avg, agg_peak); > + rate = icc_units_to_bps(rate); > + do_div(rate, qn->buswidth); > + > + for (index = 0; index < qp->max_state - 1; index++) { > + if (qp->lut_tables[index] >= rate) > + break; > + } > + > + writel_relaxed(index, qp->base + REG_PERF_STATE); > + > + return 0; > +} > + > +static int qcom_osm_l3_remove(struct platform_device *pdev) > +{ > + struct qcom_osm_l3_icc_provider *qp = platform_get_drvdata(pdev); > + > + icc_nodes_remove(&qp->provider); > + return icc_provider_del(&qp->provider); > +} > + > +static int qcom_osm_l3_probe(struct platform_device *pdev) > +{ > + u32 info, src, lval, i, prev_freq = 0, freq; > + static unsigned long hw_rate, xo_rate; > + struct qcom_osm_l3_icc_provider *qp; > + const struct qcom_icc_desc *desc; > + struct icc_onecell_data *data; > + struct icc_provider *provider; > + struct qcom_icc_node **qnodes; > + struct icc_node *node; > + size_t num_nodes; > + struct clk *clk; > + int ret; > + > + clk = clk_get(&pdev->dev, "xo"); > + if (IS_ERR(clk)) > + return PTR_ERR(clk); > + > + xo_rate = clk_get_rate(clk); > + clk_put(clk); > + > + clk = clk_get(&pdev->dev, "alternate"); > + if (IS_ERR(clk)) > + return PTR_ERR(clk); > + > + hw_rate = clk_get_rate(clk) / CLK_HW_DIV; > + clk_put(clk); > + > + qp = devm_kzalloc(&pdev->dev, sizeof(*qp), GFP_KERNEL); > + if (!qp) > + return -ENOMEM; > + > + qp->base = devm_platform_ioremap_resource(pdev, 0); > + if (IS_ERR(qp->base)) > + return PTR_ERR(qp->base); > + > + /* HW should be in enabled state to proceed */ > + if (!(readl_relaxed(qp->base + REG_ENABLE) & 0x1)) { > + dev_err(&pdev->dev, "error hardware not enabled\n"); > + return -ENODEV; > + } > + > + for (i = 0; i < LUT_MAX_ENTRIES; i++) { > + info = readl_relaxed(qp->base + REG_FREQ_LUT + > + i * LUT_ROW_SIZE); > + src = FIELD_GET(LUT_SRC, info); > + lval = FIELD_GET(LUT_L_VAL, info); > + if (src) > + freq = xo_rate * lval; > + else > + freq = hw_rate; > + > + /* Two of the same frequencies signify end of table */ > + if (i > 0 && prev_freq == freq) > + break; > + > + dev_dbg(&pdev->dev, "index=%d freq=%d\n", i, freq); > + > + qp->lut_tables[i] = freq; > + prev_freq = freq; > + } > + qp->max_state = i; > + > + desc = of_device_get_match_data(&pdev->dev); > + if (!desc) > + return -EINVAL; > + > + qnodes = desc->nodes; > + num_nodes = desc->num_nodes; > + > + data = devm_kcalloc(&pdev->dev, num_nodes, sizeof(*node), GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + provider = &qp->provider; > + provider->dev = &pdev->dev; > + provider->set = qcom_icc_set; > + provider->aggregate = icc_std_aggregate; > + provider->xlate = of_icc_xlate_onecell; > + INIT_LIST_HEAD(&provider->nodes); > + provider->data = data; > + > + ret = icc_provider_add(provider); > + if (ret) { > + dev_err(&pdev->dev, "error adding interconnect provider\n"); > + return ret; > + } > + > + for (i = 0; i < num_nodes; i++) { > + size_t j; > + > + node = icc_node_create(qnodes[i]->id); > + if (IS_ERR(node)) { > + ret = PTR_ERR(node); > + goto err; > + } > + > + node->name = qnodes[i]->name; > + node->data = qnodes[i]; > + icc_node_add(node, provider); > + > + dev_dbg(&pdev->dev, "registered node %p %s %d\n", node, > + qnodes[i]->name, node->id); Not sure how useful is this, but maybe it would be more appropriate to move it to the framework instead of duplicating it in all the drivers. Please remove it. > + > + for (j = 0; j < qnodes[i]->num_links; j++) > + icc_link_create(node, qnodes[i]->links[j]); > + > + data->nodes[i] = node; > + } > + data->num_nodes = num_nodes; > + > + platform_set_drvdata(pdev, qp); > + > + return ret; Just return 0. > +err: > + qcom_osm_l3_remove(pdev); I am afraid that this will not work. This function is using platform_get_drvdata(), but the data is set after all the nodes and links are created. > + return ret; > +} > + > +static const struct of_device_id osm_l3_of_match[] = { > + { .compatible = "qcom,sdm845-osm-l3", .data = &sdm845_icc_osm_l3 }, > + { }, The comma is not needed. > +}; > +MODULE_DEVICE_TABLE(of, osm_l3_of_match); > + > +static struct platform_driver osm_l3_driver = { > + .probe = qcom_osm_l3_probe, > + .remove = qcom_osm_l3_remove, > + .driver = { > + .name = "osm-l3", > + .of_match_table = osm_l3_of_match, > + }, > +}; > +module_platform_driver(osm_l3_driver); > + > +MODULE_DESCRIPTION("Qualcomm OSM L3 interconnect driver"); > +MODULE_LICENSE("GPL v2"); > Thanks, Georgi