linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs()
@ 2017-07-31 16:37 Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data Lorenzo Pieralisi
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Ralf Baechle, Arnd Bergmann,
	Paul Burton, Rich Felker, Bjorn Helgaas, Richard Henderson,
	Tanmay Inamdar, Ivan Kokshaysky, Chris Metcalf, David S. Miller,
	Matthew Minter, Yoshinori Sato, Geert Uytterhoeven, Guan Xuetao

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus trees
(and possibly rooted at different host bridges) and may well be enabled
(ie probed and bound to a driver) by the time pci_fixup_irqs() is called
when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to
assign legacy PCI IRQs to devices does not work at all for
hotplugged devices in that the code carrying out the IRQ fixup
is called at host bridge driver probe time, which just cannot take
into account devices hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

This series converts all arches still relying on pci_fixup_irqs() to
the new pci_scan_root_bus_bridge() API and consequently remove
pci_fixup_irqs() from the kernel in that it is not used anymore.

Compile tested only, I do not have the necessary hardware.

[1] git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/linux.git pci/pci-fixup-irqs-removal

Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Tanmay Inamdar <tinamdar@apm.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Matthew Minter <matt@masarand.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>

Lorenzo Pieralisi (7):
  sh/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping
    hooks
  alpha/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
    mapping hooks
  m68k/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
    mapping hooks
  MIPS/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
    mapping hooks
  tile/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
    mapping hooks
  unicore32/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
    mapping hooks
  sparc/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
    mapping hooks

Matthew Minter (2):
  sh/PCI: Remove __init optimisations from IRQ mapping functions/data
  PCI: Remove pci_fixup_irqs() function

 arch/alpha/kernel/pci.c                 | 27 ++++++++++++++++------
 arch/alpha/kernel/sys_nautilus.c        | 31 +++++++++++++++++++++----
 arch/m68k/coldfire/pci.c                | 36 +++++++++++++++++++++++++----
 arch/mips/pci/pci-legacy.c              | 24 +++++++++++++------
 arch/sh/drivers/pci/fixups-cayman.c     |  2 +-
 arch/sh/drivers/pci/fixups-dreamcast.c  |  2 +-
 arch/sh/drivers/pci/fixups-r7780rp.c    |  2 +-
 arch/sh/drivers/pci/fixups-rts7751r2d.c |  6 ++---
 arch/sh/drivers/pci/fixups-sdk7780.c    |  4 ++--
 arch/sh/drivers/pci/fixups-se7751.c     |  2 +-
 arch/sh/drivers/pci/fixups-sh03.c       |  2 +-
 arch/sh/drivers/pci/fixups-snapgear.c   |  2 +-
 arch/sh/drivers/pci/fixups-titan.c      |  4 ++--
 arch/sh/drivers/pci/pci.c               | 41 ++++++++++++++++++++-------------
 arch/sh/drivers/pci/pcie-sh7786.c       |  2 +-
 arch/sparc/kernel/leon_pci.c            | 24 ++++++++++++++-----
 arch/tile/kernel/pci.c                  | 21 +++++++++++++----
 arch/tile/kernel/pci_gx.c               | 21 +++++++++++++----
 arch/unicore32/kernel/pci.c             | 35 ++++++++++++++++++++++++----
 drivers/pci/setup-irq.c                 | 24 -------------------
 include/linux/pci.h                     |  2 --
 21 files changed, 216 insertions(+), 98 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 2/9] sh/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks Lorenzo Pieralisi
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Matthew Minter, Rich Felker, Yoshinori Sato,
	Arnd Bergmann, Bjorn Helgaas, Tanmay Inamdar, Richard Henderson,
	Ivan Kokshaysky, Geert Uytterhoeven, Ralf Baechle, Paul Burton,
	Chris Metcalf, Guan Xuetao, David S. Miller

From: Matthew Minter <matt@masarand.com>

Currently the many IRQ mapping functions and data structures use
the __init and __initdata optimisations. These result in the
relevant functions being innacessable after boot time.

However for deferred IRQ assignment it is important to have
access to these functions at PCI device enable time.

Therefore the optimisation is removed from the relevant data
structures and functions to prepare for deferred IRQ assignment.

Signed-off-by: Matthew Minter <matt@masarand.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 arch/sh/drivers/pci/fixups-cayman.c     | 2 +-
 arch/sh/drivers/pci/fixups-dreamcast.c  | 2 +-
 arch/sh/drivers/pci/fixups-r7780rp.c    | 2 +-
 arch/sh/drivers/pci/fixups-rts7751r2d.c | 6 +++---
 arch/sh/drivers/pci/fixups-sdk7780.c    | 4 ++--
 arch/sh/drivers/pci/fixups-se7751.c     | 2 +-
 arch/sh/drivers/pci/fixups-sh03.c       | 2 +-
 arch/sh/drivers/pci/fixups-snapgear.c   | 2 +-
 arch/sh/drivers/pci/fixups-titan.c      | 4 ++--
 arch/sh/drivers/pci/pcie-sh7786.c       | 2 +-
 10 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/sh/drivers/pci/fixups-cayman.c b/arch/sh/drivers/pci/fixups-cayman.c
index edc2fb7..3246788 100644
--- a/arch/sh/drivers/pci/fixups-cayman.c
+++ b/arch/sh/drivers/pci/fixups-cayman.c
@@ -5,7 +5,7 @@
 #include <cpu/irq.h>
 #include "pci-sh5.h"
 
-int __init pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
 	int result = -1;
 
diff --git a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c
index 1d1c5a2..9d597f7 100644
--- a/arch/sh/drivers/pci/fixups-dreamcast.c
+++ b/arch/sh/drivers/pci/fixups-dreamcast.c
@@ -76,7 +76,7 @@ static void gapspci_fixup_resources(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, gapspci_fixup_resources);
 
-int __init pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
 	/*
 	 * The interrupt routing semantics here are quite trivial.
diff --git a/arch/sh/drivers/pci/fixups-r7780rp.c b/arch/sh/drivers/pci/fixups-r7780rp.c
index 57ed3f0..2c9b58f 100644
--- a/arch/sh/drivers/pci/fixups-r7780rp.c
+++ b/arch/sh/drivers/pci/fixups-r7780rp.c
@@ -15,7 +15,7 @@
 #include <linux/sh_intc.h>
 #include "pci-sh4.h"
 
-int __init pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
 	return evt2irq(0xa20) + slot;
 }
diff --git a/arch/sh/drivers/pci/fixups-rts7751r2d.c b/arch/sh/drivers/pci/fixups-rts7751r2d.c
index eaddb56..358ac10 100644
--- a/arch/sh/drivers/pci/fixups-rts7751r2d.c
+++ b/arch/sh/drivers/pci/fixups-rts7751r2d.c
@@ -20,18 +20,18 @@
 #define PCIMCR_MRSET_OFF	0xBFFFFFFF
 #define PCIMCR_RFSH_OFF		0xFFFFFFFB
 
-static u8 rts7751r2d_irq_tab[] __initdata = {
+static u8 rts7751r2d_irq_tab[] = {
 	IRQ_PCI_INTA,
 	IRQ_PCI_INTB,
 	IRQ_PCI_INTC,
 	IRQ_PCI_INTD,
 };
 
-static char lboxre2_irq_tab[] __initdata = {
+static char lboxre2_irq_tab[] = {
 	IRQ_ETH0, IRQ_ETH1, IRQ_INTA, IRQ_INTD,
 };
 
-int __init pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
 	if (mach_is_lboxre2())
 		return lboxre2_irq_tab[slot];
diff --git a/arch/sh/drivers/pci/fixups-sdk7780.c b/arch/sh/drivers/pci/fixups-sdk7780.c
index c0a015a..24e96df 100644
--- a/arch/sh/drivers/pci/fixups-sdk7780.c
+++ b/arch/sh/drivers/pci/fixups-sdk7780.c
@@ -22,7 +22,7 @@
 #define IRQ_INTD	evt2irq(0xa80)
 
 /* IDSEL [16][17][18][19][20][21][22][23][24][25][26][27][28][29][30][31] */
