diff mbox

[v10] PCI: tango: Add MSI controller support

Message ID 26b17bd9-232f-b992-68ac-3b5a7752ba54@free.fr (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Mason Aug. 28, 2017, 4:13 p.m. UTC
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?

Comments

Rob Herring Sept. 18, 2017, 9:30 p.m. UTC | #1
On Mon, Aug 28, 2017 at 11:13 AM, Mason <slash.tmp@free.fr> wrote:
> 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?

I thought I had commented (maybe that was on IRC), but looks fine.

This series should also fix a build failure on rcar with !OF, so can
you send a proper patch?

Rob
Mason Sept. 19, 2017, 10:41 a.m. UTC | #2
On 18/09/2017 23:30, Rob Herring wrote:
> On Aug 28, 2017 at 11:13 AM, Mason wrote:
>> 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?
> 
> I thought I had commented (maybe that was on IRC), but looks fine.
> 
> This series should also fix a build failure on rcar with !OF, so can
> you send a proper patch?

You're not misremembering, you did review the formal patch ;-)

"[PATCH 0/3] Tango PCIe host bridge MSI support + required API"
https://patchwork.kernel.org/patch/9927539/
https://patchwork.kernel.org/patch/9927541/

Regards.
diff mbox

Patch

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(