From: Peng Fan <peng.fan@nxp.com>
To: Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>, Frank Li <frank.li@nxp.com>,
Daniel Baluta <daniel.baluta@nxp.com>
Cc: linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 2/5] remoteproc: imx_rproc: Make detach operation platform-specific
Date: Thu, 18 Sep 2025 19:51:17 +0800 [thread overview]
Message-ID: <20250918-imx_rproc_c2-v1-2-deec8183185f@nxp.com> (raw)
In-Reply-To: <20250918-imx_rproc_c2-v1-0-deec8183185f@nxp.com>
Refactor the detach logic to support platform-specific implementations via
the dcfg->ops->detach callback. Allow finer control over detach behavior
depending on the remote processor management method, and make it easier
to add detach support for new SoCs.
The previous hardcoded SCU API detach logic is now moved into a dedicated
imx_rproc_scu_api_detach() function, and registered via the plat ops
structure. The generic imx_rproc_detach() now delegates to the
platform-specific handler if available.
Also, the dcfg->method check with IMX_RPROC_SCU_API is removed.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_rproc.c | 18 +++++++++++++-----
drivers/remoteproc/imx_rproc.h | 1 +
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 71617b20f9d0ae698e7f655aae22e8895434f32c..74c958d44611b66e024180d69d71daac5a2f9e76 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -575,13 +575,9 @@ static int imx_rproc_attach(struct rproc *rproc)
return imx_rproc_xtr_mbox_init(rproc, true);
}
-static int imx_rproc_detach(struct rproc *rproc)
+static int imx_rproc_scu_api_detach(struct rproc *rproc)
{
struct imx_rproc *priv = rproc->priv;
- const struct imx_rproc_dcfg *dcfg = priv->dcfg;
-
- if (dcfg->method != IMX_RPROC_SCU_API)
- return -EOPNOTSUPP;
if (imx_sc_rm_is_resource_owned(priv->ipc_handle, priv->rsrc_id))
return -EOPNOTSUPP;
@@ -591,6 +587,17 @@ static int imx_rproc_detach(struct rproc *rproc)
return 0;
}
+static int imx_rproc_detach(struct rproc *rproc)
+{
+ struct imx_rproc *priv = rproc->priv;
+ const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+
+ if (!dcfg->ops || !dcfg->ops->detach)
+ return -EOPNOTSUPP;
+
+ return dcfg->ops->detach(rproc);
+}
+
static struct resource_table *imx_rproc_get_loaded_rsc_table(struct rproc *rproc, size_t *table_sz)
{
struct imx_rproc *priv = rproc->priv;
@@ -1152,6 +1159,7 @@ static const struct imx_rproc_plat_ops imx_rproc_ops_mmio = {
static const struct imx_rproc_plat_ops imx_rproc_ops_scu_api = {
.start = imx_rproc_scu_api_start,
.stop = imx_rproc_scu_api_stop,
+ .detach = imx_rproc_scu_api_detach,
.detect_mode = imx_rproc_scu_api_detect_mode,
};
diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
index a9cba623560c85ea37e47401c392c06dada500aa..aeed08bdfb5619c7afd7201589f417cfd6745818 100644
--- a/drivers/remoteproc/imx_rproc.h
+++ b/drivers/remoteproc/imx_rproc.h
@@ -35,6 +35,7 @@ enum imx_rproc_method {
struct imx_rproc_plat_ops {
int (*start)(struct rproc *rproc);
int (*stop)(struct rproc *rproc);
+ int (*detach)(struct rproc *rproc);
int (*detect_mode)(struct rproc *rproc);
};
--
2.37.1
next prev parent reply other threads:[~2025-09-18 11:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 11:51 [PATCH 0/5] remoteproc: imx_rproc: misc clean up Peng Fan
2025-09-18 11:51 ` [PATCH 1/5] remoteproc: imx_rproc: Simplify clock enable logic using dcfg flags Peng Fan
2025-09-18 12:32 ` Daniel Baluta
2025-09-19 2:02 ` Peng Fan
2025-09-19 8:25 ` Daniel Baluta
2025-09-18 16:38 ` Frank Li
2025-09-18 11:51 ` Peng Fan [this message]
2025-09-18 12:36 ` [PATCH 2/5] remoteproc: imx_rproc: Make detach operation platform-specific Daniel Baluta
2025-09-18 16:39 ` Frank Li
2025-09-18 11:51 ` [PATCH 3/5] remoteproc: imx_rproc: Enable PM runtime support unconditionally Peng Fan
2025-09-18 12:37 ` Daniel Baluta
2025-09-18 16:40 ` Frank Li
2025-09-18 11:51 ` [PATCH 4/5] remoteproc: imx_rproc: Remove the assignement to method Peng Fan
2025-09-19 11:26 ` Daniel Baluta
2025-09-19 14:52 ` Frank Li
2025-09-18 11:51 ` [PATCH 5/5] MAINTAINERS: Add an entry for i.MX remoteproc driver Peng Fan
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=20250918-imx_rproc_c2-v1-2-deec8183185f@nxp.com \
--to=peng.fan@nxp.com \
--cc=andersson@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.com \
--cc=frank.li@nxp.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=s.hauer@pengutronix.de \
--cc=shawnguo@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®