-static char sdk7780_irq_tab[4][16] __initdata = {
+static char sdk7780_irq_tab[4][16] = {
 	/* INTA */
 	{ IRQ_INTA, IRQ_INTD, IRQ_INTC, IRQ_INTD, -1, -1, -1, -1, -1, -1,
 	  -1, -1, -1, -1, -1, -1 },
@@ -37,7 +37,7 @@ static char sdk7780_irq_tab[4][16] __initdata = {
 	  -1, -1, -1 },
 };
 
-int __init pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
        return sdk7780_irq_tab[pin-1][slot];
 }
diff --git a/arch/sh/drivers/pci/fixups-se7751.c b/arch/sh/drivers/pci/fixups-se7751.c
index 84a88ca..1cb8d0a 100644
--- a/arch/sh/drivers/pci/fixups-se7751.c
+++ b/arch/sh/drivers/pci/fixups-se7751.c
@@ -7,7 +7,7 @@
 #include <linux/sh_intc.h>
 #include "pci-sh4.h"
 
-int __init pcibios_map_platform_irq(const struct pci_dev *, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *, u8 slot, u8 pin)
 {
         switch (slot) {
         case 0: return evt2irq(0x3a0);
diff --git a/arch/sh/drivers/pci/fixups-sh03.c b/arch/sh/drivers/pci/fixups-sh03.c
index 16207be..55ac1ba 100644
--- a/arch/sh/drivers/pci/fixups-sh03.c
+++ b/arch/sh/drivers/pci/fixups-sh03.c
@@ -4,7 +4,7 @@
 #include <linux/pci.h>
 #include <linux/sh_intc.h>
 
-int __init pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
 	int irq;
 
diff --git a/arch/sh/drivers/pci/fixups-snapgear.c b/arch/sh/drivers/pci/fixups-snapgear.c
index 6e33ba4..a931e59 100644
--- a/arch/sh/drivers/pci/fixups-snapgear.c
+++ b/arch/sh/drivers/pci/fixups-snapgear.c
@@ -19,7 +19,7 @@
 #include <linux/sh_intc.h>
 #include "pci-sh4.h"
 
-int __init pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
 	int irq = -1;
 
diff --git a/arch/sh/drivers/pci/fixups-titan.c b/arch/sh/drivers/pci/fixups-titan.c
index bd1addb..a9d563e 100644
--- a/arch/sh/drivers/pci/fixups-titan.c
+++ b/arch/sh/drivers/pci/fixups-titan.c
@@ -19,7 +19,7 @@
 #include <mach/titan.h>
 #include "pci-sh4.h"
 
-static char titan_irq_tab[] __initdata = {
+static char titan_irq_tab[] = {
 	TITAN_IRQ_WAN,
 	TITAN_IRQ_LAN,
 	TITAN_IRQ_MPCIA,
@@ -27,7 +27,7 @@ static char titan_irq_tab[] __initdata = {
 	TITAN_IRQ_USB,
 };
 
-int __init pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
 	int irq = titan_irq_tab[slot];
 
diff --git a/arch/sh/drivers/pci/pcie-sh7786.c b/arch/sh/drivers/pci/pcie-sh7786.c
index a162a7f..0167a73 100644
--- a/arch/sh/drivers/pci/pcie-sh7786.c
+++ b/arch/sh/drivers/pci/pcie-sh7786.c
@@ -467,7 +467,7 @@ static int __init pcie_init(struct sh7786_pcie_port *port)
 	return 0;
 }
 
-int __init pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
+int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
         return evt2irq(0xae0);
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 2/9] sh/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 3/9] alpha/PCI: " Lorenzo Pieralisi
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Rich Felker, Bjorn Helgaas,
	Yoshinori Sato, Arnd Bergmann, Matthew Minter, Tanmay Inamdar,
	Richard Henderson, Ivan Kokshaysky, Geert Uytterhoeven,
	Ralf Baechle, Paul Burton, Chris Metcalf, Guan Xuetao,
	David S. Miller

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus
trees (and possibly rooted at different host bridges) and may well be
enabled (ie probed and bound to a driver) by the time pci_fixup_irqs()
is called when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to assign
legacy PCI IRQs to devices does not work at all for hotplugged devices
in that the code carrying out the IRQ fixup is called at host bridge
driver probe time, which just cannot take into account devices
hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

Convert PCI host bridge initialization code to the
pci_scan_root_bus_bridge() API (that allows to pass a struct
pci_host_bridge with initialized map/swizzle pointers) and remove the
pci_fixup_irqs() call from arch code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Rich Felker <dalias@libc.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 arch/sh/drivers/pci/pci.c | 41 +++++++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index c99ee28..357278c 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -39,8 +39,12 @@ static void pcibios_scanbus(struct pci_channel *hose)
 	LIST_HEAD(resources);
 	struct resource *res;
 	resource_size_t offset;
-	int i;
-	struct pci_bus *bus;
+	int i, ret;
+	struct pci_host_bridge *bridge;
+
+	bridge = pci_alloc_host_bridge(0);
+	if (!bridge)
+		return;
 
 	for (i = 0; i < hose->nr_resources; i++) {
 		res = hose->resources + i;
@@ -52,19 +56,26 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		pci_add_resource_offset(&resources, res, offset);
 	}
 
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
-	hose->bus = bus;
+	list_splice_init(&resources, &bridge->windows);
+	bridge->dev.parent = NULL;
+	bridge->sysdata = hose;
+	bridge->busnr = next_busno;
+	bridge->ops = hose->pci_ops;
+	bridge->swizzle_irq = pci_common_swizzle;
+	bridge->map_irq = pcibios_map_platform_irq;
+
+	ret = pci_scan_root_bus_bridge(bridge);
+	if (ret) {
+		pci_free_host_bridge(bridge);
+		return;
+	}
+
+	hose->bus = bridge->bus;
 
 	need_domain_info = need_domain_info || hose->index;
 	hose->need_domain_info = need_domain_info;
 
-	if (!bus) {
-		pci_free_resource_list(&resources);
-		return;
-	}
-
-	next_busno = bus->busn_res.end + 1;
+	next_busno = hose->bus->busn_res.end + 1;
 	/* Don't allow 8-bit bus number overflow inside the hose -
 	   reserve some space for bridges. */
 	if (next_busno > 224) {
@@ -72,9 +83,9 @@ static void pcibios_scanbus(struct pci_channel *hose)
 		need_domain_info = 1;
 	}
 
-	pci_bus_size_bridges(bus);
-	pci_bus_assign_resources(bus);
-	pci_bus_add_devices(bus);
+	pci_bus_size_bridges(hose->bus);
+	pci_bus_assign_resources(hose->bus);
+	pci_bus_add_devices(hose->bus);
 }
 
 /*
@@ -144,8 +155,6 @@ static int __init pcibios_init(void)
 	for (hose = hose_head; hose; hose = hose->next)
 		pcibios_scanbus(hose);
 
-	pci_fixup_irqs(pci_common_swizzle, pcibios_map_platform_irq);
-
 	dma_debug_add_bus(&pci_bus_type);
 
 	pci_initialized = 1;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 3/9] alpha/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 2/9] sh/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 4/9] m68k/PCI: " Lorenzo Pieralisi
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Bjorn Helgaas,
	Richard Henderson, Ivan Kokshaysky, Arnd Bergmann,
	Matthew Minter, Tanmay Inamdar, Rich Felker, Yoshinori Sato,
	Geert Uytterhoeven, Ralf Baechle, Paul Burton, Chris Metcalf,
	Guan Xuetao, David S. Miller

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus
trees (and possibly rooted at different host bridges) and may well be
enabled (ie probed and bound to a driver) by the time pci_fixup_irqs()
is called when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to assign
legacy PCI IRQs to devices does not work at all for hotplugged devices
in that the code carrying out the IRQ fixup is called at host bridge
driver probe time, which just cannot take into account devices
hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

Convert PCI host bridge initialization code to the
pci_scan_root_bus_bridge() API (that allows to pass a struct
pci_host_bridge with initialized map/swizzle pointers) and remove the
pci_fixup_irqs() call from arch code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
---
 arch/alpha/kernel/pci.c          | 27 ++++++++++++++++++++-------
 arch/alpha/kernel/sys_nautilus.c | 31 +++++++++++++++++++++++++++----
 2 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 5f387ee..d558287 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -312,8 +312,9 @@ common_init_pci(void)
 {
 	struct pci_controller *hose;
 	struct list_head resources;
+	struct pci_host_bridge *bridge;
 	struct pci_bus *bus;
-	int next_busno;
+	int ret, next_busno;
 	int need_domain_info = 0;
 	u32 pci_mem_end;
 	u32 sg_base;
@@ -336,11 +337,25 @@ common_init_pci(void)
 		pci_add_resource_offset(&resources, hose->mem_space,
 					hose->mem_space->start);
 
-		bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
-					hose, &resources);
-		if (!bus)
+		bridge = pci_alloc_host_bridge(0);
+		if (!bridge)
 			continue;
-		hose->bus = bus;
+
+		list_splice_init(&resources, &bridge->windows);
+		bridge->dev.parent = NULL;
+		bridge->sysdata = hose;
+		bridge->busnr = next_busno;
+		bridge->ops = alpha_mv.pci_ops;
+		bridge->swizzle_irq = alpha_mv.pci_swizzle;
+		bridge->map_irq = alpha_mv.pci_map_irq;
+
+		ret = pci_scan_root_bus_bridge(bridge);
+		if (ret) {
+			pci_free_host_bridge(bridge);
+			continue;
+		}
+
+		bus = hose->bus = bridge->bus;
 		hose->need_domain_info = need_domain_info;
 		next_busno = bus->busn_res.end + 1;
 		/* Don't allow 8-bit bus number overflow inside the hose -
@@ -354,7 +369,6 @@ common_init_pci(void)
 	pcibios_claim_console_setup();
 
 	pci_assign_unassigned_resources();
-	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
 	for (hose = hose_head; hose; hose = hose->next) {
 		bus = hose->bus;
 		if (bus)
@@ -362,7 +376,6 @@ common_init_pci(void)
 	}
 }
 
-
 struct pci_controller * __init
 alloc_pci_controller(void)
 {
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 2cfaa0e..8ae04a1 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -194,22 +194,46 @@ static struct resource irongate_mem = {
 	.name	= "Irongate PCI MEM",
 	.flags	= IORESOURCE_MEM,
 };
+static struct resource busn_resource = {
+	.name	= "PCI busn",
+	.start	= 0,
+	.end	= 255,
+	.flags	= IORESOURCE_BUS,
+};
 
 void __init
 nautilus_init_pci(void)
 {
 	struct pci_controller *hose = hose_head;
+	struct pci_host_bridge *bridge;
 	struct pci_bus *bus;
 	struct pci_dev *irongate;
 	unsigned long bus_align, bus_size, pci_mem;
 	unsigned long memtop = max_low_pfn << PAGE_SHIFT;
+	int ret;
+
+	bridge = pci_alloc_host_bridge(0);
+	if (!bridge)
+		return;
+
+	pci_add_resource(&bridge->windows, &ioport_resource);
+	pci_add_resource(&bridge->windows, &iomem_resource);
+	pci_add_resource(&bridge->windows, &busn_resource);
+	bridge->dev.parent = NULL;
+	bridge->sysdata = hose;
+	bridge->busnr = 0;
+	bridge->ops = alpha_mv.pci_ops;
+	bridge->swizzle_irq = alpha_mv.pci_swizzle;
+	bridge->map_irq = alpha_mv.pci_map_irq;
 
 	/* Scan our single hose.  */
