Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management
@ 2026-11-17  7:14 Peng Fan
  2026-11-17  7:14 ` [PATCH 1/8] irqchip/imx-intmux: Fix probe error path Peng Fan
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Peng Fan @ 2026-11-17  7: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

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.

The first two patches fix the error and removal paths. Probe failures
leaked IRQ domains and mappings and left the already-installed chained
handlers pointing into driver data that was about to be freed, while the
remove path never released the child or parent IRQ mappings.

The next three patches tighten the device-tree input handling: propagate
all errors from platform_irq_count() instead of carrying a negative
channel count into devm_kzalloc_flex(), reject a zero channel count,
stop WARNing on malformed interrupt specifiers that can come from
user-supplied DT, and mark the multiplexed interrupts as level-triggered
to match handle_level_irq() and the type advertised by xlate().

The last three patches convert the IPG clock, the per-channel IRQ
domains and runtime PM to their device-managed variants. This removes
the manual probe/remove/error-path teardown while preserving the
existing runtime suspend/resume behavior, including gating the clock
after probe.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (8):
      irqchip/imx-intmux: Fix probe error path
      irqchip/imx-intmux: Dispose IRQ mappings on remove
      irqchip/imx-intmux: Handle platform_irq_count() errors
      irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers
      irqchip/imx-intmux: Mark input interrupts as level-triggered
      irqchip/imx-intmux: Use devm_clk_get_enabled()
      irqchip/imx-intmux: Use devm_irq_domain_create_linear()
      irqchip/imx-intmux: Use devm_pm_runtime_set_active_enabled()

 drivers/irqchip/irq-imx-intmux.c | 57 ++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 26 deletions(-)
---
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
change-id: 20261116-imx-intmux-7bebdcb8c20b

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] irqchip/imx-intmux: Fix probe error path
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17  7:14 ` [PATCH 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-11-17  7: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

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. Also enable the clock before touching runtime PM so
that a clock failure cannot leave runtime PM enabled with an
unbalanced usage counter.

Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/irqchip/irq-imx-intmux.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index c7914fea3d1f..a9eda7646e2f 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -233,16 +233,16 @@ 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);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
 	for (i = 0; i < channum; i++) {
 		data->irqchip_data[i].chanidx = i;
 
@@ -258,6 +258,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;
@@ -281,6 +282,17 @@ static int imx_intmux_probe(struct platform_device *pdev)
 
 	return 0;
 out:
+	while (i--) {
+		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);
 	clk_disable_unprepare(data->ipg_clk);
 	return ret;
 }

-- 
2.56.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
  2026-11-17  7:14 ` [PATCH 1/8] irqchip/imx-intmux: Fix probe error path Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17  7:14 ` [PATCH 3/8] irqchip/imx-intmux: Handle platform_irq_count() errors Peng Fan
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-11-17  7: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

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.

