[PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition

Lee Jones lee at kernel.org
Mon Nov 23 09:20:50 PST 2026


imx_rproc_scu_api_detect_mode() registers the imx_rproc_put_scu()
devres cleanup action before attaching power domains or registering the
SCU partition reboot notifier and enabling its interrupt group.  If
imx_sc_rm_get_resource_owner() or imx_scu_irq_register_notifier() fails,
imx_rproc_put_scu() runs during failure unwind and unregisters an
unregistered notifier block while disabling an unconfigured interrupt
bit.  Worse, if imx_scu_irq_group_enable() fails, the error path
explicitly unregisters priv->rproc_nb and devres subsequently invokes
imx_rproc_put_scu() to unregister the same notifier block a second time.

Defer devm_add_action_or_reset() until power-domain attachment or SCU
notifier and interrupt setup have completed.

Fixes: 9b2451658afa ("remoteproc: imx_rproc: Use devm_add_action_or_reset() for scu cleanup")
Closes: https://sashiko.dev/#/bug/linux-1230a154-7627-4ce2-96f3-d0033709ba4e
Cc: stable at vger.kernel.org
Signed-off-by: Lee Jones <lee at kernel.org>
---
 drivers/remoteproc/imx_rproc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index a77a3342e1ed..9ff2cd50acb6 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -1083,10 +1083,6 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 	else
 		priv->core_index = 0;
 
-	ret = devm_add_action_or_reset(dev, imx_rproc_put_scu, priv);
-	if (ret)
-		return dev_err_probe(dev, ret, "Failed to add action for put scu\n");
-
 	/*
 	 * If Mcore resource is not owned by Acore partition, It is kicked by ROM,
 	 * and Linux could only do IPC with Mcore and nothing else.
@@ -1095,7 +1091,11 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 		if (of_property_read_u32(dev->of_node, "fsl,entry-address", &priv->entry))
 			return -EINVAL;
 
-		return imx_rproc_attach_pd(priv);
+		ret = imx_rproc_attach_pd(priv);
+		if (ret)
+			return ret;
+
+		goto add_scu_action;
 	}
 
 	priv->rproc->state = RPROC_DETACHED;
@@ -1126,6 +1126,11 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 		return ret;
 	}
 
+add_scu_action:
+	ret = devm_add_action_or_reset(dev, imx_rproc_put_scu, priv);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add action for put scu\n");
+
 	return 0;
 }
 
-- 
2.56.1.750.gf70dc682cf-goog




More information about the linux-arm-kernel mailing list