Skip to contentSkip to conversation

irqchip: MSI parent cleanup and PCI host driver conversion

PATCH Applied Marc Zyngier 4 participants 23 messages May 13, 2025 – May 16, 2025

Subsystems (17)
lore
Share & tools
lore

Marc Zyngier

author maintainer
#0 lore raw

v2 cover irqchip: MSI parent cleanup and PCI host driver conversion

This is v2 of a series I posted[1] a few months back before running out of time, energy, and interest. I have now reduced it to the stuff I actually care about, and got rid of all things non-arm64.

I've become annoyed by the couple of machines I have around that haven't been converted to the per-device MSI infrastructure. At the same time, I've also moaned at the amount of boilerplate code required to make use of this infrastructure.

This series therefore does a number of things:

- make irq-msi-lib.h globally available, so that PCI (and other subsystems) may make use of it

- add a new helper (msi_create_parent_irq_domain()) that encapsulates most of the magic required to create an MSI-parent domain

- convert the arm64 I have access to (and *only* that)

- convert the Apple, XGene and Tegra MSI drivers to the MSI-parent infrastructure, which is why I came here the first place.

* From v1 [1]:

- use irq_domain_info as an the holder of most information required to instantiate the domain. I decided against using a specific structure, because they would mostly have the same fields.

- added a patch to convert the Tegra driver, which required dealing with the MSI_FLAG_NO_AFFINITY flag

- got rid of x86 and riscv patches (life is too short).

[1] https://lore.kernel.org/all/[email protected]

Marc Zyngier (9):
irqchip: Make irq-msi-lib.h globally available genirq/msi: Add helper for creating MSI-parent irq domains irqchip/gic: Convert to msi_create_parent_irq_domain() helper irqchip/mvebu: Convert to msi_create_parent_irq_domain() helper
irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag
PCI: apple: Convert to MSI parent infrastructure
PCI: xgene: Convert to MSI parent infrastructure
PCI: tegra: Convert to MSI parent infrastructure

 drivers/irqchip/irq-bcm2712-mip.c             |  2 +-
 drivers/irqchip/irq-gic-v2m.c                 | 16 ++---
 drivers/irqchip/irq-gic-v3-its-msi-parent.c   |  4 +-
 drivers/irqchip/irq-gic-v3-its.c              | 21 +++----
 drivers/irqchip/irq-gic-v3-mbi.c              | 15 ++---
 drivers/irqchip/irq-imx-mu-msi.c              |  2 +-
 drivers/irqchip/irq-loongarch-avec.c          |  2 +-
 drivers/irqchip/irq-loongson-pch-msi.c        |  2 +-
 drivers/irqchip/irq-msi-lib.c                 |  9 ++-
 drivers/irqchip/irq-mvebu-gicp.c              | 18 +++---
 drivers/irqchip/irq-mvebu-icu.c               |  2 +-
 drivers/irqchip/irq-mvebu-odmi.c              | 18 +++---
 drivers/irqchip/irq-mvebu-sei.c               | 18 +++---
 drivers/irqchip/irq-riscv-imsic-platform.c    |  2 +-
 drivers/irqchip/irq-sg2042-msi.c              |  2 +-
 drivers/pci/controller/Kconfig                |  3 +
 drivers/pci/controller/pci-tegra.c            | 60 ++++++------------
 drivers/pci/controller/pci-xgene-msi.c        | 46 +++++---------
 drivers/pci/controller/pcie-apple.c           | 62 +++++++------------
 .../linux}/irqchip/irq-msi-lib.h              |  6 +-
 include/linux/msi.h                           |  4 ++
 kernel/irq/msi.c                              | 26 ++++++++
 22 files changed, 160 insertions(+), 180 deletions(-)
 rename {drivers => include/linux}/irqchip/irq-msi-lib.h (84%)
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v2 1/9 irqchip: Make irq-msi-lib.h globally available

Move irq-msi-lib.h into include/linux/irqchip, making it available to compilation units outside of drivers/irqchip.

This requires some churn in drivers to fetch it from the new location, generated using this script:

	git grep -l -w \"irq-msi-lib.h\" | \
	xargs sed -i -e 's:"irq-msi-lib.h":\<linux/irqchip/irq-msi-lib.h\>:'
---
 drivers/irqchip/irq-bcm2712-mip.c                | 2 +-
 drivers/irqchip/irq-gic-v2m.c                    | 2 +-
 drivers/irqchip/irq-gic-v3-its-msi-parent.c      | 2 +-
 drivers/irqchip/irq-gic-v3-its.c                 | 2 +-
 drivers/irqchip/irq-gic-v3-mbi.c                 | 2 +-
 drivers/irqchip/irq-imx-mu-msi.c                 | 2 +-
 drivers/irqchip/irq-loongarch-avec.c             | 2 +-
 drivers/irqchip/irq-loongson-pch-msi.c           | 2 +-
 drivers/irqchip/irq-msi-lib.c                    | 2 +-
 drivers/irqchip/irq-mvebu-gicp.c                 | 2 +-
 drivers/irqchip/irq-mvebu-icu.c                  | 2 +-
 drivers/irqchip/irq-mvebu-odmi.c                 | 2 +-
 drivers/irqchip/irq-mvebu-sei.c                  | 2 +-
 drivers/irqchip/irq-riscv-imsic-platform.c       | 2 +-
 drivers/irqchip/irq-sg2042-msi.c                 | 2 +-
 {drivers => include/linux}/irqchip/irq-msi-lib.h | 6 +++---
 16 files changed, 18 insertions(+), 18 deletions(-)
 rename {drivers => include/linux}/irqchip/irq-msi-lib.h (84%)
drivers/irqchip/irq-bcm2712-mip.c +1 -1
index 49a19db2d1e1b..f04a42b16cca0 100644
@@ -11,7 +11,7 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define MIP_INT_RAISE		0x00
 #define MIP_INT_CLEAR		0x10
drivers/irqchip/irq-gic-v2m.c +1 -1
index c698948618666..62676994d0695 100644
@@ -26,7 +26,7 @@
 #include <linux/irqchip/arm-gic.h>
 #include <linux/irqchip/arm-gic-common.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 /*
 * MSI_TYPER:
