Skip to contentSkip to conversation

PCI: move DT PCI functions to PCI core

PATCH Applied Rob Herring 3 participants 7 messages Jan 4, 2018 – Jan 19, 2018

Subsystems (6)
lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

cover PCI: move DT PCI functions to PCI core

Most subsystem specific functions have been moved into the respective subsystems. Only PCI and networking remain. This series moves most of the PCI related code to drivers/pci/of.c. Some bus address functions for PCI remain in of/address.c because we don't have infrastructure to split up the per bus helper functions.

I expect Bjorn to take this series, so PPC maintainers please ack.

Rob

Rob Herring (3):
PCI: move OF related PCI functions into PCI core powerpc/pci: use of_irq_parse_and_map_pci helper
PCI: make of_irq_parse_pci static

 arch/arm/mach-mvebu/Kconfig      |   1 -
 arch/powerpc/kernel/pci-common.c |   8 +-
 drivers/of/Kconfig               |  16 --
 drivers/of/Makefile              |   2 -
 drivers/of/address.c             |   8 +-
 drivers/of/of_pci.c              | 384 -----------------------------
 drivers/of/of_pci_irq.c          | 131 ----------
 drivers/pci/of.c                 | 505 +++++++++++++++++++++++++++++++++++++++
 include/linux/of_pci.h           |   8 +-
 9 files changed, 510 insertions(+), 553 deletions(-)
 delete mode 100644 drivers/of/of_pci.c
 delete mode 100644 drivers/of/of_pci_irq.c
author maintainer
#1 lore raw

PATCH 1/3 PCI: move OF related PCI functions into PCI core

Following what has been done for other subsystems, move the remaining PCI related code out of drivers/of/ and into drivers/pci/of.c

With this, we can kill a few kconfig symbols.

---
 arch/arm/mach-mvebu/Kconfig |   1 -
 drivers/of/Kconfig          |  16 --
 drivers/of/Makefile         |   2 -
 drivers/of/address.c        |   8 +-
 drivers/of/of_pci.c         | 384 ---------------------------------
 drivers/of/of_pci_irq.c     | 131 ------------
 drivers/pci/of.c            | 506 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of_pci.h      |   2 +-
 8 files changed, 510 insertions(+), 540 deletions(-)
 delete mode 100644 drivers/of/of_pci.c
 delete mode 100644 drivers/of/of_pci_irq.c
arch/arm/mach-mvebu/Kconfig +0 -1
index 9b49867154bf..6b32dc527edc 100644
@@ -10,7 +10,6 @@ menuconfig ARCH_MVEBU
 	select ZONE_DMA if ARM_LPAE
 	select GPIOLIB
 	select PCI_QUIRKS if PCI
-	select OF_ADDRESS_PCI
 
 if ARCH_MVEBU
 
drivers/of/Kconfig +0 -16
index 5020d7ef7494..35b5b8ec13c9 100644
@@ -63,10 +63,6 @@ config OF_DYNAMIC
 config OF_ADDRESS
 	def_bool y
 	depends on !SPARC && (HAS_IOMEM || UML)
-	select OF_ADDRESS_PCI if PCI
-
-config OF_ADDRESS_PCI
-	bool
 
 config OF_IRQ
 	def_bool y
@@ -83,18 +79,6 @@ config OF_MDIO
 	help
 	  OpenFirmware MDIO bus (Ethernet PHY) accessors
 
-config OF_PCI
-	def_tristate PCI
-	depends on PCI
-	help
-	  OpenFirmware PCI bus accessors
-
-config OF_PCI_IRQ
-	def_tristate PCI
-	depends on OF_PCI && OF_IRQ
-	help
-	  OpenFirmware PCI IRQ routing helpers
-
 config OF_RESERVED_MEM
 	depends on OF_EARLY_FLATTREE
 	bool
drivers/of/Makefile +0 -2
index 63a4be62ce19..663a4af0cccd 100644
@@ -10,8 +10,6 @@ obj-$(CONFIG_OF_IRQ)    += irq.o
 obj-$(CONFIG_OF_NET)	+= of_net.o
 obj-$(CONFIG_OF_UNITTEST) += unittest.o
 obj-$(CONFIG_OF_MDIO)	+= of_mdio.o
-obj-$(CONFIG_OF_PCI)	+= of_pci.o
-obj-$(CONFIG_OF_PCI_IRQ)  += of_pci_irq.o
 obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
 obj-$(CONFIG_OF_RESOLVE)  += resolver.o
 obj-$(CONFIG_OF_OVERLAY) += overlay.o
drivers/of/address.c +3 -5
index fa6cabfc3cb9..8591afbdfe99 100644
@@ -96,7 +96,7 @@ static unsigned int of_bus_default_get_flags(const __be32 *addr)
 	return IORESOURCE_MEM;
 }
 
-#ifdef CONFIG_OF_ADDRESS_PCI
+#ifdef CONFIG_PCI
 /*
  * PCI bus specific translator
  */