-	bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
-	if (!bus)
+	ret = pci_scan_root_bus_bridge(bridge);
+	if (ret) {
+		pci_free_host_bridge(bridge);
 		return;
+	}
 
-	hose->bus = bus;
+	bus = hose->bus = bridge->bus;
 	pcibios_claim_one_bus(bus);
 
 	irongate = pci_get_bus_and_slot(0, 0);
@@ -254,7 +278,6 @@ nautilus_init_pci(void)
 	/* pci_common_swizzle() relies on bus->self being NULL
 	   for the root bus, so just clear it. */
 	bus->self = NULL;
-	pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);
 	pci_bus_add_devices(bus);
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 4/9] m68k/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (2 preceding siblings ...)
  2017-07-31 16:37 ` [RFT PATCH 3/9] alpha/PCI: " Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 5/9] MIPS/PCI: " Lorenzo Pieralisi
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Bjorn Helgaas,
	Geert Uytterhoeven, Arnd Bergmann, Matthew Minter,
	Tanmay Inamdar, Rich Felker, Yoshinori Sato, Richard Henderson,
	Ivan Kokshaysky, Ralf Baechle, Paul Burton, Chris Metcalf,
	Guan Xuetao, David S. Miller

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus
trees (and possibly rooted at different host bridges) and may well be
enabled (ie probed and bound to a driver) by the time pci_fixup_irqs()
is called when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to assign
legacy PCI IRQs to devices does not work at all for hotplugged devices
in that the code carrying out the IRQ fixup is called at host bridge
driver probe time, which just cannot take into account devices
hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

Convert PCI host bridge initialization code to the
pci_scan_root_bus_bridge() API (that allows to pass a struct
pci_host_bridge with initialized map/swizzle pointers) and remove the
pci_fixup_irqs() call from arch code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
---
 arch/m68k/coldfire/pci.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
index 6a640be..3097fa2 100644
--- a/arch/m68k/coldfire/pci.c
+++ b/arch/m68k/coldfire/pci.c
@@ -243,6 +243,13 @@ static struct resource mcf_pci_io = {
 	.flags	= IORESOURCE_IO,
 };
 
+static struct resource busn_resource = {
+	.name	= "PCI busn",
+	.start	= 0,
+	.end	= 255,
+	.flags	= IORESOURCE_BUS,
+};
+
 /*
  * Interrupt mapping and setting.
  */
@@ -258,6 +265,13 @@ static int mcf_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 
 static int __init mcf_pci_init(void)
 {
+	struct pci_host_bridge *bridge;
+	int ret;
+
+	bridge = pci_alloc_host_bridge(0);
+	if (!bridge)
+		return -ENOMEM;
+
 	pr_info("ColdFire: PCI bus initialization...\n");
 
 	/* Reset the external PCI bus */
@@ -312,14 +326,28 @@ static int __init mcf_pci_init(void)
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout(msecs_to_jiffies(200));
 
-	rootbus = pci_scan_bus(0, &mcf_pci_ops, NULL);
-	if (!rootbus)
-		return -ENODEV;
+
+	pci_add_resource(&bridge->windows, &ioport_resource);
+	pci_add_resource(&bridge->windows, &iomem_resource);
+	pci_add_resource(&bridge->windows, &busn_resource);
+	bridge->dev.parent = NULL;
+	bridge->sysdata = NULL;
+	bridge->busnr = 0;
+	bridge->ops = &mcf_pci_ops;
+	bridge->swizzle_irq = pci_common_swizzle;
+	bridge->map_irq = mcf_pci_map_irq;
+
+	ret = pci_scan_root_bus_bridge(bridge);
+	if (ret) {
+		pci_free_host_bridge(bridge);
+		return ret;
+	}
+
+	rootbus = bridge->bus;
 
 	rootbus->resource[0] = &mcf_pci_io;
 	rootbus->resource[1] = &mcf_pci_mem;
 
-	pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq);
 	pci_bus_size_bridges(rootbus);
 	pci_bus_assign_resources(rootbus);
 	pci_bus_add_devices(rootbus);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 5/9] MIPS/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (3 preceding siblings ...)
  2017-07-31 16:37 ` [RFT PATCH 4/9] m68k/PCI: " Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 6/9] tile/PCI: " Lorenzo Pieralisi
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Ralf Baechle, Paul Burton,
	Bjorn Helgaas, Arnd Bergmann, Matthew Minter, Tanmay Inamdar,
	Rich Felker, Yoshinori Sato, Richard Henderson, Ivan Kokshaysky,
	Geert Uytterhoeven, Chris Metcalf, Guan Xuetao, David S. Miller

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus
trees (and possibly rooted at different host bridges) and may well be
enabled (ie probed and bound to a driver) by the time pci_fixup_irqs()
is called when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to assign
legacy PCI IRQs to devices does not work at all for hotplugged devices
in that the code carrying out the IRQ fixup is called at host bridge
driver probe time, which just cannot take into account devices
hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

