Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp799744ybt; Wed, 1 Jul 2020 10:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjGBMEDunwZOSt4mWQGCrHzRJgjrihK1iekGL3vhiQSYb3SvQ9veFtjqfOJck2J62jhOtV X-Received: by 2002:a17:906:5909:: with SMTP id h9mr20955635ejq.501.1593623731838; Wed, 01 Jul 2020 10:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593623731; cv=none; d=google.com; s=arc-20160816; b=IhIilT+bNb9jUcZUHnt3d5uS29SUueIM8gEWiNsajOsO4N+zxMOJevT4fJQ3mJlGbd hCQpI40V5R3MutX6ezTQfRgJR6fgozodILWWtRvETlx0nHbOq3x4zLt5fWUIvN2G05nu 4lzpE2HbbW5RPUwrphvxoFS+EZBcu8yxVROHu+yFym7BX+ITjVsZVanz+3oww1SqV8JE UzoT795kV5unf4KTPxzkCpDkc9ddM6enf/TmnGkSY340DUNHyaVZ1hVAurLvLobA3N5n 8SKfvhInRC6GV6+4w+GDDXkEjaYWdwvIm4ic8JiWFP3V5LMDN+/drUihPUGbNbgjHaAc Y10g== 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 :from:references:cc:to:subject:dkim-signature; bh=TRT2eGY8Zk/CLkX+7ZsdwVBPTCAQcwVx/IkeDBQOzgI=; b=GHNqgtL2DYLzOjnKjavKCKGrgjt3H81ORgR7l3ZZRwJ2A5wMr7J2iaZ24rMJ8uOya+ lugy4UFYa0U/w/Fi+J0phTw3djfgYqlXOubxGTjiAhM2SZ8zNCnIRwSqTQgSouJCrSgP I0Mt6G4tO3Kk6+fAF/gfuLVwcf3YEKP5Pow+0sqgDXy2QxUZuDc/b4kDpkrB6FquoPdT LgmZWByC/K21dvpauqP26v9Ymgjz0YozIkeu026yYonhCN/tBHnWEaxrosdfVeNorkWg vhyUUTbWD6pXARomtH/AmQhVmdywr1CKdCmxJN68JIKx7iZwi7ewswYazDrHQxfnvUVO Uu3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bCDrYnK3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id ds10si5329579ejc.183.2020.07.01.10.15.07; Wed, 01 Jul 2020 10:15:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bCDrYnK3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1731122AbgGARM1 (ORCPT + 99 others); Wed, 1 Jul 2020 13:12:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728385AbgGARM0 (ORCPT ); Wed, 1 Jul 2020 13:12:26 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 539B0C08C5DB for ; Wed, 1 Jul 2020 10:12:26 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id a6so24896231wrm.4 for ; Wed, 01 Jul 2020 10:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:autocrypt:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TRT2eGY8Zk/CLkX+7ZsdwVBPTCAQcwVx/IkeDBQOzgI=; b=bCDrYnK3vveQkkUILpaZmRCO2PcFzRg5W/A5ohrU+isHgm/4xHLrkjtULuqa3cHMoA 3UJ3E4PmLHA4KaQ8UK2UqTpbngLq3Rq6p98V1i8JCWi3m7Eh4rrHPy4uRST4Nw/wq5to 98ex9A4ChixgpRJsv9WSW2EGCJ3FOBLabYq3fFM5bgPy19TCzF1eqxHeOGWhc/hMQM8l 4UDx6ChIsT3gav16Olva68FypMJOmDEpwIZKdvq3h8GTXg5lUKrmpD3cU1B2bWsrXOG5 fkONXPsZlAQkImm4fjfnn6nEOhwj7ZR+7D8SwaHE8WGQHSmEDI0kyur0DPa6gltnPoDy /Z0g== 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:autocrypt :message-id:date:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TRT2eGY8Zk/CLkX+7ZsdwVBPTCAQcwVx/IkeDBQOzgI=; b=e3DsT2EtxqDkf924oUnxi4W8w0k7LxqRnjSf662FuL7rk+jL9f9CdIWktC/E0UbCfs rX75fGtG8YtCuePYtntkMKlyl3mjtaIKTev3mf+AvEoORpmrkNxFGdUdhTD8p0CEUway Tp22A90vfaFI8yx/Cw6zryFuHqvLs0Mo3X734kBtcA69X15R7li+XhVAAU1/5b76RzK1 ibDcmZbn3ekINxoACCb9rRWCxXkS/NbKutWg34Rt9Rb+Sq1ZuWPCf8YIZvFu/wHSHgdw 0/QuVed/xj/r/jKKBw8YHuGVP/tmfCxWVaQDibspRxK8AOsD1mU3ijEYoXjN6os8lTMN cxmg== X-Gm-Message-State: AOAM533PGwuZpgh7AJmWQDyw8RSMktumTCGzmBAhst0RWXt9vDzCVIRl znydmosCVv92BhPozd4gL/8Gbg== X-Received: by 2002:a5d:4986:: with SMTP id r6mr26610285wrq.424.1593623544836; Wed, 01 Jul 2020 10:12:24 -0700 (PDT) Received: from [10.44.66.8] ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id w17sm8768090wra.42.2020.07.01.10.12.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jul 2020 10:12:24 -0700 (PDT) Subject: Re: [PATCH v4 28/37] memory: tegra: Register as interconnect provider To: Dmitry Osipenko Cc: Thierry Reding , Jonathan Hunter , Rob Herring , Michael Turquette , Stephen Boyd , Peter De Schrijver , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Mikko Perttunen , =?UTF-8?B?QXJ0dXIgxZp3aWdvxYQ=?= , linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org References: <20200609131404.17523-1-digetx@gmail.com> <20200609131404.17523-29-digetx@gmail.com> From: Georgi Djakov Autocrypt: addr=georgi.djakov@linaro.org; prefer-encrypt=mutual; keydata= xsFNBFjTuRcBEACyAOVzghvyN19Sa/Nit4LPBWkICi5W20p6bwiZvdjhtuh50H5q4ktyxJtp 1+s8dMSa/j58hAWhrc2SNL3fttOCo+MM1bQWwe8uMBQJP4swgXf5ZUYkSssQlXxGKqBSbWLB uFHOOBTzaQBaNgsdXo+mQ1h8UCgM0zQOmbs2ort8aHnH2i65oLs5/Xgv/Qivde/FcFtvEFaL 0TZ7odM67u+M32VetH5nBVPESmnEDjRBPw/DOPhFBPXtal53ZFiiRr6Bm1qKVu3dOEYXHHDt nF13gB+vBZ6x5pjl02NUEucSHQiuCc2Aaavo6xnuBc3lnd4z/xk6GLBqFP3P/eJ56eJv4d0B 0LLgQ7c1T3fU4/5NDRRCnyk6HJ5+HSxD4KVuluj0jnXW4CKzFkKaTxOp7jE6ZD/9Sh74DM8v etN8uwDjtYsM07I3Szlh/I+iThxe/4zVtUQsvgXjwuoOOBWWc4m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82aIQc4+FlDX2Ot6T/4tGUDr9MAHaBKFtVyIqXBO xOf0vQEokkUGRKWBE0uA3zFVRfLiT6NUjDQ0vdphTnsdA7h01MliZLQ2lLL2Mt5lsqU+6sup Tfql1omgEpjnFsPsyFebzcKGbdEr6vySGa3Cof+miX06hQXKe99a5+eHNhtZJcMAIO89wZmj 7ayYJIXFqjl/X0KBcCbiAl4vbdBw1bqFnO4zd1lMXKVoa29UHqby4MPbQhjWNVv9kqp8A39+ E9xw890l1xdERkjVKX6IEJu2hf7X3MMl9tOjBK6MvdOUxvh1bNNmXh7OlBL1MpJYY/ydIm3B KEmKjLDvB0pePJkdTw== Message-ID: Date: Wed, 1 Jul 2020 20:12:22 +0300 MIME-Version: 1.0 In-Reply-To: <20200609131404.17523-29-digetx@gmail.com> 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 Dmitry, Thank you for updating the patches! On 6/9/20 16:13, Dmitry Osipenko wrote: > Now memory controller is a memory interconnection provider. This allows us > to use interconnect API in order to change memory configuration. > > Signed-off-by: Dmitry Osipenko > --- > drivers/memory/tegra/Kconfig | 1 + > drivers/memory/tegra/mc.c | 114 +++++++++++++++++++++++++++++++++++ > drivers/memory/tegra/mc.h | 8 +++ > include/soc/tegra/mc.h | 3 + > 4 files changed, 126 insertions(+) > > diff --git a/drivers/memory/tegra/Kconfig b/drivers/memory/tegra/Kconfig > index 5bf75b316a2f..7055fdef2c32 100644 > --- a/drivers/memory/tegra/Kconfig > +++ b/drivers/memory/tegra/Kconfig > @@ -3,6 +3,7 @@ config TEGRA_MC > bool "NVIDIA Tegra Memory Controller support" > default y > depends on ARCH_TEGRA > + select INTERCONNECT > help > This driver supports the Memory Controller (MC) hardware found on > NVIDIA Tegra SoCs. > diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c > index 772aa021b5f6..7ef7ac9e103e 100644 > --- a/drivers/memory/tegra/mc.c > +++ b/drivers/memory/tegra/mc.c > @@ -594,6 +594,118 @@ static __maybe_unused irqreturn_t tegra20_mc_irq(int irq, void *data) > return IRQ_HANDLED; > } > > +static int tegra_mc_icc_set(struct icc_node *src, struct icc_node *dst) > +{ > + return 0; > +} > + > +static int tegra_mc_icc_aggregate(struct icc_node *node, > + u32 tag, u32 avg_bw, u32 peak_bw, > + u32 *agg_avg, u32 *agg_peak) > +{ > + *agg_avg = min((u64)avg_bw + (*agg_avg), (u64)U32_MAX); > + *agg_peak = max(*agg_peak, peak_bw); > + > + return 0; > +} > + > +/* > + * Memory Controller (MC) has few Memory Clients that are issuing memory > + * bandwidth allocation requests to the MC interconnect provider. The MC > + * provider aggregates the requests and then sends the aggregated request > + * up to the External Memory Controller (EMC) interconnect provider which > + * re-configures hardware interface to External Memory (EMEM) in accordance > + * to the required bandwidth. Each MC interconnect node represents an > + * individual Memory Client. > + * > + * Memory interconnect topology: > + * > + * +----+ > + * +--------+ | | > + * | TEXSRD +--->+ | > + * +--------+ | | > + * | | +-----+ +------+ > + * ... | MC +--->+ EMC +--->+ EMEM | > + * | | +-----+ +------+ > + * +--------+ | | > + * | DISP.. +--->+ | > + * +--------+ | | > + * +----+ > + */ > +static int tegra_mc_interconnect_setup(struct tegra_mc *mc) > +{ > + struct icc_onecell_data *data; > + struct icc_node *node; > + unsigned int num_nodes; > + unsigned int i; > + int err; > + > + /* older device-trees don't have interconnect properties */ > + if (!of_find_property(mc->dev->of_node, "#interconnect-cells", NULL)) > + return 0; > + > + num_nodes = mc->soc->num_clients; > + > + data = devm_kzalloc(mc->dev, struct_size(data, nodes, num_nodes), > + GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + mc->provider.dev = mc->dev; > + mc->provider.set = tegra_mc_icc_set; Hmm, maybe the core should not require a set() implementation and we can just make it optional instead. Then the dummy function would not be needed. > + mc->provider.data = data; > + mc->provider.xlate = of_icc_xlate_onecell; > + mc->provider.aggregate = tegra_mc_icc_aggregate; > + > + err = icc_provider_add(&mc->provider); > + if (err) > + goto err_msg; Nit: I am planning to re-organize some of the existing drivers to call icc_provider_add() after the topology is populated. Could you please move this after the nodes are created and linked. > + > + /* create Memory Controller node */ > + node = icc_node_create(TEGRA_ICC_MC); > + err = PTR_ERR_OR_ZERO(node); > + if (err) > + goto del_provider; > + > + node->name = "Memory Controller"; > + icc_node_add(node, &mc->provider); > + > + /* link Memory Controller to External Memory Controller */ > + err = icc_link_create(node, TEGRA_ICC_EMC); > + if (err) > + goto remove_nodes; > + > + for (i = 0; i < num_nodes; i++) { > + /* create MC client node */ > + node = icc_node_create(mc->soc->clients[i].id); > + err = PTR_ERR_OR_ZERO(node); > + if (err) > + goto remove_nodes; > + > + node->name = mc->soc->clients[i].name; > + icc_node_add(node, &mc->provider); > + > + /* link Memory Client to Memory Controller */ > + err = icc_link_create(node, TEGRA_ICC_MC); > + if (err) > + goto remove_nodes; > + > + data->nodes[i] = node; > + } > + data->num_nodes = num_nodes; > + > + return 0; > + > +remove_nodes: > + icc_nodes_remove(&mc->provider); > +del_provider: > + icc_provider_del(&mc->provider); > +err_msg: > + dev_err(mc->dev, "failed to initialize ICC: %d\n", err); > + > + return err; > +} > + > static int tegra_mc_probe(struct platform_device *pdev) > { > struct resource *res; > @@ -702,6 +814,8 @@ static int tegra_mc_probe(struct platform_device *pdev) > } > } > > + tegra_mc_interconnect_setup(mc); > + > return 0; > } > > diff --git a/drivers/memory/tegra/mc.h b/drivers/memory/tegra/mc.h > index afa3ba45c9e6..abeb6a2cc36a 100644 > --- a/drivers/memory/tegra/mc.h > +++ b/drivers/memory/tegra/mc.h > @@ -115,4 +115,12 @@ extern const struct tegra_mc_soc tegra132_mc_soc; > extern const struct tegra_mc_soc tegra210_mc_soc; > #endif > > +/* > + * These IDs are for internal use of Tegra's ICC, the values are chosen > + * such that they don't conflict with the device-tree ICC node IDs. > + */ > +#define TEGRA_ICC_EMC 1000 > +#define TEGRA_ICC_EMEM 2000 > +#define TEGRA_ICC_MC 3000 > + > #endif /* MEMORY_TEGRA_MC_H */ > diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h > index 1238e35653d1..71de023f9f47 100644 > --- a/include/soc/tegra/mc.h > +++ b/include/soc/tegra/mc.h > @@ -7,6 +7,7 @@ > #define __SOC_TEGRA_MC_H__ > > #include > +#include > #include > #include > > @@ -178,6 +179,8 @@ struct tegra_mc { > > struct reset_controller_dev reset; > > + struct icc_provider provider; > + > spinlock_t lock; > }; The rest looks good to me! Thanks, Georgi