drivers/irqchip/irq-gic-v3-its-msi-parent.c +1 -1
index 68f9ba4085ce5..51cc961bc3181 100644
@@ -8,7 +8,7 @@
 #include <linux/pci.h>
 
 #include "irq-gic-common.h"
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define ITS_MSI_FLAGS_REQUIRED  (MSI_FLAG_USE_DEF_DOM_OPS |	\
 				 MSI_FLAG_USE_DEF_CHIP_OPS |	\
drivers/irqchip/irq-gic-v3-its.c +1 -1
index fd6e7c170d37e..9e6380f597488 100644
@@ -41,7 +41,7 @@
 #include <asm/exception.h>
 
 #include "irq-gic-common.h"
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING		(1ULL << 0)
 #define ITS_FLAGS_WORKAROUND_CAVIUM_22375	(1ULL << 1)
drivers/irqchip/irq-gic-v3-mbi.c +1 -1
index 34e9ca77a8c36..e562b57923229 100644
@@ -18,7 +18,7 @@
 
 #include <linux/irqchip/arm-gic-v3.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 struct mbi_range {
 	u32			spi_start;
drivers/irqchip/irq-imx-mu-msi.c +1 -1
index 69aacdfc8bef0..137da1927d144 100644
@@ -24,7 +24,7 @@
 #include <linux/pm_domain.h>
 #include <linux/spinlock.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define IMX_MU_CHANS            4
 
drivers/irqchip/irq-loongarch-avec.c +1 -1
index 80e55955a29fa..bf52dc8345f5f 100644
@@ -18,7 +18,7 @@
 #include <asm/loongarch.h>
 #include <asm/setup.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 #include "irq-loongson.h"
 
 #define VECTORS_PER_REG		64
drivers/irqchip/irq-loongson-pch-msi.c +1 -1
index 9c62108b3ad58..fb690c7cbcaa6 100644
@@ -15,7 +15,7 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 #include "irq-loongson.h"
 
 static int nr_pics;
drivers/irqchip/irq-msi-lib.c +1 -1
index 51464c6257f37..2a61c06c4da07 100644
@@ -4,7 +4,7 @@
 
 #include <linux/export.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 /**
  * msi_lib_init_dev_msi_info - Domain info setup for MSI domains
drivers/irqchip/irq-mvebu-gicp.c +1 -1
index d67f93f6d7505..0b2a857b49018 100644
@@ -17,7 +17,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
drivers/irqchip/irq-mvebu-icu.c +1 -1
index 4eebed39880a5..db5dbc6e88b05 100644
@@ -20,7 +20,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #include <dt-bindings/interrupt-controller/mvebu-icu.h>
 
drivers/irqchip/irq-mvebu-odmi.c +1 -1
index 28f7e81df94f0..306a7754e44f8 100644
@@ -18,7 +18,7 @@
 #include <linux/of_address.h>
 #include <linux/slab.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
drivers/irqchip/irq-mvebu-sei.c +1 -1
index ebd4a9014e8da..a962ef4977169 100644
@@ -14,7 +14,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 /* Cause register */
 #define GICP_SECR(idx)		(0x0  + ((idx) * 0x4))
drivers/irqchip/irq-riscv-imsic-platform.c +1 -1
index b8ae67c25b37a..1b9fbfce95816 100644
@@ -20,7 +20,7 @@
 #include <linux/spinlock.h>
 #include <linux/smp.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 #include "irq-riscv-imsic-state.h"
 
 static bool imsic_cpu_page_phys(unsigned int cpu, unsigned int guest_index,
drivers/irqchip/irq-sg2042-msi.c +1 -1
index ee682e87eb8be..d641f3a5eee9e 100644
@@ -17,7 +17,7 @@
 #include <linux/property.h>
 #include <linux/slab.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define SG2042_MAX_MSI_VECTOR	32
 
include/linux/irqchip/irq-msi-lib.h renamed from drivers/irqchip/irq-msi-lib.h +3 -3
similarity index 84%
rename from drivers/irqchip/irq-msi-lib.h
rename to include/linux/irqchip/irq-msi-lib.h
index 681ceabb7bc74..dd8d1d1385449 100644
@@ -2,8 +2,8 @@
 // Copyright (C) 2022 Linutronix GmbH
 // Copyright (C) 2022 Intel
 
-#ifndef _DRIVERS_IRQCHIP_IRQ_MSI_LIB_H
-#define _DRIVERS_IRQCHIP_IRQ_MSI_LIB_H
+#ifndef _IRQCHIP_IRQ_MSI_LIB_H
+#define _IRQCHIP_IRQ_MSI_LIB_H
 
 #include <linux/bits.h>
 #include <linux/irqdomain.h>
@@ -24,4 +24,4 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 			       struct irq_domain *real_parent,
 			       struct msi_domain_info *info);
 
-#endif /* _DRIVERS_IRQCHIP_IRQ_MSI_LIB_H */
+#endif /* _IRQCHIP_IRQ_MSI_LIB_H */
Signature · 1 line
2.39.2
merge bot Applied
#2 lore raw

[tip: irq/msi] irqchip: Make irq-msi-lib.h globally available

The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     e51b27438a10391fdc94dd2046d9ffa9c2679c74
Gitweb:        https://git.kernel.org/tip/e51b27438a10391fdc94dd2046d9ffa9c2679c74
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:11 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:19 +02:00

irqchip: Make irq-msi-lib.h globally available

Move irq-msi-lib.h into include/linux/irqchip, making it available to compilation units outside of drivers/irqchip.

This requires some churn in drivers to fetch it from the new location, generated using this script:

	git grep -l -w \"irq-msi-lib.h\" | \
	xargs sed -i -e 's:"irq-msi-lib.h":\<linux/irqchip/irq-msi-lib.h\>:'
---
 drivers/irqchip/irq-bcm2712-mip.c           |  2 +-
 drivers/irqchip/irq-gic-v2m.c               |  2 +-
 drivers/irqchip/irq-gic-v3-its-msi-parent.c |  2 +-
 drivers/irqchip/irq-gic-v3-its.c            |  2 +-
 drivers/irqchip/irq-gic-v3-mbi.c            |  2 +-
 drivers/irqchip/irq-imx-mu-msi.c            |  2 +-
 drivers/irqchip/irq-loongarch-avec.c        |  2 +-
 drivers/irqchip/irq-loongson-pch-msi.c      |  2 +-
 drivers/irqchip/irq-msi-lib.c               |  2 +-
 drivers/irqchip/irq-msi-lib.h               | 27 +--------------------
 drivers/irqchip/irq-mvebu-gicp.c            |  2 +-
 drivers/irqchip/irq-mvebu-icu.c             |  2 +-
 drivers/irqchip/irq-mvebu-odmi.c            |  2 +-
 drivers/irqchip/irq-mvebu-sei.c             |  2 +-
 drivers/irqchip/irq-riscv-imsic-platform.c  |  2 +-
 drivers/irqchip/irq-sg2042-msi.c            |  2 +-
 include/linux/irqchip/irq-msi-lib.h         | 27 ++++++++++++++++++++-
 17 files changed, 42 insertions(+), 42 deletions(-)
 delete mode 100644 drivers/irqchip/irq-msi-lib.h
 create mode 100644 include/linux/irqchip/irq-msi-lib.h
drivers/irqchip/irq-bcm2712-mip.c +1 -1
index 49a19db..f04a42b 100644
@@ -11,7 +11,7 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define MIP_INT_RAISE		0x00
 #define MIP_INT_CLEAR		0x10
drivers/irqchip/irq-gic-v2m.c +1 -1
index c698948..6267699 100644
@@ -26,7 +26,7 @@
 #include <linux/irqchip/arm-gic.h>
 #include <linux/irqchip/arm-gic-common.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 /*
 * MSI_TYPER:
drivers/irqchip/irq-gic-v3-its-msi-parent.c +1 -1
index 6a5f64f..d039ec5 100644
@@ -8,7 +8,7 @@
 #include <linux/pci.h>
 
 #include "irq-gic-common.h"
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define ITS_MSI_FLAGS_REQUIRED  (MSI_FLAG_USE_DEF_DOM_OPS |	\
 				 MSI_FLAG_USE_DEF_CHIP_OPS |	\
drivers/irqchip/irq-gic-v3-its.c +1 -1
index a77f11e..d651cd4 100644
@@ -41,7 +41,7 @@
 #include <asm/exception.h>
 
 #include "irq-gic-common.h"
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING		(1ULL << 0)
 #define ITS_FLAGS_WORKAROUND_CAVIUM_22375	(1ULL << 1)
drivers/irqchip/irq-gic-v3-mbi.c +1 -1
index 34e9ca7..e562b57 100644
@@ -18,7 +18,7 @@
 
 #include <linux/irqchip/arm-gic-v3.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 struct mbi_range {
 	u32			spi_start;
drivers/irqchip/irq-imx-mu-msi.c +1 -1
index 69aacdf..137da19 100644
@@ -24,7 +24,7 @@
 #include <linux/pm_domain.h>
 #include <linux/spinlock.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define IMX_MU_CHANS            4
 
drivers/irqchip/irq-loongarch-avec.c +1 -1
index 80e5595..bf52dc8 100644
@@ -18,7 +18,7 @@
 #include <asm/loongarch.h>
 #include <asm/setup.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 #include "irq-loongson.h"
 
 #define VECTORS_PER_REG		64
drivers/irqchip/irq-loongson-pch-msi.c +1 -1
index 9c62108..fb690c7 100644
@@ -15,7 +15,7 @@
 #include <linux/pci.h>
 #include <linux/slab.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 #include "irq-loongson.h"
 
 static int nr_pics;
drivers/irqchip/irq-msi-lib.c +1 -1
index 51464c6..2a61c06 100644
@@ -4,7 +4,7 @@
 
 #include <linux/export.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 /**
  * msi_lib_init_dev_msi_info - Domain info setup for MSI domains
drivers/irqchip/irq-msi-lib.h deleted +0 -27
deleted file mode 100644
index 681ceab..0000000
@@ -1,27 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// Copyright (C) 2022 Linutronix GmbH
-// Copyright (C) 2022 Intel
-
-#ifndef _DRIVERS_IRQCHIP_IRQ_MSI_LIB_H
-#define _DRIVERS_IRQCHIP_IRQ_MSI_LIB_H
-
-#include <linux/bits.h>
-#include <linux/irqdomain.h>
-#include <linux/msi.h>
-
-#ifdef CONFIG_PCI_MSI
-#define MATCH_PCI_MSI		BIT(DOMAIN_BUS_PCI_MSI)
-#else
-#define MATCH_PCI_MSI		(0)
-#endif
-
-#define MATCH_PLATFORM_MSI	BIT(DOMAIN_BUS_PLATFORM_MSI)
-
-int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec,
-			      enum irq_domain_bus_token bus_token);
-
-bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
-			       struct irq_domain *real_parent,
-			       struct msi_domain_info *info);
-
-#endif /* _DRIVERS_IRQCHIP_IRQ_MSI_LIB_H */
drivers/irqchip/irq-mvebu-gicp.c +1 -1
index d67f93f..0b2a857 100644
@@ -17,7 +17,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
drivers/irqchip/irq-mvebu-icu.c +1 -1
index 4eebed3..db5dbc6 100644
@@ -20,7 +20,7 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #include <dt-bindings/interrupt-controller/mvebu-icu.h>
 
drivers/irqchip/irq-mvebu-odmi.c +1 -1
index 28f7e81..306a775 100644
@@ -18,7 +18,7 @@
 #include <linux/of_address.h>
 #include <linux/slab.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
