mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org
Cc: "Thomas Gleixner" <tglx@linutronix.de>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Gregory Clement" <gregory.clement@bootlin.com>,
	"Sebastian Hesselbarth" <sebastian.hesselbarth@gmail.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Toan Le" <toan@os.amperecomputing.com>,
	"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Jonathan Hunter" <jonathanh@nvidia.com>
Subject: [PATCH v2 2/9] genirq/msi: Add helper for creating MSI-parent irq domains
Date: Tue, 13 May 2025 18:28:12 +0100	[thread overview]
Message-ID: <20250513172819.2216709-3-maz@kernel.org> (raw)
In-Reply-To: <20250513172819.2216709-1-maz@kernel.org>

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


  parent reply	other threads:[~2025-05-13 17:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-16 19:47   ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-13 17:28 ` Marc Zyngier [this message]
2025-05-16 19:47   ` [tip: irq/msi] genirq/msi: Add helper for creating MSI-parent irq domains tip-bot2 for 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-16 19:47   ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 4/9] irqchip/mvebu: " Marc Zyngier
2025-05-16 19:47   ` [tip: irq/msi] " tip-bot2 for 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-14 14:27   ` [tip: irq/urgent] " tip-bot2 for 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-16 19:47   ` [tip: irq/msi] " tip-bot2 for 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-16 19:47   ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 8/9] PCI: xgene: " Marc Zyngier
2025-05-16 19:47   ` [tip: irq/msi] " tip-bot2 for Marc Zyngier
2025-05-13 17:28 ` [PATCH v2 9/9] PCI: tegra: " Marc Zyngier
2025-05-16 19:47   ` [tip: irq/msi] " tip-bot2 for Marc Zyngier

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=20250513172819.2216709-3-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alyssa@rosenzweig.io \
    --cc=andrew@lunn.ch \
    --cc=bhelgaas@google.com \
    --cc=gregory.clement@bootlin.com \
    --cc=jonathanh@nvidia.com \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=sebastian.hesselbarth@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=thierry.reding@gmail.com \
    --cc=toan@os.amperecomputing.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

all inboxes | Powered by JetHome®