From: Frank Li <Frank.li@nxp.com>
To: Peng Fan <peng.fan@nxp.com>
Cc: 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>,
Daniel Baluta <daniel.baluta@nxp.com>,
Hiago De Franco <hiago.franco@toradex.com>,
linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/6] remoteproc: imx_rproc: Simplify IMX_RPROC_SMC switch case
Date: Mon, 8 Sep 2025 11:02:04 -0400 [thread overview]
Message-ID: <aL7v7P5kRDt3vTuc@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250908-imx-rproc-cleanup-v1-5-e838cb14436c@nxp.com>
On Mon, Sep 08, 2025 at 09:07:38PM +0800, Peng Fan wrote:
> Introduce imx_rproc_arm_smc_{start, stop, detect_mode}() helper functions
> for all i.MX variants using IMX_RPROC_SMC to manage remote processors.
>
> This allows the removal of the IMX_RPROC_SMC switch-case blocks from
> imx_rproc_start(), imx_rproc_stop(), and imx_rproc_detect_mode(), resulting
> in cleaner and more maintainable code.
>
> Since this is the last switch in imx_rproc_{start,stop}{}, remove
> the switch-case.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/remoteproc/imx_rproc.c | 69 ++++++++++++++++++++++++++----------------
> 1 file changed, 43 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index ea34080970c6a5a9b035ef0d389014b8268660a9..5fa729f4286f6ac939357c32fef41d7d97e5f860 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -285,6 +285,15 @@ static const struct imx_rproc_att imx_rproc_att_imx6sx[] = {
> { 0x80000000, 0x80000000, 0x60000000, 0 },
> };
>
> +static int imx_rproc_arm_smc_start(struct rproc *rproc)
> +{
> + struct arm_smccc_res res;
> +
> + arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_START, 0, 0, 0, 0, 0, 0, &res);
> +
> + return res.a0;
> +}
> +
> static int imx_rproc_mmio_start(struct rproc *rproc)
> {
> struct imx_rproc *priv = rproc->priv;
> @@ -308,7 +317,6 @@ static int imx_rproc_start(struct rproc *rproc)
> struct imx_rproc *priv = rproc->priv;
> const struct imx_rproc_dcfg *dcfg = priv->dcfg;
> struct device *dev = priv->dev;
> - struct arm_smccc_res res;
> int ret;
>
> ret = imx_rproc_xtr_mbox_init(rproc, true);
> @@ -320,14 +328,7 @@ static int imx_rproc_start(struct rproc *rproc)
> goto start_ret;
> }
>
> - switch (dcfg->method) {
> - case IMX_RPROC_SMC:
> - arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_START, 0, 0, 0, 0, 0, 0, &res);
> - ret = res.a0;
> - break;
> - default:
> - return -EOPNOTSUPP;
> - }
> + return -EOPNOTSUPP;
>
> start_ret:
> if (ret)
> @@ -336,6 +337,18 @@ static int imx_rproc_start(struct rproc *rproc)
> return ret;
> }
>
> +static int imx_rproc_arm_smc_stop(struct rproc *rproc)
> +{
> + struct imx_rproc *priv = rproc->priv;
> + struct arm_smccc_res res;
> +
> + arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_STOP, 0, 0, 0, 0, 0, 0, &res);
> + if (res.a1)
> + dev_info(priv->dev, "Not in wfi, force stopped\n");
> +
> + return res.a0;
> +}
> +
> static int imx_rproc_mmio_stop(struct rproc *rproc)
> {
> struct imx_rproc *priv = rproc->priv;
> @@ -365,7 +378,6 @@ static int imx_rproc_stop(struct rproc *rproc)
> struct imx_rproc *priv = rproc->priv;
> const struct imx_rproc_dcfg *dcfg = priv->dcfg;
> struct device *dev = priv->dev;
> - struct arm_smccc_res res;
> int ret;
>
> if (dcfg->ops && dcfg->ops->stop) {
> @@ -373,16 +385,7 @@ static int imx_rproc_stop(struct rproc *rproc)
> goto stop_ret;
> }
>
> - switch (dcfg->method) {
> - case IMX_RPROC_SMC:
> - arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_STOP, 0, 0, 0, 0, 0, 0, &res);
> - ret = res.a0;
> - if (res.a1)
> - dev_info(dev, "Not in wfi, force stopped\n");
> - break;
> - default:
> - return -EOPNOTSUPP;
> - }
> + return -EOPNOTSUPP;
>
> stop_ret:
> if (ret)
> @@ -867,6 +870,18 @@ static int imx_rproc_attach_pd(struct imx_rproc *priv)
> return 0;
> }
>
> +static int imx_rproc_arm_smc_detect_mode(struct rproc *rproc)
> +{
> + struct imx_rproc *priv = rproc->priv;
> + struct arm_smccc_res res;
> +
> + arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_STARTED, 0, 0, 0, 0, 0, 0, &res);
> + if (res.a0)
> + priv->rproc->state = RPROC_DETACHED;
> +
> + return 0;
> +}
> +
> static int imx_rproc_mmio_detect_mode(struct rproc *rproc)
> {
> const struct regmap_config config = { .name = "imx-rproc" };
> @@ -981,7 +996,6 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
> static int imx_rproc_detect_mode(struct imx_rproc *priv)
> {
> const struct imx_rproc_dcfg *dcfg = priv->dcfg;
> - struct arm_smccc_res res;
>
> if (dcfg->ops && dcfg->ops->detect_mode)
> return dcfg->ops->detect_mode(priv->rproc);
> @@ -990,11 +1004,6 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
> case IMX_RPROC_NONE:
> priv->rproc->state = RPROC_DETACHED;
> return 0;
> - case IMX_RPROC_SMC:
> - arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_STARTED, 0, 0, 0, 0, 0, 0, &res);
> - if (res.a0)
> - priv->rproc->state = RPROC_DETACHED;
> - return 0;
> default:
> break;
> }
> @@ -1170,6 +1179,12 @@ static void imx_rproc_remove(struct platform_device *pdev)
> destroy_workqueue(priv->workqueue);
> }
>
> +static const struct imx_rproc_plat_ops imx_rproc_ops_arm_smc = {
> + .start = imx_rproc_arm_smc_start,
> + .stop = imx_rproc_arm_smc_stop,
> + .detect_mode = imx_rproc_arm_smc_detect_mode,
> +};
> +
> static const struct imx_rproc_plat_ops imx_rproc_ops_mmio = {
> .start = imx_rproc_mmio_start,
> .stop = imx_rproc_mmio_stop,
> @@ -1199,6 +1214,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mn = {
> .att = imx_rproc_att_imx8mn,
> .att_size = ARRAY_SIZE(imx_rproc_att_imx8mn),
> .method = IMX_RPROC_SMC,
> + .ops = &imx_rproc_ops_arm_smc,
> };
>
> static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
> @@ -1265,6 +1281,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx93 = {
> .att = imx_rproc_att_imx93,
> .att_size = ARRAY_SIZE(imx_rproc_att_imx93),
> .method = IMX_RPROC_SMC,
> + .ops = &imx_rproc_ops_arm_smc,
> };
>
> static const struct of_device_id imx_rproc_of_match[] = {
>
> --
> 2.37.1
>
next prev parent reply other threads:[~2025-09-08 15:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 13:07 [PATCH 0/6] remoteproc: imx_proc: Simplify driver by removing the switch-case Peng Fan
2025-09-08 13:07 ` [PATCH 1/6] remoteproc: imx_rproc: Introduce start/stop/detect_mode ops for imx_rproc_dcfg Peng Fan
2025-09-08 14:54 ` Frank Li
2025-09-08 13:07 ` [PATCH 2/6] remoteproc: imx_rproc: Move imx_rproc_dcfg closer to imx_rproc_of_match Peng Fan
2025-09-08 14:55 ` Frank Li
2025-09-08 13:07 ` [PATCH 3/6] remoteproc: imx_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
2025-09-08 14:57 ` Frank Li
2025-09-08 13:07 ` [PATCH 4/6] remoteproc: imx_rproc: Simplify IMX_RPROC_SCU_API " Peng Fan
2025-09-08 14:59 ` Frank Li
2025-09-08 13:07 ` [PATCH 5/6] remoteproc: imx_rproc: Simplify IMX_RPROC_SMC " Peng Fan
2025-09-08 15:02 ` Frank Li [this message]
2025-09-08 13:07 ` [PATCH 6/6] remoteproc: imx_rproc: Clean up after ops introduction Peng Fan
2025-09-08 15:03 ` Frank Li
2025-09-09 3:52 ` Peng Fan
2025-09-09 16:15 ` Mathieu Poirier
2025-09-09 3:53 ` [PATCH 0/6] remoteproc: imx_proc: Simplify driver by removing the switch-case Peng Fan
2025-09-09 12:08 ` Daniel Baluta
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=aL7v7P5kRDt3vTuc@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=andersson@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=festevam@gmail.com \
--cc=hiago.franco@toradex.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=peng.fan@nxp.com \
--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®