Unchain each output interrupt, dispose the child mappings and the
parent mapping, and only then remove the domain.

Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/irqchip/irq-imx-intmux.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index a9eda7646e2f..644282228f1a 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -312,8 +312,11 @@ static void imx_intmux_remove(struct platform_device *pdev)
 			writel_relaxed(0, data->regs + CHANIER(i));
 		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 3/8] irqchip/imx-intmux: Handle platform_irq_count() errors
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
  2026-11-17  7:14 ` [PATCH 1/8] irqchip/imx-intmux: Fix probe error path Peng Fan
  2026-11-17  7:14 ` [PATCH 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17  7:14 ` [PATCH 4/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-11-17  7: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

From: Peng Fan <peng.fan@nxp.com>

platform_irq_count() returns a negative errno on failure, but the driver
only special-cased -EPROBE_DEFER. For any other negative value probe
continued with a negative channel count and passed it to
devm_kzalloc_flex(), which is broken.

Propagate every negative return value and also reject a zero channel
count, which would otherwise register a controller without any channels.

Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/irqchip/irq-imx-intmux.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 644282228f1a..c7b6b475bfb9 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -207,11 +207,11 @@ static int imx_intmux_probe(struct platform_device *pdev)
 	int i, ret;
 
 	channum = platform_irq_count(pdev);
-	if (channum == -EPROBE_DEFER) {
-		return -EPROBE_DEFER;
-	} else if (channum > CHAN_MAX_NUM) {
-		dev_err(&pdev->dev, "supports up to %d multiplex channels\n",
-			CHAN_MAX_NUM);
+	if (channum < 0)
+		return channum;
+	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 4/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
                   ` (2 preceding siblings ...)
  2026-11-17  7:14 ` [PATCH 3/8] irqchip/imx-intmux: Handle platform_irq_count() errors Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17  7:14 ` [PATCH 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-11-17  7: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

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.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/irqchip/irq-imx-intmux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index c7b6b475bfb9..31fd895f477b 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -144,10 +144,10 @@ 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[1] >= data->channum)
 		return -EINVAL;
 
 	*out_hwirq = intspec[0];

-- 
2.56.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
                   ` (3 preceding siblings ...)
  2026-11-17  7:14 ` [PATCH 4/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17  7:14 ` [PATCH 6/8] irqchip/imx-intmux: Use devm_clk_get_enabled() Peng Fan
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-11-17  7: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

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.

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 31fd895f477b..ebfff621e5a9 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 6/8] irqchip/imx-intmux: Use devm_clk_get_enabled()
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
                   ` (4 preceding siblings ...)
  2026-11-17  7:14 ` [PATCH 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17  7:14 ` [PATCH 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-11-17  7: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

From: Peng Fan <peng.fan@nxp.com>

Enable the IPG clock with devm_clk_get_enabled() so that it is enabled
during probe and automatically disabled when the device is detached.

No functional change.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/irqchip/irq-imx-intmux.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index ebfff621e5a9..755c07007390 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -226,7 +226,7 @@ static int imx_intmux_probe(struct platform_device *pdev)
 		return PTR_ERR(data->regs);
 	}
 
-	data->ipg_clk = devm_clk_get(&pdev->dev, "ipg");
+	data->ipg_clk = devm_clk_get_enabled(&pdev->dev, "ipg");
 	if (IS_ERR(data->ipg_clk))
 		return dev_err_probe(&pdev->dev, PTR_ERR(data->ipg_clk),
 				     "failed to get ipg clk\n");
@@ -234,12 +234,6 @@ static int imx_intmux_probe(struct platform_device *pdev)
 	data->channum = channum;
 	raw_spin_lock_init(&data->lock);
 
-	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);
 	pm_runtime_set_active(&pdev->dev);
 	pm_runtime_enable(&pdev->dev);
@@ -294,7 +288,6 @@ static int imx_intmux_probe(struct platform_device *pdev)
 	}
 	pm_runtime_disable(&pdev->dev);
 	pm_runtime_put_noidle(&pdev->dev);
-	clk_disable_unprepare(data->ipg_clk);
 	return ret;
 }
 
@@ -323,7 +316,6 @@ static void imx_intmux_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 	if (ret >= 0) {
 		pm_runtime_put_noidle(&pdev->dev);
-		clk_disable_unprepare(data->ipg_clk);
 		pm_runtime_set_suspended(&pdev->dev);
 	}
 }

