mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Bjorn Andersson <andersson@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>, Peng Fan <peng.fan@nxp.com>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	Daniel Baluta <daniel.baluta@nxp.com>,
	linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 06/10] remoteproc: imx_rproc: Register SCU cleanup after resource acquisition
Date: Mon, 23 Nov 2026 17:20:50 +0000	[thread overview]
Message-ID: <20261123172140.3547896-7-lee@kernel.org> (raw)
In-Reply-To: <20261123172140.3547896-1-lee@kernel.org>

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@vger.kernel.org
Signed-off-by: Lee Jones <lee@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


  parent reply	other threads:[~2026-11-23 17:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 17:20 [PATCH 00/10] remoteproc: Assorted bug fixes across remoteproc core and drivers Lee Jones
2026-11-23 17:20 ` [PATCH 01/10] remoteproc: core: Fix integer overflow in rproc_check_carveout_da() Lee Jones
2026-11-23 17:20 ` [PATCH 02/10] remoteproc: k3: Fix integer overflow in k3_rproc_da_to_va() Lee Jones
2026-11-23 17:20 ` [PATCH 03/10] remoteproc: omap: Fix integer overflow in omap_rproc_da_to_va() Lee Jones
2026-11-23 17:20 ` [PATCH 04/10] remoteproc: elf_loader: Fix overflow in rproc_elf_load_segments() Lee Jones
2026-11-23 17:20 ` [PATCH 05/10] remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure Lee Jones
2026-11-23 17:20 ` Lee Jones [this message]
2026-11-23 17:20 ` [PATCH 07/10] remoteproc: qcom: Clear glink->node on allocation failure Lee Jones
2026-11-23 17:20 ` [PATCH 08/10] remoteproc: qcom: Skip unregistering uninitialised SSR subdevice Lee Jones
2026-11-23 17:20 ` [PATCH 09/10] remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset() Lee Jones
2026-11-23 17:20 ` [PATCH 10/10] remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes Lee Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123172140.3547896-7-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=andersson@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=o.rempel@pengutronix.de \
    --cc=peng.fan@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®