From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.9 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 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 D92BDC35242 for ; Fri, 24 Jan 2020 12:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98ED1222D9 for ; Fri, 24 Jan 2020 12:32:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="QcqxNJa4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732686AbgAXMcU (ORCPT ); Fri, 24 Jan 2020 07:32:20 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34348 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729774AbgAXMcT (ORCPT ); Fri, 24 Jan 2020 07:32:19 -0500 Received: by mail-wr1-f68.google.com with SMTP id t2so1787964wrr.1 for ; Fri, 24 Jan 2020 04:32:17 -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=2DvfRhHynNvctGDhIqeR+A7ckBUP/GgKqU+ftyJEj8E=; b=QcqxNJa4FJnDj4SpaEVyp4D2B2IPaYqBMGC/maq+JnQRzhU+NEBZ0pf95egBsFNbBL J17y6kLTgygg5I9NbLrTchWHd0fqhQUIxqUYDKH3tm4NdEeydVGoOe7fv3mbbfRtaLmz NARCH2NodNr+ar1IIC+GVuwTKcXknaDWjgZkVjHmgOxdCG7HXKNq0Fz+3QehMXKKwtRy k1NWeE/Y4qW3i1uaq8YwWRJRt1lOFRa6+IP9U6pPUVKOrhsSCB4yK9yrN2PBGGeVSfkI UH829eXz53LcIGiUvvMabQ391A0YnIl2J9FYoUHaU2Af6rq6v632/d9MUsh4RBbon99H b6og== 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=2DvfRhHynNvctGDhIqeR+A7ckBUP/GgKqU+ftyJEj8E=; b=QBcJQXuzXtXyaZHPBhJLyLFbKxOv6ZflNYf0gf4p53hey3RUWeqmdS7f8thMoZ49dc 4QnsprzfrMh0NmhsUPl0qxnsv6k1SHfDg4jOMNLf7nOtdZ8VfgZ+hMReqjktaFtiIX5M +KcjwreddWB2iHVld7GKrs6+VjyPWpza9QaJqf2Mq2EDSVocJyuYdkwrpvg8ELWWzmcq ivp5eglnoekaYo7DjqH0b7wpKqP5xt1Al99PVpgyHIikkSyia3ajSzdrnXlcJ/acjxrL lKXSh4vyIhyYCiDyywRu89j/cOm6gMdwCXBV7gMiBiQsq3hc/H/3MHausaUU9YBtP0Kk 0AjQ== X-Gm-Message-State: APjAAAWpu4b5N1ld6Fv12b/4JHi80/qlOtRA/dqKNZqKifQR+dYUZAmN +25TAIDjoNiT25rW1DENRjAclQ== X-Google-Smtp-Source: APXvYqzDAdDLZuyqLkswFIwJJPxGUAZE5C98kj6jNyQtTG2iqwxJUaeWHUIDU3//WV6i1/A3Ttkyzg== X-Received: by 2002:adf:ef92:: with SMTP id d18mr3961599wro.234.1579869136650; Fri, 24 Jan 2020 04:32:16 -0800 (PST) Received: from [10.44.66.8] ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id n3sm6982315wrs.8.2020.01.24.04.32.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jan 2020 04:32:15 -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> <15795421-db12-8466-bb7e-688e6625cf4a@linaro.org> <0de33b1ae7c52270d11c606ecccc9af5f44d0421.camel@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 etN8uwDjtYsM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6v40gBn00 OOB13qJe9zyKpReWMAhg7BYPBKIm/qSr82aIQc4+FlDX2Ot6T/4tGUDr9MAHaBKFtVyIqXBO xOf0vQEokkUGRKWBE0uA3zFVRfLiT6NUjDQ0vdphTnsdA7h01MliZLQ2lLL2Mt5lsqU+6sup Tfql1omgEpjnFsPsyFebzcKGbdEr6vySGa3Cof+miX06hQXKe99a5+eHNhtZJcMAIO89wZmj 7ayYJIXFqjl/X0KBcCbiAl4vbdBw1bqFnO4zd1lMXKVoa29UHqby4MPbQhjWNVv9kqp8A39+ E9xw890l1xdERkjVKX6IEJu2hf7X3MMl9tOjBK6MvdOUxvh1bNNmXh7OlBL1MpJYY/ydIm3B KEmKjLDvB0pePJkdTw== Message-ID: <58060878-c08d-dc40-7367-ae6e4391245b@linaro.org> Date: Fri, 24 Jan 2020 14:32:14 +0200 MIME-Version: 1.0 In-Reply-To: <0de33b1ae7c52270d11c606ecccc9af5f44d0421.camel@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi Artur, On 1/24/20 13:22, Artur Świgoń wrote: > Hi Georgi, > > On Wed, 2020-01-22 at 19:02 +0200, Georgi Djakov wrote: >> 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? > > Yes, this functions solely as an extension to devfreq, hence the slightly > unusual architecture (one icc_provider/icc_node per devfreq). Ok, thanks for clarifying. > (Compared to a singleton icc_provider, this approach yields less code with > a very simple xlate()). > > With exactly one icc_node for every devfreq device, I think I will actually > reuse the devfreq ID (as seen in the device name, e.g. the "3" in "devfreq3") > for the node ID. The devfreq framework already does the dynamic numbering > thing that I do in this patch using IDR. > Sounds good. >>> 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. > > I think adding: > depends on INTERCONNECT || !INTERCONNECT Yes, exactly. > under ARM_EXYNOS_BUS_DEVFREQ does the trick. > >>> >>> 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) { I have been also thinking that all the code that you add in this patch would fit nicely into a separate interconnect provider driver. Then instead of the above icc_init() you can create a sub-device (platform_device_register_data() maybe?). The separate driver will be handling just the interconnect functionality and could be enabled on top of this devfreq driver. Thanks, Georgi P.S. I think that grouping all the related patches into a single patch-set would make reviewing them easier. Then we can decide about the merge path of each. >>> + 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); >>> >> >>