Convert PCI host bridge initialization code to the
pci_scan_root_bus_bridge() API (that allows to pass a struct
pci_host_bridge with initialized map/swizzle pointers) and remove the
pci_fixup_irqs() call from arch code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
---
 arch/mips/pci/pci-legacy.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c
index 71d62f8..fc77260 100644
--- a/arch/mips/pci/pci-legacy.c
+++ b/arch/mips/pci/pci-legacy.c
@@ -78,6 +78,12 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	static int need_domain_info;
 	LIST_HEAD(resources);
 	struct pci_bus *bus;
+	struct pci_host_bridge *bridge;
+	int ret;
+
+	bridge = pci_alloc_host_bridge(0);
+	if (!bridge)
+		return;
 
 	if (hose->get_busno && pci_has_flag(PCI_PROBE_ONLY))
 		next_busno = (*hose->get_busno)();
@@ -87,14 +93,20 @@ static void pcibios_scanbus(struct pci_controller *hose)
 	pci_add_resource_offset(&resources,
 				hose->io_resource, hose->io_offset);
 	pci_add_resource(&resources, hose->busn_resource);
-	bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
-				&resources);
-	if (!bus) {
-		pci_free_resource_list(&resources);
+	list_splice_init(&resources, &bridge->windows);
+	bridge->dev.parent = NULL;
+	bridge->sysdata = hose;
+	bridge->busnr = next_busno;
+	bridge->ops = hose->pci_ops;
+	bridge->swizzle_irq = pci_common_swizzle;
+	bridge->map_irq = pcibios_map_irq;
+	ret = pci_scan_root_bus_bridge(bridge);
+	if (ret) {
+		pci_free_host_bridge(bridge);
 		return;
 	}
 
-	hose->bus = bus;
+	hose->bus = bus = bridge->bus;
 
 	need_domain_info = need_domain_info || pci_domain_nr(bus);
 	set_pci_need_domain_info(hose, need_domain_info);
@@ -224,8 +236,6 @@ static int __init pcibios_init(void)
 	list_for_each_entry(hose, &controllers, list)
 		pcibios_scanbus(hose);
 
-	pci_fixup_irqs(pci_common_swizzle, pcibios_map_irq);
-
 	pci_initialized = 1;
 
 	return 0;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 6/9] tile/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (4 preceding siblings ...)
  2017-07-31 16:37 ` [RFT PATCH 5/9] MIPS/PCI: " Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 7/9] unicore32/PCI: " Lorenzo Pieralisi
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Bjorn Helgaas, Chris Metcalf,
	Arnd Bergmann, Matthew Minter, Tanmay Inamdar, Rich Felker,
	Yoshinori Sato, Richard Henderson, Ivan Kokshaysky,
	Geert Uytterhoeven, Ralf Baechle, Paul Burton, Guan Xuetao,
	David S. Miller

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus
trees (and possibly rooted at different host bridges) and may well be
enabled (ie probed and bound to a driver) by the time pci_fixup_irqs()
is called when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to assign
legacy PCI IRQs to devices does not work at all for hotplugged devices
in that the code carrying out the IRQ fixup is called at host bridge
driver probe time, which just cannot take into account devices
hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

Convert PCI host bridge initialization code to the
pci_scan_root_bus_bridge() API (that allows to pass a struct
pci_host_bridge with initializedmap/swizzle pointers) and remove the
pci_fixup_irqs() call from arch code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
---
 arch/tile/kernel/pci.c    | 21 ++++++++++++++++-----
 arch/tile/kernel/pci_gx.c | 21 ++++++++++++++++-----
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c
index bc6656b..8848261 100644
--- a/arch/tile/kernel/pci.c
+++ b/arch/tile/kernel/pci.c
@@ -274,6 +274,7 @@ static void fixup_read_and_payload_sizes(void)
  */
 int __init pcibios_init(void)
 {
+	struct pci_host_bridge *bridge;
 	int i;
 
 	pr_info("PCI: Probing PCI hardware\n");
@@ -306,16 +307,26 @@ int __init pcibios_init(void)
 
 			pci_add_resource(&resources, &ioport_resource);
 			pci_add_resource(&resources, &iomem_resource);
-			bus = pci_scan_root_bus(NULL, 0, controller->ops,
-						controller, &resources);
+
+			bridge = pci_alloc_host_bridge(0);
+			if (!bridge)
+				break;
+
+			list_splice_init(&resources, &bridge->windows);
+			bridge->dev.parent = NULL;
+			bridge->sysdata = controller;
+			bridge->busnr = 0;
+			bridge->ops = controller->ops;
+			bridge->swizzle_irq = pci_common_swizzle;
+			bridge->map_irq = tile_map_irq;
+
+			pci_scan_root_bus_bridge(bridge);
+			bus = bridge->bus;
 			controller->root_bus = bus;
 			controller->last_busno = bus->busn_res.end;
 		}
 	}
 
-	/* Do machine dependent PCI interrupt routing */
-	pci_fixup_irqs(pci_common_swizzle, tile_map_irq);
-
 	/*
 	 * This comes from the generic Linux PCI driver.
 	 *
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c
index b554a68..e683170 100644
--- a/arch/tile/kernel/pci_gx.c
+++ b/arch/tile/kernel/pci_gx.c
@@ -669,6 +669,7 @@ int __init pcibios_init(void)
 	resource_size_t offset;
 	LIST_HEAD(resources);
 	int next_busno;
+	struct pci_host_bridge *bridge;
 	int i;
 
 	tile_pci_init();
@@ -881,15 +882,25 @@ int __init pcibios_init(void)
 					controller->mem_offset);
 		pci_add_resource(&resources, &controller->io_space);
 		controller->first_busno = next_busno;
-		bus = pci_scan_root_bus(NULL, next_busno, controller->ops,
-					controller, &resources);
+
+		bridge = pci_alloc_host_bridge(0);
+		if (!bridge)
+			break;
+
+		list_splice_init(&resources, &bridge->windows);
+		bridge->dev.parent = NULL;
+		bridge->sysdata = controller;
+		bridge->busnr = next_busno;
+		bridge->ops = controller->ops;
+		bridge->swizzle_irq = pci_common_swizzle;
+		bridge->map_irq = tile_map_irq;
+
+		pci_scan_root_bus_bridge(bridge);
+		bus = bridge->bus;
 		controller->root_bus = bus;
 		next_busno = bus->busn_res.end + 1;
 	}
 
-	/* Do machine dependent PCI interrupt routing */
-	pci_fixup_irqs(pci_common_swizzle, tile_map_irq);
-
 	/*
 	 * This comes from the generic Linux PCI driver.
 	 *
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 7/9] unicore32/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (5 preceding siblings ...)
  2017-07-31 16:37 ` [RFT PATCH 6/9] tile/PCI: " Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 8/9] sparc/PCI: " Lorenzo Pieralisi
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Bjorn Helgaas, Guan Xuetao,
	Arnd Bergmann, Matthew Minter, Tanmay Inamdar, Rich Felker,
	Yoshinori Sato, Richard Henderson, Ivan Kokshaysky,
	Geert Uytterhoeven, Ralf Baechle, Paul Burton, Chris Metcalf,
	David S. Miller

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus
trees (and possibly rooted at different host bridges) and may well be
enabled (ie probed and bound to a driver) by the time pci_fixup_irqs()
is called when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to assign
legacy PCI IRQs to devices does not work at all for hotplugged devices
in that the code carrying out the IRQ fixup is called at host bridge
driver probe time, which just cannot take into account devices
hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

