linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Shivamurthy Shastri <shivamurthy.shastri@linutronix.de>
To: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
	maz@kernel.org, tglx@linutronix.de, anna-maria@linutronix.de,
	shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com,
	bhelgaas@google.com, rdunlap@infradead.org, vidyas@nvidia.com,
	ilpo.jarvinen@linux.intel.com, apatel@ventanamicro.com,
	kevin.tian@intel.com, nipun.gupta@amd.com, den@valinux.co.jp,
	andrew@lunn.ch, gregory.clement@bootlin.com,
	sebastian.hesselbarth@gmail.com, gregkh@linuxfoundation.org,
	rafael@kernel.org, alex.williamson@redhat.com, will@kernel.org,
	lorenzo.pieralisi@arm.com, jgg@mellanox.com,
	ammarfaizi2@gnuweeb.org, robin.murphy@arm.com,
	lpieralisi@kernel.org, nm@ti.com, kristo@kernel.org,
	vkoul@kernel.org, okaya@kernel.org, agross@kernel.org,
	andersson@kernel.org, mark.rutland@arm.com,
	shameerali.kolothum.thodi@huawei.com, yuzenghui@huawei.com,
	shivamurthy.shastri@linutronix.de
Subject: [PATCH v3 16/24] irqchip/gic-v2m: Switch to device MSI
Date: Fri, 14 Jun 2024 12:23:55 +0200	[thread overview]
Message-ID: <20240614102403.13610-17-shivamurthy.shastri@linutronix.de> (raw)
In-Reply-To: <20240614102403.13610-1-shivamurthy.shastri@linutronix.de>

From: Thomas Gleixner <tglx@linutronix.de>

All platform MSI users and the PCI/MSI code handle per device MSI domains
when the irqdomain associated to the device provides MSI parent
functionality.

Remove the "global" PCI/MSI and platform domain related code and provide
the MSI parent functionality by filling in msi_parent_ops.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Shivamurthy Shastri <shivamurthy.shastri@linutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Marc Zyngier <maz@kernel.org>
---
v3: enabled MSI_FLAG_PCI_MSI_MASK_PARENT in msi_parent_ops::supported_flags
---
 drivers/irqchip/Kconfig       |  1 +
 drivers/irqchip/irq-gic-v2m.c | 80 +++++++++++------------------------
 2 files changed, 25 insertions(+), 56 deletions(-)

diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index b51863fa9b38..2104b8727b1a 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -26,6 +26,7 @@ config ARM_GIC_V2M
 	bool
 	depends on PCI
 	select ARM_GIC
+	select IRQ_MSI_LIB
 	select PCI_MSI
 
 config GIC_NON_BANKED
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c
index f2ff4387870d..428132aa26cc 100644
--- a/drivers/irqchip/irq-gic-v2m.c
+++ b/drivers/irqchip/irq-gic-v2m.c
@@ -26,6 +26,8 @@
 #include <linux/irqchip/arm-gic.h>
 #include <linux/irqchip/arm-gic-common.h>
 
+#include "irq-msi-lib.h"
+
 /*
 * MSI_TYPER:
 *     [31:26] Reserved
@@ -72,31 +74,6 @@ struct v2m_data {
 	u32 flags;		/* v2m flags for specific implementation */
 };
 
-static void gicv2m_mask_msi_irq(struct irq_data *d)
-{
-	pci_msi_mask_irq(d);
-	irq_chip_mask_parent(d);
-}
-
-static void gicv2m_unmask_msi_irq(struct irq_data *d)
-{
-	pci_msi_unmask_irq(d);
-	irq_chip_unmask_parent(d);
-}
-
-static struct irq_chip gicv2m_msi_irq_chip = {
-	.name			= "MSI",
-	.irq_mask		= gicv2m_mask_msi_irq,
-	.irq_unmask		= gicv2m_unmask_msi_irq,
-	.irq_eoi		= irq_chip_eoi_parent,
-};
-
-static struct msi_domain_info gicv2m_msi_domain_info = {
-	.flags	= (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
-		   MSI_FLAG_PCI_MSIX | MSI_FLAG_MULTI_PCI_MSI),
-	.chip	= &gicv2m_msi_irq_chip,
-};
-
 static phys_addr_t gicv2m_get_msi_addr(struct v2m_data *v2m, int hwirq)
 {
 	if (v2m->flags & GICV2M_GRAVITON_ADDRESS_ONLY)
@@ -230,6 +207,7 @@ static void gicv2m_irq_domain_free(struct irq_domain *domain,
 }
 
 static const struct irq_domain_ops gicv2m_domain_ops = {
+	.select			= msi_lib_irq_domain_select,
 	.alloc			= gicv2m_irq_domain_alloc,
 	.free			= gicv2m_irq_domain_free,
 };
@@ -250,19 +228,6 @@ static bool is_msi_spi_valid(u32 base, u32 num)
 	return true;
 }
 