drivers/irqchip/irq-mvebu-sei.c +1 -1
index ebd4a90..a962ef4 100644
@@ -14,7 +14,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 /* Cause register */
 #define GICP_SECR(idx)		(0x0  + ((idx) * 0x4))
drivers/irqchip/irq-riscv-imsic-platform.c +1 -1
index b8ae67c..1b9fbfc 100644
@@ -20,7 +20,7 @@
 #include <linux/spinlock.h>
 #include <linux/smp.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 #include "irq-riscv-imsic-state.h"
 
 static bool imsic_cpu_page_phys(unsigned int cpu, unsigned int guest_index,
drivers/irqchip/irq-sg2042-msi.c +1 -1
index ee682e8..d641f3a 100644
@@ -17,7 +17,7 @@
 #include <linux/property.h>
 #include <linux/slab.h>
 
-#include "irq-msi-lib.h"
+#include <linux/irqchip/irq-msi-lib.h>
 
 #define SG2042_MAX_MSI_VECTOR	32
 
include/linux/irqchip/irq-msi-lib.h new file +27 -0
new file mode 100644
index 0000000..dd8d1d1
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// Copyright (C) 2022 Linutronix GmbH
+// Copyright (C) 2022 Intel
+
+#ifndef _IRQCHIP_IRQ_MSI_LIB_H
+#define _IRQCHIP_IRQ_MSI_LIB_H
+
+#include <linux/bits.h>
+#include <linux/irqdomain.h>
+#include <linux/msi.h>
+
+#ifdef CONFIG_PCI_MSI
+#define MATCH_PCI_MSI		BIT(DOMAIN_BUS_PCI_MSI)
+#else
+#define MATCH_PCI_MSI		(0)
+#endif
+
+#define MATCH_PLATFORM_MSI	BIT(DOMAIN_BUS_PLATFORM_MSI)
+
+int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec,
+			      enum irq_domain_bus_token bus_token);
+
+bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
+			       struct irq_domain *real_parent,
+			       struct msi_domain_info *info);
+
+#endif /* _IRQCHIP_IRQ_MSI_LIB_H */
author maintainer
#3 lore raw

PATCH v2 2/9 genirq/msi: Add helper for creating MSI-parent irq domains

In reply to Marc Zyngier

Creating an irq domain that serves as an MSI parent requires a substantial amount of esoteric boiler-plate code, some of which is often provided twice (such as the bus token).

To make things a bit simpler for the unsuspecting MSI tinkerer, provide a helper that does it for them, and serves as documentation of what needs to be provided.

---
 include/linux/msi.h |  4 ++++
 kernel/irq/msi.c    | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
include/linux/msi.h +4 -0
index 8c0ec9fc05a39..56c69d14ef4a2 100644
@@ -628,6 +628,10 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
 					 struct msi_domain_info *info,
 					 struct irq_domain *parent);
 
+struct irq_domain_info;
+struct irq_domain *msi_create_parent_irq_domain(struct irq_domain_info *info,
+						const struct msi_parent_ops *msi_parent_ops);
+
 bool msi_create_device_irq_domain(struct device *dev, unsigned int domid,
 				  const struct msi_domain_template *template,
 				  unsigned int hwsize, void *domain_data,
kernel/irq/msi.c +26 -0
index a8f7701c2929f..e702e536c8034 100644
@@ -903,6 +903,32 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
 	return __msi_create_irq_domain(fwnode, info, 0, parent);
 }
 