Convert PCI host bridge initialization code to the
pci_scan_root_bus_bridge() API (that allows to pass a struct
pci_host_bridge with initialized map/swizzle pointers) and remove the
pci_fixup_irqs() call from arch code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 arch/unicore32/kernel/pci.c | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index 1053bca..9f26840 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -101,7 +101,7 @@ void pci_puv3_preinit(void)
 	writel(readl(PCIBRI_CMD) | PCIBRI_CMD_IO | PCIBRI_CMD_MEM, PCIBRI_CMD);
 }
 
-static int __init pci_puv3_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
+static int pci_puv3_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
 	if (dev->bus->number == 0) {
 #ifdef CONFIG_ARCH_FPGA /* 4 pci slots */
@@ -252,19 +252,46 @@ void pcibios_fixup_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL(pcibios_fixup_bus);
 
+static struct resource busn_resource = {
+	.name	= "PCI busn",
+	.start	= 0,
+	.end	= 255,
+	.flags	= IORESOURCE_BUS,
+};
+
 static int __init pci_common_init(void)
 {
 	struct pci_bus *puv3_bus;
+	struct pci_host_bridge *bridge;
+	int ret;
+
+	bridge = pci_alloc_host_bridge(0);
+	if (!bridge)
+		return -ENOMEM;
 
 	pci_puv3_preinit();
 
-	puv3_bus = pci_scan_bus(0, &pci_puv3_ops, NULL);
+	pci_add_resource(&bridge->windows, &ioport_resource);
+	pci_add_resource(&bridge->windows, &iomem_resource);
+	pci_add_resource(&bridge->windows, &busn_resource);
+	bridge->sysdata = NULL;
+	bridge->busnr = 0;
+	bridge->ops = &pci_puv3_ops;
+	bridge->swizzle_irq = pci_common_swizzle;
+	bridge->map_irq = pci_puv3_map_irq;
+
+	/* Scan our single hose.  */
+	ret = pci_scan_root_bus_bridge(bridge);
+	if (ret) {
+		pci_free_host_bridge(bridge);
+		return;
+	}
+
+	puv3_bus = bridge->bus;
 
 	if (!puv3_bus)
 		panic("PCI: unable to scan bus!");
 
-	pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
-
 	pci_bus_size_bridges(puv3_bus);
 	pci_bus_assign_resources(puv3_bus);
 	pci_bus_add_devices(puv3_bus);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 8/9] sparc/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (6 preceding siblings ...)
  2017-07-31 16:37 ` [RFT PATCH 7/9] unicore32/PCI: " Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-07-31 16:37 ` [RFT PATCH 9/9] PCI: Remove pci_fixup_irqs() function Lorenzo Pieralisi
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Lorenzo Pieralisi, Bjorn Helgaas, David S. Miller,
	Arnd Bergmann, Matthew Minter, Tanmay Inamdar, Rich Felker,
	Yoshinori Sato, Richard Henderson, Ivan Kokshaysky,
	Geert Uytterhoeven, Ralf Baechle, Paul Burton, Chris Metcalf,
	Guan Xuetao

The pci_fixup_irqs() function allocates IRQs for all PCI devices present
in a system; those PCI devices possibly belong to different PCI bus
trees (and possibly rooted at different host bridges) and may well be
enabled (ie probed and bound to a driver) by the time pci_fixup_irqs()
is called when probing a given host bridge driver.

Furthermore, current kernel code relying on pci_fixup_irqs() to assign
legacy PCI IRQs to devices does not work at all for hotplugged devices
in that the code carrying out the IRQ fixup is called at host bridge
driver probe time, which just cannot take into account devices
hotplugged after system has booted.

The introduction of map/swizzle functions hook in struct pci_host_bridge
allows to define per-bridge map/swizzle functions, that can be used at
device probe time in PCI core code to allocate IRQs for a given device
(through pci_assign_irq()).

Convert PCI host bridge initialization code to the
pci_scan_root_bus_bridge() API (that allows to pass a struct
pci_host_bridge with initialized map/swizzle pointers) and remove the
pci_fixup_irqs() call from arch code.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
---
 arch/sparc/kernel/leon_pci.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 4371f72..7b5c707 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -25,6 +25,12 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 {
 	LIST_HEAD(resources);
 	struct pci_bus *root_bus;
+	struct pci_host_bridge *bridge;
+	int ret;
+
+	bridge = pci_alloc_host_bridge(0);
+	if (!bridge)
+		return;
 
 	pci_add_resource_offset(&resources, &info->io_space,
 				info->io_space.start - 0x1000);
@@ -32,15 +38,21 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
 	info->busn.flags = IORESOURCE_BUS;
 	pci_add_resource(&resources, &info->busn);
 
-	root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
-				     &resources);
-	if (!root_bus) {
-		pci_free_resource_list(&resources);
+	list_splice_init(&resources, &bridge->windows);
+	bridge->dev.parent = &ofdev->dev;
+	bridge->sysdata = info;
+	bridge->busnr = 0;
+	bridge->ops = info->ops;
+	bridge->swizzle_irq = pci_common_swizzle;
+	bridge->map_irq = info->map_irq;
+
+	ret = pci_scan_root_bus_bridge(bridge);
+	if (ret) {
+		pci_free_host_bridge(bridge);
 		return;
 	}
 
-	/* Setup IRQs of all devices using custom routines */
-	pci_fixup_irqs(pci_common_swizzle, info->map_irq);
+	root_bus = bridge->bus;
 
 	/* Assign devices with resources */
 	pci_assign_unassigned_resources();
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [RFT PATCH 9/9] PCI: Remove pci_fixup_irqs() function
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (7 preceding siblings ...)
  2017-07-31 16:37 ` [RFT PATCH 8/9] sparc/PCI: " Lorenzo Pieralisi
@ 2017-07-31 16:37 ` Lorenzo Pieralisi
  2017-08-03 21:35 ` [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Bjorn Helgaas
  2017-08-10 17:52 ` [PATCH] PCI: Inline and remove pcibios_update_irq() Bjorn Helgaas
  10 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-07-31 16:37 UTC (permalink / raw)
  To: linux-pci
  Cc: linux-kernel, Matthew Minter, Lorenzo Pieralisi, Arnd Bergmann,
	Bjorn Helgaas, Tanmay Inamdar, Rich Felker, Yoshinori Sato,
	Richard Henderson, Ivan Kokshaysky, Geert Uytterhoeven,
	Ralf Baechle, Paul Burton, Chris Metcalf, Guan Xuetao,
	David S. Miller

From: Matthew Minter <matt@masarand.com>

Now we have removed all callers of pci_fixup_irqs() and
migrated everything to pci_assign_irq() delete the
pci_fixup_irqs() function completely.

Signed-off-by: Matthew Minter <matt@masarand.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
---
 drivers/pci/setup-irq.c | 24 ------------------------
 include/linux/pci.h     |  2 --
 2 files changed, 26 deletions(-)

diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c
index 81eda3d..69e3b56 100644
--- a/drivers/pci/setup-irq.c
+++ b/drivers/pci/setup-irq.c
@@ -67,27 +67,3 @@ void pci_assign_irq(struct pci_dev *dev)
 	   the real IRQ to use; the device does not use it. */
 	pcibios_update_irq(dev, irq);
 }
-
-void pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
-		    int (*map_irq)(const struct pci_dev *, u8, u8))
-{
-	/*
-	 * Implement pci_fixup_irqs() through pci_assign_irq().
-	 * This code should be remove eventually, it is a wrapper
-	 * around pci_assign_irq() interface to keep current
-	 * pci_fixup_irqs() behaviour unchanged on architecture
-	 * code still relying on its interface.
-	 */
-	struct pci_dev *dev = NULL;
-	struct pci_host_bridge *hbrg = NULL;
-
-	for_each_pci_dev(dev) {
-		hbrg = pci_find_host_bridge(dev->bus);
-		hbrg->swizzle_irq = swizzle;
-		hbrg->map_irq = map_irq;
-		pci_assign_irq(dev);
-		hbrg->swizzle_irq = NULL;
-		hbrg->map_irq = NULL;
-	}
-}
-EXPORT_SYMBOL_GPL(pci_fixup_irqs);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 4869e66..69034ab 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1160,8 +1160,6 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus);
 void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus);
 void pdev_enable_device(struct pci_dev *);
 int pci_enable_resources(struct pci_dev *, int mask);
