Received: by 10.223.164.221 with SMTP id h29csp1785418wrb; Thu, 2 Nov 2017 00:30:12 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SIGTEVWndLQsPPZsw6uz0MMaLyGHtpxl+Lq4/m4bNKDX7mBNLFRJLVWXqilJq74zWnL5nv X-Received: by 10.159.235.142 with SMTP id f14mr2281134plr.450.1509607812498; Thu, 02 Nov 2017 00:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509607812; cv=none; d=google.com; s=arc-20160816; b=uUej8lvJegNdSMfRfnhsaTHXx9V1nbeuFRbhs3aFSZvNm9vztG9O8UL18YHRZoK9Ea ZTBRSBXx1fYcWVBagyNL5uGgtxAxxcVAA52sTzLORrm10dicPXMsoU97rfEQoxUW/M97 8uG6aRqmzaBNqV7uQfuHsnlgngTyZJGiPXT664IsUbVtgEg2vxSrLj4AeDwmM8Zoj3xk V/TsmmLxxNNzuU2uAzWRZA9b2nNG49JoNnE+qmX+I4aU7/Ybd1OnhfB5uR93TjkM0buV wU/n/JBiJZ66QBAPYUfYeGr9Om3IeNgfobkSVWpPOGnrEg+ydZfA3nkAaLNgF4ShjzEA oaJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=45eenBygFNeU5uWhePLnTouW5ePNb/jUhUIcMWdwVtQ=; b=iDneSm4ZZn7h+jT+f07YAIMylVC1ZxRc814bk41rmqoPkegxbcIlK5nYv95Ec4eoPP Vc4DCeuAE64hwsA6AwTnJaYULj9oZDYSe6R+o5kFzVm2yvbG4tULDSJP5Mr9IQfrD9y6 DSMp3HAA/8ZnZpkowI19sAH05dyDEhcitAjA0z1r6jLk0+X5hGCJI7gUFab9Y46CuujY rHGtYkwWlE+pvh3Soj+jkowTUwz9GQHNa2rDWEDzEuR4nQMlzJzeql6gGiUPA+yG1juI JUpL07ER2mpvPfwwUe2Sr2jctJBqpF/QSPXbnA2QXYPo7vV2tPgH510uXds7xHn6vgyV HQfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=agHB4a97; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i11si2905317pgq.753.2017.11.02.00.29.58; Thu, 02 Nov 2017 00:30:12 -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=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=agHB4a97; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755326AbdKBH2z (ORCPT + 99 others); Thu, 2 Nov 2017 03:28:55 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:52986 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755193AbdKBH2w (ORCPT ); Thu, 2 Nov 2017 03:28:52 -0400 Received: by mail-ot0-f193.google.com with SMTP id v105so789071ota.9 for ; Thu, 02 Nov 2017 00:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdurent-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=45eenBygFNeU5uWhePLnTouW5ePNb/jUhUIcMWdwVtQ=; b=agHB4a97/tsdtbv8Ol2K78aoJUXhsPCghs0wI2IDm6R3Wzfjs5KRMy4D4hV0MzVXrR 3UHSgcSpkSiLIetRYECsQoJ23mleRE/8MPv75q2r8chjoououJD1vhCrtUDh1RKHeub9 NotGIp+VrnIMZmoimtWLBy2FCGvg5EC4tF5eHwZv/SP997Yz5LWfDCbonIZ7k4QfJLEM ZFHRyj/V6j6nTO2ZT5XBnZ1arooA2P0NRQlpZrwn8mygUtclaUXQ8MSlPdC+hnoeZOlv touL15gXJgU+BFoPpHSmWFNhLXXpriuY+lCAraRp5RYxlELT7hUG9c/ArZn95ZATnghM k1rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=45eenBygFNeU5uWhePLnTouW5ePNb/jUhUIcMWdwVtQ=; b=opi+VZlxgNIsIVOFHV+VwYucCmnZz0ju4jw+f7KPH6/INbY1BTk2c3X7nDAG50tpEP VsTK00jefgKPf4vpprNY52xJtCKdu/94g2WdI1FhqfixLdTvj/L344tC3PWbNp+emSs/ qXECGbxyFzR48j9KwoQpjgPXYffu8vhQ2PffVe1mh3jF/YmqK57rsKmFP4RmJDkCBXj5 XCtnD6Ok7j4KJj/FqFS5pRcqYGEvffjyAXQoHxhPLUQJ5Uu5zIegifgq7CC1wvR94Cub uoKnh+1gd4jY4gtxCMThAl7fi4AQDBdKl3mSvp9upxLeHjLxsrPnuqXGd0nR0TGgZUyI +MAQ== X-Gm-Message-State: AMCzsaUwQwFsGSrsnNgcN6xIuv6x51mU9iKPLs5+qgR6+BMSYWM7YY4f OK9iHBg+76JABqqhTf0kUQGziaKQNz4/rI7v2t1Zcg== X-Received: by 10.157.65.161 with SMTP id p30mr1546582ote.2.1509607731561; Thu, 02 Nov 2017 00:28:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.173.141 with HTTP; Thu, 2 Nov 2017 00:28:50 -0700 (PDT) In-Reply-To: <20170908171830.13813-4-georgi.djakov@linaro.org> References: <20170908171830.13813-1-georgi.djakov@linaro.org> <20170908171830.13813-4-georgi.djakov@linaro.org> From: Amit Kucheria Date: Thu, 2 Nov 2017 12:58:50 +0530 Message-ID: Subject: Re: [PATCH v3 3/3] interconnect: Add Qualcomm msm8916 interconnect provider driver To: Georgi Djakov Cc: Linux PM list , gregkh@linuxfoundation.org, "Rafael J. Wysocki" , robh+dt@kernel.org, khilman@baylibre.com, Michael Turquette , Vincent Guittot , Saravana Kannan , Stephen Boyd , Andy Gross , seansw@qti.qualcomm.com, davidai@quicinc.com, LKML , lakml , linux-arm-msm@vger.kernel.org, mark.rutland@arm.com, Lorenzo Pieralisi Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 8, 2017 at 10:48 PM, Georgi Djakov wrote: > Add driver for the Qualcomm interconnect buses found in msm8916 based > platforms. This patch contains only a partial topology to make reviewing > easier. > > Signed-off-by: Georgi Djakov > --- > drivers/interconnect/Kconfig | 5 + > drivers/interconnect/Makefile | 1 + > drivers/interconnect/qcom/Kconfig | 11 + > drivers/interconnect/qcom/Makefile | 1 + > drivers/interconnect/qcom/interconnect_msm8916.c | 375 +++++++++++++++++++++++ > include/linux/interconnect/qcom-msm8916.h | 92 ++++++ > 6 files changed, 485 insertions(+) > create mode 100644 drivers/interconnect/qcom/Kconfig > create mode 100644 drivers/interconnect/qcom/Makefile > create mode 100644 drivers/interconnect/qcom/interconnect_msm8916.c > create mode 100644 include/linux/interconnect/qcom-msm8916.h > > diff --git a/drivers/interconnect/Kconfig b/drivers/interconnect/Kconfig > index 1e50e951cdc1..b123a76e2f9d 100644 > --- a/drivers/interconnect/Kconfig > +++ b/drivers/interconnect/Kconfig > @@ -8,3 +8,8 @@ menuconfig INTERCONNECT > > If unsure, say no. > > +if INTERCONNECT > + > +source "drivers/interconnect/qcom/Kconfig" > + > +endif > diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile > index d9da6a6c3560..62a01de24aeb 100644 > --- a/drivers/interconnect/Makefile > +++ b/drivers/interconnect/Makefile > @@ -1 +1,2 @@ > obj-$(CONFIG_INTERCONNECT) += interconnect.o > +obj-$(CONFIG_INTERCONNECT_QCOM) += qcom/ > diff --git a/drivers/interconnect/qcom/Kconfig b/drivers/interconnect/qcom/Kconfig > new file mode 100644 > index 000000000000..86465dc37bd4 > --- /dev/null > +++ b/drivers/interconnect/qcom/Kconfig > @@ -0,0 +1,11 @@ > +config INTERCONNECT_QCOM > + bool "Qualcomm Network-on-Chip interconnect drivers" > + depends on INTERCONNECT > + depends on ARCH_QCOM || COMPILE_TEST > + default y > + > +config INTERCONNECT_QCOM_MSM8916 > + tristate "Qualcomm MSM8916 interconnect driver" > + depends on INTERCONNECT_QCOM > + help > + This is a driver for the Qualcomm Network-on-Chip on msm8916-based platforms. > diff --git a/drivers/interconnect/qcom/Makefile b/drivers/interconnect/qcom/Makefile > new file mode 100644 > index 000000000000..0831080e1100 > --- /dev/null > +++ b/drivers/interconnect/qcom/Makefile > @@ -0,0 +1 @@ > +obj-$(CONFIG_INTERCONNECT_QCOM_MSM8916) += interconnect_msm8916.o > diff --git a/drivers/interconnect/qcom/interconnect_msm8916.c b/drivers/interconnect/qcom/interconnect_msm8916.c > new file mode 100644 > index 000000000000..9b001e100974 > --- /dev/null > +++ b/drivers/interconnect/qcom/interconnect_msm8916.c > @@ -0,0 +1,375 @@ > +/* > + * Copyright (C) 2017 Linaro Ltd > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 and > + * only version 2 as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define to_qcom_icp(_icp) \ > + container_of(_icp, struct qcom_interconnect_provider, icp) > +#define to_qcom_node(_node) \ > + container_of(_node, struct qcom_interconnect_node, node) > + > +enum qcom_bus_type { > + QCOM_BUS_TYPE_NOC = 0, > + QCOM_BUS_TYPE_MEM, > +}; > + > +struct qcom_interconnect_provider { > + struct icp icp; > + void __iomem *base; > + struct clk *bus_clk; > + struct clk *bus_a_clk; > + u32 base_offset; > + u32 qos_offset; > + enum qcom_bus_type type; > +}; > + > +struct qcom_interconnect_node { > + struct interconnect_node node; > + unsigned char *name; > + struct interconnect_node *links[8]; Magic number 8. Replace with 8916_MAX_LINKS or something. > + u16 id; > + u16 num_links; > + u16 port; > + u16 buswidth; Comment on what a buswidth is just to be clear > + u64 rate; Comment on units > +}; > + > +static struct qcom_interconnect_node snoc_int_0; > +static struct qcom_interconnect_node snoc_int_1; > +static struct qcom_interconnect_node snoc_int_bimc; > +static struct qcom_interconnect_node snoc_bimc_0_mas; > +static struct qcom_interconnect_node pnoc_snoc_slv; > + > +static struct qcom_interconnect_node snoc_bimc_0_slv; IMO, saving an 'a' and 'e' is not worth it for the sake of readability. Just use 'slave' and 'master' in the names. > +static struct qcom_interconnect_node slv_ebi_ch0; > + > +static struct qcom_interconnect_node pnoc_int_1; > +static struct qcom_interconnect_node mas_pnoc_sdcc_1; > +static struct qcom_interconnect_node mas_pnoc_sdcc_2; > +static struct qcom_interconnect_node pnoc_snoc_mas; > + > +struct qcom_interconnect_desc { > + struct qcom_interconnect_node **nodes; > + size_t num_nodes; > +}; > + > +static struct qcom_interconnect_node snoc_int_0 = { > + .id = 10004, > + .name = "snoc-int-0", > +#if 0 Please get rid if these. > + .links = { &snoc_pnoc_mas.node }, > + .num_links = 1, > +#endif > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node snoc_int_1 = { > + .id = 10005, > + .name = "snoc-int-1", > +#if 0 > + .links = { &slv_apss.node, &slv_cats_0.node, &slv_cats_1.node }, > + .num_links = 3, > +#endif > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node snoc_int_bimc = { > + .id = 10006, > + .name = "snoc-bimc", > + .links = { &snoc_bimc_0_mas.node }, > + .num_links = 1, > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node snoc_bimc_0_mas = { > + .id = 10007, > + .name = "snoc-bimc-0-mas", > + .links = { &snoc_bimc_0_slv.node }, > + .num_links = 1, > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node pnoc_snoc_slv = { > + .id = 10011, > + .name = "snoc-pnoc", > + .links = { &snoc_int_0.node, &snoc_int_bimc.node, &snoc_int_1.node }, > + .num_links = 3, > + .buswidth = 8, > +}; Suggest replacing this list of definitions with a macro such as: #define DEFINE_XCON_NODE(_name, _id, numlinks, buswidth, ...) \ static struct qcom_interconnect_node _name; \ static struct qcom_interconnect_node _name = { \ .id = _id, \ .name = _name, \ .buswidth = buswidth, \ .num_links = numlinks, \ .links = { __VA_ARGS__ }, \ }; This will reduce these definitions to a series of definitions as follows that improves readability. DEFINE_XCON_NODE(snoc_int_0, 10004, 1, 8, &snoc_pnoc_mas.node) DEFINE_XCON_NODE(snoc_int_1, 10005, 3, 8, &snoc_apss.node, &slv_cats_0.node, &slv_cats_1.node) DEFINE_XCON_NODE(snoc_int_bimc, 10006, 1, 8, &snoc_bimc_0_mas.node) If fact you could take it one step further and move the definitions under the provider definition below directly. > +static struct qcom_interconnect_node *msm8916_snoc_nodes[] = { > + [SNOC_INT_0] = &snoc_int_0, > + [SNOC_INT_1] = &snoc_int_1, > + [SNOC_INT_BIMC] = &snoc_int_bimc, > + [SNOC_BIMC_0_MAS] = &snoc_bimc_0_mas, > + [PNOC_SNOC_SLV] = &pnoc_snoc_slv, > +}; > + > +static struct qcom_interconnect_desc msm8916_snoc = { > + .nodes = msm8916_snoc_nodes, > + .num_nodes = ARRAY_SIZE(msm8916_snoc_nodes), > +}; > + > +static struct qcom_interconnect_node snoc_bimc_0_slv = { > + .id = 10025, > + .name = "snoc_bimc_0_slv", > + .links = { &slv_ebi_ch0.node }, > + .num_links = 1, > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node slv_ebi_ch0 = { > + .id = 512, > + .name = "slv-ebi-ch0", > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node *msm8916_bimc_nodes[] = { > + [SNOC_BIMC_0_SLV] = &snoc_bimc_0_slv, > + [SLV_EBI_CH0] = &slv_ebi_ch0, > +}; > + > +static struct qcom_interconnect_desc msm8916_bimc = { > + .nodes = msm8916_bimc_nodes, > + .num_nodes = ARRAY_SIZE(msm8916_bimc_nodes), > +}; > + > +static struct qcom_interconnect_node pnoc_int_1 = { > + .id = 10013, > + .name = "pnoc-int-1", > + .links = { &pnoc_snoc_mas.node }, > + .num_links = 1, > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node mas_pnoc_sdcc_1 = { > + .id = 78, > + .name = "mas-pnoc-sdcc-1", > + .links = { &pnoc_int_1.node }, > + .num_links = 1, > + .port = 7, > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node mas_pnoc_sdcc_2 = { > + .id = 81, > + .name = "mas-pnoc-sdcc-2", > + .links = { &pnoc_int_1.node }, > + .num_links = 1, > + .port = 8, > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node pnoc_snoc_mas = { > + .id = 10010, > + .name = "pnoc-snoc-mas", > + .links = { &pnoc_snoc_slv.node }, > + .num_links = 1, > + .buswidth = 8, > +}; > + > +static struct qcom_interconnect_node *msm8916_pnoc_nodes[] = { > + [PNOC_INT_1] = &pnoc_int_1, > + [MAS_PNOC_SDCC_1] = &mas_pnoc_sdcc_1, > + [MAS_PNOC_SDCC_2] = &mas_pnoc_sdcc_2, > + [PNOC_SNOC_MAS] = &pnoc_snoc_mas, > +}; There are big holes in this node array definition because the index values are not contiguous. Are you planning fill these in later for each of the providers? > +static struct qcom_interconnect_desc msm8916_pnoc = { > + .nodes = msm8916_pnoc_nodes, > + .num_nodes = ARRAY_SIZE(msm8916_pnoc_nodes), > +}; > + > +static int qcom_interconnect_init(struct interconnect_node *node) > +{ > + struct qcom_interconnect_node *qn = to_qcom_node(node); > + > + /* populate default values */ > + if (!qn->buswidth) > + qn->buswidth = 8; > + > + /* TODO: init qos and priority */ > + > + return 0; From 1577992818368267790@xxx Fri Sep 08 17:20:22 +0000 2017 X-GM-THRID: 1577992818368267790 X-Gmail-Labels: Inbox,Category Forums