@@ -171,9 +171,7 @@ static int of_bus_pci_translate(__be32 *addr, u64 offset, int na)
 {
 	return of_bus_default_translate(addr + 1, offset, na - 1);
 }
-#endif /* CONFIG_OF_ADDRESS_PCI */
 
-#ifdef CONFIG_PCI
 const __be32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
 			unsigned int *flags)
 {
@@ -426,7 +424,7 @@ static unsigned int of_bus_isa_get_flags(const __be32 *addr)
  */
 
 static struct of_bus of_busses[] = {
-#ifdef CONFIG_OF_ADDRESS_PCI
+#ifdef CONFIG_PCI
 	/* PCI */
 	{
 		.name = "pci",
@@ -437,7 +435,7 @@ static struct of_bus of_busses[] = {
 		.translate = of_bus_pci_translate,
 		.get_flags = of_bus_pci_get_flags,
 	},
-#endif /* CONFIG_OF_ADDRESS_PCI */
+#endif /* CONFIG_PCI */
 	/* ISA */
 	{
 		.name = "isa",
drivers/of/of_pci.c deleted +0 -384

384 lines not on this page · raw message

drivers/of/of_pci_irq.c deleted +0 -131

131 lines not on this page · raw message

drivers/pci/of.c +506 -0

521 lines not on this page · raw message

include/linux/of_pci.h +1 -1
index bf588a05d0d0..f0e129e848ea 100644
@@ -9,7 +9,7 @@ struct pci_dev;
 struct of_phandle_args;
 struct device_node;
 
-#ifdef CONFIG_OF_PCI
+#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_PCI)
 int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq);
 struct device_node *of_pci_find_child_device(struct device_node *parent,
 					     unsigned int devfn);
Signature · 1 line
2.14.1
author maintainer
#2 lore raw

PATCH 2/3 powerpc/pci: use of_irq_parse_and_map_pci helper

In reply to Rob Herring

Instead of calling both of_irq_parse_pci and irq_create_of_mapping, call of_irq_parse_and_map_pci instead which does the same thing. This will allow making of_irq_parse_pci a private, static function.

This changes the logic slightly in that the fallback path will also be taken if irq_create_of_mapping fails internally.

Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Michael Ellerman <[email protected]>
---
 arch/powerpc/kernel/pci-common.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/powerpc/kernel/pci-common.c +1 -7
index 0ac7aa346c69..f65c07dec23e 100644
@@ -339,7 +339,6 @@ struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node)
  */
 static int pci_read_irq_line(struct pci_dev *pci_dev)
 {
-	struct of_phandle_args oirq;
 	unsigned int virq;
 
 	pr_debug("PCI: Try to map irq for %s...\n", pci_name(pci_dev));
@@ -348,7 +347,7 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
 	memset(&oirq, 0xff, sizeof(oirq));
 #endif
 	/* Try to get a mapping from the device-tree */
-	if (of_irq_parse_pci(pci_dev, &oirq)) {
+	if (!of_irq_parse_and_map_pci(pci_dev, 0, 0)) {
 		u8 line, pin;
 
 		/* If that fails, lets fallback to what is in the config
@@ -372,11 +371,6 @@ static int pci_read_irq_line(struct pci_dev *pci_dev)
 		virq = irq_create_mapping(NULL, line);
 		if (virq)
 			irq_set_irq_type(virq, IRQ_TYPE_LEVEL_LOW);
-	} else {
-		pr_debug(" Got one, spec %d cells (0x%08x 0x%08x...) on %pOF\n",
-			 oirq.args_count, oirq.args[0], oirq.args[1], oirq.np);
-
-		virq = irq_create_of_mapping(&oirq);
 	}
 
 	if (!virq) {
Signature · 1 line
2.14.1
author maintainer
#3 lore raw

PATCH 3/3 PCI: make of_irq_parse_pci static

In reply to Rob Herring

Now that the DT PCI code is merged into drivers/pci, of_irq_parse_pci can be static.

---
 drivers/pci/of.c       | 3 +--
 include/linux/of_pci.h | 6 ------
 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/pci/of.c +1 -2
index 859a43dd098d..511a5ec83f6e 100644
@@ -479,7 +479,7 @@ int of_pci_map_rid(struct device_node *np, u32 rid,
  * PCI tree until an device-node is found, at which point it will finish
  * resolving using the OF tree walking.
  */
-int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
+static int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
 {
 	struct device_node *dn, *ppnode;
 	struct pci_dev *ppdev;
@@ -569,7 +569,6 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq
 	}
 	return rc;
 }
-EXPORT_SYMBOL_GPL(of_irq_parse_pci);
 
 /**
  * of_irq_parse_and_map_pci() - Decode a PCI irq from the device tree and map to a virq
include/linux/of_pci.h +0 -6
index f0e129e848ea..88865e0ebf4d 100644
@@ -10,7 +10,6 @@ struct of_phandle_args;
 struct device_node;
 
 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_PCI)
-int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq);
 struct device_node *of_pci_find_child_device(struct device_node *parent,
 					     unsigned int devfn);
 int of_pci_get_devfn(struct device_node *np);
@@ -23,11 +22,6 @@ int of_pci_map_rid(struct device_node *np, u32 rid,
 		   const char *map_name, const char *map_mask_name,
 		   struct device_node **target, u32 *id_out);
 #else
-static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
-{
-	return 0;
-}
-
 static inline struct device_node *of_pci_find_child_device(struct device_node *parent,
 					     unsigned int devfn)
 {
Signature · 1 line
2.14.1
#4 lore raw
In reply to Rob Herring
Quoted 7 lines · Rob Herring

Most subsystem specific functions have been moved into the respective subsystems. Only PCI and networking remain. This series moves most of the PCI related code to drivers/pci/of.c. Some bus address functions for PCI remain in of/address.c because we don't have infrastructure to split up the per bus helper functions.

I expect Bjorn to take this series, so PPC maintainers please ack.

I plan to merge this for v4.16, so PPC maintainers, this is your chance to speak up :)

Quoted 20 lines

Rob Herring (3):
PCI: move OF related PCI functions into PCI core powerpc/pci: use of_irq_parse_and_map_pci helper
PCI: make of_irq_parse_pci static

 arch/arm/mach-mvebu/Kconfig      |   1 -
 arch/powerpc/kernel/pci-common.c |   8 +-
 drivers/of/Kconfig               |  16 --
 drivers/of/Makefile              |   2 -
 drivers/of/address.c             |   8 +-
 drivers/of/of_pci.c              | 384 -----------------------------
 drivers/of/of_pci_irq.c          | 131 ----------
 drivers/pci/of.c                 | 505 +++++++++++++++++++++++++++++++++++++++
 include/linux/of_pci.h           |   8 +-
 9 files changed, 510 insertions(+), 553 deletions(-)
 delete mode 100644 drivers/of/of_pci.c
 delete mode 100644 drivers/of/of_pci_irq.c

--
2.14.1

#5 lore raw
In reply to Rob Herring
Quoted 15 lines · Rob Herring

Most subsystem specific functions have been moved into the respective subsystems. Only PCI and networking remain. This series moves most of the PCI related code to drivers/pci/of.c. Some bus address functions for PCI remain in of/address.c because we don't have infrastructure to split up the per bus helper functions.

I expect Bjorn to take this series, so PPC maintainers please ack.

Rob

Rob Herring (3):
PCI: move OF related PCI functions into PCI core powerpc/pci: use of_irq_parse_and_map_pci helper
PCI: make of_irq_parse_pci static

Quoted 12 lines
 arch/arm/mach-mvebu/Kconfig      |   1 -
 arch/powerpc/kernel/pci-common.c |   8 +-
 drivers/of/Kconfig               |  16 --
 drivers/of/Makefile              |   2 -
 drivers/of/address.c             |   8 +-
 drivers/of/of_pci.c              | 384 -----------------------------
 drivers/of/of_pci_irq.c          | 131 ----------
 drivers/pci/of.c                 | 505 +++++++++++++++++++++++++++++++++++++++
 include/linux/of_pci.h           |   8 +-
 9 files changed, 510 insertions(+), 553 deletions(-)
 delete mode 100644 drivers/of/of_pci.c
 delete mode 100644 drivers/of/of_pci_irq.c

Applied to pci/dt-resources for v4.16, thanks!

I'll update this if necessary if PPC maintainers comment.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 29 lines · Bjorn Helgaas
Quoted 15 lines · Rob Herring

Most subsystem specific functions have been moved into the respective subsystems. Only PCI and networking remain. This series moves most of the PCI related code to drivers/pci/of.c. Some bus address functions for PCI remain in of/address.c because we don't have infrastructure to split up the per bus helper functions.

I expect Bjorn to take this series, so PPC maintainers please ack.

Rob

Rob Herring (3):
PCI: move OF related PCI functions into PCI core powerpc/pci: use of_irq_parse_and_map_pci helper
PCI: make of_irq_parse_pci static

Quoted 12 lines
 arch/arm/mach-mvebu/Kconfig      |   1 -
 arch/powerpc/kernel/pci-common.c |   8 +-
 drivers/of/Kconfig               |  16 --
 drivers/of/Makefile              |   2 -
 drivers/of/address.c             |   8 +-
 drivers/of/of_pci.c              | 384 -----------------------------
 drivers/of/of_pci_irq.c          | 131 ----------
 drivers/pci/of.c                 | 505 +++++++++++++++++++++++++++++++++++++++
 include/linux/of_pci.h           |   8 +-
 9 files changed, 510 insertions(+), 553 deletions(-)
 delete mode 100644 drivers/of/of_pci.c
 delete mode 100644 drivers/of/of_pci_irq.c
Quoted 3 lines

Applied to pci/dt-resources for v4.16, thanks!

I'll update this if necessary if PPC maintainers comment.

Thanks. Seems fine, fingers crossed :)

cheers
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html