-void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
-		    int (*)(const struct pci_dev *, u8, u8));
 void pci_assign_irq(struct pci_dev *dev);
 struct resource *pci_find_resource(struct pci_dev *dev, struct resource *res);
 #define HAVE_PCI_REQ_REGIONS	2
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs()
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (8 preceding siblings ...)
  2017-07-31 16:37 ` [RFT PATCH 9/9] PCI: Remove pci_fixup_irqs() function Lorenzo Pieralisi
@ 2017-08-03 21:35 ` Bjorn Helgaas
  2017-08-04 15:08   ` Lorenzo Pieralisi
  2017-08-10 17:52 ` [PATCH] PCI: Inline and remove pcibios_update_irq() Bjorn Helgaas
  10 siblings, 1 reply; 13+ messages in thread
From: Bjorn Helgaas @ 2017-08-03 21:35 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: linux-pci, linux-kernel, Ralf Baechle, Arnd Bergmann,
	Paul Burton, Rich Felker, Bjorn Helgaas, Richard Henderson,
	Tanmay Inamdar, Ivan Kokshaysky, Chris Metcalf, David S. Miller,
	Matthew Minter, Yoshinori Sato, Geert Uytterhoeven, Guan Xuetao

On Mon, Jul 31, 2017 at 05:37:48PM +0100, Lorenzo Pieralisi wrote:
> The pci_fixup_irqs() function allocates IRQs for all PCI devices present
> in a system; those PCI devices possibly belong to different PCI bus trees
> (and possibly rooted at different host bridges) and may well be enabled
> (ie probed and bound to a driver) by the time pci_fixup_irqs() is called
> when probing a given host bridge driver.
> 
> Furthermore, current kernel code relying on pci_fixup_irqs() to
> assign legacy PCI IRQs to devices does not work at all for
> hotplugged devices in that the code carrying out the IRQ fixup
> is called at host bridge driver probe time, which just cannot take
> into account devices hotplugged after system has booted.
> 
> The introduction of map/swizzle functions hook in struct pci_host_bridge
> allows to define per-bridge map/swizzle functions, that can be used at
> device probe time in PCI core code to allocate IRQs for a given device
> (through pci_assign_irq()).
> 
> This series converts all arches still relying on pci_fixup_irqs() to
> the new pci_scan_root_bus_bridge() API and consequently remove
> pci_fixup_irqs() from the kernel in that it is not used anymore.
> 
> Compile tested only, I do not have the necessary hardware.