-static struct irq_chip gicv2m_pmsi_irq_chip = {
-	.name			= "pMSI",
-};
-
-static struct msi_domain_ops gicv2m_pmsi_ops = {
-};
-
-static struct msi_domain_info gicv2m_pmsi_domain_info = {
-	.flags	= (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS),
-	.ops	= &gicv2m_pmsi_ops,
-	.chip	= &gicv2m_pmsi_irq_chip,
-};
-
 static void __init gicv2m_teardown(void)
 {
 	struct v2m_data *v2m, *tmp;
@@ -278,9 +243,26 @@ static void __init gicv2m_teardown(void)
 	}
 }
 
+#define GICV2M_MSI_FLAGS_REQUIRED  (MSI_FLAG_USE_DEF_DOM_OPS |	\
+				    MSI_FLAG_USE_DEF_CHIP_OPS)
+
+#define GICV2M_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK |	\
+				    MSI_FLAG_PCI_MSIX      |	\
+				    MSI_FLAG_MULTI_PCI_MSI |	\
+				    MSI_FLAG_PCI_MSI_MASK_PARENT)
+
+static struct msi_parent_ops gicv2m_msi_parent_ops = {
+	.supported_flags	= GICV2M_MSI_FLAGS_SUPPORTED,
+	.required_flags		= GICV2M_MSI_FLAGS_REQUIRED,
+	.bus_select_token	= DOMAIN_BUS_NEXUS,
+	.bus_select_mask	= MATCH_PCI_MSI | MATCH_PLATFORM_MSI,
+	.prefix			= "GICv2m-",
+	.init_dev_msi_info	= msi_lib_init_dev_msi_info,
+};
+
 static __init int gicv2m_allocate_domains(struct irq_domain *parent)
 {
-	struct irq_domain *inner_domain, *pci_domain, *plat_domain;
+	struct irq_domain *inner_domain;
 	struct v2m_data *v2m;
 
 	v2m = list_first_entry_or_null(&v2m_nodes, struct v2m_data, entry);
@@ -295,22 +277,8 @@ static __init int gicv2m_allocate_domains(struct irq_domain *parent)
 	}
 
 	irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS);
-	pci_domain = pci_msi_create_irq_domain(v2m->fwnode,
-					       &gicv2m_msi_domain_info,
-					       inner_domain);
-	plat_domain = platform_msi_create_irq_domain(v2m->fwnode,
-						     &gicv2m_pmsi_domain_info,
-						     inner_domain);
-	if (!pci_domain || !plat_domain) {
-		pr_err("Failed to create MSI domains\n");
-		if (plat_domain)
-			irq_domain_remove(plat_domain);
-		if (pci_domain)
-			irq_domain_remove(pci_domain);
-		irq_domain_remove(inner_domain);
-		return -ENOMEM;
-	}
-
+	inner_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
+	inner_domain->msi_parent_ops = &gicv2m_msi_parent_ops;
 	return 0;
 }
 
