* [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management
@ 2026-12-03 9:29 Peng Fan
2026-12-03 9:29 ` [PATCH v2 1/8] irqchip/imx-intmux: Don't create parent mappings while counting channels Peng Fan
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
When I worked on guard_chained_irq patch, sashiko reported pre-exist
issues in imx-intmux driver. So I gave a look on this driver and found
more that need to be addressed.
Even there are a few fixes, but I think they are not critial for current
release cycle.
The first patch avoids creating parent IRQ mappings while counting channels.
It counts the entries with of_irq_count() and resolves each parent lazily
with of_irq_get() in the channel loop, preserving -EPROBE_DEFER.
The next two patches fix the removal and probe error paths. Both mask the
parent interrupt, wait for an in-flight chained handler, detach it, dispose
the child mappings, and release the parent mapping. The probe error path
also unwinds the initialized channels, tears down runtime PM, and enables
the clock before touching runtime PM so that a clock failure cannot leave
the usage counter unbalanced; a pm_runtime_set_active() failure is
propagated after unwinding.
The next three patches tighten the device-tree input handling: reject a zero
channel count, return -EINVAL instead of WARNing on malformed interrupt
specifiers (including source numbers beyond the 32 inputs), and mark the
multiplexed interrupts as level-triggered to match handle_level_irq() and
the type advertised by xlate().
The last two patches are cleanups with no functional change: use
devm_irq_domain_create_linear() for the per-channel domains and factor the
per-channel teardown into a helper shared by the probe error and remove
paths.
The teardown assumes the default fw_devlink=on/rpm behaviour, where managed
device links unbind consumers before the interrupt controller so that
consumers release their IRQ actions first. With fw_devlink=off or
permissive, an active consumer can keep its IRQ actions and threads while
child mappings are disposed, and a concurrently probing consumer can race
with the deferred domain removal; those configurations are not supported by
this series.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Changes in v2:
- Add a patch to avoid creating parent IRQ mappings while counting channels,
using of_irq_count() and lazy of_irq_get().
- Rework the zero channel count check for of_irq_count().
- Drain in-flight chained handlers before detaching them in the remove and
probe error paths.
- Check pm_runtime_set_active() and enable the clock before runtime PM.
- Reject malformed interrupt specifiers in xlate instead of WARNing.
- Correct the devm IRQ domain lifetime description in the commit message.
- Document that the teardown relies on fw_devlink=on/rpm consumer ordering.
- Link to v1: https://lore.kernel.org/r/20261117-imx-intmux-v1-0-189e7e0ad98d@nxp.com
---
Peng Fan (8):
irqchip/imx-intmux: Don't create parent mappings while counting channels
irqchip/imx-intmux: Dispose IRQ mappings on remove
irqchip/imx-intmux: Fix probe error path
irqchip/imx-intmux: Reject zero channel count
irqchip/imx-intmux: Mark input interrupts as level-triggered
irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers
irqchip/imx-intmux: Use devm_irq_domain_create_linear()
irqchip/imx-intmux: Factor out imx_intmux_teardown_channel()
drivers/irqchip/irq-imx-intmux.c | 70 ++++++++++++++++++++++++++++------------
1 file changed, 49 insertions(+), 21 deletions(-)
---
base-commit: 799dd936553182df5770dde7f38d94c8337df75a
change-id: 20261116-imx-intmux-7bebdcb8c20b
Best regards,
--
Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/8] irqchip/imx-intmux: Don't create parent mappings while counting channels
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 9:29 ` [PATCH v2 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove Peng Fan
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
platform_irq_count() resolves every parent interrupt while counting the
channels. Resolving an interrupt creates a Linux IRQ mapping as a side
effect, so a probe failure before or during channel setup leaves
mappings behind for channels that were counted but never reached.
Count the interrupt entries with of_irq_count(), which does not create
mappings, and resolve each parent lazily with of_irq_get() in the channel
loop. of_irq_count() cannot return -EPROBE_DEFER, but of_irq_get() still
does when the parent interrupt domain is unavailable, so probe deferral
is preserved.
Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 73926dec52ab..7552a3d0c369 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -204,10 +204,8 @@ static int imx_intmux_probe(struct platform_device *pdev)
int channum;
int i, ret;
- channum = platform_irq_count(pdev);
- if (channum == -EPROBE_DEFER) {
- return -EPROBE_DEFER;
- } else if (channum > CHAN_MAX_NUM) {
+ channum = of_irq_count(np);
+ if (channum > CHAN_MAX_NUM) {
dev_err(&pdev->dev, "supports up to %d multiplex channels\n",
CHAN_MAX_NUM);
return -EINVAL;
@@ -244,10 +242,12 @@ static int imx_intmux_probe(struct platform_device *pdev)
for (i = 0; i < channum; i++) {
data->irqchip_data[i].chanidx = i;
- data->irqchip_data[i].irq = irq_of_parse_and_map(np, i);
+ data->irqchip_data[i].irq = of_irq_get(np, i);
if (data->irqchip_data[i].irq <= 0) {
- ret = -EINVAL;
- dev_err(&pdev->dev, "failed to get irq\n");
+ ret = data->irqchip_data[i].irq;
+ if (!ret)
+ ret = -EINVAL;
+ dev_err_probe(&pdev->dev, ret, "failed to get irq\n");
goto out;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
2026-12-03 9:29 ` [PATCH v2 1/8] irqchip/imx-intmux: Don't create parent mappings while counting channels Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 9:29 ` [PATCH v2 3/8] irqchip/imx-intmux: Fix probe error path Peng Fan
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
The driver removes its IRQ domains without disposing the mappings
created for their 32 input lines, and it never releases the parent
IRQ mappings obtained with irq_of_parse_and_map(). Removing a domain
while mappings are still present leaves those descriptors pointing at
a freed domain, and the parent mappings leak on every unbind.
Mask the parent interrupt and wait for a handler that is already
running to finish before detaching it, then unchain it, dispose the
child mappings, remove the domain and release the parent mapping.
Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 7552a3d0c369..3b4eb9bd6678 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -296,10 +296,19 @@ static void imx_intmux_remove(struct platform_device *pdev)
/* disable all interrupt sources of this channel */
if (ret >= 0)
writel_relaxed(0, data->regs + CHANIER(i));
+ /*
+ * Mask the parent interrupt and wait for a handler that is
+ * already running to finish before its data and mappings are
+ * torn down.
+ */
+ disable_irq(data->irqchip_data[i].irq);
irq_set_chained_handler_and_data(data->irqchip_data[i].irq,
NULL, NULL);
-
+ for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
+ irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
+ hwirq));
irq_domain_remove(data->irqchip_data[i].domain);
+ irq_dispose_mapping(data->irqchip_data[i].irq);
}
pm_runtime_disable(&pdev->dev);
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/8] irqchip/imx-intmux: Fix probe error path
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
2026-12-03 9:29 ` [PATCH v2 1/8] irqchip/imx-intmux: Don't create parent mappings while counting channels Peng Fan
2026-12-03 9:29 ` [PATCH v2 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 9:29 ` [PATCH v2 4/8] irqchip/imx-intmux: Reject zero channel count Peng Fan
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
When setting up a channel fails after previous channels have been
initialized, the error path only disables the clock. The chained
handlers of those channels stay registered with handler data pointing
into the devres-managed intmux_data, which is released when probe
fails, leaving dangling pointers behind. The created IRQ domains and
parent IRQ mappings are leaked as well.
Unwind the initialized channels, tear down runtime PM and only then
disable the clock. Mask each parent interrupt and wait for a running
chained handler to finish before detaching it, so the rollback cannot
race with an in-flight imx_intmux_irq_handler().
Also enable the clock before touching runtime PM so that a clock
failure cannot leave runtime PM enabled with an unbalanced usage
counter, and propagate a pm_runtime_set_active() failure after
unwinding the usage count and clock reference.
Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 3b4eb9bd6678..06cf75a93373 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -229,16 +229,21 @@ static int imx_intmux_probe(struct platform_device *pdev)
data->channum = channum;
raw_spin_lock_init(&data->lock);
- pm_runtime_get_noresume(&pdev->dev);
- pm_runtime_set_active(&pdev->dev);
- pm_runtime_enable(&pdev->dev);
-
ret = clk_prepare_enable(data->ipg_clk);
if (ret) {
dev_err(&pdev->dev, "failed to enable ipg clk: %d\n", ret);
return ret;
}
+ pm_runtime_get_noresume(&pdev->dev);
+ ret = pm_runtime_set_active(&pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to set runtime PM active: %d\n", ret);
+ pm_runtime_put_noidle(&pdev->dev);
+ goto err_disable_clk;
+ }
+ pm_runtime_enable(&pdev->dev);
+
for (i = 0; i < channum; i++) {
data->irqchip_data[i].chanidx = i;
@@ -256,6 +261,7 @@ static int imx_intmux_probe(struct platform_device *pdev)
if (!domain) {
ret = -ENOMEM;
dev_err(&pdev->dev, "failed to create IRQ domain\n");
+ irq_dispose_mapping(data->irqchip_data[i].irq);
goto out;
}
data->irqchip_data[i].domain = domain;
@@ -279,6 +285,24 @@ static int imx_intmux_probe(struct platform_device *pdev)
return 0;
out:
+ while (i--) {
+ /*
+ * Mask the parent interrupt and wait for a handler that is
+ * already running to finish before its data and mappings are
+ * torn down.
+ */
+ disable_irq(data->irqchip_data[i].irq);
+ irq_set_chained_handler_and_data(data->irqchip_data[i].irq,
+ NULL, NULL);
+ for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
+ irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
+ hwirq));
+ irq_domain_remove(data->irqchip_data[i].domain);
+ irq_dispose_mapping(data->irqchip_data[i].irq);
+ }
+ pm_runtime_disable(&pdev->dev);
+ pm_runtime_put_noidle(&pdev->dev);
+err_disable_clk:
clk_disable_unprepare(data->ipg_clk);
return ret;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 4/8] irqchip/imx-intmux: Reject zero channel count
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
` (2 preceding siblings ...)
2026-12-03 9:29 ` [PATCH v2 3/8] irqchip/imx-intmux: Fix probe error path Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 9:29 ` [PATCH v2 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered Peng Fan
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
of_irq_count() returns the number of interrupt entries and never a
negative error. A node without interrupts yields zero, which passes the
upper-bound check and lets probe succeed without initializing a channel.
Reject a zero channel count.
Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 06cf75a93373..8eae3ed121c8 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -205,9 +205,9 @@ static int imx_intmux_probe(struct platform_device *pdev)
int i, ret;
channum = of_irq_count(np);
- if (channum > CHAN_MAX_NUM) {
- dev_err(&pdev->dev, "supports up to %d multiplex channels\n",
- CHAN_MAX_NUM);
+ if (!channum || channum > CHAN_MAX_NUM) {
+ dev_err(&pdev->dev, "invalid number of channels: %d\n",
+ channum);
return -EINVAL;
}
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
` (3 preceding siblings ...)
2026-12-03 9:29 ` [PATCH v2 4/8] irqchip/imx-intmux: Reject zero channel count Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 9:29 ` [PATCH v2 6/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
The child interrupts are handled by handle_level_irq() and xlate()
advertises IRQ_TYPE_LEVEL_HIGH, but the descriptors are not marked
IRQ_LEVEL. Apart from the inconsistency, the flag feeds IRQD_LEVEL,
which makes check_irq_resend() skip replaying level interrupts.
Set IRQ_LEVEL in the map callback.
Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 8eae3ed121c8..a9c554eba958 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -124,6 +124,7 @@ static int imx_intmux_irq_map(struct irq_domain *h, unsigned int irq,
{
struct intmux_irqchip_data *data = h->host_data;
+ irq_set_status_flags(irq, IRQ_LEVEL);
irq_set_chip_data(irq, data);
irq_set_chip_and_handler(irq, &imx_intmux_irq_chip, handle_level_irq);
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 6/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
` (4 preceding siblings ...)
2026-12-03 9:29 ` [PATCH v2 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 9:29 ` [PATCH v2 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear() Peng Fan
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
The xlate callback validates the interrupt specifier cells, but uses
WARN_ON() for checks that can be triggered by user-supplied device tree
data. A malformed specifier is an expected, recoverable error, so the
WARN only floods the log.
Return -EINVAL without the splat. Also reject source numbers beyond the
32 inputs of a channel instead of letting the association hit the WARN
in irq_domain_associate_locked().
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index a9c554eba958..369132b4677b 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -145,10 +145,13 @@ static int imx_intmux_irq_xlate(struct irq_domain *d, struct device_node *node,
* the 1st cell: hw interrupt number
* the 2nd cell: channel index
*/
- if (WARN_ON(intsize != 2))
+ if (intsize != 2)
return -EINVAL;
- if (WARN_ON(intspec[1] >= data->channum))
+ if (intspec[0] >= 32)
+ return -EINVAL;
+
+ if (intspec[1] >= data->channum)
return -EINVAL;
*out_hwirq = intspec[0];
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear()
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
` (5 preceding siblings ...)
2026-12-03 9:29 ` [PATCH v2 6/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 9:29 ` [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() Peng Fan
2026-12-03 14:14 ` [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Manage the per-channel IRQ domains with devres so that they are removed
automatically when probe fails or the driver is unbound, instead of
calling irq_domain_remove() explicitly in the probe error path and in
imx_intmux_remove().
The child mappings are still disposed explicitly before the domains go
away. devres runs after imx_intmux_remove() and after the probe error
path returns, so each domain is removed with an empty reverse map once
the IPG clock is no longer in use. The clock has no managed disable
action.
No functional change.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 369132b4677b..eeba45f312be 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -260,8 +260,9 @@ static int imx_intmux_probe(struct platform_device *pdev)
goto out;
}
- domain = irq_domain_create_linear(of_fwnode_handle(np), 32, &imx_intmux_domain_ops,
- &data->irqchip_data[i]);
+ domain = devm_irq_domain_create_linear(&pdev->dev, dev_fwnode(&pdev->dev), 32,
+ &imx_intmux_domain_ops,
+ &data->irqchip_data[i]);
if (!domain) {
ret = -ENOMEM;
dev_err(&pdev->dev, "failed to create IRQ domain\n");
@@ -301,7 +302,6 @@ static int imx_intmux_probe(struct platform_device *pdev)
for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
hwirq));
- irq_domain_remove(data->irqchip_data[i].domain);
irq_dispose_mapping(data->irqchip_data[i].irq);
}
pm_runtime_disable(&pdev->dev);
@@ -335,7 +335,6 @@ static void imx_intmux_remove(struct platform_device *pdev)
for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
hwirq));
- irq_domain_remove(data->irqchip_data[i].domain);
irq_dispose_mapping(data->irqchip_data[i].irq);
}
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel()
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
` (6 preceding siblings ...)
2026-12-03 9:29 ` [PATCH v2 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear() Peng Fan
@ 2026-12-03 9:29 ` Peng Fan
2026-12-03 14:14 ` [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 9:29 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
The per-channel teardown sequence (detach the chained handler, dispose
all child IRQ mappings, dispose the parent mapping) is open-coded in
both the probe error path and imx_intmux_remove(). Factor it out into
imx_intmux_teardown_channel() so the two paths cannot diverge.
The helper takes the driver data directly: probe only calls
platform_set_drvdata() after the channel loop, so re-fetching it via
platform_get_drvdata() would dereference NULL on the error path.
No functional change.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/irqchip/irq-imx-intmux.c | 44 ++++++++++++++++------------------------
1 file changed, 18 insertions(+), 26 deletions(-)
diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index eeba45f312be..cce21ac8c21d 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -200,6 +200,21 @@ static void imx_intmux_irq_handler(struct irq_desc *desc)
generic_handle_domain_irq(irqchip_data->domain, pos);
}
+static void imx_intmux_teardown_channel(struct intmux_data *data, int i)
+{
+ /*
+ * Mask the parent interrupt and wait for a handler that is already
+ * running to finish before its handler data, chip and mappings are
+ * torn down. irq_dispose_mapping() installs no_irq_chip before its
+ * own synchronize_irq(), which loses the GIC active-state check.
+ */
+ disable_irq(data->irqchip_data[i].irq);
+ irq_set_chained_handler_and_data(data->irqchip_data[i].irq, NULL, NULL);
+ for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
+ irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain, hwirq));
+ irq_dispose_mapping(data->irqchip_data[i].irq);
+}
+
static int imx_intmux_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -290,20 +305,8 @@ static int imx_intmux_probe(struct platform_device *pdev)
return 0;
out:
- while (i--) {
- /*
- * Mask the parent interrupt and wait for a handler that is
- * already running to finish before its data and mappings are
- * torn down.
- */
- disable_irq(data->irqchip_data[i].irq);
- irq_set_chained_handler_and_data(data->irqchip_data[i].irq,
- NULL, NULL);
- for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
- irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
- hwirq));
- irq_dispose_mapping(data->irqchip_data[i].irq);
- }
+ while (i--)
+ imx_intmux_teardown_channel(data, i);
pm_runtime_disable(&pdev->dev);
pm_runtime_put_noidle(&pdev->dev);
err_disable_clk:
@@ -324,18 +327,7 @@ static void imx_intmux_remove(struct platform_device *pdev)
/* disable all interrupt sources of this channel */
if (ret >= 0)
writel_relaxed(0, data->regs + CHANIER(i));
- /*
- * Mask the parent interrupt and wait for a handler that is
- * already running to finish before its data and mappings are
- * torn down.
- */
- disable_irq(data->irqchip_data[i].irq);
- irq_set_chained_handler_and_data(data->irqchip_data[i].irq,
- NULL, NULL);
- for (unsigned int hwirq = 0; hwirq < 32; hwirq++)
- irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain,
- hwirq));
- irq_dispose_mapping(data->irqchip_data[i].irq);
+ imx_intmux_teardown_channel(data, i);
}
pm_runtime_disable(&pdev->dev);
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
` (7 preceding siblings ...)
2026-12-03 9:29 ` [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() Peng Fan
@ 2026-12-03 14:14 ` Peng Fan
8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-12-03 14:14 UTC (permalink / raw)
To: Thomas Gleixner, Radu Rendec, Frank Li, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Shengjiu Wang,
Marc Zyngier
Cc: linux-kernel, imx, linux-arm-kernel, Peng Fan
On Thu, Dec 03, 2026 at 05:29:12PM +0800, Peng Fan wrote:
>
>---
>Changes in v2:
>- Add a patch to avoid creating parent IRQ mappings while counting channels,
> using of_irq_count() and lazy of_irq_get().
>- Rework the zero channel count check for of_irq_count().
>- Drain in-flight chained handlers before detaching them in the remove and
> probe error paths.
>- Check pm_runtime_set_active() and enable the clock before runtime PM.
>- Reject malformed interrupt specifiers in xlate instead of WARNing.
>- Correct the devm IRQ domain lifetime description in the commit message.
>- Document that the teardown relies on fw_devlink=on/rpm consumer ordering.
>- Link to v1: https://lore.kernel.org/r/20261117-imx-intmux-v1-0-189e7e0ad98d@nxp.com
Sashiko reported some issues, I will fix in v3.
https://sashiko.dev/#/patchset/20261203-imx-intmux-v2-0-a6db1eed3b5f%40nxp.com
Thanks
Peng
>
>---
>Peng Fan (8):
> irqchip/imx-intmux: Don't create parent mappings while counting channels
> irqchip/imx-intmux: Dispose IRQ mappings on remove
> irqchip/imx-intmux: Fix probe error path
> irqchip/imx-intmux: Reject zero channel count
> irqchip/imx-intmux: Mark input interrupts as level-triggered
> irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers
> irqchip/imx-intmux: Use devm_irq_domain_create_linear()
> irqchip/imx-intmux: Factor out imx_intmux_teardown_channel()
>
> drivers/irqchip/irq-imx-intmux.c | 70 ++++++++++++++++++++++++++++------------
> 1 file changed, 49 insertions(+), 21 deletions(-)
>---
>base-commit: 799dd936553182df5770dde7f38d94c8337df75a
>change-id: 20261116-imx-intmux-7bebdcb8c20b
>
>Best regards,
>--
>Peng Fan <peng.fan@nxp.com>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-12-03 14:14 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 9:29 [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
2026-12-03 9:29 ` [PATCH v2 1/8] irqchip/imx-intmux: Don't create parent mappings while counting channels Peng Fan
2026-12-03 9:29 ` [PATCH v2 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove Peng Fan
2026-12-03 9:29 ` [PATCH v2 3/8] irqchip/imx-intmux: Fix probe error path Peng Fan
2026-12-03 9:29 ` [PATCH v2 4/8] irqchip/imx-intmux: Reject zero channel count Peng Fan
2026-12-03 9:29 ` [PATCH v2 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered Peng Fan
2026-12-03 9:29 ` [PATCH v2 6/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
2026-12-03 9:29 ` [PATCH v2 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear() Peng Fan
2026-12-03 9:29 ` [PATCH v2 8/8] irqchip/imx-intmux: Factor out imx_intmux_teardown_channel() Peng Fan
2026-12-03 14:14 ` [PATCH v2 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox