[PATCH v7 1/3] irqdomain: Pass temporary data to initialization callbacks

From: Fil Dunsky via B4 Relay

Date: Fri Dec 04 2026 - 14:59:40 EST


From: Fil Dunsky <filipp.dunsky@xxxxxxxxx>

Interrupt controller drivers may need the same temporary setup data in
both their generic chip and domain initialization callbacks. Passing it
through host_data requires managing its lifetime outside the core and
risks exposing the transient pointer with a published domain.

Add init_data for the initialization callbacks and clear it before
the domain is published. Callbacks must not retain this pointer.

Suggested-by: Thomas Gleixner <tglx@xxxxxxxxxx>
Link: https://lore.kernel.org/r/87zeuoogwp.ffs@fw13
Signed-off-by: Fil Dunsky <filipp.dunsky@xxxxxxxxx>
---
include/linux/irqdomain.h | 7 +++++++
kernel/irq/irqdomain.c | 3 +++
2 files changed, 10 insertions(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index d8caafcecc..2c5b9a2fe7 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -149,6 +149,9 @@ struct irq_domain_chip_generic;
* @gc: Pointer to a list of generic chips. There is a helper function for
* setting up one or more generic chips for interrupt controllers
* drivers using the generic chip library which uses this pointer.
+ * @init_data: Temporary private data for the domain and generic chip init
+ * callbacks. It may point to stack memory and is cleared before
+ * the domain is published. Callbacks must not retain this pointer.
* @dev: Pointer to the device which instantiated the irqdomain
* With per device irq domains this is not necessarily the same
* as @pm_dev.
@@ -188,6 +191,7 @@ struct irq_domain {
const struct msi_parent_ops *msi_parent_ops;
#endif
void (*exit)(struct irq_domain *d);
+ void *init_data;

/* reverse map data. The linear map gets appended to the irq_domain */
irq_hw_number_t hwirq_max;
@@ -325,6 +329,8 @@ struct irq_domain_chip_generic_info;
* domains are added using same fwnode
* @ops: Domain operation callbacks
* @host_data: Controller private data pointer
+ * @init_data: Temporary data for the domain and generic chip init
+ * callbacks. It may point to stack memory.
* @dev: Device which creates the domain
* @dgc_info: Geneneric chip information structure pointer used to
* create generic chips for the domain if not NULL.
@@ -345,6 +351,7 @@ struct irq_domain_info {
const char *name_suffix;
const struct irq_domain_ops *ops;
void *host_data;
+ void *init_data;
struct device *dev;
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
/**
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index 4fdcb6df53..daa7894c05 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -332,6 +332,7 @@ static struct irq_domain *__irq_domain_instantiate(const struct irq_domain_info
domain->flags |= info->domain_flags;
domain->exit = info->exit;
domain->dev = info->dev;
+ domain->init_data = info->init_data;

#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
if (info->parent) {
@@ -353,6 +354,8 @@ static struct irq_domain *__irq_domain_instantiate(const struct irq_domain_info
goto err_domain_gc_remove;
}

+ /* The temporary data may live on the caller's stack. */
+ domain->init_data = NULL;
__irq_domain_publish(domain);

if (cond_alloc_descs && info->virq_base > 0)

--
2.53.0