-- 
2.56.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear()
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
                   ` (5 preceding siblings ...)
  2026-11-17  7:14 ` [PATCH 6/8] irqchip/imx-intmux: Use devm_clk_get_enabled() Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17  7:14 ` [PATCH 8/8] irqchip/imx-intmux: Use devm_pm_runtime_set_active_enabled() Peng Fan
  2026-11-17 13:27 ` [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
  8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-11-17  7: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

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(), so each domain is removed
with an empty reverse map, and the domains are torn down before the IPG
clock devres action disables the clock.

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 755c07007390..1f6e5d9c797a 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -248,8 +248,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");
@@ -283,7 +284,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);
@@ -309,7 +309,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 8/8] irqchip/imx-intmux: Use devm_pm_runtime_set_active_enabled()
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
                   ` (6 preceding siblings ...)
  2026-11-17  7:14 ` [PATCH 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear() Peng Fan
@ 2026-11-17  7:14 ` Peng Fan
  2026-11-17 13:27 ` [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
  8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-11-17  7: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

From: Peng Fan <peng.fan@nxp.com>

Use devm_pm_runtime_set_active_enabled() to manage the runtime PM
enablement instead of calling pm_runtime_set_active() and
pm_runtime_enable() manually. The devres actions then disable runtime PM
and mark the device suspended when probe fails or the driver is unbound.

Keep the explicit pm_runtime_get_noresume()/pm_runtime_put() pair so the
device is still suspended immediately after a successful probe, and keep
pm_runtime_put_noidle() in remove() to drop the reference acquired by
pm_runtime_resume_and_get().

The devres teardown runs after imx_intmux_remove() and disables runtime
PM before marking the device suspended, which is the order required by
the PM core. The IPG clock devres action still disables the clock last.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/irqchip/irq-imx-intmux.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index 1f6e5d9c797a..770656ef10ec 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -234,9 +234,11 @@ static int imx_intmux_probe(struct platform_device *pdev)
 	data->channum = channum;
 	raw_spin_lock_init(&data->lock);
 
+	ret = devm_pm_runtime_set_active_enabled(&pdev->dev);
+	if (ret)
+		return ret;
+
 	pm_runtime_get_noresume(&pdev->dev);
-	pm_runtime_set_active(&pdev->dev);
-	pm_runtime_enable(&pdev->dev);
 
 	for (i = 0; i < channum; i++) {
 		data->irqchip_data[i].chanidx = i;
@@ -286,7 +288,6 @@ static int imx_intmux_probe(struct platform_device *pdev)
 							     hwirq));
 		irq_dispose_mapping(data->irqchip_data[i].irq);
 	}
-	pm_runtime_disable(&pdev->dev);
 	pm_runtime_put_noidle(&pdev->dev);
 	return ret;
 }
@@ -312,11 +313,8 @@ static void imx_intmux_remove(struct platform_device *pdev)
 		irq_dispose_mapping(data->irqchip_data[i].irq);
 	}
 
-	pm_runtime_disable(&pdev->dev);
-	if (ret >= 0) {
+	if (ret >= 0)
 		pm_runtime_put_noidle(&pdev->dev);
-		pm_runtime_set_suspended(&pdev->dev);
-	}
 }
 
 #ifdef CONFIG_PM

-- 
2.56.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management
  2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
                   ` (7 preceding siblings ...)
  2026-11-17  7:14 ` [PATCH 8/8] irqchip/imx-intmux: Use devm_pm_runtime_set_active_enabled() Peng Fan
@ 2026-11-17 13:27 ` Peng Fan
  8 siblings, 0 replies; 10+ messages in thread
From: Peng Fan @ 2026-11-17 13:27 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

Sashiko reported some findings [1], please wait V2.

[1] https://sashiko.dev/#/patchset/20261117-imx-intmux-v1-0-189e7e0ad98d%40nxp.com

Thanks
Peng


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-17 13:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17  7:14 [PATCH 0/8] irqchip/imx-intmux: Fix and modernize resource management Peng Fan
2026-11-17  7:14 ` [PATCH 1/8] irqchip/imx-intmux: Fix probe error path Peng Fan
2026-11-17  7:14 ` [PATCH 2/8] irqchip/imx-intmux: Dispose IRQ mappings on remove Peng Fan
2026-11-17  7:14 ` [PATCH 3/8] irqchip/imx-intmux: Handle platform_irq_count() errors Peng Fan
2026-11-17  7:14 ` [PATCH 4/8] irqchip/imx-intmux: Don't WARN on malformed interrupt specifiers Peng Fan
2026-11-17  7:14 ` [PATCH 5/8] irqchip/imx-intmux: Mark input interrupts as level-triggered Peng Fan
2026-11-17  7:14 ` [PATCH 6/8] irqchip/imx-intmux: Use devm_clk_get_enabled() Peng Fan
2026-11-17  7:14 ` [PATCH 7/8] irqchip/imx-intmux: Use devm_irq_domain_create_linear() Peng Fan
2026-11-17  7:14 ` [PATCH 8/8] irqchip/imx-intmux: Use devm_pm_runtime_set_active_enabled() Peng Fan
2026-11-17 13:27 ` [PATCH 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