Skip to content

Commit e4d001b

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
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 <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent e51b274 commit e4d001b

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
@@ -911,6 +911,32 @@ struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode,
911911
return __msi_create_irq_domain(fwnode, info, 0, parent);
912912
}
913913

914+
/**
915+
* msi_create_parent_irq_domain - Create an MSI-parent interrupt domain
916+
* @info: MSI irqdomain creation info
917+
* @msi_parent_ops: MSI parent callbacks and configuration
918+
*
919+
* Return: pointer to the created &struct irq_domain or %NULL on failure
920+
*/
921+
struct irq_domain *msi_create_parent_irq_domain(struct irq_domain_info *info,
922+
const struct msi_parent_ops *msi_parent_ops)
923+
{
924+
struct irq_domain *d;
925+
926+
info->hwirq_max = max(info->hwirq_max, info->size);
927+
info->size = info->hwirq_max;
928+
info->domain_flags |= IRQ_DOMAIN_FLAG_MSI_PARENT;
929+
info->bus_token = msi_parent_ops->bus_select_token;
930+
931+
d = irq_domain_instantiate(info);
932+
if (IS_ERR(d))
933+
return NULL;
934+
935+
d->msi_parent_ops = msi_parent_ops;
936+
return d;
937+
}
938+
EXPORT_SYMBOL_GPL(msi_create_parent_irq_domain);
939+
914940
/**
915941
* msi_parent_init_dev_msi_info - Delegate initialization of device MSI info down
916942
* in the domain hierarchy

0 commit comments

Comments
 (0)