Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1318930imm; Fri, 11 May 2018 14:32:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZos7v1H94f78V0S5Urmv7PNgNQ60wUQL8Yr5lk0jGDgTQqr0TdwQY5KVGbnWJaBq6/sdoiS X-Received: by 2002:a62:6c3:: with SMTP id 186-v6mr418523pfg.151.1526074329350; Fri, 11 May 2018 14:32:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526074329; cv=none; d=google.com; s=arc-20160816; b=0jeosGjimjwxvDLogisZ/IWY4W/iKoShyn0badfc177bxWBENutEByPSRNJLrYvEpT O0uVyHLfmvVngEcmuc4KsG3d3aVWOZRZGHBjHNai2cIyQrSFcW+iRZ4IjL5+wr2H+x87 Eat4wYu76f3BeDLEY3VfuSHyMP+qCNflp8C6o/fO4Vwi/MPEmA2NeArKq+uzHttlodbb 4R3g67aao7+R+4EwseiXQNQCiJQDOvk8cK33pWnzb9jjL6sAab7lK5IpfgMyQVK3qw9g GS26HHaPSLSfkNP2naxfaMWtmArh3tEPB5e33nxvUtWiHL6TaelrSi1MXGnXiSXj4cgY Ha+Q== 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 :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=KhHTBbPROWpsLmB6VKzbBhZ4l4nkCJcen1H70OdYJf4=; b=L+EaA1/6P7MRnPrluVcTpzM76tqwNeFrAdPNinGX40SLchrH6QpvujX3X+Z8a/3tgF Ze8pMtSWwEQaHe9G6rHPW9dLrWAesSWzrfiTCNc+Hbu4DckbXyl8amrpnCiFbA+ECIVc 4Zz+FG8uF32bVgdcswR3kr374ocSWw4HYYttotGCynXFTlnMTvJrp76e2aWX1ICyzPrG JoFj1WwGbuEdNyLYCgZocZQojcH4hipZwInfyDDwWFT/tpYrKrT7MzqSoDD6Jx47RfZ0 hrKZwDnTNQ08JX1yJua31kuzN4LiD/lyFgIsixpVP/4r6IrcxjX9LHgd9aguGE2Ki/8t 577A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nxlB7dPk; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n3-v6si3327196pgs.589.2018.05.11.14.31.54; Fri, 11 May 2018 14:32:09 -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=@chromium.org header.s=google header.b=nxlB7dPk; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752000AbeEKVaY (ORCPT + 99 others); Fri, 11 May 2018 17:30:24 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:41609 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751947AbeEKVaW (ORCPT ); Fri, 11 May 2018 17:30:22 -0400 Received: by mail-oi0-f67.google.com with SMTP id 11-v6so5922184ois.8 for ; Fri, 11 May 2018 14:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KhHTBbPROWpsLmB6VKzbBhZ4l4nkCJcen1H70OdYJf4=; b=nxlB7dPkiKzzLIklE5rvk7EgV8Xgs7dH4XA7SOfp82FSnqzY5eWHHilSPGq0O8eO/A UlNlmPDvkIVROcWQ8kqGy9pzftc2wiu+YLFOpmy0h8r60spTiZ/4EBC44QgTCgvu830D 7oNgCCaD0F2XBO2LexQHprMw9wzhCJs3swiwQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KhHTBbPROWpsLmB6VKzbBhZ4l4nkCJcen1H70OdYJf4=; b=X3025H4AOlBio9WpUcHpS6pelQR957hSLZVBBlRFzW74KEmk8iKsI1PDabg5qGYFuh SSt5WqHAa6HmuePyD/IBIlRzZS/u8I8zA9Qw2TxVVv03pQTuUuipIBGLUC/cTZqt4GhD nMEiuSZBQqb7R7Pnpd1INwgejm8Sh4K053J98T8xcO9GEzZh0NI5UUUJ3joyfqzuNyIB DnpLUJzRYqdVmTUXJNbCdITacGXb40nrrpNsgMCJAnkAXkJuA50Nha8+PdWlUMfWhtpC rQGQQNvMBgdckzEEu2oaURiLsPaoObx4PIAnOtsPWykH5HIj1KkOhmL5e9HVV7IGHCzc RLMw== X-Gm-Message-State: ALKqPwfs8pNwk7dAX065hhISWFlFDTLmmSL3sbWyrB/HO7TkgUl5tzs0 4A7u2UHRWRxoBl2pyF2DYqXp31UVBrk= X-Received: by 2002:aca:dd46:: with SMTP id u67-v6mr315094oig.355.1526074221872; Fri, 11 May 2018 14:30:21 -0700 (PDT) Received: from mail-ot0-f174.google.com (mail-ot0-f174.google.com. [74.125.82.174]) by smtp.gmail.com with ESMTPSA id d9-v6sm2204713oth.34.2018.05.11.14.30.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 May 2018 14:30:19 -0700 (PDT) Received: by mail-ot0-f174.google.com with SMTP id l22-v6so7818724otj.0 for ; Fri, 11 May 2018 14:30:19 -0700 (PDT) X-Received: by 2002:a9d:36c8:: with SMTP id s8-v6mr2232462otd.247.1526074218816; Fri, 11 May 2018 14:30:18 -0700 (PDT) MIME-Version: 1.0 References: <20180309210958.16672-1-georgi.djakov@linaro.org> <20180309210958.16672-6-georgi.djakov@linaro.org> In-Reply-To: <20180309210958.16672-6-georgi.djakov@linaro.org> From: Evan Green Date: Fri, 11 May 2018 14:29:42 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 5/7] interconnect: qcom: Add msm8916 interconnect provider driver To: georgi.djakov@linaro.org Cc: linux-pm@vger.kernel.org, gregkh@linuxfoundation.org, rjw@rjwysocki.net, robh+dt@kernel.org, Michael Turquette , khilman@baylibre.com, vincent.guittot@linaro.org, skannan@codeaurora.org, Bjorn Andersson , amit.kucheria@linaro.org, seansw@qti.qualcomm.com, davidai@quicinc.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org 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 Hi Georgi, On Fri, Mar 9, 2018 at 1:11 PM Georgi Djakov wrote: > Add driver for the Qualcomm interconnect buses found in msm8916 based > platforms. > Signed-off-by: Georgi Djakov > --- > drivers/interconnect/Kconfig | 5 + > drivers/interconnect/Makefile | 1 + > drivers/interconnect/qcom/Kconfig | 11 + > drivers/interconnect/qcom/Makefile | 2 + > drivers/interconnect/qcom/msm8916.c | 482 ++++++++++++++++++++++++++++++++++++ > include/linux/interconnect/qcom.h | 350 ++++++++++++++++++++++++++ > 6 files changed, 851 insertions(+) > create mode 100644 drivers/interconnect/qcom/Kconfig > create mode 100644 drivers/interconnect/qcom/msm8916.c > create mode 100644 include/linux/interconnect/qcom.h ... > diff --git a/drivers/interconnect/qcom/msm8916.c b/drivers/interconnect/qcom/msm8916.c > new file mode 100644 > index 000000000000..d5b54f8261c8 > --- /dev/null > +++ b/drivers/interconnect/qcom/msm8916.c ... > +static int qnoc_probe(struct platform_device *pdev) > +{ > + const struct qcom_icc_desc *desc; > + struct qcom_icc_node **qnodes; > + struct qcom_icc_provider *qp; > + struct resource *res; > + struct icc_provider *provider; > + size_t num_nodes, i; > + int ret; > + > + /* wait for RPM */ > + if (!qcom_icc_rpm_smd_available()) > + return -EPROBE_DEFER; > + > + desc = of_device_get_match_data(&pdev->dev); > + if (!desc) > + return -EINVAL; > + > + qnodes = desc->nodes; > + num_nodes = desc->num_nodes; > + > + qp = devm_kzalloc(&pdev->dev, sizeof(*qp), GFP_KERNEL); > + if (!qp) > + return -ENOMEM; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + qp->base = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(qp->base)) > + return PTR_ERR(qp->base); > + > + qp->bus_clk = devm_clk_get(&pdev->dev, "bus_clk"); > + if (IS_ERR(qp->bus_clk)) > + return PTR_ERR(qp->bus_clk); > + > + qp->bus_a_clk = devm_clk_get(&pdev->dev, "bus_a_clk"); > + if (IS_ERR(qp->bus_a_clk)) > + return PTR_ERR(qp->bus_a_clk); > + > + provider = &qp->provider; > + provider->dev = &pdev->dev; > + provider->set = &qcom_icc_set; > + INIT_LIST_HEAD(&provider->nodes); > + provider->data = qp; > + > + ret = icc_add_provider(provider); > + if (ret) { > + dev_err(&pdev->dev, "error adding interconnect provider\n"); > + return ret; > + } > + > + for (i = 0; i < num_nodes; i++) { > + struct icc_node *node; > + int ret; > + size_t j; > + > + node = icc_node_create(qnodes[i]->id); > + if (IS_ERR(node)) { > + ret = PTR_ERR(node); > + goto err; > + } > + > + node->name = qnodes[i]->name; > + node->data = qnodes[i]; > + icc_node_add(node, provider); > + > + dev_dbg(&pdev->dev, "registered node %p %s %d\n", node, > + qnodes[i]->name, node->id); > + > + /* populate links */ > + for (j = 0; j < qnodes[i]->num_links; j++) > + if (qnodes[i]->links[j]) > + icc_link_create(node, qnodes[i]->links[j]); > + > + ret = qcom_icc_init(node); > + if (ret) > + dev_err(&pdev->dev, "%s init error (%d)\n", node->name, > + ret); Don't you want to call qcom_icc_init before icc_link_create? As soon as icc_link_create is called, the node is connected to the graph, and qcom_icc_set can be called. > + } > + > + platform_set_drvdata(pdev, provider); > + > + return ret; > +err: > + icc_del_provider(provider); > + return ret; > +} > + > +static int qnoc_remove(struct platform_device *pdev) > +{ > + struct icc_provider *provider = platform_get_drvdata(pdev); > + > + icc_del_provider(provider); Presumably in the framework nodes and links ought to get cleaned up somewhere too, right? As it is now, the devm code frees provider when this device is removed, even though provider is still very connected in the graph via the nodes and links. > + > + return 0; > +} > + > +static const struct of_device_id qnoc_of_match[] = { > + { .compatible = "qcom,msm8916-pnoc", .data = &msm8916_pnoc }, > + { .compatible = "qcom,msm8916-snoc", .data = &msm8916_snoc }, > + { .compatible = "qcom,msm8916-bimc", .data = &msm8916_bimc }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, qnoc_of_match); > + > +static struct platform_driver qnoc_driver = { > + .probe = qnoc_probe, > + .remove = qnoc_remove, > + .driver = { > + .name = "qnoc-msm8916", > + .of_match_table = qnoc_of_match, > + }, > +}; > +module_platform_driver(qnoc_driver); > +MODULE_AUTHOR("Georgi Djakov "); > +MODULE_DESCRIPTION("Qualcomm msm8916 NoC driver"); > +MODULE_LICENSE("GPL v2"); > diff --git a/include/linux/interconnect/qcom.h b/include/linux/interconnect/qcom.h > new file mode 100644 > index 000000000000..2cd378d2f575 > --- /dev/null > +++ b/include/linux/interconnect/qcom.h > @@ -0,0 +1,350 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Qualcomm interconnect IDs > + * > + * Copyright (c) 2018, Linaro Ltd. > + * Author: Georgi Djakov > + */ > + > +#ifndef __QCOM_INTERCONNECT_IDS_H > +#define __QCOM_INTERCONNECT_IDS_H > + > +#define FAB_BIMC 0 > +#define FAB_SYS_NOC 1024 > +#define FAB_MMSS_NOC 2048 > +#define FAB_OCMEM_NOC 3072 > +#define FAB_PERIPH_NOC 4096 > +#define FAB_CONFIG_NOC 5120 > +#define FAB_OCMEM_VNOC 6144 Looks like you're still following that downstream convention of NoCs being divisible by 1024, masters in 1-512, and slaves in 512-1023, then I don't know about the 10000s. This was documented somewhere downstream, can you add that documentation somewhere in here? -Evan