Yay!  I applied this to pci/irq-fixups for v4.14.

Huge thanks to both Matthew and Lorenzo for all the hard work it took
to make this happen!

> [1] git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/linux.git pci/pci-fixup-irqs-removal
> 
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Paul Burton <paul.burton@imgtec.com>
> Cc: Rich Felker <dalias@libc.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Tanmay Inamdar <tinamdar@apm.com>
> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> Cc: Chris Metcalf <cmetcalf@mellanox.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Matthew Minter <matt@masarand.com>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> 
> Lorenzo Pieralisi (7):
>   sh/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping
>     hooks
>   alpha/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
>     mapping hooks
>   m68k/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
>     mapping hooks
>   MIPS/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
>     mapping hooks
>   tile/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
>     mapping hooks
>   unicore32/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
>     mapping hooks
>   sparc/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
>     mapping hooks
> 
> Matthew Minter (2):
>   sh/PCI: Remove __init optimisations from IRQ mapping functions/data
>   PCI: Remove pci_fixup_irqs() function
> 
>  arch/alpha/kernel/pci.c                 | 27 ++++++++++++++++------
>  arch/alpha/kernel/sys_nautilus.c        | 31 +++++++++++++++++++++----
>  arch/m68k/coldfire/pci.c                | 36 +++++++++++++++++++++++++----
>  arch/mips/pci/pci-legacy.c              | 24 +++++++++++++------
>  arch/sh/drivers/pci/fixups-cayman.c     |  2 +-
>  arch/sh/drivers/pci/fixups-dreamcast.c  |  2 +-
>  arch/sh/drivers/pci/fixups-r7780rp.c    |  2 +-
>  arch/sh/drivers/pci/fixups-rts7751r2d.c |  6 ++---
>  arch/sh/drivers/pci/fixups-sdk7780.c    |  4 ++--
>  arch/sh/drivers/pci/fixups-se7751.c     |  2 +-
>  arch/sh/drivers/pci/fixups-sh03.c       |  2 +-
>  arch/sh/drivers/pci/fixups-snapgear.c   |  2 +-
>  arch/sh/drivers/pci/fixups-titan.c      |  4 ++--
>  arch/sh/drivers/pci/pci.c               | 41 ++++++++++++++++++++-------------
>  arch/sh/drivers/pci/pcie-sh7786.c       |  2 +-
>  arch/sparc/kernel/leon_pci.c            | 24 ++++++++++++++-----
>  arch/tile/kernel/pci.c                  | 21 +++++++++++++----
>  arch/tile/kernel/pci_gx.c               | 21 +++++++++++++----
>  arch/unicore32/kernel/pci.c             | 35 ++++++++++++++++++++++++----
>  drivers/pci/setup-irq.c                 | 24 -------------------
>  include/linux/pci.h                     |  2 --
>  21 files changed, 216 insertions(+), 98 deletions(-)
> 
> -- 
> 2.10.0
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs()
  2017-08-03 21:35 ` [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Bjorn Helgaas
@ 2017-08-04 15:08   ` Lorenzo Pieralisi
  0 siblings, 0 replies; 13+ messages in thread
From: Lorenzo Pieralisi @ 2017-08-04 15:08 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-pci, linux-kernel, Ralf Baechle, Arnd Bergmann,
	Paul Burton, Rich Felker, Bjorn Helgaas, Richard Henderson,
	Tanmay Inamdar, Ivan Kokshaysky, Chris Metcalf, David S. Miller,
	Matthew Minter, Yoshinori Sato, Geert Uytterhoeven, Guan Xuetao

On Thu, Aug 03, 2017 at 04:35:03PM -0500, Bjorn Helgaas wrote:
> On Mon, Jul 31, 2017 at 05:37:48PM +0100, Lorenzo Pieralisi wrote:
> > The pci_fixup_irqs() function allocates IRQs for all PCI devices present
> > in a system; those PCI devices possibly belong to different PCI bus trees
> > (and possibly rooted at different host bridges) and may well be enabled
> > (ie probed and bound to a driver) by the time pci_fixup_irqs() is called
> > when probing a given host bridge driver.
> > 
> > Furthermore, current kernel code relying on pci_fixup_irqs() to
> > assign legacy PCI IRQs to devices does not work at all for
> > hotplugged devices in that the code carrying out the IRQ fixup
> > is called at host bridge driver probe time, which just cannot take
> > into account devices hotplugged after system has booted.
> > 
> > The introduction of map/swizzle functions hook in struct pci_host_bridge
> > allows to define per-bridge map/swizzle functions, that can be used at
> > device probe time in PCI core code to allocate IRQs for a given device
> > (through pci_assign_irq()).
> > 
> > This series converts all arches still relying on pci_fixup_irqs() to
> > the new pci_scan_root_bus_bridge() API and consequently remove
> > pci_fixup_irqs() from the kernel in that it is not used anymore.
> > 
> > Compile tested only, I do not have the necessary hardware.
> 
> Yay!  I applied this to pci/irq-fixups for v4.14.
> 
> Huge thanks to both Matthew and Lorenzo for all the hard work it took
> to make this happen!

Thank you (and Matt), I hope this will be enough to prevent people from
using pci_fixup_irqs() from now on :)

I would appreciate help in testing this series - it is a mechanical
change but that does not mean I have not added regressions - hopefully
CC'ed maintainers can help with that and -next exposure too.

Thank you !
Lorenzo