+/**
+ * msi_create_parent_irq_domain - Create an MSI-parent interrupt domain
+ * @info:		MSI irqdomain creation info
+ * @msi_parent_ops:	MSI parent callbacks and configuration
+ *
+ * Return: pointer to the created &struct irq_domain or %NULL on failure
+ */
+struct irq_domain *msi_create_parent_irq_domain(struct irq_domain_info *info,
+						const struct msi_parent_ops *msi_parent_ops)
+{
+	struct irq_domain *d;
+
+	info->hwirq_max		= max(info->hwirq_max, info->size);
+	info->size		= info->hwirq_max;
+	info->domain_flags	|= IRQ_DOMAIN_FLAG_MSI_PARENT;
+	info->bus_token		= msi_parent_ops->bus_select_token;
+
+	d = irq_domain_instantiate(info);
+	if (IS_ERR(d))
+		return NULL;
+
+	d->msi_parent_ops = msi_parent_ops;
+	return d;
+}
+EXPORT_SYMBOL_GPL(msi_create_parent_irq_domain);
+
 /**
  * msi_parent_init_dev_msi_info - Delegate initialization of device MSI info down
  *				  in the domain hierarchy
Signature · 1 line
2.39.2
merge bot Applied
#4 lore raw

[tip: irq/msi] genirq/msi: Add helper for creating MSI-parent irq domains

The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     e4d001b54f78769ba1a1404c2801ae95e19fd893
Gitweb:        https://git.kernel.org/tip/e4d001b54f78769ba1a1404c2801ae95e19fd893
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:12 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:20 +02:00

genirq/msi: Add helper for creating MSI-parent irq domains

Creating an irq domain that serves as an MSI parent requires a substantial amount of esoteric boiler-plate code, some of which is often provided twice (such as the bus token).

To make things a bit simpler for the unsuspecting MSI tinkerer, provide a helper that does it for them, and serves as documentation of what needs to be provided.

---
 include/linux/msi.h |  4 ++++
 kernel/irq/msi.c    | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
include/linux/msi.h +4 -0
index f4b94cc..6863540 100644
@@ -636,6 +636,10 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
 					 struct msi_domain_info *info,
 					 struct irq_domain *parent);
 
+struct irq_domain_info;
+struct irq_domain *msi_create_parent_irq_domain(struct irq_domain_info *info,
+						const struct msi_parent_ops *msi_parent_ops);
+
 bool msi_create_device_irq_domain(struct device *dev, unsigned int domid,
 				  const struct msi_domain_template *template,
 				  unsigned int hwsize, void *domain_data,
kernel/irq/msi.c +26 -0
index b5559fa..4830b75 100644
@@ -912,6 +912,32 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
 }
 
 /**
+ * msi_create_parent_irq_domain - Create an MSI-parent interrupt domain
+ * @info:		MSI irqdomain creation info
+ * @msi_parent_ops:	MSI parent callbacks and configuration
+ *
+ * Return: pointer to the created &struct irq_domain or %NULL on failure
+ */
+struct irq_domain *msi_create_parent_irq_domain(struct irq_domain_info *info,
+						const struct msi_parent_ops *msi_parent_ops)
+{
+	struct irq_domain *d;
+
+	info->hwirq_max		= max(info->hwirq_max, info->size);
+	info->size		= info->hwirq_max;
+	info->domain_flags	|= IRQ_DOMAIN_FLAG_MSI_PARENT;
+	info->bus_token		= msi_parent_ops->bus_select_token;
+
+	d = irq_domain_instantiate(info);
+	if (IS_ERR(d))
+		return NULL;
+
+	d->msi_parent_ops = msi_parent_ops;
+	return d;
+}
+EXPORT_SYMBOL_GPL(msi_create_parent_irq_domain);
+
+/**
  * msi_parent_init_dev_msi_info - Delegate initialization of device MSI info down
  *				  in the domain hierarchy
  * @dev:		The device for which the domain should be created
author maintainer
#5 lore raw

PATCH v2 3/9 irqchip/gic: Convert to msi_create_parent_irq_domain() helper

In reply to Marc Zyngier

Now that we have a concise helper to create an MSI parent domain, switch the GIC family over to that.

---
 drivers/irqchip/irq-gic-v2m.c    | 12 +++++++-----
 drivers/irqchip/irq-gic-v3-its.c | 19 +++++++++----------
 drivers/irqchip/irq-gic-v3-mbi.c | 11 ++++++-----
 3 files changed, 22 insertions(+), 20 deletions(-)
drivers/irqchip/irq-gic-v2m.c +7 -5
index 62676994d0695..9050792e3242f 100644
@@ -268,16 +268,18 @@ static __init int gicv2m_allocate_domains(struct irq_domain *parent)
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode,
-						   &gicv2m_domain_ops, v2m);
+	inner_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= v2m->fwnode,
+			.ops		= &gicv2m_domain_ops,
+			.host_data	= v2m,
+			.parent		= parent,
+		}, &gicv2m_msi_parent_ops);
+
 	if (!inner_domain) {
 		pr_err("Failed to create GICv2m domain\n");
 		return -ENOMEM;
 	}
 
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	inner_domain->msi_parent_ops = &gicv2m_msi_parent_ops;
 	return 0;
 }
 
drivers/irqchip/irq-gic-v3-its.c +9 -10
index 9e6380f597488..9ea3a6723263c 100644
@@ -5128,20 +5128,19 @@ static int its_init_domain(struct its_node *its)
 	info->ops = &its_msi_domain_ops;
 	info->data = its;
 
-	inner_domain = irq_domain_create_hierarchy(its_parent,
-						   its->msi_domain_flags, 0,
-						   its->fwnode_handle, &its_domain_ops,
-						   info);
+	inner_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= its->fwnode_handle,
+			.ops		= &its_domain_ops,
+			.host_data	= info,
+			.domain_flags	= its->msi_domain_flags,
+			.parent		= its_parent,
+		}, &gic_v3_its_msi_parent_ops);
+
 	if (!inner_domain) {
 		kfree(info);
 		return -ENOMEM;
 	}
 
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
-
-	inner_domain->msi_parent_ops = &gic_v3_its_msi_parent_ops;
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT | IRQ_DOMAIN_FLAG_MSI_IMMUTABLE;
-
 	return 0;
 }
 
@@ -5518,7 +5517,7 @@ static struct its_node __init *its_node_init(struct resource *res,
 	its->base = its_base;
 	its->phys_base = res->start;
 	its->get_msi_base = its_irq_get_msi_base;
-	its->msi_domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI;
+	its->msi_domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI | IRQ_DOMAIN_FLAG_MSI_IMMUTABLE;
 
 	its->numa_node = numa_node;
 	its->fwnode_handle = handle;
drivers/irqchip/irq-gic-v3-mbi.c +6 -5
index e562b57923229..11fa5df9da8c7 100644
@@ -208,14 +208,15 @@ static int mbi_allocate_domain(struct irq_domain *parent)
 {
 	struct irq_domain *nexus_domain;
 
-	nexus_domain = irq_domain_create_hierarchy(parent, 0, 0, parent->fwnode,
-						   &mbi_domain_ops, NULL);
+	nexus_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= parent->fwnode,
+			.ops		= &mbi_domain_ops,
+			.parent		= parent,
+		}, &gic_v3_mbi_msi_parent_ops);
+
 	if (!nexus_domain)
 		return -ENOMEM;
 
-	irq_domain_update_bus_token(nexus_domain, DOMAIN_BUS_NEXUS);
-	nexus_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	nexus_domain->msi_parent_ops = &gic_v3_mbi_msi_parent_ops;
 	return 0;
 }
 
Signature · 1 line
2.39.2
#6 lore raw

Re: [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper

drivers/irqchip/irq-gic-v2m.c static __init int gicv2m_allocate_domains(struct irq_domain *parent) · line 277

Quoted 12 lines · Marc Zyngier
drivers/irqchip/irq-gic-v2m.c +7 -2
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode,
-						   &gicv2m_domain_ops, v2m);
+	inner_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= v2m->fwnode,
+			.ops		= &gicv2m_domain_ops,
+			.host_data	= v2m,
+			.parent		= parent,
+		}, &gicv2m_msi_parent_ops);
+

This really makes my eyes bleed.

if (!v2m)
return 0;

- inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode,
- &gicv2m_domain_ops, v2m);
+ struct irq_domain_info info = {
+ .fwnode = v2m->fwnode,
+ .ops = &gicv2m_domain_ops,
+ .host_data = v2m,
+ .parent = parent,
+ };
+
+ inner_domain = msi_create_parent_irq_domain(&info, &gicv2m_msi_parent_ops);

That's too readable, right?

No need to resend, I just hacked up a few lines of coccinelle script to eliminate this offense.

Thanks,

tglx

author maintainer
#7 lore raw

Re: [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper

Quoted 31 lines · Thomas Gleixner

drivers/irqchip/irq-gic-v2m.c static __init int gicv2m_allocate_domains(struct irq_domain *parent) · line 277

Quoted 12 lines · Marc Zyngier
drivers/irqchip/irq-gic-v2m.c +7 -2
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode,
-						   &gicv2m_domain_ops, v2m);
+	inner_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= v2m->fwnode,
+			.ops		= &gicv2m_domain_ops,
+			.host_data	= v2m,
+			.parent		= parent,
+		}, &gicv2m_msi_parent_ops);
+

This really makes my eyes bleed.

drivers/irqchip/irq-gic-v2m.c +8 -2
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode,
-						   &gicv2m_domain_ops, v2m);
+	struct irq_domain_info info = {
+		.fwnode		= v2m->fwnode,
+		.ops		= &gicv2m_domain_ops,
+		.host_data	= v2m,
+		.parent		= parent,
+	};
+
+	inner_domain = msi_create_parent_irq_domain(&info, &gicv2m_msi_parent_ops);
Quoted 4 lines

That's too readable, right?

No need to resend, I just hacked up a few lines of coccinelle script to eliminate this offense.

I personally find the rework much uglier than the original contraption. Variables declared in the middle of the code, Rust-style? Meh.

But hey, your call.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#8 lore raw

Re: [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper

Quoted 7 lines · Marc Zyngier
Quoted 2 lines · Thomas Gleixner

No need to resend, I just hacked up a few lines of coccinelle script to eliminate this offense.

I personally find the rework much uglier than the original contraption. Variables declared in the middle of the code, Rust-style? Meh.

That's not a Rust invention and we already moved over to do this to make the __free() magic more obvious.

Thanks,

tglx

merge bot Applied
#9 lore raw

[tip: irq/msi] irqchip/gic: Convert to msi_create_parent_irq_domain() helper

In reply to Marc Zyngier
The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     c6b77822347afc17623120dbc4d10c6658304622
Gitweb:        https://git.kernel.org/tip/c6b77822347afc17623120dbc4d10c6658304622
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:13 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:20 +02:00

irqchip/gic: Convert to msi_create_parent_irq_domain() helper

Switch the GIC family of interrupt chip drivers over to the common helper function to create the interrupt domains.

[ tglx: Moved the struct out of the function call argument ]

---
 drivers/irqchip/irq-gic-v2m.c    | 16 ++++++++--------
 drivers/irqchip/irq-gic-v3-its.c | 22 +++++++++-------------
 drivers/irqchip/irq-gic-v3-mbi.c | 16 ++++++----------
 3 files changed, 23 insertions(+), 31 deletions(-)
drivers/irqchip/irq-gic-v2m.c +8 -8
index 6267699..102f171 100644
@@ -261,23 +261,23 @@ static struct msi_parent_ops gicv2m_msi_parent_ops = {
 
 static __init int gicv2m_allocate_domains(struct irq_domain *parent)
 {
-	struct irq_domain *inner_domain;
+	struct irq_domain_info info = {
+		.ops		= &gicv2m_domain_ops,
+		.parent		= parent,
+	};
 	struct v2m_data *v2m;
 
 	v2m = list_first_entry_or_null(&v2m_nodes, struct v2m_data, entry);
 	if (!v2m)
 		return 0;
 
-	inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode,
-						   &gicv2m_domain_ops, v2m);
-	if (!inner_domain) {
+	info.host_data = v2m;
+	info.fwnode = v2m->fwnode;
+
+	if (!msi_create_parent_irq_domain(&info, &gicv2m_msi_parent_ops)) {
 		pr_err("Failed to create GICv2m domain\n");
 		return -ENOMEM;
 	}
-
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	inner_domain->msi_parent_ops = &gicv2m_msi_parent_ops;
 	return 0;
 }
 
drivers/irqchip/irq-gic-v3-its.c +9 -13
index d651cd4..57ecf5b 100644
@@ -5122,7 +5122,12 @@ out_unmap:
 
 static int its_init_domain(struct its_node *its)
 {
-	struct irq_domain *inner_domain;
+	struct irq_domain_info dom_info = {
+		.fwnode		= its->fwnode_handle,
+		.ops		= &its_domain_ops,
+		.domain_flags	= its->msi_domain_flags,
+		.parent		= its_parent,
+	};
 	struct msi_domain_info *info;
 
 	info = kzalloc(sizeof(*info), GFP_KERNEL);
@@ -5131,21 +5136,12 @@ static int its_init_domain(struct its_node *its)
 
 	info->ops = &its_msi_domain_ops;
 	info->data = its;
+	dom_info.host_data = info;
 
-	inner_domain = irq_domain_create_hierarchy(its_parent,
-						   its->msi_domain_flags, 0,
-						   its->fwnode_handle, &its_domain_ops,
-						   info);
-	if (!inner_domain) {
+	if (!msi_create_parent_irq_domain(&dom_info, &gic_v3_its_msi_parent_ops)) {
 		kfree(info);
 		return -ENOMEM;
 	}
-
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
-
-	inner_domain->msi_parent_ops = &gic_v3_its_msi_parent_ops;
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT | IRQ_DOMAIN_FLAG_MSI_IMMUTABLE;
-
 	return 0;
 }
 
@@ -5522,7 +5518,7 @@ static struct its_node __init *its_node_init(struct resource *res,
 	its->base = its_base;
 	its->phys_base = res->start;
 	its->get_msi_base = its_irq_get_msi_base;
-	its->msi_domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI;
+	its->msi_domain_flags = IRQ_DOMAIN_FLAG_ISOLATED_MSI | IRQ_DOMAIN_FLAG_MSI_IMMUTABLE;
 
 	its->numa_node = numa_node;
 	its->fwnode_handle = handle;
drivers/irqchip/irq-gic-v3-mbi.c +6 -10
index e562b57..6a4afd1 100644
@@ -206,17 +206,13 @@ static const struct msi_parent_ops gic_v3_mbi_msi_parent_ops = {
 
 static int mbi_allocate_domain(struct irq_domain *parent)
 {
-	struct irq_domain *nexus_domain;
+	struct irq_domain_info info = {
+		.fwnode		= parent->fwnode,
+		.ops		= &mbi_domain_ops,
+		.parent		= parent,
+	};
 
-	nexus_domain = irq_domain_create_hierarchy(parent, 0, 0, parent->fwnode,
-						   &mbi_domain_ops, NULL);
-	if (!nexus_domain)
-		return -ENOMEM;
-
-	irq_domain_update_bus_token(nexus_domain, DOMAIN_BUS_NEXUS);
-	nexus_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	nexus_domain->msi_parent_ops = &gic_v3_mbi_msi_parent_ops;
-	return 0;
+	return msi_create_parent_irq_domain(&info, &gic_v3_mbi_msi_parent_ops) ? 0 : -ENOMEM;
 }
 
 int __init mbi_init(struct fwnode_handle *fwnode, struct irq_domain *parent)
author maintainer
#10 lore raw

PATCH v2 4/9 irqchip/mvebu: Convert to msi_create_parent_irq_domain() helper

In reply to Marc Zyngier

Now that we have a concise helper to create an MSI parent domain, switch the mvebu family of interrupt controllers over to that.

---
 drivers/irqchip/irq-mvebu-gicp.c | 14 +++++++-------
 drivers/irqchip/irq-mvebu-odmi.c | 14 ++++++--------
 drivers/irqchip/irq-mvebu-sei.c  | 16 +++++++---------
 3 files changed, 20 insertions(+), 24 deletions(-)
drivers/irqchip/irq-mvebu-gicp.c +7 -7
index 0b2a857b49018..c7c83f8923fcd 100644
@@ -230,16 +230,16 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	inner_domain = irq_domain_create_hierarchy(parent_domain, 0,
-						   gicp->spi_cnt,
-						   of_node_to_fwnode(node),
-						   &gicp_domain_ops, gicp);
+	inner_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= of_node_to_fwnode(node),
+			.ops		= &gicp_domain_ops,
+			.size		= gicp->spi_cnt,
+			.host_data	= gicp,
+			.parent		= parent_domain,
+		}, &gicp_msi_parent_ops);
 	if (!inner_domain)
 		return -ENOMEM;
 
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_GENERIC_MSI);
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	inner_domain->msi_parent_ops = &gicp_msi_parent_ops;
 	return 0;
 }
 
drivers/irqchip/irq-mvebu-odmi.c +6 -8
index 306a7754e44f8..e6049f647a017 100644
@@ -205,19 +205,17 @@ static int __init mvebu_odmi_init(struct device_node *node,
 
 	parent_domain = irq_find_host(parent);
 
-	inner_domain = irq_domain_create_hierarchy(parent_domain, 0,
-						   odmis_count * NODMIS_PER_FRAME,
-						   of_node_to_fwnode(node),
-						   &odmi_domain_ops, NULL);
+	inner_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= of_node_to_fwnode(node),
+			.ops		= &odmi_domain_ops,
+			.size		= odmis_count * NODMIS_PER_FRAME,
+			.parent		= parent_domain,
+		}, &odmi_msi_parent_ops);
 	if (!inner_domain) {
 		ret = -ENOMEM;
 		goto err_unmap;
 	}
 
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_GENERIC_MSI);
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	inner_domain->msi_parent_ops = &odmi_msi_parent_ops;
-
 	return 0;
 
 err_unmap:
drivers/irqchip/irq-mvebu-sei.c +7 -9
index a962ef4977169..cacf88530e444 100644
@@ -430,21 +430,19 @@ static int mvebu_sei_probe(struct platform_device *pdev)
 	irq_domain_update_bus_token(sei->ap_domain, DOMAIN_BUS_WIRED);
 
 	/* Create the 'MSI' domain */
