Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1776745ybn; Thu, 26 Sep 2019 01:59:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7SD/RSW6IIqKfD3Oc9olKeIcwus8Do4KlHPzuYog6b5XuO6s3igz7QmnQt9f/G9Gu+DUd X-Received: by 2002:aa7:d718:: with SMTP id t24mr2300556edq.300.1569488388863; Thu, 26 Sep 2019 01:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569488388; cv=none; d=google.com; s=arc-20160816; b=ZiBbfpEUf2oZzaxtkjPVYnW5taXzjQSJzaRgU7lT84ygOeB4cCeW+hUE5enSgHLgUO uLXyNrdexsl8DoGmBe5hk/oCXZva/UQ2lBrrwgK9gAiQr11rbC/o+hDSyqIMng3poylz VYrFxh/wAL/jfZa4c5BPYCRscONEalTLrkbo6K/F6PfjXbNHUwOYdFuOfe0Cm92uM7L1 EeN5r7EnNWHRZWDApyR1tPVaCKDjUyQC/BQASdM4fGNyS/vWyTVZvhqtat3EzKRZWDjh XZjukZX0mKBMYj+dNFPe51RJpU28orkJFjcFbqQsf/s0VO1+ZCsVvFMqM8TgpIa+W9Nn 717w== 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:references:cc:to:subject:from:dkim-signature; bh=obNyCqqGzElvX7boXde6fghsyxBcR3pkK61f0Ir2WaE=; b=hXzX9JPXhQY/JUv8+tDEOebt4VaDoXWkkzGlW7N9OaFAJKWwEDyif8auYFTdPCV6YO woWgTB/WSVuHAeDUxkjrGVmI/VZqsgn+24n0ocqgZCTge2aORPO3sZy7Vj6a2DPEIzdV PQE1cXuPApslWub15HW90fi4CzRHtIEn+CUc1pwZpd5fqKVaQ5EcmKw6jmsRMRE2bwz+ AZK9eeXb+p336afz+/7ASg3oOTzZF9xAVqNneaLF70o4TZYjARBxWfhRy454xB3gzCSq 3kib9NgUhJYOtfPGfymqaagzUNTIDKAsDM3hdSxWbG47tDU9LyNbg3f/xLMDZuudqaIS 9XrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=egLwcybA; 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 i13si848398edv.182.2019.09.26.01.59.25; Thu, 26 Sep 2019 01:59:48 -0700 (PDT) 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=egLwcybA; 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 S2442125AbfIXXyJ (ORCPT + 99 others); Tue, 24 Sep 2019 19:54:09 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39347 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2442084AbfIXXyJ (ORCPT ); Tue, 24 Sep 2019 19:54:09 -0400 Received: by mail-wm1-f66.google.com with SMTP id v17so2144325wml.4 for ; Tue, 24 Sep 2019 16:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:subject:to:cc:references:openpgp:autocrypt:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=obNyCqqGzElvX7boXde6fghsyxBcR3pkK61f0Ir2WaE=; b=egLwcybANyqSdgRAu9EcaRb3zkdDSUzA8up5iGrUH1nSg/9R21k6DUoH5TKYnLSRES p90H6yNYvY3NUYffvlkjJn3TZu7unDdviFFCoY+cAss2Sye+j4YueusDO3Rrw6gCQx+p VPY9bXIE60S8kkT51PbkVrZcHzMVvSDmlZluI7dfH589h3nSgKUsE2CNV065yoI7/MTU luzfS+RbH+MLXdf9OaW5TY3+73jqTkb/XKlGl+XV57wkdcwDlgplxn/+ffRUx+vAq4tY ldGg3FLU/pG/kSxFvgiaSfAYDj0B+CscmAkYV5mp7Qr8SdgEvXzgOzGF2fn/BII5EMBg WvkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:openpgp:autocrypt :message-id:date:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=obNyCqqGzElvX7boXde6fghsyxBcR3pkK61f0Ir2WaE=; b=sQdyURjYCXd61R0a7Ub0TxSV82jDpAATvw+Ah1cr+wrpqWpmZaXHWj34OsMHbT/4+l qwj/1w5hXX+2j6PVOd2GpudU4mE0lLkv54I21eLbsPD4IN0k1lAPEMYI2KNyIy/Vukqg OPDPg84f8BGWqpvvax/hOK/coxqDDikGER7DvA/wWri01w8bQeiCEzL10Ds52Pe3mKRN ZF6KhH/JbjnSFCX0qr8wplAmVhcqnr6bnCiiA3p5Z5wCAQLSyZVtXF8LUGKik/7PyFSF 4C9j6voWHP+cHA0AQp2LuuDxkftzWlnmgGADgAl+2TpIsgeTcjtVlP+z+Rr/x/RbM0K4 0piA== X-Gm-Message-State: APjAAAWGnpTauxYK5hgjOEQshJVnXo6i/yzcyyiOC3ZkoNeswLcjcY58 u+gZbQMfuMdllPBkeRcM3Awx+A== X-Received: by 2002:a1c:6a03:: with SMTP id f3mr3355287wmc.167.1569369244941; Tue, 24 Sep 2019 16:54:04 -0700 (PDT) Received: from [10.44.66.8] ([212.45.67.2]) by smtp.googlemail.com with ESMTPSA id t8sm2884615wrx.76.2019.09.24.16.54.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Sep 2019 16:54:04 -0700 (PDT) From: Georgi Djakov Subject: Re: [PATCH V3 09/10] interconnect: mediatek: Add mt8183 interconnect provider driver To: Henry Chen , Rob Herring , Matthias Brugger , Viresh Kumar , Stephen Boyd , Ryan Case Cc: Nicolas Boichat , Fan Chen , James Liao , Weiyi Lu , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Linux PM list References: <1566995328-15158-1-git-send-email-henryc.chen@mediatek.com> <1566995328-15158-10-git-send-email-henryc.chen@mediatek.com> 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 f67WiEZgvN7tPXEzi84zT1PiUOM98dOnmREIamSpKOKFereIrKX2IcnZn8jyycE12zMkk+Sc ASMfXhfywB0tXRNmzsywdxQFcJ6jblPNxscnGMh2VlY2rezmqJdcK4G4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vySGa3Cof+miX06hQXKe99a5+eHNhtZJcMAIO89wZmj 7ayYJIXFqjl/X0KBcCbiAl4vbdBw1bqFnO4zd1lMXKVoa29UHqby4MPbQhjWNVv9kqp8A39+ E9xw890l1xdERkjVKX6IEJu2hf7X3MMl9tOjBK6MvdOUxvh1bNNmXh7OlBL1MpJYY/ydIm3B KEmKjLDvB0pePJkdTw== Message-ID: Date: Tue, 24 Sep 2019 16:53:57 -0700 MIME-Version: 1.0 In-Reply-To: <1566995328-15158-10-git-send-email-henryc.chen@mediatek.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 Henry, Please CC also the linux-pm@ list. On 8/28/19 05:28, Henry Chen wrote: > Introduce Mediatek MT8183 specific provider driver using the > interconnect framework. > > Signed-off-by: Henry Chen > --- > drivers/interconnect/Kconfig | 1 + > drivers/interconnect/Makefile | 1 + > drivers/interconnect/mediatek/Kconfig | 13 ++ > drivers/interconnect/mediatek/Makefile | 3 + > drivers/interconnect/mediatek/mtk-emi.c | 246 ++++++++++++++++++++++++++++++++ > 5 files changed, 264 insertions(+) > create mode 100644 drivers/interconnect/mediatek/Kconfig > create mode 100644 drivers/interconnect/mediatek/Makefile > create mode 100644 drivers/interconnect/mediatek/mtk-emi.c > [..] > + > +#define MT8183_MAX_LINKS 6 Looks like 1 is enough. Sorry for missing this in my earlier review. > + > +/** > + * struct mtk_icc_node - Mediatek specific interconnect nodes > + * @name: the node name used in debugfs > + * @ep: true if the node is an end point. > + * @id: a unique node identifier > + * @links: an array of nodes where we can go next while traversing > + * @num_links: the total number of @links > + * @buswidth: width of the interconnect between a node and the bus > + * @sum_avg: current sum aggregate value of all avg bw kBps requests > + * @max_peak: current max aggregate value of all peak bw kBps requests > + */ > +struct mtk_icc_node { > + unsigned char *name; > + bool ep; > + u16 id; > + u16 links[MT8183_MAX_LINKS]; > + u16 num_links; > + u16 buswidth; > + u64 sum_avg; > + u64 max_peak; > +}; > + > +struct mtk_icc_desc { > + struct mtk_icc_node **nodes; > + size_t num_nodes; > +}; > + > +#define DEFINE_MNODE(_name, _id, _buswidth, _ep, ...) \ > + static struct mtk_icc_node _name = { \ > + .name = #_name, \ > + .id = _id, \ > + .buswidth = _buswidth, \ > + .ep = _ep, \ > + .num_links = ARRAY_SIZE(((int[]){ __VA_ARGS__ })), \ > +} > + > +DEFINE_MNODE(ddr_emi, SLAVE_DDR_EMI, 1024, 1, 0); > +DEFINE_MNODE(mcusys, MASTER_MCUSYS, 256, 0, SLAVE_DDR_EMI); > +DEFINE_MNODE(gpu, MASTER_GPUSYS, 256, 0, SLAVE_DDR_EMI); > +DEFINE_MNODE(mmsys, MASTER_MMSYS, 256, 0, SLAVE_DDR_EMI); > +DEFINE_MNODE(mm_vpu, MASTER_MM_VPU, 128, 0, MASTER_MMSYS); > +DEFINE_MNODE(mm_disp, MASTER_MM_DISP, 128, 0, MASTER_MMSYS); > +DEFINE_MNODE(mm_vdec, MASTER_MM_VDEC, 128, 0, MASTER_MMSYS); > +DEFINE_MNODE(mm_venc, MASTER_MM_VENC, 128, 0, MASTER_MMSYS); > +DEFINE_MNODE(mm_cam, MASTER_MM_CAM, 128, 0, MASTER_MMSYS); > +DEFINE_MNODE(mm_img, MASTER_MM_IMG, 128, 0, MASTER_MMSYS); > +DEFINE_MNODE(mm_mdp, MASTER_MM_MDP, 128, 0, MASTER_MMSYS); > + [..] > +static int emi_icc_aggregate(struct icc_node *node, u32 avg_bw, > + u32 peak_bw, u32 *agg_avg, u32 *agg_peak) > +{ The prototype of this function has changed meanwhile, so you might want to update. [..] > +static int emi_icc_probe(struct platform_device *pdev) > +{ > + int ret; > + const struct mtk_icc_desc *desc; > + struct icc_node *node; > + struct icc_onecell_data *data; > + struct icc_provider *provider; > + struct mtk_icc_node **mnodes; > + size_t num_nodes, i, j; > + > + desc = of_device_get_match_data(&pdev->dev); > + if (!desc) > + return -EINVAL; > + > + mnodes = desc->nodes; > + num_nodes = desc->num_nodes; > + > + provider = devm_kzalloc(&pdev->dev, sizeof(*provider), GFP_KERNEL); > + if (!provider) > + return -ENOMEM; > + > + data = devm_kcalloc(&pdev->dev, num_nodes, sizeof(*node), GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + provider->dev = &pdev->dev; > + provider->set = emi_icc_set; > + provider->aggregate = emi_icc_aggregate; > + provider->xlate = of_icc_xlate_onecell; > + INIT_LIST_HEAD(&provider->nodes); > + provider->data = data; > + > + ret = icc_provider_add(provider); > + if (ret) { > + dev_err(&pdev->dev, "error adding interconnect provider\n"); > + return ret; > + } > + > + for (i = 0; i < num_nodes; i++) { > + node = icc_node_create(mnodes[i]->id); > + if (IS_ERR(node)) { > + ret = PTR_ERR(node); > + goto err; > + } > + > + node->name = mnodes[i]->name; > + node->data = mnodes[i]; > + icc_node_add(node, provider); > + > + dev_dbg(&pdev->dev, "registered node %s, num link: %d\n", > + mnodes[i]->name, mnodes[i]->num_links); > + > + /* populate links */ > + for (j = 0; j < mnodes[i]->num_links; j++) > + icc_link_create(node, mnodes[i]->links[j]); > + > + data->nodes[i] = node; > + } > + data->num_nodes = num_nodes; > + > + platform_set_drvdata(pdev, provider); > + > + return 0; > +err: > + list_for_each_entry(node, &provider->nodes, node_list) { > + icc_node_del(node); > + icc_node_destroy(node->id); > + } > + > + icc_provider_del(provider); You can just call emi_icc_remove() instead of the above. Thanks, Georgi > + return ret; > +} > + > +static int emi_icc_remove(struct platform_device *pdev) > +{ > + struct icc_provider *provider = platform_get_drvdata(pdev); > + struct icc_node *n; > + > + list_for_each_entry(n, &provider->nodes, node_list) { > + icc_node_del(n); > + icc_node_destroy(n->id); > + } > + > + return icc_provider_del(provider); > +}