From patchwork Mon Aug 28 16:13:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mason X-Patchwork-Id: 9925835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF30B60329 for ; Mon, 28 Aug 2017 16:14:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEDCB28066 for ; Mon, 28 Aug 2017 16:14:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A084C28738; Mon, 28 Aug 2017 16:14:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2F66C28066 for ; Mon, 28 Aug 2017 16:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eouLpb4o0dzVisDk/kdu2hV2y41/fN2oFPIxoYZJzO8=; b=Dfcbth94/wBUMO vLsZgnqDfROXb9hjadb2uKuGHdb9C96S2XnVpxogaaABNnphwTNOdL0TLBUS+JyVrvds4t3UJweXp DXDC1bXFpsZoY/fXJXtLuJNg1VZu8ps97FYabhqte8VJYfVX+MgmxowXU/gGFL1F/TOvwVbpY91US MfTrRGOHLKNBrmjoK+HfSyfFEU906Auxk/+RNduwnyIVoQ8JQ1G9/zC63F8Ex5Ils35czRgnNaGMn h88a5DTo+nQN7e6J03gwVOs8Ai6Lr4VuflCZd6eN2snjVWjKllGNoEkx1h/qSM2ydUwu7PK3XHfY7 FDsD70FzBouYVTOLkyfA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmMgK-0002vr-BA; Mon, 28 Aug 2017 16:14:32 +0000 Received: from smtp5-g21.free.fr ([212.27.42.5]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmMgF-0002t4-66 for linux-arm-kernel@lists.infradead.org; Mon, 28 Aug 2017 16:14:30 +0000 Received: from [172.27.0.114] (unknown [92.154.11.170]) (Authenticated sender: slash.tmp) by smtp5-g21.free.fr (Postfix) with ESMTPSA id B85625FF9F; Mon, 28 Aug 2017 18:13:24 +0200 (CEST) Subject: Re: [PATCH v10] PCI: tango: Add MSI controller support To: Robin Murphy , Rob Herring , Frank Rowand References: <7b7278f4-7639-62b3-8a35-e6f7f9afa998@sigmadesigns.com> <8452c9ca-7131-cf43-d35c-afc4252844f0@arm.com> <4b93964c-49eb-efbf-f6b2-956c67694182@sigmadesigns.com> <86efs3wesi.fsf@arm.com> <20170824170445.GO31858@bhelgaas-glaptop.roam.corp.google.com> <871so09j6g.fsf@arm.com> <4954977e-46fd-8d54-ec76-db2134d3073a@arm.com> From: Mason Message-ID: <26b17bd9-232f-b992-68ac-3b5a7752ba54@free.fr> Date: Mon, 28 Aug 2017 18:13:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: <4954977e-46fd-8d54-ec76-db2134d3073a@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170828_091427_565376_6488A20F X-CRM114-Status: GOOD ( 12.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Thomas Petazzoni , Phil Edworthy , Ard Biesheuvel , Marc Zyngier , linux-pci , Thibaud Cornic , Andrew Murray , Liviu Dudau , Bjorn Helgaas , Ray Jui , Linus Walleij , Linux ARM , Marc Gonzalez Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 25/08/2017 17:25, Robin Murphy wrote: > If your host controller driver needs to discover its windows from DT to > configure *itself*, it needs to parse dma-ranges itself; see pcie-iproc, > pcie-rcar, pcie-xgene, etc. for examples. $ git grep '"dma-ranges"' drivers/pci/host drivers/pci/host/pci-ftpci100.c: parser->range = of_get_property(node, "dma-ranges", &rlen); drivers/pci/host/pci-rcar-gen2.c: parser->range = of_get_property(node, "dma-ranges", &rlen); drivers/pci/host/pci-xgene.c: parser->range = of_get_property(node, "dma-ranges", &rlen); drivers/pci/host/pcie-iproc.c: parser->range = of_get_property(node, "dma-ranges", &rlen); drivers/pci/host/pcie-rcar.c: parser->range = of_get_property(node, "dma-ranges", &rlen); These 5 drivers are using the same function: pci_dma_range_parser_init pci-ftpci100.c: d3c68e0a7e34a (Linus Walleij 2017-03-12 pci-rcar-gen2.c: 8d598cabf50d8 (Phil Edworthy 2015-11-03 pci-xgene.c: 5f6b6ccdbe1cd (Tanmay Inamdar 2014-10-01 pcie-iproc.c: dd9d4e7498de3 (Ray Jui 2016-10-31 pcie-rcar.c: c25da4778803b (Phil Edworthy 2014-05-12 which seems to be a copy of of_pci_range_parser_init with "ranges" changed to "dma-ranges" drivers/of/address.c 29b635c00f3eb (Andrew Murray 2013-05-16 Perhaps pci_dma_range_parser_init() can be factorized? Rob, Frank, what do you think of the patch below? diff --git a/drivers/of/address.c b/drivers/of/address.c index 580bbf6ca2b1..4cfd29e4ee1b 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -232,8 +232,8 @@ int of_pci_address_to_resource(struct device_node *dev, int bar, } EXPORT_SYMBOL_GPL(of_pci_address_to_resource); -int of_pci_range_parser_init(struct of_pci_range_parser *parser, - struct device_node *node) +static int parser_init(struct of_pci_range_parser *parser, + struct device_node *node, const char *name) { const int na = 3, ns = 2; int rlen; @@ -242,7 +242,7 @@ int of_pci_range_parser_init(struct of_pci_range_parser *parser, parser->pna = of_n_addr_cells(node); parser->np = parser->pna + na + ns; - parser->range = of_get_property(node, "ranges", &rlen); + parser->range = of_get_property(node, name, &rlen); if (parser->range == NULL) return -ENOENT; @@ -250,8 +250,21 @@ int of_pci_range_parser_init(struct of_pci_range_parser *parser, return 0; } + +int of_pci_range_parser_init(struct of_pci_range_parser *parser, + struct device_node *node) +{ + return parser_init(parser, node, "ranges"); +} EXPORT_SYMBOL_GPL(of_pci_range_parser_init); +int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser, + struct device_node *node) +{ + return parser_init(parser, node, "dma-ranges"); +} +EXPORT_SYMBOL_GPL(of_pci_dma_range_parser_init); + struct of_pci_range *of_pci_range_parser_one(struct of_pci_range_parser *parser, struct of_pci_range *range) { diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 37864734ca50..8beed2de98e9 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -49,6 +49,8 @@ extern const __be32 *of_get_address(struct device_node *dev, int index, extern int of_pci_range_parser_init(struct of_pci_range_parser *parser, struct device_node *node); +extern int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser, + struct device_node *node); extern struct of_pci_range *of_pci_range_parser_one( struct of_pci_range_parser *parser, struct of_pci_range *range); @@ -85,7 +87,13 @@ static inline const __be32 *of_get_address(struct device_node *dev, int index, static inline int of_pci_range_parser_init(struct of_pci_range_parser *parser, struct device_node *node) { - return -1; + return -ENOSYS; +} + +static inline int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser, + struct device_node *node) +{ + return -ENOSYS; } static inline struct of_pci_range *of_pci_range_parser_one(