-	sei->cp_domain = irq_domain_create_hierarchy(sei->sei_domain, 0,
-						     sei->caps->cp_range.size,
-						     of_node_to_fwnode(node),
-						     &mvebu_sei_cp_domain_ops,
-						     sei);
+	sei->cp_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= of_node_to_fwnode(node),
+			.ops		= &mvebu_sei_cp_domain_ops,
+			.size		= sei->caps->cp_range.size,
+			.host_data	= sei,
+			.parent		= sei->sei_domain,
+		}, &sei_msi_parent_ops);
 	if (!sei->cp_domain) {
 		pr_err("Failed to create CPs IRQ domain\n");
 		ret = -ENOMEM;
 		goto remove_ap_domain;
 	}
 
-	irq_domain_update_bus_token(sei->cp_domain, DOMAIN_BUS_GENERIC_MSI);
-	sei->cp_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	sei->cp_domain->msi_parent_ops = &sei_msi_parent_ops;
-
 	mvebu_sei_reset(sei);
 
 	irq_set_chained_handler_and_data(parent_irq, mvebu_sei_handle_cascade_irq, sei);
Signature · 1 line
2.39.2
merge bot Applied
#11 lore raw

[tip: irq/msi] irqchip/mvebu: Convert to msi_create_parent_irq_domain() helper

The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     b35961ce0a979fa9c2b0d30a346d3a74ef670aa6
Gitweb:        https://git.kernel.org/tip/b35961ce0a979fa9c2b0d30a346d3a74ef670aa6
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:14 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:20 +02:00

irqchip/mvebu: Convert to msi_create_parent_irq_domain() helper

Switch the MVEBU family of interrupt chip drivers over to the common helper function to create the interrupt domains.

[ tglx: Moved the struct out of the function call argument and fix up
the of_node_to_fwnode() instances ]

---
 drivers/irqchip/irq-mvebu-gicp.c | 24 ++++++++++--------------
 drivers/irqchip/irq-mvebu-odmi.c | 25 +++++++++----------------
 drivers/irqchip/irq-mvebu-sei.c  | 22 +++++++++++-----------
 3 files changed, 30 insertions(+), 41 deletions(-)
