linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion
@ 2025-05-13 17:28 Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 1/9] irqchip: Make irq-msi-lib.h globally available Marc Zyngier
                   ` (8 more replies)
  0 siblings, 9 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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/20241204124549.607054-1-maz@kernel.org

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%)

-- 
2.39.2


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

* [PATCH v2 1/9] irqchip: Make irq-msi-lib.h globally available
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 2/9] genirq/msi: Add helper for creating MSI-parent irq domains Marc Zyngier
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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\>:'

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 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%)

diff --git a/drivers/irqchip/irq-bcm2712-mip.c b/drivers/irqchip/irq-bcm2712-mip.c
index 49a19db2d1e1b..f04a42b16cca0 100644
--- a/drivers/irqchip/irq-bcm2712-mip.c
+++ b/drivers/irqchip/irq-bcm2712-mip.c
@@ -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
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index c698948618666..62676994d0695 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -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:
diff --git a/drivers/irqchip/irq-gic-v3-its-msi-parent.c b/drivers/irqchip/irq-gic-v3-its-msi-parent.c
index 68f9ba4085ce5..51cc961bc3181 100644
--- a/drivers/irqchip/irq-gic-v3-its-msi-parent.c
+++ b/drivers/irqchip/irq-gic-v3-its-msi-parent.c
@@ -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 |	\
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index fd6e7c170d37e..9e6380f597488 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -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)
diff --git a/drivers/irqchip/irq-gic-v3-mbi.c b/drivers/irqchip/irq-gic-v3-mbi.c
index 34e9ca77a8c36..e562b57923229 100644
--- a/drivers/irqchip/irq-gic-v3-mbi.c
+++ b/drivers/irqchip/irq-gic-v3-mbi.c
@@ -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;
diff --git a/drivers/irqchip/irq-imx-mu-msi.c b/drivers/irqchip/irq-imx-mu-msi.c
index 69aacdfc8bef0..137da1927d144 100644
--- a/drivers/irqchip/irq-imx-mu-msi.c
+++ b/drivers/irqchip/irq-imx-mu-msi.c
@@ -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
 
diff --git a/drivers/irqchip/irq-loongarch-avec.c b/drivers/irqchip/irq-loongarch-avec.c
index 80e55955a29fa..bf52dc8345f5f 100644
--- a/drivers/irqchip/irq-loongarch-avec.c
+++ b/drivers/irqchip/irq-loongarch-avec.c
@@ -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
diff --git a/drivers/irqchip/irq-loongson-pch-msi.c b/drivers/irqchip/irq-loongson-pch-msi.c
index 9c62108b3ad58..fb690c7cbcaa6 100644
--- a/drivers/irqchip/irq-loongson-pch-msi.c
+++ b/drivers/irqchip/irq-loongson-pch-msi.c
@@ -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;
diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c
index 51464c6257f37..2a61c06c4da07 100644
--- a/drivers/irqchip/irq-msi-lib.c
+++ b/drivers/irqchip/irq-msi-lib.c
@@ -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
diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c
index d67f93f6d7505..0b2a857b49018 100644
--- a/drivers/irqchip/irq-mvebu-gicp.c
+++ b/drivers/irqchip/irq-mvebu-gicp.c
@@ -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>
 
diff --git a/drivers/irqchip/irq-mvebu-icu.c b/drivers/irqchip/irq-mvebu-icu.c
index 4eebed39880a5..db5dbc6e88b05 100644
--- a/drivers/irqchip/irq-mvebu-icu.c
+++ b/drivers/irqchip/irq-mvebu-icu.c
@@ -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>
 
diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c
index 28f7e81df94f0..306a7754e44f8 100644
--- a/drivers/irqchip/irq-mvebu-odmi.c
+++ b/drivers/irqchip/irq-mvebu-odmi.c
@@ -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>
 
diff --git a/drivers/irqchip/irq-mvebu-sei.c b/drivers/irqchip/irq-mvebu-sei.c
index ebd4a9014e8da..a962ef4977169 100644
--- a/drivers/irqchip/irq-mvebu-sei.c
+++ b/drivers/irqchip/irq-mvebu-sei.c
@@ -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))
diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c
index b8ae67c25b37a..1b9fbfce95816 100644
--- a/drivers/irqchip/irq-riscv-imsic-platform.c
+++ b/drivers/irqchip/irq-riscv-imsic-platform.c
@@ -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,
diff --git a/drivers/irqchip/irq-sg2042-msi.c b/drivers/irqchip/irq-sg2042-msi.c
index ee682e87eb8be..d641f3a5eee9e 100644
--- a/drivers/irqchip/irq-sg2042-msi.c
+++ b/drivers/irqchip/irq-sg2042-msi.c
@@ -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
 
diff --git a/drivers/irqchip/irq-msi-lib.h b/include/linux/irqchip/irq-msi-lib.h
similarity index 84%
rename from drivers/irqchip/irq-msi-lib.h
rename to include/linux/irqchip/irq-msi-lib.h
index 681ceabb7bc74..dd8d1d1385449 100644
--- a/drivers/irqchip/irq-msi-lib.h
+++ b/include/linux/irqchip/irq-msi-lib.h
@@ -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 */
-- 
2.39.2


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

* [PATCH v2 2/9] genirq/msi: Add helper for creating MSI-parent irq domains
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 1/9] irqchip: Make irq-msi-lib.h globally available Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper Marc Zyngier
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 include/linux/msi.h |  4 ++++
 kernel/irq/msi.c    | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/linux/msi.h b/include/linux/msi.h
index 8c0ec9fc05a39..56c69d14ef4a2 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -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,
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index a8f7701c2929f..e702e536c8034 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -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
-- 
2.39.2


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

* [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 1/9] irqchip: Make irq-msi-lib.h globally available Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 2/9] genirq/msi: Add helper for creating MSI-parent irq domains Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-16 10:36   ` Thomas Gleixner
  2025-05-13 17:28 ` [PATCH v2 4/9] irqchip/mvebu: " Marc Zyngier
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 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(-)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 62676994d0695..9050792e3242f 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -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;
 }
 
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 9e6380f597488..9ea3a6723263c 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -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;
diff --git a/drivers/irqchip/irq-gic-v3-mbi.c b/drivers/irqchip/irq-gic-v3-mbi.c
index e562b57923229..11fa5df9da8c7 100644
--- a/drivers/irqchip/irq-gic-v3-mbi.c
+++ b/drivers/irqchip/irq-gic-v3-mbi.c
@@ -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;
 }
 
-- 
2.39.2


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

* [PATCH v2 4/9] irqchip/mvebu: Convert to msi_create_parent_irq_domain() helper
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
                   ` (2 preceding siblings ...)
  2025-05-13 17:28 ` [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 5/9] irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers Marc Zyngier
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 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(-)

diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c
index 0b2a857b49018..c7c83f8923fcd 100644
--- a/drivers/irqchip/irq-mvebu-gicp.c
+++ b/drivers/irqchip/irq-mvebu-gicp.c
@@ -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;
 }
 
diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c
index 306a7754e44f8..e6049f647a017 100644
--- a/drivers/irqchip/irq-mvebu-odmi.c
+++ b/drivers/irqchip/irq-mvebu-odmi.c
@@ -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:
diff --git a/drivers/irqchip/irq-mvebu-sei.c b/drivers/irqchip/irq-mvebu-sei.c
index a962ef4977169..cacf88530e444 100644
--- a/drivers/irqchip/irq-mvebu-sei.c
+++ b/drivers/irqchip/irq-mvebu-sei.c
@@ -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);
-- 
2.39.2


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

* [PATCH v2 5/9] irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
                   ` (3 preceding siblings ...)
  2025-05-13 17:28 ` [PATCH v2 4/9] irqchip/mvebu: " Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 6/9] irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag Marc Zyngier
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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()")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 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(-)

diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index 9050792e3242f..e30463a7bf1ea 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -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-",
diff --git a/drivers/irqchip/irq-gic-v3-its-msi-parent.c b/drivers/irqchip/irq-gic-v3-its-msi-parent.c
index 51cc961bc3181..443e8fcf2fc16 100644
--- a/drivers/irqchip/irq-gic-v3-its-msi-parent.c
+++ b/drivers/irqchip/irq-gic-v3-its-msi-parent.c
@@ -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-",
diff --git a/drivers/irqchip/irq-gic-v3-mbi.c b/drivers/irqchip/irq-gic-v3-mbi.c
index 11fa5df9da8c7..a9142677c810c 100644
--- a/drivers/irqchip/irq-gic-v3-mbi.c
+++ b/drivers/irqchip/irq-gic-v3-mbi.c
@@ -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-",
diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c
index c7c83f8923fcd..68764e7754ba6 100644
--- a/drivers/irqchip/irq-mvebu-gicp.c
+++ b/drivers/irqchip/irq-mvebu-gicp.c
@@ -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-",
diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c
index e6049f647a017..fe99888b8134d 100644
--- a/drivers/irqchip/irq-mvebu-odmi.c
+++ b/drivers/irqchip/irq-mvebu-odmi.c
@@ -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-",
-- 
2.39.2


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

* [PATCH v2 6/9] irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
                   ` (4 preceding siblings ...)
  2025-05-13 17:28 ` [PATCH v2 5/9] irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 7/9] PCI: apple: Convert to MSI parent infrastructure Marc Zyngier
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/irqchip/irq-msi-lib.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-msi-lib.c b/drivers/irqchip/irq-msi-lib.c
index 2a61c06c4da07..246c30205af40 100644
--- a/drivers/irqchip/irq-msi-lib.c
+++ b/drivers/irqchip/irq-msi-lib.c
@@ -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);
-- 
2.39.2


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

* [PATCH v2 7/9] PCI: apple: Convert to MSI parent infrastructure
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
                   ` (5 preceding siblings ...)
  2025-05-13 17:28 ` [PATCH v2 6/9] irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-13 18:06   ` Alyssa Rosenzweig
  2025-05-13 17:28 ` [PATCH v2 8/9] PCI: xgene: " Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 9/9] PCI: tegra: " Marc Zyngier
  8 siblings, 1 reply; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pci/controller/Kconfig      |  1 +
 drivers/pci/controller/pcie-apple.c | 62 ++++++++++-------------------
 2 files changed, 22 insertions(+), 41 deletions(-)

diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 9800b76810540..98a62f4559dfd 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -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
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index 18e11b9a7f464..6c88b4dd34151 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -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;
 }
-- 
2.39.2


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

* [PATCH v2 8/9] PCI: xgene: Convert to MSI parent infrastructure
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
                   ` (6 preceding siblings ...)
  2025-05-13 17:28 ` [PATCH v2 7/9] PCI: apple: Convert to MSI parent infrastructure Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  2025-05-13 17:28 ` [PATCH v2 9/9] PCI: tegra: " Marc Zyngier
  8 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pci/controller/Kconfig         |  1 +
 drivers/pci/controller/pci-xgene-msi.c | 46 ++++++++++----------------
 2 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 98a62f4559dfd..205e0e365c6b1 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -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.
diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c
index 7bce327897c93..857177ab3d30f 100644
--- a/drivers/pci/controller/pci-xgene-msi.c
+++ b/drivers/pci/controller/pci-xgene-msi.c
@@ -12,6 +12,7 @@
 #include <linux/module.h>
 #include <linux/msi.h>
 #include <linux/irqchip/chained_irq.h>
+#include <linux/irqchip/irq-msi-lib.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/of_pci.h>
@@ -32,7 +33,6 @@ struct xgene_msi_group {
 struct xgene_msi {
 	struct device_node	*node;
 	struct irq_domain	*inner_domain;
-	struct irq_domain	*msi_domain;
 	u64			msi_addr;
 	void __iomem		*msi_regs;
 	unsigned long		*bitmap;
@@ -44,20 +44,6 @@ struct xgene_msi {
 /* Global data */
 static struct xgene_msi xgene_msi_ctrl;
 
-static struct irq_chip xgene_msi_top_irq_chip = {
-	.name		= "X-Gene1 MSI",
-	.irq_enable	= pci_msi_unmask_irq,
-	.irq_disable	= pci_msi_mask_irq,
-	.irq_mask	= pci_msi_mask_irq,
-	.irq_unmask	= pci_msi_unmask_irq,
-};
-
-static struct  msi_domain_info xgene_msi_domain_info = {
-	.flags	= (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
-		  MSI_FLAG_PCI_MSIX),
-	.chip	= &xgene_msi_top_irq_chip,
-};
-
 /*
  * X-Gene v1 has 16 groups of MSI termination registers MSInIRx, where
  * n is group number (0..F), x is index of registers in each group (0..7)
@@ -235,34 +221,36 @@ static void xgene_irq_domain_free(struct irq_domain *domain,
 	irq_domain_free_irqs_parent(domain, virq, nr_irqs);
 }
 
-static const struct irq_domain_ops msi_domain_ops = {
+static const struct irq_domain_ops xgene_msi_domain_ops = {
 	.alloc  = xgene_irq_domain_alloc,
 	.free   = xgene_irq_domain_free,
 };
 
+static const struct msi_parent_ops xgene_msi_parent_ops = {
+	.supported_flags	= (MSI_GENERIC_FLAGS_MASK	|
+				   MSI_FLAG_PCI_MSIX),
+	.required_flags		= (MSI_FLAG_USE_DEF_DOM_OPS	|
+				   MSI_FLAG_USE_DEF_CHIP_OPS),
+	.bus_select_token	= DOMAIN_BUS_PCI_MSI,
+	.init_dev_msi_info	= msi_lib_init_dev_msi_info,
+};
+
 static int xgene_allocate_domains(struct xgene_msi *msi)
 {
-	msi->inner_domain = irq_domain_add_linear(NULL, NR_MSI_VEC,
-						  &msi_domain_ops, msi);
+	msi->inner_domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= of_node_to_fwnode(msi->node),
+			.ops		= &xgene_msi_domain_ops,
+			.size		= NR_MSI_VEC,
+			.host_data	= msi,
+		}, &xgene_msi_parent_ops);
 	if (!msi->inner_domain)
 		return -ENOMEM;
 
-	msi->msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(msi->node),
-						    &xgene_msi_domain_info,
-						    msi->inner_domain);
-
-	if (!msi->msi_domain) {
-		irq_domain_remove(msi->inner_domain);
-		return -ENOMEM;
-	}
-
 	return 0;
 }
 
 static void xgene_free_domains(struct xgene_msi *msi)
 {
-	if (msi->msi_domain)
-		irq_domain_remove(msi->msi_domain);
 	if (msi->inner_domain)
 		irq_domain_remove(msi->inner_domain);
 }
-- 
2.39.2


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

* [PATCH v2 9/9] PCI: tegra: Convert to MSI parent infrastructure
  2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
                   ` (7 preceding siblings ...)
  2025-05-13 17:28 ` [PATCH v2 8/9] PCI: xgene: " Marc Zyngier
@ 2025-05-13 17:28 ` Marc Zyngier
  8 siblings, 0 replies; 14+ messages in thread
From: Marc Zyngier @ 2025-05-13 17:28 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-pci
  Cc: Thomas Gleixner, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

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.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/pci/controller/Kconfig     |  1 +
 drivers/pci/controller/pci-tegra.c | 60 +++++++++---------------------
 2 files changed, 19 insertions(+), 42 deletions(-)

diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
index 205e0e365c6b1..eb3cc28d43f82 100644
--- a/drivers/pci/controller/Kconfig
+++ b/drivers/pci/controller/Kconfig
@@ -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.
diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index d2f88997283ae..def9384bd6ff0 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -22,6 +22,7 @@
 #include <linux/iopoll.h>
 #include <linux/irq.h>
 #include <linux/irqchip/chained_irq.h>
+#include <linux/irqchip/irq-msi-lib.h>
 #include <linux/irqdomain.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -1547,7 +1548,7 @@ static void tegra_pcie_msi_irq(struct irq_desc *desc)
 			unsigned int index = i * 32 + offset;
 			int ret;
 
-			ret = generic_handle_domain_irq(msi->domain->parent, index);
+			ret = generic_handle_domain_irq(msi->domain, index);
 			if (ret) {
 				/*
 				 * that's weird who triggered this?
@@ -1565,30 +1566,6 @@ static void tegra_pcie_msi_irq(struct irq_desc *desc)
 	chained_irq_exit(chip, desc);
 }
 
-static void tegra_msi_top_irq_ack(struct irq_data *d)
-{
-	irq_chip_ack_parent(d);
-}
-
-static void tegra_msi_top_irq_mask(struct irq_data *d)
-{
-	pci_msi_mask_irq(d);
-	irq_chip_mask_parent(d);
-}
-
-static void tegra_msi_top_irq_unmask(struct irq_data *d)
-{
-	pci_msi_unmask_irq(d);
-	irq_chip_unmask_parent(d);
-}
-
-static struct irq_chip tegra_msi_top_chip = {
-	.name		= "Tegra PCIe MSI",
-	.irq_ack	= tegra_msi_top_irq_ack,
-	.irq_mask	= tegra_msi_top_irq_mask,
-	.irq_unmask	= tegra_msi_top_irq_unmask,
-};
-
 static void tegra_msi_irq_ack(struct irq_data *d)
 {
 	struct tegra_msi *msi = irq_data_get_irq_chip_data(d);
@@ -1690,30 +1667,32 @@ static const struct irq_domain_ops tegra_msi_domain_ops = {
 	.free = tegra_msi_domain_free,
 };
 
-static struct msi_domain_info tegra_msi_info = {
-	.flags	= MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
-		  MSI_FLAG_NO_AFFINITY | MSI_FLAG_PCI_MSIX,
-	.chip	= &tegra_msi_top_chip,
+static const struct msi_parent_ops tegra_msi_parent_ops = {
+	.supported_flags	= (MSI_GENERIC_FLAGS_MASK	|
+				   MSI_FLAG_PCI_MSIX),
+	.required_flags		= (MSI_FLAG_USE_DEF_DOM_OPS	|
+				   MSI_FLAG_USE_DEF_CHIP_OPS	|
+				   MSI_FLAG_PCI_MSI_MASK_PARENT	|
+				   MSI_FLAG_NO_AFFINITY),
+	.chip_flags		= MSI_CHIP_FLAG_SET_ACK,
+	.bus_select_token	= DOMAIN_BUS_PCI_MSI,
+	.init_dev_msi_info	= msi_lib_init_dev_msi_info,
 };
 
 static int tegra_allocate_domains(struct tegra_msi *msi)
 {
 	struct tegra_pcie *pcie = msi_to_pcie(msi);
 	struct fwnode_handle *fwnode = dev_fwnode(pcie->dev);
-	struct irq_domain *parent;
 
-	parent = irq_domain_create_linear(fwnode, INT_PCI_MSI_NR,
-					  &tegra_msi_domain_ops, msi);
-	if (!parent) {
-		dev_err(pcie->dev, "failed to create IRQ domain\n");
-		return -ENOMEM;
-	}
-	irq_domain_update_bus_token(parent, DOMAIN_BUS_NEXUS);
+	msi->domain = msi_create_parent_irq_domain(&(struct irq_domain_info){
+			.fwnode		= fwnode,
+			.ops		= &tegra_msi_domain_ops,
+			.size		= INT_PCI_MSI_NR,
+			.host_data	= msi,
+		}, &tegra_msi_parent_ops);
 
-	msi->domain = pci_msi_create_irq_domain(fwnode, &tegra_msi_info, parent);
 	if (!msi->domain) {
 		dev_err(pcie->dev, "failed to create MSI domain\n");
-		irq_domain_remove(parent);
 		return -ENOMEM;
 	}
 
@@ -1722,10 +1701,7 @@ static int tegra_allocate_domains(struct tegra_msi *msi)
 
 static void tegra_free_domains(struct tegra_msi *msi)
 {
-	struct irq_domain *parent = msi->domain->parent;
-
 	irq_domain_remove(msi->domain);
-	irq_domain_remove(parent);
 }
 
 static int tegra_pcie_msi_setup(struct tegra_pcie *pcie)
-- 
2.39.2


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

* Re: [PATCH v2 7/9] PCI: apple: Convert to MSI parent infrastructure
  2025-05-13 17:28 ` [PATCH v2 7/9] PCI: apple: Convert to MSI parent infrastructure Marc Zyngier
@ 2025-05-13 18:06   ` Alyssa Rosenzweig
  0 siblings, 0 replies; 14+ messages in thread
From: Alyssa Rosenzweig @ 2025-05-13 18:06 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: linux-kernel, linux-arm-kernel, linux-pci, Thomas Gleixner,
	Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
	Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Bjorn Helgaas, Toan Le, Thierry Reding,
	Jonathan Hunter

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>

Le Tue , May 13, 2025 at 06:28:17PM +0100, Marc Zyngier a écrit :
> 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.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  drivers/pci/controller/Kconfig      |  1 +
>  drivers/pci/controller/pcie-apple.c | 62 ++++++++++-------------------
>  2 files changed, 22 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig
> index 9800b76810540..98a62f4559dfd 100644
> --- a/drivers/pci/controller/Kconfig
> +++ b/drivers/pci/controller/Kconfig
> @@ -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
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index 18e11b9a7f464..6c88b4dd34151 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -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;
>  }
> -- 
> 2.39.2
> 

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

* Re: [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper
  2025-05-13 17:28 ` [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper Marc Zyngier
@ 2025-05-16 10:36   ` Thomas Gleixner
  2025-05-16 10:47     ` Marc Zyngier
  0 siblings, 1 reply; 14+ messages in thread
From: Thomas Gleixner @ 2025-05-16 10:36 UTC (permalink / raw)
  To: Marc Zyngier, linux-kernel, linux-arm-kernel, linux-pci
  Cc: Andrew Lunn, Gregory Clement, Sebastian Hesselbarth,
	Lorenzo Pieralisi, Krzysztof Wilczyński,
	Manivannan Sadhasivam, Bjorn Helgaas, Toan Le, Alyssa Rosenzweig,
	Thierry Reding, Jonathan Hunter

On Tue, May 13 2025 at 18:28, Marc Zyngier wrote:
>  	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

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

* Re: [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper
  2025-05-16 10:36   ` Thomas Gleixner
@ 2025-05-16 10:47     ` Marc Zyngier
  2025-05-16 10:55       ` Thomas Gleixner
  0 siblings, 1 reply; 14+ messages in thread
From: Marc Zyngier @ 2025-05-16 10:47 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: linux-kernel, linux-arm-kernel, linux-pci, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

On Fri, 16 May 2025 11:36:07 +0100,
Thomas Gleixner <tglx@linutronix.de> wrote:
> 
> On Tue, May 13 2025 at 18:28, Marc Zyngier wrote:
> >  	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.

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.

-- 
Without deviation from the norm, progress is not possible.

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

* Re: [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper
  2025-05-16 10:47     ` Marc Zyngier
@ 2025-05-16 10:55       ` Thomas Gleixner
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Gleixner @ 2025-05-16 10:55 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: linux-kernel, linux-arm-kernel, linux-pci, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Bjorn Helgaas,
	Toan Le, Alyssa Rosenzweig, Thierry Reding, Jonathan Hunter

On Fri, May 16 2025 at 11:47, Marc Zyngier wrote:
> On Fri, 16 May 2025 11:36:07 +0100,
> Thomas Gleixner <tglx@linutronix.de> wrote:
>> 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

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

end of thread, other threads:[~2025-05-16 10:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-13 17:28 [PATCH v2 0/9] irqchip: MSI parent cleanup and PCI host driver conversion Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 1/9] irqchip: Make irq-msi-lib.h globally available Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 2/9] genirq/msi: Add helper for creating MSI-parent irq domains Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 3/9] irqchip/gic: Convert to msi_create_parent_irq_domain() helper Marc Zyngier
2025-05-16 10:36   ` Thomas Gleixner
2025-05-16 10:47     ` Marc Zyngier
2025-05-16 10:55       ` Thomas Gleixner
2025-05-13 17:28 ` [PATCH v2 4/9] irqchip/mvebu: " Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 5/9] irqchip: Drop MSI_CHIP_FLAG_SET_ACK from unsuspecting MSI drivers Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 6/9] irqchip/msi-lib: Honour the MSI_FLAG_NO_AFFINITY flag Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 7/9] PCI: apple: Convert to MSI parent infrastructure Marc Zyngier
2025-05-13 18:06   ` Alyssa Rosenzweig
2025-05-13 17:28 ` [PATCH v2 8/9] PCI: xgene: " Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 9/9] PCI: tegra: " Marc Zyngier

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