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: 9925833 X-Patchwork-Delegate: bhelgaas@google.com 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 C809460329 for ; Mon, 28 Aug 2017 16:14:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B362528735 for ; Mon, 28 Aug 2017 16:14:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7AAB28738; Mon, 28 Aug 2017 16:14:07 +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=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3449028735 for ; Mon, 28 Aug 2017 16:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751236AbdH1QOG (ORCPT ); Mon, 28 Aug 2017 12:14:06 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:49792 "EHLO smtp5-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751197AbdH1QOF (ORCPT ); Mon, 28 Aug 2017 12:14:05 -0400 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 Cc: Marc Zyngier , Mark Rutland , Ard Biesheuvel , Bjorn Helgaas , linux-pci , Linux ARM , Thibaud Cornic , Marc Gonzalez , Linus Walleij , Phil Edworthy , Ray Jui , Andrew Murray , Liviu Dudau , Thomas Petazzoni 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> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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(