> > [1] git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/linux.git pci/pci-fixup-irqs-removal
> > 
> > Cc: Ralf Baechle <ralf@linux-mips.org>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Paul Burton <paul.burton@imgtec.com>
> > Cc: Rich Felker <dalias@libc.org>
> > Cc: Bjorn Helgaas <bhelgaas@google.com>
> > Cc: Richard Henderson <rth@twiddle.net>
> > Cc: Tanmay Inamdar <tinamdar@apm.com>
> > Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
> > Cc: Chris Metcalf <cmetcalf@mellanox.com>
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: Matthew Minter <matt@masarand.com>
> > Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
> > 
> > Lorenzo Pieralisi (7):
> >   sh/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping
> >     hooks
> >   alpha/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
> >     mapping hooks
> >   m68k/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
> >     mapping hooks
> >   MIPS/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
> >     mapping hooks
> >   tile/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
> >     mapping hooks
> >   unicore32/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
> >     mapping hooks
> >   sparc/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ
> >     mapping hooks
> > 
> > Matthew Minter (2):
> >   sh/PCI: Remove __init optimisations from IRQ mapping functions/data
> >   PCI: Remove pci_fixup_irqs() function
> > 
> >  arch/alpha/kernel/pci.c                 | 27 ++++++++++++++++------
> >  arch/alpha/kernel/sys_nautilus.c        | 31 +++++++++++++++++++++----
> >  arch/m68k/coldfire/pci.c                | 36 +++++++++++++++++++++++++----
> >  arch/mips/pci/pci-legacy.c              | 24 +++++++++++++------
> >  arch/sh/drivers/pci/fixups-cayman.c     |  2 +-
> >  arch/sh/drivers/pci/fixups-dreamcast.c  |  2 +-
> >  arch/sh/drivers/pci/fixups-r7780rp.c    |  2 +-
> >  arch/sh/drivers/pci/fixups-rts7751r2d.c |  6 ++---
> >  arch/sh/drivers/pci/fixups-sdk7780.c    |  4 ++--
> >  arch/sh/drivers/pci/fixups-se7751.c     |  2 +-
> >  arch/sh/drivers/pci/fixups-sh03.c       |  2 +-
> >  arch/sh/drivers/pci/fixups-snapgear.c   |  2 +-
> >  arch/sh/drivers/pci/fixups-titan.c      |  4 ++--
> >  arch/sh/drivers/pci/pci.c               | 41 ++++++++++++++++++++-------------
> >  arch/sh/drivers/pci/pcie-sh7786.c       |  2 +-
> >  arch/sparc/kernel/leon_pci.c            | 24 ++++++++++++++-----
> >  arch/tile/kernel/pci.c                  | 21 +++++++++++++----
> >  arch/tile/kernel/pci_gx.c               | 21 +++++++++++++----
> >  arch/unicore32/kernel/pci.c             | 35 ++++++++++++++++++++++++----
> >  drivers/pci/setup-irq.c                 | 24 -------------------
> >  include/linux/pci.h                     |  2 --
> >  21 files changed, 216 insertions(+), 98 deletions(-)
> > 
> > -- 
> > 2.10.0
> > 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH] PCI: Inline and remove pcibios_update_irq()
  2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
                   ` (9 preceding siblings ...)
  2017-08-03 21:35 ` [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Bjorn Helgaas
@ 2017-08-10 17:52 ` Bjorn Helgaas
  10 siblings, 0 replies; 13+ messages in thread
From: Bjorn Helgaas @ 2017-08-10 17:52 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: linux-pci, linux-kernel, Ralf Baechle, Arnd Bergmann,
	Paul Burton, Rich Felker, Bjorn Helgaas, Richard Henderson,
	Tanmay Inamdar, Ivan Kokshaysky, Chris Metcalf, David S. Miller,
	Matthew Minter, Yoshinori Sato, Geert Uytterhoeven, Guan Xuetao

On Mon, Jul 31, 2017 at 05:37:48PM +0100, Lorenzo Pieralisi wrote:
> The pci_fixup_irqs() function allocates IRQs for all PCI devices present
> in a system; those PCI devices possibly belong to different PCI bus trees
> (and possibly rooted at different host bridges) and may well be enabled
> (ie probed and bound to a driver) by the time pci_fixup_irqs() is called
> when probing a given host bridge driver.
> 
> Furthermore, current kernel code relying on pci_fixup_irqs() to
> assign legacy PCI IRQs to devices does not work at all for
> hotplugged devices in that the code carrying out the IRQ fixup
> is called at host bridge driver probe time, which just cannot take
> into account devices hotplugged after system has booted.
> 
> The introduction of map/swizzle functions hook in struct pci_host_bridge
> allows to define per-bridge map/swizzle functions, that can be used at
> device probe time in PCI core code to allocate IRQs for a given device
> (through pci_assign_irq()).
> 
> This series converts all arches still relying on pci_fixup_irqs() to
> the new pci_scan_root_bus_bridge() API and consequently remove
> pci_fixup_irqs() from the kernel in that it is not used anymore.

I tentatively applied the following patch on top of this series on
pci/irq-fixups for v4.14.  Any comments welcome.

commit 606799cc5049ae4ccb51ba3242365ca2d411da13
Author: Bjorn Helgaas <bhelgaas@google.com>
Date:   Thu Aug 10 12:49:57 2017 -0500

    PCI: Inline and remove pcibios_update_irq()
    
    pcibios_update_irq() was a weak function with only one trivial
    implementation.  Inline it and remove the weak function.
    
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c
index 69e3b56c32a4..86106c44ce94 100644
--- a/drivers/pci/setup-irq.c
+++ b/drivers/pci/setup-irq.c
@@ -17,12 +17,6 @@
 #include <linux/cache.h>
 #include "pci.h"
 
-void __weak pcibios_update_irq(struct pci_dev *dev, int irq)
-{
-	dev_dbg(&dev->dev, "assigning IRQ %02d\n", irq);
-	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
-}
-
 void pci_assign_irq(struct pci_dev *dev)
 {
 	u8 pin;
@@ -65,5 +59,5 @@ void pci_assign_irq(struct pci_dev *dev)
 
 	/* Always tell the device, so the driver knows what is
 	   the real IRQ to use; the device does not use it. */
-	pcibios_update_irq(dev, irq);
+	pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
 }
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 69034ab8a68e..a9e8d2f3bd91 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -844,7 +844,6 @@ char *pcibios_setup(char *str);
 resource_size_t pcibios_align_resource(void *, const struct resource *,
 				resource_size_t,
 				resource_size_t);
-void pcibios_update_irq(struct pci_dev *, int irq);
 
 /* Weak but can be overriden by arch */
 void pci_fixup_cardbus(struct pci_bus *);

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-08-10 17:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-31 16:37 [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 2/9] sh/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 3/9] alpha/PCI: " Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 4/9] m68k/PCI: " Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 5/9] MIPS/PCI: " Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 6/9] tile/PCI: " Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 7/9] unicore32/PCI: " Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 8/9] sparc/PCI: " Lorenzo Pieralisi
2017-07-31 16:37 ` [RFT PATCH 9/9] PCI: Remove pci_fixup_irqs() function Lorenzo Pieralisi
2017-08-03 21:35 ` [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Bjorn Helgaas
2017-08-04 15:08   ` Lorenzo Pieralisi
2017-08-10 17:52 ` [PATCH] PCI: Inline and remove pcibios_update_irq() Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).