@@ -511,7 +479,7 @@ acpi_parse_madt_msi(union acpi_subtable_headers *header,
 		pr_info("applying Amazon Graviton quirk\n");
 		res.end = res.start + SZ_8K - 1;
 		flags |= GICV2M_GRAVITON_ADDRESS_ONLY;
-		gicv2m_msi_domain_info.flags &= ~MSI_FLAG_MULTI_PCI_MSI;
+		gicv2m_msi_parent_ops.supported_flags &= ~MSI_FLAG_MULTI_PCI_MSI;
 	}
 
 	if (m->flags & ACPI_MADT_OVERRIDE_SPI_VALUES) {
-- 
2.34.1



  parent reply	other threads:[~2024-06-14 11:34 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14 10:23 [PATCH v3 00/24] genirq, irqchip: Convert ARM MSI handling to Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 01/24] irqdomain: Fix formatting irq_find_matching_fwspec() kerneldoc comment Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 02/24] irqchip/imx-mu-msi: Fix codingstyle in imx_mu_msi_domains_init() Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 03/24] PCI/MSI: Provide MSI_FLAG_PCI_MSI_MASK_PARENT Shivamurthy Shastri
2024-06-14 16:09   ` Bjorn Helgaas
2024-06-17 12:52     ` Thomas Gleixner
2024-06-14 10:23 ` [PATCH v3 04/24] irqchip: Provide irq-msi-lib Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 05/24] irqchip/gic-v3-its: Provide MSI parent infrastructure Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 06/24] irqchip/irq-msi-lib: Prepare for PCI MSI/MSIX Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 07/24] irqchip/gic-v3-its: Provide MSI parent for PCI/MSI[-X] Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 08/24] irqchip/irq-msi-lib: Prepare for DEVICE MSI to replace platform MSI Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 09/24] irqchip/mbigen: Prepare for real per device MSI Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 10/24] irqchip/irq-msi-lib: Prepare for DOMAIN_BUS_WIRED_TO_MSI Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 11/24] irqchip/gic-v3-its: Switch platform MSI to MSI parent Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 12/24] irqchip/mbigen: Remove platform_msi_create_device_domain() fallback Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 13/24] genirq/msi: Remove platform_msi_create_device_domain() Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 14/24] genirq/gic-v3-mbi: Remove unused wired MSI mechanics Shivamurthy Shastri
2024-06-15 17:24   ` Marc Zyngier
2024-06-17 12:55     ` Thomas Gleixner
2024-06-17 13:03       ` Marc Zyngier
2024-06-17 14:02         ` Thomas Gleixner
2024-06-17 14:15           ` Thomas Gleixner
2024-06-21 14:04             ` Thomas Gleixner
2024-06-23 11:26               ` Thomas Gleixner
2024-06-25  7:37             ` Marc Zyngier
2024-06-25  7:47               ` Thomas Gleixner
2024-06-14 10:23 ` [PATCH v3 15/24] genirq/gic-v3-mbi: Switch to MSI parent Shivamurthy Shastri
2024-06-14 10:23 ` Shivamurthy Shastri [this message]
2024-06-14 10:23 ` [PATCH v3 17/24] irqchip/imx-mu-msi: " Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 18/24] irqchip/irq-mvebu-icu: Prepare for real per device MSI Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 19/24] irqchip/mvebu-gicp: Switch to MSI parent Shivamurthy Shastri
2024-06-14 10:23 ` [PATCH v3 20/24] irqchip/mvebu-odmi: Switch to parent MSI Shivamurthy Shastri
2024-06-14 10:24 ` [PATCH v3 21/24] irqchip/irq-mvebu-sei: Switch to MSI parent Shivamurthy Shastri
2024-06-14 10:24 ` [PATCH v3 22/24] irqchip/irq-mvebu-icu: Remove platform MSI leftovers Shivamurthy Shastri
2024-06-14 10:24 ` [PATCH v3 23/24] genirq/msi: " Shivamurthy Shastri
2024-06-14 10:24 ` [PATCH v3 24/24] genirq/msi: Move msi_device_data to core Shivamurthy Shastri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240614102403.13610-17-shivamurthy.shastri@linutronix.de \
    --to=shivamurthy.shastri@linutronix.de \
    --cc=agross@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=andersson@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=anna-maria@linutronix.de \
    --cc=apatel@ventanamicro.com \
    --cc=bhelgaas@google.com \
    --cc=den@valinux.co.jp \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@bootlin.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jgg@mellanox.com \
    --cc=kevin.tian@intel.com \
    --cc=kristo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=nipun.gupta@amd.com \
    --cc=nm@ti.com \
    --cc=okaya@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=shawnguo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vidyas@nvidia.com \
    --cc=vkoul@kernel.org \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).