Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5032661ybl; Wed, 22 Jan 2020 09:03:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzjgcXKc9t47s30mKio/j1uEOjAB0a+YFPVCmaP3WnuVk+5NzfS6NsLjk9u10VTt+ifrtlY X-Received: by 2002:a05:6830:2014:: with SMTP id e20mr7797644otp.272.1579712624742; Wed, 22 Jan 2020 09:03:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579712624; cv=none; d=google.com; s=arc-20160816; b=SLfk7FwWg96FKRfA83pV+cQMcgaOAySEZXHoyP0tTgV0WH8pFjTG+GvUqtBT7sSF30 BiDwI5W/O2rWh9r4hIXV0pVrFDcoRLF7ntRnsBBdrhfuUgVxGyW0n1Kz4GwqfWKFv/k7 /lqBXj80ByY92N5AKmnLtweMKJqTDANStgX/28Rn5XpUlj6Xji0F9gQssTXHPRAvUVnC 8Zy2T24kzhj6B6C9uLSoqGzrlpo5BT/8rPo730Rq/X6Kf4AydMcHYCNW7ApVIh+uqz+2 0aUWjibUOTRhJkWXMxRXXfOplI4v7ECEM4VfjiiXEbaYyJ3DR3r4CmHl4BJOZxdsfndQ aKnw== 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=6yEZAxxxHYV12v4fDlL+top5CchSxDt3hhEnOERCk/E=; b=XRS/FAO5gxUbgHaYiGn6GTUfMTS25sZ+iSJRcVRt4V2N45DBzg0w6LD58TY2EV8Xal Sem9MXarX3gPwPVEX+MjTlEtmJqPELVYRR4PgHA/nFC5yN7rShL2PcapW/JJZksKzwI2 efXREywadPGkGPptXaz2wxBYjKKgfX9yrorxKnwt4uKrDLbYVZ21xq6mj4yWDEMhlESb ubbcnz7mK0DSCD9wMmjtLF3mTwvOFuoL4RhZ6SarXHwO3JK/dhpcGf/gsoGXd8rWWS9u SU3PGI+XXoeoy6HL6It2+NAbR9SZSkgBK4KayzT/KVgqxTWkMMUCO19GXTWB6H8Kn1vt IsgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K4mkXA6R; 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 d188si21211387oib.273.2020.01.22.09.03.26; Wed, 22 Jan 2020 09:03:44 -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=K4mkXA6R; 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 S1728767AbgAVRCH (ORCPT + 99 others); Wed, 22 Jan 2020 12:02:07 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:32924 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726004AbgAVRCG (ORCPT ); Wed, 22 Jan 2020 12:02:06 -0500 Received: by mail-wr1-f66.google.com with SMTP id b6so8154959wrq.0 for ; Wed, 22 Jan 2020 09:02:03 -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=6yEZAxxxHYV12v4fDlL+top5CchSxDt3hhEnOERCk/E=; b=K4mkXA6RgYkzeT0Rv8x5ic+MSLWPsJ7lETAUabyHh3rHjaPGJELBZ9PX1MqEIOcRl2 xgoijdQBfTc2c/mQ02IdBAlbPWmbhx7SFUUATxOrjR31DCwkFfOf7e73siKqTDQTh91L kGXLqXpw9FMfSYgL2xVxXezDir3rCVARbBKhrnz8cJxZozn60+TEBAu5QqIQpZ2PIZVx J0+yi66sRk8Xxe9yLIkTyVJoRY9X3KT+HolvND3rY6E+4+KVnVSON/TsKBQ+HjznXAO8 0epTiXE7u4IGJJmOKQ8J+9gRPCVyCP3BMNd9ZJGwaEuPL4BwqaCDitW/k7xsc0d4+txN hCKQ== 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=6yEZAxxxHYV12v4fDlL+top5CchSxDt3hhEnOERCk/E=; b=c5RNm327yfX1OEpTSXhvVG+tFPEorn67BZbljL3yjt0s1wbUM2a48SLbtFvTJDeLAG ZzBaxNz027G5SrOAGOOJr0EtTwPc4Exs/zjMuj/jTZfGoejyzepeCGX6Vy8BUlA45KL/ ol/yksX9Ykps6JE4AXcnvkmsGEfm3k9WKr2+U2F2BwxMWrBcuZEIdLdF3ltyu/A1NYla GMBo0EPc50YISPESmtOwYRVcaDP2NCJT1uF24AovYfpdq5pd53rjVxm+lJhShrzfSf8L mGMNRM5jRLsMg/6oMsklzhTaNxtPDGPx/mfa7IpomPIizXqPDZ49gk0uvDgt4K716DAF c4LA== X-Gm-Message-State: APjAAAWT73slr9JPLAhwqK2K6ysomc8kC6+QNT+K1+gnsDSnfzAx4ddj EY6RQtAHJZ87h6gfjK5qFUEoPg== X-Received: by 2002:a5d:4602:: with SMTP id t2mr11748574wrq.37.1579712522950; Wed, 22 Jan 2020 09:02:02 -0800 (PST) Received: from [10.44.66.8] ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id x16sm4775064wmk.35.2020.01.22.09.02.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jan 2020 09:02:02 -0800 (PST) Subject: Re: [RFC PATCH v3 5/7] devfreq: exynos-bus: Add interconnect functionality to exynos-bus To: =?UTF-8?B?QXJ0dXIgxZp3aWdvxYQ=?= , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: cw00.choi@samsung.com, myungjoo.ham@samsung.com, inki.dae@samsung.com, sw0312.kim@samsung.com, leonard.crestez@nxp.com, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, krzk@kernel.org References: <20191220115653.6487-1-a.swigon@samsung.com> <20191220115653.6487-6-a.swigon@samsung.com> 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 f67WiEZgvN7tPXEzi84z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BO xOf0vQEokkUGRKWBE0uA3zFVRfLiT6NUjDQ0vdphTnsdA7h01MliZLQ2lLL2Mt5lsqU+6sup Tfql1omgEpjnFsPsyFebzcKGbdEr6vySGa3Cof+miX06hQXKe99a5+eHNhtZJcMAIO89wZmj 7ayYJIXFqjl/X0KBcCbiAl4vbdBw1bqFnO4zd1lMXKVoa29UHqby4MPbQhjWNVv9kqp8A39+ E9xw890l1xdERkjVKX6IEJu2hf7X3MMl9tOjBK6MvdOUxvh1bNNmXh7OlBL1MpJYY/ydIm3B KEmKjLDvB0pePJkdTw== Message-ID: <15795421-db12-8466-bb7e-688e6625cf4a@linaro.org> Date: Wed, 22 Jan 2020 19:02:00 +0200 MIME-Version: 1.0 In-Reply-To: <20191220115653.6487-6-a.swigon@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Artur, On 12/20/19 13:56, Artur Świgoń wrote: > This patch adds interconnect functionality to the exynos-bus devfreq > driver. > > The SoC topology is a graph (or, more specifically, a tree) and its > edges are specified using the 'exynos,interconnect-parent-node' in the > DT. Due to unspecified relative probing order, -EPROBE_DEFER may be > propagated to ensure that the parent is probed before its children. > > Each bus is now an interconnect provider and an interconnect node as well > (cf. Documentation/interconnect/interconnect.rst), i.e. every bus registers > itself as a node. Node IDs are not hardcoded but rather assigned at Just to note that usually the provider consists of multiple nodes and each node represents a single master or slave port on the AXI bus for example. I am not sure whether this represents correctly the Exynos hardware, so it's up to you. > runtime, in probing order (subject to the above-mentioned exception > regarding relative order). This approach allows for using this driver with > various Exynos SoCs. This sounds good. I am wondering whether such dynamic probing would be useful for other platforms too. Then maybe it would make sense to even have a common DT property, but we will see. Is this going to be used only together with devfreq? > Frequencies requested via the interconnect API for a given node are > propagated to devfreq using dev_pm_qos_update_request(). Please note that > it is not an error when CONFIG_INTERCONNECT is 'n', in which case all > interconnect API functions are no-op. How about the case where CONFIG_INTERCONNECT=m. Looks like the build will fail if CONFIG_ARM_EXYNOS_BUS_DEVFREQ=y, so this dependency should be expressed in Kconfig. Thanks, Georgi > > Signed-off-by: Artur Świgoń > --- > drivers/devfreq/exynos-bus.c | 144 +++++++++++++++++++++++++++++++++++ > 1 file changed, 144 insertions(+) > > diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c > index 9fdb188915e8..694a9581dcdb 100644 > --- a/drivers/devfreq/exynos-bus.c > +++ b/drivers/devfreq/exynos-bus.c > @@ -14,14 +14,19 @@ > #include > #include > #include > +#include > +#include > #include > #include > #include > +#include > #include > #include > > #define DEFAULT_SATURATION_RATIO 40 > > +#define kbps_to_khz(x) ((x) / 8) > + > struct exynos_bus { > struct device *dev; > > @@ -35,6 +40,12 @@ struct exynos_bus { > struct opp_table *opp_table; > struct clk *clk; > unsigned int ratio; > + > + /* One provider per bus, one node per provider */ > + struct icc_provider provider; > + struct icc_node *node; > + > + struct dev_pm_qos_request qos_req; > }; > > /* > @@ -205,6 +216,39 @@ static void exynos_bus_passive_exit(struct device *dev) > clk_disable_unprepare(bus->clk); > } > > +static int exynos_bus_icc_set(struct icc_node *src, struct icc_node *dst) > +{ > + struct exynos_bus *src_bus = src->data, *dst_bus = dst->data; > + s32 src_freq = kbps_to_khz(src->avg_bw); > + s32 dst_freq = kbps_to_khz(dst->avg_bw); > + int ret; > + > + ret = dev_pm_qos_update_request(&src_bus->qos_req, src_freq); > + if (ret < 0) { > + dev_err(src_bus->dev, "failed to update PM QoS request"); > + return ret; > + } > + > + ret = dev_pm_qos_update_request(&dst_bus->qos_req, dst_freq); > + if (ret < 0) { > + dev_err(dst_bus->dev, "failed to update PM QoS request"); > + return ret; > + } > + > + return 0; > +} > + > +static struct icc_node *exynos_bus_icc_xlate(struct of_phandle_args *spec, > + void *data) > +{ > + struct exynos_bus *bus = data; > + > + if (spec->np != bus->dev->of_node) > + return ERR_PTR(-EINVAL); > + > + return bus->node; > +} > + > static int exynos_bus_parent_parse_of(struct device_node *np, > struct exynos_bus *bus) > { > @@ -419,6 +463,96 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, > return 0; > } > > +static struct icc_node *exynos_bus_icc_get_parent(struct exynos_bus *bus) > +{ > + struct device_node *np = bus->dev->of_node; > + struct of_phandle_args args; > + int num, ret; > + > + num = of_count_phandle_with_args(np, "exynos,interconnect-parent-node", > + "#interconnect-cells"); > + if (num != 1) > + return NULL; /* parent nodes are optional */ > + > + ret = of_parse_phandle_with_args(np, "exynos,interconnect-parent-node", > + "#interconnect-cells", 0, &args); > + if (ret < 0) > + return ERR_PTR(ret); > + > + of_node_put(args.np); > + > + return of_icc_get_from_provider(&args); > +} > + > +static int exynos_bus_icc_init(struct exynos_bus *bus) > +{ > + static DEFINE_IDA(ida); > + > + struct device *dev = bus->dev; > + struct icc_provider *provider = &bus->provider; > + struct icc_node *node, *parent_node; > + int id, ret; > + > + /* Initialize the interconnect provider */ > + provider->set = exynos_bus_icc_set; > + provider->aggregate = icc_std_aggregate; > + provider->xlate = exynos_bus_icc_xlate; > + provider->dev = dev; > + provider->inter_set = true; > + provider->data = bus; > + > + ret = icc_provider_add(provider); > + if (ret < 0) > + return ret; > + > + ret = id = ida_alloc(&ida, GFP_KERNEL); > + if (ret < 0) > + goto err_id; > + > + node = icc_node_create(id); > + if (IS_ERR(node)) { > + ret = PTR_ERR(node); > + goto err_node; > + } > + > + bus->node = node; > + node->name = dev->of_node->name; > + node->data = bus; > + icc_node_add(node, provider); > + > + parent_node = exynos_bus_icc_get_parent(bus); > + if (IS_ERR(parent_node)) { > + ret = PTR_ERR(parent_node); > + goto err_parent; > + } > + > + if (parent_node) { > + ret = icc_link_create(node, parent_node->id); > + if (ret < 0) > + goto err_parent; > + } > + > + ret = dev_pm_qos_add_request(bus->devfreq->dev.parent, &bus->qos_req, > + DEV_PM_QOS_MIN_FREQUENCY, 0); > + if (ret < 0) > + goto err_request; > + > + return 0; > + > +err_request: > + if (parent_node) > + icc_link_destroy(node, parent_node); > +err_parent: > + icc_node_del(node); > + icc_node_destroy(id); > +err_node: > + ida_free(&ida, id); > +err_id: > + icc_provider_del(provider); > + > + return ret; > +} > + > static int exynos_bus_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > @@ -468,6 +602,16 @@ static int exynos_bus_probe(struct platform_device *pdev) > if (ret < 0) > goto err; > > + /* > + * Initialize interconnect provider. A return value of -ENOTSUPP means > + * that CONFIG_INTERCONNECT is disabled. > + */ > + ret = exynos_bus_icc_init(bus); > + if (ret < 0 && ret != -ENOTSUPP) { > + dev_err(dev, "failed to initialize the interconnect provider"); > + goto err; > + } > + > max_state = bus->devfreq->profile->max_state; > min_freq = (bus->devfreq->profile->freq_table[0] / 1000); > max_freq = (bus->devfreq->profile->freq_table[max_state - 1] / 1000); >