drivers/irqchip/irq-mvebu-gicp.c +10 -14
index 0b2a857..9cd3c6c 100644
@@ -170,9 +170,12 @@ static const struct msi_parent_ops gicp_msi_parent_ops = {
 
 static int mvebu_gicp_probe(struct platform_device *pdev)
 {
-	struct irq_domain *inner_domain, *parent_domain;
 	struct device_node *node = pdev->dev.of_node;
 	struct device_node *irq_parent_dn;
+	struct irq_domain_info info = {
+		.fwnode	= of_fwnode_handle(node),
+		.ops	= &gicp_domain_ops,
+	};
 	struct mvebu_gicp *gicp;
 	int ret, i;
 
@@ -217,30 +220,23 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
 	if (!gicp->spi_bitmap)
 		return -ENOMEM;
 
+	info.size = gicp->spi_cnt;
+	info.host_data = gicp;
+
 	irq_parent_dn = of_irq_find_parent(node);
 	if (!irq_parent_dn) {
 		dev_err(&pdev->dev, "failed to find parent IRQ node\n");
 		return -ENODEV;
 	}
 
-	parent_domain = irq_find_host(irq_parent_dn);
+	info.parent = irq_find_host(irq_parent_dn);
 	of_node_put(irq_parent_dn);
-	if (!parent_domain) {
+	if (!info.parent) {
 		dev_err(&pdev->dev, "failed to find parent IRQ domain\n");
 		return -ENODEV;
 	}
 
-	inner_domain = irq_domain_create_hierarchy(parent_domain, 0,
-						   gicp->spi_cnt,
-						   of_node_to_fwnode(node),
-						   &gicp_domain_ops, gicp);
-	if (!inner_domain)
-		return -ENOMEM;
-
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_GENERIC_MSI);
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	inner_domain->msi_parent_ops = &gicp_msi_parent_ops;
-	return 0;
+	return msi_create_parent_irq_domain(&info, &gicp_msi_parent_ops) ? 0 : -ENOMEM;
 }
 
 static const struct of_device_id mvebu_gicp_of_match[] = {
drivers/irqchip/irq-mvebu-odmi.c +9 -16
index 306a775..46256b9 100644
@@ -167,7 +167,12 @@ static const struct msi_parent_ops odmi_msi_parent_ops = {
 static int __init mvebu_odmi_init(struct device_node *node,
 				  struct device_node *parent)
 {
-	struct irq_domain *parent_domain, *inner_domain;
+	struct irq_domain_info info = {
+		.fwnode	= of_fwnode_handle(node),
+		.ops	= &odmi_domain_ops,
+		.size	= odmis_count * NODMIS_PER_FRAME,
+		.parent	= irq_find_host(parent),
+	};
 	int ret, i;
 
 	if (of_property_read_u32(node, "marvell,odmi-frames", &odmis_count))
@@ -203,22 +208,10 @@ static int __init mvebu_odmi_init(struct device_node *node,
 		}
 	}
 
-	parent_domain = irq_find_host(parent);
+	if (msi_create_parent_irq_domain(&info, &odmi_msi_parent_ops))
+		return 0;
 
-	inner_domain = irq_domain_create_hierarchy(parent_domain, 0,
-						   odmis_count * NODMIS_PER_FRAME,
-						   of_node_to_fwnode(node),
-						   &odmi_domain_ops, NULL);
-	if (!inner_domain) {
-		ret = -ENOMEM;
-		goto err_unmap;
-	}
-
-	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_GENERIC_MSI);
-	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	inner_domain->msi_parent_ops = &odmi_msi_parent_ops;
-
-	return 0;
+	ret = -ENOMEM;
 
 err_unmap:
 	for (i = 0; i < odmis_count; i++) {
drivers/irqchip/irq-mvebu-sei.c +11 -11
index a962ef4..5822ea8 100644
@@ -366,6 +366,10 @@ static const struct msi_parent_ops sei_msi_parent_ops = {
 static int mvebu_sei_probe(struct platform_device *pdev)
 {
 	struct device_node *node = pdev->dev.of_node;
+	struct irq_domain_info info = {
+		.fwnode	= of_fwnode_handle(node),
+		.ops	= &mvebu_sei_cp_domain_ops,
+	};
 	struct mvebu_sei *sei;
 	u32 parent_irq;
 	int ret;
@@ -402,7 +406,7 @@ static int mvebu_sei_probe(struct platform_device *pdev)
 	}
 
 	/* Create the root SEI domain */
-	sei->sei_domain = irq_domain_create_linear(of_node_to_fwnode(node),
+	sei->sei_domain = irq_domain_create_linear(of_fwnode_handle(node),
 						   (sei->caps->ap_range.size +
 						    sei->caps->cp_range.size),
 						   &mvebu_sei_domain_ops,
@@ -418,7 +422,7 @@ static int mvebu_sei_probe(struct platform_device *pdev)
 	/* Create the 'wired' domain */
 	sei->ap_domain = irq_domain_create_hierarchy(sei->sei_domain, 0,
 						     sei->caps->ap_range.size,
-						     of_node_to_fwnode(node),
+						     of_fwnode_handle(node),
 						     &mvebu_sei_ap_domain_ops,
 						     sei);
 	if (!sei->ap_domain) {
@@ -430,21 +434,17 @@ static int mvebu_sei_probe(struct platform_device *pdev)
 	irq_domain_update_bus_token(sei->ap_domain, DOMAIN_BUS_WIRED);
 
 	/* Create the 'MSI' domain */
-	sei->cp_domain = irq_domain_create_hierarchy(sei->sei_domain, 0,
-						     sei->caps->cp_range.size,
-						     of_node_to_fwnode(node),
-						     &mvebu_sei_cp_domain_ops,
-						     sei);
+	info.size = sei->caps->cp_range.size;
+	info.host_data = sei;
+	info.parent = sei->sei_domain;
+
+	sei->cp_domain = msi_create_parent_irq_domain(&info, &sei_msi_parent_ops);
 	if (!sei->cp_domain) {
 		pr_err("Failed to create CPs IRQ domain\n");
 		ret = -ENOMEM;
 		goto remove_ap_domain;
 	}
 
-	irq_domain_update_bus_token(sei->cp_domain, DOMAIN_BUS_GENERIC_MSI);
-	sei->cp_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
-	sei->cp_domain->msi_parent_ops = &sei_msi_parent_ops;
-
 	mvebu_sei_reset(sei);
 
 	irq_set_chained_handler_and_data(parent_irq, mvebu_sei_handle_cascade_irq, sei);
author maintainer
#12 lore raw

PATCH v2 5/9 irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers

In reply to Marc Zyngier

Commit 1c000dcaad2be ("irqchip/irq-msi-lib: Optionally set default irq_eoi()/irq_ack()") added blancket MSI_CHIP_FLAG_SET_ACK flags, irrespective of whether the underlying irqchip required it or not.

Drop it from a number of drivers that do not require it.

Fixes 1c000dcaad2be ("irqchip/irq-msi-lib: Optionally set default irq_eoi()/irq_ack()")
---
 drivers/irqchip/irq-gic-v2m.c               | 2 +-
 drivers/irqchip/irq-gic-v3-its-msi-parent.c | 2 +-
 drivers/irqchip/irq-gic-v3-mbi.c            | 2 +-
 drivers/irqchip/irq-mvebu-gicp.c            | 2 +-
 drivers/irqchip/irq-mvebu-odmi.c            | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-gic-v2m.c +1 -1
index 9050792e3242f..e30463a7bf1ea 100644
@@ -252,7 +252,7 @@ static void __init gicv2m_teardown(void)
 static struct msi_parent_ops gicv2m_msi_parent_ops = {
 	.supported_flags	= GICV2M_MSI_FLAGS_SUPPORTED,
 	.required_flags		= GICV2M_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_NEXUS,
 	.bus_select_mask	= MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
 	.prefix			= "GICv2m-",
drivers/irqchip/irq-gic-v3-its-msi-parent.c +1 -1
index 51cc961bc3181..443e8fcf2fc16 100644
@@ -211,7 +211,7 @@ static bool its_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 const struct msi_parent_ops gic_v3_its_msi_parent_ops = {
 	.supported_flags	= ITS_MSI_FLAGS_SUPPORTED,
 	.required_flags		= ITS_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_NEXUS,
 	.bus_select_mask	= MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
 	.prefix			= "ITS-",
drivers/irqchip/irq-gic-v3-mbi.c +1 -1
index 11fa5df9da8c7..a9142677c810c 100644
@@ -197,7 +197,7 @@ static bool mbi_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 static const struct msi_parent_ops gic_v3_mbi_msi_parent_ops = {
 	.supported_flags	= MBI_MSI_FLAGS_SUPPORTED,
 	.required_flags		= MBI_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_NEXUS,
 	.bus_select_mask	= MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
 	.prefix			= "MBI-",
drivers/irqchip/irq-mvebu-gicp.c +1 -1
index c7c83f8923fcd..68764e7754ba6 100644
@@ -161,7 +161,7 @@ static const struct irq_domain_ops gicp_domain_ops = {
 static const struct msi_parent_ops gicp_msi_parent_ops = {
 	.supported_flags	= GICP_MSI_FLAGS_SUPPORTED,
 	.required_flags		= GICP_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token       = DOMAIN_BUS_GENERIC_MSI,
 	.bus_select_mask	= MATCH_PLATFORM_MSI,
 	.prefix			= "GICP-",
drivers/irqchip/irq-mvebu-odmi.c +1 -1
index e6049f647a017..fe99888b8134d 100644
@@ -157,7 +157,7 @@ static const struct irq_domain_ops odmi_domain_ops = {
 static const struct msi_parent_ops odmi_msi_parent_ops = {
 	.supported_flags	= ODMI_MSI_FLAGS_SUPPORTED,
 	.required_flags		= ODMI_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_GENERIC_MSI,
 	.bus_select_mask	= MATCH_PLATFORM_MSI,
 	.prefix			= "ODMI-",
Signature · 1 line
2.39.2
merge bot Applied
#13 lore raw

[tip: irq/urgent] irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers

The following commit has been merged into the irq/urgent branch of tip:

The following commit has been merged into the irq/urgent branch of tip:

Commit-ID:     fb0ea6e4878a45b1ac81972027907fc424a792e6
Gitweb:        https://git.kernel.org/tip/fb0ea6e4878a45b1ac81972027907fc424a792e6
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:15 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 14 May 2025 16:24:27 +02:00

irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers

Commit 1c000dcaad2be ("irqchip/irq-msi-lib: Optionally set default irq_eoi()/irq_ack()") added blanket MSI_CHIP_FLAG_SET_ACK flags, irrespective of whether the underlying irqchip required it or not.

Drop it from a number of drivers that do not require it.

Fixes 1c000dcaad2be ("irqchip/irq-msi-lib: Optionally set default irq_eoi()/irq_ack()")
---
 drivers/irqchip/irq-gic-v2m.c               | 2 +-
 drivers/irqchip/irq-gic-v3-its-msi-parent.c | 2 +-
 drivers/irqchip/irq-gic-v3-mbi.c            | 2 +-
 drivers/irqchip/irq-mvebu-gicp.c            | 2 +-
 drivers/irqchip/irq-mvebu-odmi.c            | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-gic-v2m.c +1 -1
index dc98c39..cc6a6c1 100644
@@ -252,7 +252,7 @@ static void __init gicv2m_teardown(void)
 static struct msi_parent_ops gicv2m_msi_parent_ops = {
 	.supported_flags	= GICV2M_MSI_FLAGS_SUPPORTED,
 	.required_flags		= GICV2M_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_NEXUS,
 	.bus_select_mask	= MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
 	.prefix			= "GICv2m-",
drivers/irqchip/irq-gic-v3-its-msi-parent.c +1 -1
index bdb04c8..c5a7eb1 100644
@@ -203,7 +203,7 @@ static bool its_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 const struct msi_parent_ops gic_v3_its_msi_parent_ops = {
 	.supported_flags	= ITS_MSI_FLAGS_SUPPORTED,
 	.required_flags		= ITS_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_NEXUS,
 	.bus_select_mask	= MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
 	.prefix			= "ITS-",
drivers/irqchip/irq-gic-v3-mbi.c +1 -1
index 34e9ca7..647b18e 100644
@@ -197,7 +197,7 @@ static bool mbi_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 static const struct msi_parent_ops gic_v3_mbi_msi_parent_ops = {
 	.supported_flags	= MBI_MSI_FLAGS_SUPPORTED,
 	.required_flags		= MBI_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_NEXUS,
 	.bus_select_mask	= MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
 	.prefix			= "MBI-",
drivers/irqchip/irq-mvebu-gicp.c +1 -1
index d67f93f..60b9762 100644
@@ -161,7 +161,7 @@ static const struct irq_domain_ops gicp_domain_ops = {
 static const struct msi_parent_ops gicp_msi_parent_ops = {
 	.supported_flags	= GICP_MSI_FLAGS_SUPPORTED,
 	.required_flags		= GICP_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token       = DOMAIN_BUS_GENERIC_MSI,
 	.bus_select_mask	= MATCH_PLATFORM_MSI,
 	.prefix			= "GICP-",
drivers/irqchip/irq-mvebu-odmi.c +1 -1
index 28f7e81..54f6f08 100644
@@ -157,7 +157,7 @@ static const struct irq_domain_ops odmi_domain_ops = {
 static const struct msi_parent_ops odmi_msi_parent_ops = {
 	.supported_flags	= ODMI_MSI_FLAGS_SUPPORTED,
 	.required_flags		= ODMI_MSI_FLAGS_REQUIRED,
-	.chip_flags		= MSI_CHIP_FLAG_SET_EOI | MSI_CHIP_FLAG_SET_ACK,
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
 	.bus_select_token	= DOMAIN_BUS_GENERIC_MSI,
 	.bus_select_mask	= MATCH_PLATFORM_MSI,
 	.prefix			= "ODMI-",
author maintainer
#14 lore raw

PATCH v2 6/9 irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag

In reply to Marc Zyngier

Bad MSI implementations multiplex MSIs onto a single downstream interrupt, meaning they have no concept of individual affinity.

The old MSI code did a reasonable job at this by honouring the MSI_FLAG_NO_AFFINITY, but the new shiny device MSI code doesn't.

Teach it about the sad reality of existing hardware.

---
 drivers/irqchip/irq-msi-lib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/irqchip/irq-msi-lib.c +6 -1
index 2a61c06c4da07..246c30205af40 100644
@@ -105,8 +105,13 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 	 * MSI message into the hardware which is the whole purpose of the
 	 * device MSI domain aside of mask/unmask which is provided e.g. by
 	 * PCI/MSI device domains.
+	 *
+	 * The exception to the rule is when the underlying domain
+	 * tells you that affinity is not a thing -- for example when
+	 * everything is muxed behind a single interrupt.
 	 */
-	chip->irq_set_affinity = msi_domain_set_affinity;
+	if (!chip->irq_set_affinity && !(info->flags & MSI_FLAG_NO_AFFINITY))
+		chip->irq_set_affinity = msi_domain_set_affinity;
 	return true;
 }
 EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info);
Signature · 1 line
2.39.2
merge bot Applied
#15 lore raw

[tip: irq/msi] irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag

The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     06526443a34c06879664eb5ae247c5e93dde7ed9
Gitweb:        https://git.kernel.org/tip/06526443a34c06879664eb5ae247c5e93dde7ed9
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:16 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:20 +02:00

irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag

Bad MSI implementations multiplex MSIs onto a single downstream interrupt, meaning they have no concept of individual affinity.

The old MSI code did a reasonable job at this by honouring the MSI_FLAG_NO_AFFINITY, but the new shiny device MSI code doesn't.

Teach it about the sad reality of existing hardware.

---
 drivers/irqchip/irq-msi-lib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/irqchip/irq-msi-lib.c +6 -1
index 2a61c06..246c302 100644
@@ -105,8 +105,13 @@ bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
 	 * MSI message into the hardware which is the whole purpose of the
 	 * device MSI domain aside of mask/unmask which is provided e.g. by
 	 * PCI/MSI device domains.
+	 *
+	 * The exception to the rule is when the underlying domain
+	 * tells you that affinity is not a thing -- for example when
+	 * everything is muxed behind a single interrupt.
 	 */
-	chip->irq_set_affinity = msi_domain_set_affinity;
+	if (!chip->irq_set_affinity && !(info->flags & MSI_FLAG_NO_AFFINITY))
+		chip->irq_set_affinity = msi_domain_set_affinity;
 	return true;
 }
 EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info);
author maintainer
#16 lore raw

PATCH v2 7/9 PCI: apple: Convert to MSI parent infrastructure

In reply to Marc Zyngier

In an effort to move arm64 away from the legacy MSI setup, convert the apple PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain.

---
 drivers/pci/controller/Kconfig      |  1 +
 drivers/pci/controller/pcie-apple.c | 62 ++++++++++-------------------
 2 files changed, 22 insertions(+), 41 deletions(-)
drivers/pci/controller/Kconfig +1 -0
index 9800b76810540..98a62f4559dfd 100644
@@ -40,6 +40,7 @@ config PCIE_APPLE
 	depends on OF
 	depends on PCI_MSI
 	select PCI_HOST_COMMON
+	select IRQ_MSI_LIB
 	help
 	  Say Y here if you want to enable PCIe controller support on Apple
 	  system-on-chips, like the Apple M1. This is required for the USB
drivers/pci/controller/pcie-apple.c +21 -41

108 lines not on this page · raw message

Signature · 1 line
2.39.2
Acked-by on v2 7/9
#17 lore raw

Re: [PATCH v2 7/9] PCI: apple: Convert to MSI parent infrastructure

Quoted 144 lines · Marc Zyngier

In an effort to move arm64 away from the legacy MSI setup, convert the apple PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain.

---
 drivers/pci/controller/Kconfig      |  1 +
 drivers/pci/controller/pcie-apple.c | 62 ++++++++++-------------------
 2 files changed, 22 insertions(+), 41 deletions(-)
drivers/pci/controller/Kconfig +1 -0
index 9800b76810540..98a62f4559dfd 100644
@@ -40,6 +40,7 @@ config PCIE_APPLE
 	depends on OF
 	depends on PCI_MSI
 	select PCI_HOST_COMMON
+	select IRQ_MSI_LIB
 	help
 	  Say Y here if you want to enable PCIe controller support on Apple
 	  system-on-chips, like the Apple M1. This is required for the USB
drivers/pci/controller/pcie-apple.c +21 -41
index 18e11b9a7f464..6c88b4dd34151 100644
@@ -22,6 +22,7 @@
 #include <linux/kernel.h>
 #include <linux/iopoll.h>
 #include <linux/irqchip/chained_irq.h>
+#include <linux/irqchip/irq-msi-lib.h>
 #include <linux/irqdomain.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -133,7 +134,6 @@ struct apple_pcie {
 	struct mutex		lock;
 	struct device		*dev;
 	void __iomem            *base;
-	struct irq_domain	*domain;
 	unsigned long		*bitmap;
 	struct list_head	ports;
 	struct completion	event;
@@ -162,27 +162,6 @@ static void rmw_clear(u32 clr, void __iomem *addr)
 	writel_relaxed(readl_relaxed(addr) & ~clr, addr);
 }
 
-static void apple_msi_top_irq_mask(struct irq_data *d)
-{
-	pci_msi_mask_irq(d);
-	irq_chip_mask_parent(d);
-}
-
-static void apple_msi_top_irq_unmask(struct irq_data *d)
-{
-	pci_msi_unmask_irq(d);
-	irq_chip_unmask_parent(d);
-}
-
-static struct irq_chip apple_msi_top_chip = {
-	.name			= "PCIe MSI",
-	.irq_mask		= apple_msi_top_irq_mask,
-	.irq_unmask		= apple_msi_top_irq_unmask,
-	.irq_eoi		= irq_chip_eoi_parent,
-	.irq_set_affinity	= irq_chip_set_affinity_parent,
-	.irq_set_type		= irq_chip_set_type_parent,
-};
-
 static void apple_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
 {
 	msg->address_hi = upper_32_bits(DOORBELL_ADDR);
@@ -226,8 +205,7 @@ static int apple_msi_domain_alloc(struct irq_domain *domain, unsigned int virq,
 
 	for (i = 0; i < nr_irqs; i++) {
 		irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
-					      &apple_msi_bottom_chip,
-					      domain->host_data);
+					      &apple_msi_bottom_chip, pcie);
 	}
 
 	return 0;
@@ -251,12 +229,6 @@ static const struct irq_domain_ops apple_msi_domain_ops = {
 	.free	= apple_msi_domain_free,
 };
 
-static struct msi_domain_info apple_msi_info = {
-	.flags	= (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
-		   MSI_FLAG_MULTI_PCI_MSI | MSI_FLAG_PCI_MSIX),
-	.chip	= &apple_msi_top_chip,
-};
-
 static void apple_port_irq_mask(struct irq_data *data)
 {
 	struct apple_pcie_port *port = irq_data_get_irq_chip_data(data);
@@ -595,6 +567,18 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
 	return 0;
 }
 
+static const struct msi_parent_ops apple_msi_parent_ops = {
+	.supported_flags	= (MSI_GENERIC_FLAGS_MASK	|
+				   MSI_FLAG_PCI_MSIX		|
+				   MSI_FLAG_MULTI_PCI_MSI),
+	.required_flags		= (MSI_FLAG_USE_DEF_DOM_OPS	|
+				   MSI_FLAG_USE_DEF_CHIP_OPS	|
+				   MSI_FLAG_PCI_MSI_MASK_PARENT),
+	.chip_flags		= MSI_CHIP_FLAG_SET_EOI,
+	.bus_select_token	= DOMAIN_BUS_PCI_MSI,
+	.init_dev_msi_info	= msi_lib_init_dev_msi_info,
+};
+
 static int apple_msi_init(struct apple_pcie *pcie)
 {
 	struct fwnode_handle *fwnode = dev_fwnode(pcie->dev);
@@ -625,21 +609,17 @@ static int apple_msi_init(struct apple_pcie *pcie)
 		return -ENXIO;
 	}
 
-	parent = irq_domain_create_hierarchy(parent, 0, pcie->nvecs, fwnode,
-					     &apple_msi_domain_ops, pcie);
+	parent = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= fwnode,
+			.ops		= &apple_msi_domain_ops,
+			.size		= pcie->nvecs,
+			.host_data	= pcie,
+			.parent		= parent,
+		}, &apple_msi_parent_ops);
 	if (!parent) {
 		dev_err(pcie->dev, "failed to create IRQ domain\n");
 		return -ENOMEM;
 	}
-	irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS);
-
-	pcie->domain = pci_msi_create_irq_domain(fwnode, &apple_msi_info,
-						 parent);
-	if (!pcie->domain) {
-		dev_err(pcie->dev, "failed to create MSI domain\n");
-		irq_domain_remove(parent);
-		return -ENOMEM;
-	}
 
 	return 0;
 }
Signature · 1 line
2.39.2
merge bot Applied
#18 lore raw

[tip: irq/msi] PCI: apple: Convert to MSI parent infrastructure

In reply to Marc Zyngier
The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     5d627a9484ec447348f7c485359b1baf6d120f0f
Gitweb:        https://git.kernel.org/tip/5d627a9484ec447348f7c485359b1baf6d120f0f
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:17 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:20 +02:00

PCI: apple: Convert to MSI parent infrastructure

In an effort to move ARM64 away from the legacy MSI setup, convert the Apple PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain.

[ tglx: Moved the struct out of the function call argument ]

---
 drivers/pci/controller/Kconfig      |  1 +-
 drivers/pci/controller/pcie-apple.c | 69 +++++++++-------------------
 2 files changed, 24 insertions(+), 46 deletions(-)
drivers/pci/controller/Kconfig +1 -0
index 9800b76..98a62f4 100644
@@ -40,6 +40,7 @@ config PCIE_APPLE
 	depends on OF
 	depends on PCI_MSI
 	select PCI_HOST_COMMON
+	select IRQ_MSI_LIB
 	help
 	  Say Y here if you want to enable PCIe controller support on Apple
 	  system-on-chips, like the Apple M1. This is required for the USB
drivers/pci/controller/pcie-apple.c +23 -46

122 lines not on this page · raw message

author maintainer
#19 lore raw

PATCH v2 8/9 PCI: xgene: Convert to MSI parent infrastructure

In reply to Marc Zyngier

In an effort to move arm64 away from the legacy MSI setup, convert the xgene PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain.

---
 drivers/pci/controller/Kconfig         |  1 +
 drivers/pci/controller/pci-xgene-msi.c | 46 ++++++++++----------------
 2 files changed, 18 insertions(+), 29 deletions(-)
drivers/pci/controller/Kconfig +1 -0
index 98a62f4559dfd..205e0e365c6b1 100644
@@ -304,6 +304,7 @@ config PCI_XGENE_MSI
 	bool "X-Gene v1 PCIe MSI feature"
 	depends on PCI_XGENE
 	depends on PCI_MSI
+	select IRQ_MSI_LIB
 	default y
 	help
 	  Say Y here if you want PCIe MSI support for the APM X-Gene v1 SoC.
drivers/pci/controller/pci-xgene-msi.c +17 -29

84 lines not on this page · raw message

Signature · 1 line
2.39.2
merge bot Applied
#20 lore raw

[tip: irq/msi] PCI: xgene: Convert to MSI parent infrastructure

The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     ae79351ef280805e0881fd2011b74ed008a4e151
Gitweb:        https://git.kernel.org/tip/ae79351ef280805e0881fd2011b74ed008a4e151
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:18 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:20 +02:00

PCI: xgene: Convert to MSI parent infrastructure

In an effort to move ARM64 away from the legacy MSI setup, convert the XGENE PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain.

[ tglx: Moved the struct out of the function call argument ]

---
 drivers/pci/controller/Kconfig         |  1 +-
 drivers/pci/controller/pci-xgene-msi.c | 53 +++++++++----------------
 2 files changed, 21 insertions(+), 33 deletions(-)
drivers/pci/controller/Kconfig +1 -0
index 98a62f4..205e0e3 100644
@@ -304,6 +304,7 @@ config PCI_XGENE_MSI
 	bool "X-Gene v1 PCIe MSI feature"
 	depends on PCI_XGENE
 	depends on PCI_MSI
+	select IRQ_MSI_LIB
 	default y
 	help
 	  Say Y here if you want PCIe MSI support for the APM X-Gene v1 SoC.
drivers/pci/controller/pci-xgene-msi.c +20 -33

87 lines not on this page · raw message

author maintainer
#21 lore raw

PATCH v2 9/9 PCI: tegra: Convert to MSI parent infrastructure

In reply to Marc Zyngier

In an effort to move arm64 away from the legacy MSI setup, convert the tegra PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain.

---
 drivers/pci/controller/Kconfig     |  1 +
 drivers/pci/controller/pci-tegra.c | 60 +++++++++---------------------
 2 files changed, 19 insertions(+), 42 deletions(-)
drivers/pci/controller/Kconfig +1 -0
index 205e0e365c6b1..eb3cc28d43f82 100644
@@ -228,6 +228,7 @@ config PCI_TEGRA
 	bool "NVIDIA Tegra PCIe controller"
 	depends on ARCH_TEGRA || COMPILE_TEST
 	depends on PCI_MSI
+	select IRQ_MSI_LIB
 	help
 	  Say Y here if you want support for the PCIe host controller found
 	  on NVIDIA Tegra SoCs.
drivers/pci/controller/pci-tegra.c +18 -42

101 lines not on this page · raw message

Signature · 1 line
2.39.2
merge bot Applied
#22 lore raw

[tip: irq/msi] PCI: tegra: Convert to MSI parent infrastructure

The following commit has been merged into the irq/msi branch of tip:

The following commit has been merged into the irq/msi branch of tip:

Commit-ID:     944242787695ec86ff00d925391d5b54902c546a
Gitweb:        https://git.kernel.org/tip/944242787695ec86ff00d925391d5b54902c546a
Author:        Marc Zyngier <[email protected]>
AuthorDate:    Tue, 13 May 2025 18:28:19 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Fri, 16 May 2025 21:32:20 +02:00

PCI: tegra: Convert to MSI parent infrastructure

In an effort to move ARM64 away from the legacy MSI setup, convert the Tegra PCIe driver to the MSI-parent infrastructure and let each device have its own MSI domain.

[ tglx: Moved the struct out of the function call argument ]

---
 drivers/pci/controller/Kconfig     |  1 +-
 drivers/pci/controller/pci-tegra.c | 63 ++++++++---------------------
 2 files changed, 20 insertions(+), 44 deletions(-)
drivers/pci/controller/Kconfig +1 -0
index 205e0e3..eb3cc28 100644
@@ -228,6 +228,7 @@ config PCI_TEGRA
 	bool "NVIDIA Tegra PCIe controller"
 	depends on ARCH_TEGRA || COMPILE_TEST
 	depends on PCI_MSI
+	select IRQ_MSI_LIB
 	help
 	  Say Y here if you want support for the PCIe host controller found
 	  on NVIDIA Tegra SoCs.
drivers/pci/controller/pci-tegra.c +19 -44

104 lines not on this page · raw message