Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700189 > unrolled thread

[RFT PATCH 0/9] PCI: Remove pci_fixup_irqs()

Started byLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
First post2017-07-31 18:40 +0200
Last post2017-08-10 20:00 +0200
Articles 8 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-31 18:40 +0200
    [RFT PATCH 6/9] tile/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-31 18:40 +0200
    [RFT PATCH 9/9] PCI: Remove pci_fixup_irqs() function Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-31 18:40 +0200
    [RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-31 18:40 +0200
    [RFT PATCH 4/9] m68k/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-07-31 18:40 +0200
    Re: [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Bjorn Helgaas <helgaas@kernel.org> - 2017-08-03 23:40 +0200
      Re: [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs() Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2017-08-04 17:10 +0200
    [PATCH] PCI: Inline and remove pcibios_update_irq() Bjorn Helgaas <helgaas@kernel.org> - 2017-08-10 20:00 +0200

#1700189 — [RFT PATCH 0/9] PCI: Remove pci_fixup_irqs()

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-31 18:40 +0200
Subject[RFT PATCH 0/9] PCI: Remove pci_fixup_irqs()
Message-ID<u9lTz-6F-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1700190 — [RFT PATCH 6/9] tile/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-31 18:40 +0200
Subject[RFT PATCH 6/9] tile/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
Message-ID<u9lTA-6F-33@gated-at.bofh.it>
In reply to#1700189
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

[toc] | [prev] | [next] | [standalone]


#1700192 — [RFT PATCH 9/9] PCI: Remove pci_fixup_irqs() function

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-31 18:40 +0200
Subject[RFT PATCH 9/9] PCI: Remove pci_fixup_irqs() function
Message-ID<u9lTA-6F-37@gated-at.bofh.it>
In reply to#1700189
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

[toc] | [prev] | [next] | [standalone]


#1700193 — [RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-31 18:40 +0200
Subject[RFT PATCH 1/9] sh/PCI: Remove __init optimisations from IRQ mapping functions/data
Message-ID<u9lTA-6F-41@gated-at.bofh.it>
In reply to#1700189
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

[toc] | [prev] | [next] | [standalone]


#1700194 — [RFT PATCH 4/9] m68k/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-07-31 18:40 +0200
Subject[RFT PATCH 4/9] m68k/PCI: Replace pci_fixup_irqs() call with PCI host bridge IRQ mapping hooks
Message-ID<u9lTA-6F-39@gated-at.bofh.it>
In reply to#1700189
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

[toc] | [prev] | [next] | [standalone]


#1703442

FromBjorn Helgaas <helgaas@kernel.org>
Date2017-08-03 23:40 +0200
Message-ID<uaw0z-5OT-33@gated-at.bofh.it>
In reply to#1700189
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
> 

[toc] | [prev] | [next] | [standalone]


#1704061

FromLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Date2017-08-04 17:10 +0200
Message-ID<uaMoG-br-9@gated-at.bofh.it>
In reply to#1703442
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
> > 

[toc] | [prev] | [next] | [standalone]


#1708933 — [PATCH] PCI: Inline and remove pcibios_update_irq()

FromBjorn Helgaas <helgaas@kernel.org>
Date2017-08-10 20:00 +0200
Subject[PATCH] PCI: Inline and remove pcibios_update_irq()
Message-ID<ucZUt-nG-9@gated-at.bofh.it>
In reply to#1700189
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 *);

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web