Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1439717ybt; Thu, 2 Jul 2020 05:37:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPrTyZNEztKFOt69hd4jZzDAzDJHPJpHwrOnPW8iBpRfYplZMdqOxSpr/Y4SZ+joVfi9Pz X-Received: by 2002:a17:906:7d9:: with SMTP id m25mr26973584ejc.25.1593693456353; Thu, 02 Jul 2020 05:37:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593693456; cv=none; d=google.com; s=arc-20160816; b=WQNXJldh970ateh9WT8xugSTXO6er9R3TqAgdgG6fx/j04aj46yEDNqLJASqJ3zFR1 cD8E34EgllrQB3K3FIAraAZ8oeG5RLClKyq0pljMtiwZSs3whoJDtTOPiTgMTEKhM5+b DT7OaP6VO4FQ9lS5T/j4he2ZJWcyuqwmcnNV5GDUyKAgNHjAfMAaSG8mio3H0cjlaxYU ikIGdDEjCKS8aZ/mhHXlxjQdzEBG5eejrwjWZOKvgbD6qUtdDwZH7RfBaqwbHenL7jX0 UJmGzFHwmkKkPJTVBdF+Y43r1OwWdfJaqXT43Er4s5Tem/k4TvR0CVXfZkdYuu9uiP1X uPRA== 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=asqQgjrfbyVj5Iv56jP1w9WQe+0TnQ0unPu7ewQBCcI=; b=eB7DGvjJtn6vpzRLM9dfUI0IGlWj2aLWf87RJcxuzWk8Q/30tY2TWvsZbXUJrdUiA4 11mnAXbUpHa6AcNrsqGBi5THf3mblwdpVhTxYCFHJukT/+c54qTMC72pKuq9Fa32LkQq BLC82txtSe/38lL36ZChpaHHe9YbxFll8wnEa6cMFv0haww+GcPH0rT0FkspJE5Gnrof iMbpg3O/fJrUqEZtHhOIAUTzriPCYik3UAPHIUhWvkDx1Ee0AzVDbpfIJPjQfJB/rTib Vh50wfWdzRp3RiYczF/MCXrQ/A4ShnLGORcxT4VgdBSsfZ4eYxACtvaKGbUXpVg+cDIf gKrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BzO7p5Wk; 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 lz15si5579530ejb.406.2020.07.02.05.37.12; Thu, 02 Jul 2020 05:37:36 -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=BzO7p5Wk; 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 S1729029AbgGBMgQ (ORCPT + 99 others); Thu, 2 Jul 2020 08:36:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729014AbgGBMgL (ORCPT ); Thu, 2 Jul 2020 08:36:11 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55099C08C5DD for ; Thu, 2 Jul 2020 05:36:11 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id j18so26577560wmi.3 for ; Thu, 02 Jul 2020 05:36:11 -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=asqQgjrfbyVj5Iv56jP1w9WQe+0TnQ0unPu7ewQBCcI=; b=BzO7p5WkwqdLrsiOO/zuKx5aLf49H4McNOyySPs8CwaC8u4rY661E3yg7jqxp136OO k6IZ2DKG3Gs/UKmmG6k+xrYKIeRxahRGAdFc1zc3rqA32vxJD04Csq9VhYwzlqE607LW qQfrZDCEbkHceyY6rjiowWtGiKtX1iaN3nOssrhWBVPXmTJY3u0NHkDgow4sL0ORBG33 Vzz2Acep2RpeRdWZnP7dfneRKmtdJNU4i98Eh3PjlSVipZ2vQcJhDZUfDZ1+w1cWOmZV 1Ul5zAahVA1ThXFY2+lyU7jTrgwJ8XZ1GOl7lrX84Iem0XVIrc8wAfzXB17E0l4/Sqt6 Jd0Q== 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=asqQgjrfbyVj5Iv56jP1w9WQe+0TnQ0unPu7ewQBCcI=; b=q7XsX344A3Oqk/Hf77K6vizFIBH8dzT/+T1OG+tmF3xAWYDrwUyfKevCWkHY/5TKJ6 X5fTFWHB6Y6+nU/BY6uVZ23Ar740ScipTPjAinmrfIxTC45c0ngcKe9BHl81aByKi/Qu E9Q/ea+kW2HEQyvdg5obMsgHxUHcgpQbXot4RMFCYz9YeLh4NEy3xHmoqsg9RUxNQvxQ QbUO950wIi9nalCIYmwaamtkdTIFttLkU9+GqaNdU3lDXV1RfxEhGnH9yxpkhaRUJfR1 b+tjSsp4CEaKVohXe7r94K2JJpwBjXIYDYISADxykbb/beYAu+LEEDpgELeZFxz3FPIn NhpA== X-Gm-Message-State: AOAM530sDkgs5glKXIqr/a3kVe4PF7YMDPv21yuRAH8nSdoi2jEK2Kom vapzwx6qCgMXarF8dY5WpWyPDw== X-Received: by 2002:a7b:c043:: with SMTP id u3mr33511858wmc.185.1593693368746; Thu, 02 Jul 2020 05:36:08 -0700 (PDT) Received: from [10.44.66.8] ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id g16sm11788693wrh.91.2020.07.02.05.36.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jul 2020 05:36:08 -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> <82d27a47-f189-6609-a584-c9ca1b35a76c@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/9Sh74DM8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1zzUYwMYk+A6v40gBn00 OOB13qJe9zyKpReWMAhg7BYPBKIm/qSr82aIQc4+FlDX2Ot6T/4tGUDr9MAHaBKFtVyIqXBO xOf0vQEokkUGRKWBE0uA3zFVRfLiT6NUjDQ0vdphTnsdA7h01MliZLQ2lLL2Mt5lsqU+6sup Tfql1omgEpjnFsPsyFebzcKGbdEr6vySGa3Cof+miX06hQXKe99a5+eHNhtZJcMAIO89wZmj 7ayYJIXFqjl/X0KBcCbiAl4vbdBw1bqFnO4zd1lMXKVoa29UHqby4MPbQhjWNVv9kqp8A39+ E9xw890l1xdERkjVKX6IEJu2hf7X3MMl9tOjBK6MvdOUxvh1bNNmXh7OlBL1MpJYY/ydIm3B KEmKjLDvB0pePJkdTw== Message-ID: <05cb459d-fc10-1537-eaea-df06f7566b6a@linaro.org> Date: Thu, 2 Jul 2020 15:36:07 +0300 MIME-Version: 1.0 In-Reply-To: <82d27a47-f189-6609-a584-c9ca1b35a76c@gmail.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 Dmitry, On 7/2/20 02:36, Dmitry Osipenko wrote: > 01.07.2020 20:12, Georgi Djakov пишет: >> Hi Dmitry, >> >> Thank you for updating the patches! > > Hello, Georgi! > > Thank you for the review! > >> 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. > > Eventually this dummy function might become populated with a memory > latency allowness programming. I could add a comment into that function > in the next version, saying that it's to-be-done for now. Ah ok! Sounds good, thanks for clarifying! >>> + 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. > > Are you planning to remove the provider's list-head initialization from > the icc_provider_add() [1] and move it to the individual provider > drivers, correct? Yes, that would be the first step, but i need to post some patches first, so let's keep it as-is for now. Sorry for the confusion. Thanks, Georgi