Skip to content

Commit 2f221ae

Browse files
author
Myron Stowe
committed
genirq/msi: Add helper for creating MSI-parent irq domains
JIRA: https://issues.redhat.com/browse/RHEL-120705 Upstream Status: e4d001b commit e4d001b Author: Marc Zyngier <maz@kernel.org> Date: Tue May 13 18:28:12 2025 +0100 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. Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250513172819.2216709-3-maz@kernel.org Signed-off-by: Myron Stowe <mstowe@redhat.com>
1 parent 82b3ff5 commit 2f221ae

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

include/linux/msi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,10 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
636636
struct msi_domain_info *info,
637637
struct irq_domain *parent);
638638

639+
struct irq_domain_info;
640+
struct irq_domain *msi_create_parent_irq_domain(struct irq_domain_info *info,
641+
const struct msi_parent_ops *msi_parent_ops);
642+
639643
bool msi_create_device_irq_domain(struct device *dev, unsigned int domid,
640644
const struct msi_domain_template *template,
641645
unsigned int hwsize, void *domain_data,

kernel/irq/msi.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,32 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
892892
return __msi_create_irq_domain(fwnode, info, 0, parent);
893893
}
894894

895+
/**
896+
* msi_create_parent_irq_domain - Create an MSI-parent interrupt domain
897+
* @info: MSI irqdomain creation info
898+
* @msi_parent_ops: MSI parent callbacks and configuration
899+
*
900+
* Return: pointer to the created &struct irq_domain or %NULL on failure
901+
*/
902+
struct irq_domain *msi_create_parent_irq_domain(struct irq_domain_info *info,
903+
const struct msi_parent_ops *msi_parent_ops)
904+
{
905+
struct irq_domain *d;
906+
907+
info->hwirq_max = max(info->hwirq_max, info->size);
908+
info->size = info->hwirq_max;
909+
info->domain_flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
910+
info->bus_token = msi_parent_ops->bus_select_token;
911+
912+
d = irq_domain_instantiate(info);
913+
if (IS_ERR(d))
914+
return NULL;
915+
916+
d->msi_parent_ops = msi_parent_ops;
917+
return d;
918+
}
919+
EXPORT_SYMBOL_GPL(msi_create_parent_irq_domain);
920+
895921
/**
896922
* msi_parent_init_dev_msi_info - Delegate initialization of device MSI info down
897923
* in the domain hierarchy

0 commit comments

Comments
 (0)