Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp179104ybl; Mon, 2 Dec 2019 09:12:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxj//V9GxKC38TcZXf1BYOTZa6OHXWV0ghqHh9mVivOlzQLnbB0dUtV0+qad+m0o/sbNeaF X-Received: by 2002:ac2:5323:: with SMTP id f3mr43545lfh.89.1575306747104; Mon, 02 Dec 2019 09:12:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575306747; cv=none; d=google.com; s=arc-20160816; b=fJ1s49fN4tZfL70vNm1bkSV16tJG1FV1MlRKWZUuh2gpk87yFguLFcrr/PxI5LKzTX NXzNrTJTsdJZSwc6CI0zsCTI8QkRzRWpXyao/fPchmwjgL2/J1AumOIJV7JP59q+ZNWI B3y9DD615bUZdCcfumf0wk47YBDA889ENSPs1H2YuEi/OJpxKOIaiXxwrxMJ2k8XwcOg 5uSOmTVFMeCFd6cq6Uz26iswFEmymeRP3z7X0UK2eK3FshkseFukOJLGemfpzp1+Uc85 vf5ryXggrmytSVQO/Hfu+A5aLVM4vrwazWTx6OOdFoLNOW63lpQgJSzKZnEHM6d/2TDI GXTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:mime-version:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature:dkim-filter; bh=st3c9KPKtPtiDw5raSov1qy5fVYNC0lFSVzRu5QYeQw=; b=FDivEhqECQ9PVqPytcrVQfCJrkjOSU/pZtdJEoCBMWVNAWWnH4mp+4Fea1oRkt/mHQ A5zvK+UgQHp2ejPGGFt+RMSoVBtErHhgrE70/BYJk7DzVO96VJFT5E3cj47eFIxj8qPn PC0E0iZmizqFh41bS2z8AoWwdLeusFL0fIwaUnGR/7rMUnWxXzt61qpQdQZPBXQBxGCg N89mgGlGTuUYryrxK/1NVqyLF37s/Ye1JASCgm76hNMdK8h7Z8IjafrPMr9PD9Rmv0oA bBvMr2UN0gWPOvj37lteBeP0wJFTAT5YS/b+PrgMpdSKhA0y/24CFJW/M1WN/+T44B6I ZiJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=mGd8TmKg; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si6388215lfh.46.2019.12.02.09.11.51; Mon, 02 Dec 2019 09:12:27 -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=@samsung.com header.s=mail20170921 header.b=mGd8TmKg; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727817AbfLBRFW (ORCPT + 99 others); Mon, 2 Dec 2019 12:05:22 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:37048 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727810AbfLBRFV (ORCPT ); Mon, 2 Dec 2019 12:05:21 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20191202170518euoutp02b7d102c86a688bf05d6a7e55feccdacd~cnMANrBxt0894508945euoutp02F for ; Mon, 2 Dec 2019 17:05:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20191202170518euoutp02b7d102c86a688bf05d6a7e55feccdacd~cnMANrBxt0894508945euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1575306318; bh=st3c9KPKtPtiDw5raSov1qy5fVYNC0lFSVzRu5QYeQw=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=mGd8TmKgUfIkFckj4SZrMmPAUbBhpsn4iq0b3y3wx40p+Xac8B1mVzol8wrrQtt9s MQgici/jsdSZAsbDI0SbKHayrm97/tCQp6FhPiMwnRL/NVgBvJ7E5soaoI6ptmzGjS 1DMXh2nLlbaWa+yMsD/ZKUfNPR0l8dt0g5BlYSnA= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20191202170517eucas1p2bd2c406bcdac2cc0142d77454aaa4ac8~cnL-zLzZs2657226572eucas1p2D; Mon, 2 Dec 2019 17:05:17 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 5E.63.60698.D4445ED5; Mon, 2 Dec 2019 17:05:17 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20191202170517eucas1p1d9298087e553dbc9d9986dc7ec41d669~cnL-fddXR2466624666eucas1p1L; Mon, 2 Dec 2019 17:05:17 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20191202170517eusmtrp1624e4c831d116920e8ed941cf479123f~cnL-er8Lk2436324363eusmtrp1W; Mon, 2 Dec 2019 17:05:17 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-c1-5de5444d1904 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 67.B7.08375.D4445ED5; Mon, 2 Dec 2019 17:05:17 +0000 (GMT) Received: from AMDC3555 (unknown [106.120.51.67]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20191202170516eusmtip1dab1e87cd2d1bc05270ebbc122ad427f~cnL_vWgkg2058220582eusmtip1e; Mon, 2 Dec 2019 17:05:16 +0000 (GMT) Message-ID: <9b3b21d3e4678946724531c58ad7f9c7a3993a95.camel@samsung.com> Subject: Re: [RFC PATCH v2 09/11] devfreq: exynos-bus: Add interconnect functionality to exynos-bus From: Artur =?UTF-8?Q?=C5=9Awigo=C5=84?= To: Chanwoo Choi , 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: myungjoo.ham@samsung.com, inki.dae@samsung.com, sw0312.kim@samsung.com, georgi.djakov@linaro.org, leonard.crestez@nxp.com, m.szyprowski@samsung.com, b.zolnierkie@samsung.com, krzk@kernel.org Date: Mon, 02 Dec 2019 18:05:16 +0100 In-Reply-To: X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTYRjG+3YuO46mxyn5YpI0KFIqrSQPFc3A6lR0769CauXRRXMbO2pX aGpWswvLiKkZWkqZIdpaSyUNdTnJ5TLLvKaUFllqtTLsojmPYf893/s9v+d5P/goTOYkAqmD mkROr1Gq5aQEt9WPNi3aHN0fE95+O4K5m1VKMK++vSeYPHsTwbz4Pkwy5ioLyWT2mHDG5SoT M0XdXwjG8raVYFoqc0nGfcGOmCxXtYgpsXeLmc6UIpLJuvyBjPJhLcVGku1qfUiyPeccIvZe 4Un27lC5iL1oLUas2zJnm3i3ZFUspz6YzOnDVu+TqMZHunBd37ojI+M1uAHlR2YgLwroCEi/ ko1nIAklo4sQuCoMmHD4hqCvw0Z6XDLajaC9ff0/wmS8RAqmWwieFaZPEe8QvLE4xRmIoqQ0 C7/c4R7Aj+Ygt+QB5tEkrYCnnSMij9+fHppoePR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H4u2p PhaIxYISf3cIQ5TISzRvnc08gVFwFpKOWQhVs5BULWBkXsUoklpanJueW2yoV5yYW1yal66X nJ+7iREYpduO/dy8g/HSxuBDjAIcjEo8vBm/nsQKsSaWFVfmHmKU4GBWEuHdJvE0Vog3JbGy KrUoP76oNCe1+BCjKdA7E5mlRJPzgQkkryTe0NTQ3MLS0NzY3NjMQkmct0PgYIyQQHpiSWp2 ampBahFMHxMHp1QD4xwzzmRWFu2nVWu/Gh1cKP3HKfr4nLcPGmINrbe1OsZEsDBu9yl/teeS 4oqzRjGB+QoHd7J/27eF7+oNxoh1+ksvt6Vx/JX+usJGOrNk1sR4N4tpG5ZGc1+6lfrQrzNt x+Xvj2wdu1dtbepIzN74l+uz2pxbjjVPOsX1Tl03Sr0ScHf1e5P2w0osxRmJhlrMRcWJALqT cq7oAgAA X-CMS-MailID: 20191202170517eucas1p1d9298087e553dbc9d9986dc7ec41d669 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190919142329eucas1p2e53992eab9ec6b404f716f955b3c228e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190919142329eucas1p2e53992eab9ec6b404f716f955b3c228e References: <20190919142236.4071-1-a.swigon@samsung.com> <20190919142236.4071-10-a.swigon@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chanwoo, On Wed, 2019-09-25 at 16:03 +0900, Chanwoo Choi wrote: > Hi, > > I need the time to dig the ICC framework > to understand them detailed. After that, I'll review this. Any updates on this topic? Regardless of the purpose of this RFC, I think patches 01-04 are still beneficial to devfreq. I can rebase and post them as a separate series if you wish. > Basically, I agree this approach. But, I'm wondering > the existing binding method between 'bus_leftbus' and 'bus_dmc'. > From before, I thought that devfreq framework need to > enhance the binding method between parent devfreq device > and passive devfreq device instead of 'devfreq' property. > > On this patch, use the same binding way between > 'bus_leftbus' and 'bus_dmc' with 'parent' property > as following: > > +++ b/arch/arm/boot/dts/exynos4412-odroid-common.dtsi > @@ -106,6 +106,7 @@ > &bus_leftbus { > devfreq-events = <&ppmu_leftbus_3>, <&ppmu_rightbus_3>; > vdd-supply = <&buck3_reg>; > + parent = <&bus_dmc>; > status = "okay"; > }; > > I'm not sure about continuing to use this method for new feature. > If possible, hope to replace the existing binding style > with new method like of_graph. Actually, I don't know the correct method. > > > On 19. 9. 19. 오후 11:22, Artur Świgoń wrote: > > From: Artur Świgoń > > > > This patch adds interconnect functionality to the exynos-bus devfreq > > driver. > > > > The SoC topology is a graph (or, more specifically, a tree) and most of > > its edges are taken from the devfreq parent-child hierarchy (cf. > > Documentation/devicetree/bindings/devfreq/exynos-bus.txt). Due to > > unspecified relative probing order, -EPROBE_DEFER may be propagated to > > guarantee that a child is probed before its parent. > > > > 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 > > runtime, in probing order (subject to the above-mentioned exception > > regarding relative order). This approach allows for using this driver with > > various Exynos SoCs. > > > > 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. > > > > Signed-off-by: Artur Świgoń > > --- > > drivers/devfreq/exynos-bus.c | 153 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 153 insertions(+) > > > > diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c > > index 8d44810cac69..e0232202720d 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 icc_units_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; > > }; > > > > /* > > @@ -59,6 +70,13 @@ exynos_bus_ops_edev(enable_edev); > > exynos_bus_ops_edev(disable_edev); > > exynos_bus_ops_edev(set_event); > > > > +static int exynos_bus_next_id(void) > > +{ > > + static DEFINE_IDA(exynos_bus_icc_ida); > > + > > + return ida_alloc(&exynos_bus_icc_ida, GFP_KERNEL); > > +} > > + > > static int exynos_bus_get_event(struct exynos_bus *bus, > > struct devfreq_event_data *edata) > > { > > @@ -171,6 +189,38 @@ 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 = icc_units_to_khz(src->avg_bw); > > + s32 dst_freq = icc_units_to_khz(dst->avg_bw); > > + > > + dev_pm_qos_update_request(&src_bus->qos_req, src_freq); > > + dev_pm_qos_update_request(&dst_bus->qos_req, dst_freq); > > + > > + return 0; > > +} > > + > > +static int exynos_bus_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw, > > + u32 peak_bw, u32 *agg_avg, u32 *agg_peak) > > +{ > > + *agg_avg += avg_bw; > > + *agg_peak = max(*agg_peak, peak_bw); > > + > > + 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) > > { > > @@ -366,6 +416,101 @@ static int exynos_bus_profile_init_passive(struct exynos_bus *bus, > > return 0; > > } > > > > +static int exynos_bus_icc_connect(struct exynos_bus *bus) > > +{ > > + struct device_node *np = bus->dev->of_node; > > + struct devfreq *parent_devfreq; > > + struct icc_node *parent_node = NULL; > > + struct of_phandle_args args; > > + int ret = 0; > > + > > + parent_devfreq = devfreq_get_devfreq_by_phandle(bus->dev, 0); > > + if (!IS_ERR(parent_devfreq)) { > > + struct exynos_bus *parent_bus; > > + > > + parent_bus = dev_get_drvdata(parent_devfreq->dev.parent); > > + parent_node = parent_bus->node; > > + } else { > > + /* Look for parent in DT */ > > + int num = of_count_phandle_with_args(np, "parent", > > + "#interconnect-cells"); > > + if (num != 1) > > + goto out; /* 'parent' is optional */ > > + > > + ret = of_parse_phandle_with_args(np, "parent", > > + "#interconnect-cells", > > + 0, &args); > > + if (ret < 0) > > + goto out; > > + > > + of_node_put(args.np); > > + > > + parent_node = of_icc_get_from_provider(&args); > > + if (IS_ERR(parent_node)) { > > + /* May be -EPROBE_DEFER */ > > + ret = PTR_ERR(parent_node); > > + goto out; > > + } > > + } > > > > > + > > + ret = icc_link_create(bus->node, parent_node->id); > > + > > +out: > > + return ret; > > +} > > + > > +static int exynos_bus_icc_init(struct exynos_bus *bus) > > +{ > > + struct device *dev = bus->dev; > > + struct icc_provider *provider = &bus->provider; > > + struct icc_node *node; > > + int id, ret; > > + > > + /* Initialize the interconnect provider */ > > + provider->set = exynos_bus_icc_set; > > + provider->aggregate = exynos_bus_icc_aggregate; > > + provider->xlate = exynos_bus_icc_xlate; > > + provider->dev = dev; > > + provider->data = bus; > > + > > + ret = icc_provider_add(provider); > > + if (ret < 0) > > + goto out; > > + > > + ret = id = exynos_bus_next_id(); > > + if (ret < 0) > > + goto err_node; > > + > > + 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); > > + > > + ret = exynos_bus_icc_connect(bus); > > + if (ret < 0) > > + goto err_connect; > > + > > + ret = dev_pm_qos_add_request(bus->devfreq->dev.parent, &bus->qos_req, > > + DEV_PM_QOS_MIN_FREQUENCY, 0); > > + > > +out: > > + return ret; > > + > > +err_connect: > > + icc_node_del(node); > > + icc_node_destroy(id); > > +err_node: > > + icc_provider_del(provider); > > + > > + return ret; > > +} > > + > > static int exynos_bus_probe(struct platform_device *pdev) > > { > > struct device *dev = &pdev->dev; > > @@ -415,6 +560,14 @@ 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) > > + 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); > > > Best regards, -- Artur Świgoń Samsung R&D Institute Poland Samsung Electronics