* [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic
@ 2025-10-31 9:08 Peng Fan
2025-10-31 9:08 ` [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling Peng Fan
` (12 more replies)
0 siblings, 13 replies; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
This patchset aligns imx_dsp_rproc with the cleanup and modernization
previously applied to imx_rproc.c. The goal is to simplify the driver by
transitioning to the new ops-based method, eliminating the legacy
switch-case logic for a cleaner and more maintainable design.
Patches 1–5: General cleanup, including code simplification and adoption
of the devres API.
Patches 6–10: Transition to the new ops-based approach, removing the
switch-case structure.
Patch 11: Remove the obsolete enum imx_rproc_method.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (11):
remoteproc: imx_dsp_rproc: simplify power domain attach and error handling
remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper
remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper
remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors
remoteproc: imx_dsp_rproc: Drop extra space
remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg
remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match
remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case
remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API switch case
remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER switch case
remoteproc: imx_rproc: Remove enum imx_rproc_method
drivers/remoteproc/imx_dsp_rproc.c | 344 ++++++++++++++++++++-----------------
drivers/remoteproc/imx_rproc.h | 14 --
2 files changed, 184 insertions(+), 174 deletions(-)
---
base-commit: 131f3d9446a6075192cdd91f197989d98302faa6
change-id: 20251031-imx-dsp-2025-10-31-260b2b979258
Best regards,
--
Peng Fan <peng.fan@nxp.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 18:46 ` Frank Li
2025-10-31 9:08 ` [PATCH 02/11] remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper Peng Fan
` (11 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Refactor imx_dsp_attach_pm_domains() to use devm_pm_domain_attach_list()
directly, removing manual detach logic and simplifying resource management.
Also replace verbose error handling in imx_dsp_rproc_probe() with
dev_err_probe() for cleaner and more consistent error reporting.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 6e78a01755c7bdc28cd93f00fe6f74affc3d96b0..c466363debbebe8f91b908b3bffaa32e9bf8b9a6 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -1062,14 +1062,12 @@ static const struct rproc_ops imx_dsp_rproc_ops = {
static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
{
struct device *dev = priv->rproc->dev.parent;
- int ret;
/* A single PM domain is already attached. */
if (dev->pm_domain)
return 0;
- ret = dev_pm_domain_attach_list(dev, NULL, &priv->pd_list);
- return ret < 0 ? ret : 0;
+ return devm_pm_domain_attach_list(dev, NULL, &priv->pd_list);
}
/**
@@ -1186,35 +1184,25 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
/* There are multiple power domains required by DSP on some platform */
ret = imx_dsp_attach_pm_domains(priv);
- if (ret) {
- dev_err(dev, "failed on imx_dsp_attach_pm_domains\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(dev, ret, "failed on imx_dsp_attach_pm_domains\n");
+
/* Get clocks */
ret = imx_dsp_rproc_clk_get(priv);
- if (ret) {
- dev_err(dev, "failed on imx_dsp_rproc_clk_get\n");
- goto err_detach_domains;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "failed on imx_dsp_rproc_clk_get\n");
init_completion(&priv->pm_comp);
rproc->auto_boot = false;
ret = rproc_add(rproc);
- if (ret) {
- dev_err(dev, "rproc_add failed\n");
- goto err_detach_domains;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "rproc_add failed\n");
rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_XTENSA);
pm_runtime_enable(dev);
return 0;
-
-err_detach_domains:
- dev_pm_domain_detach_list(priv->pd_list);
-
- return ret;
}
static void imx_dsp_rproc_remove(struct platform_device *pdev)
@@ -1224,7 +1212,6 @@ static void imx_dsp_rproc_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
rproc_del(rproc);
- dev_pm_domain_detach_list(priv->pd_list);
}
/* pm runtime functions */
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 02/11] remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
2025-10-31 9:08 ` [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 18:47 ` Frank Li
2025-10-31 9:08 ` [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper Peng Fan
` (10 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Replace manual rproc_add() and cleanup logic with devm_rproc_add(), which
ties the remoteproc lifecycle to the device's lifecycle. This simplifies
error handling and ensures proper cleanup.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index c466363debbebe8f91b908b3bffaa32e9bf8b9a6..df6a4126538d22ff6e02145edb5ac13c2d72c949 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -1194,7 +1194,7 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
init_completion(&priv->pm_comp);
rproc->auto_boot = false;
- ret = rproc_add(rproc);
+ ret = devm_rproc_add(dev, rproc);
if (ret)
return dev_err_probe(dev, ret, "rproc_add failed\n");
@@ -1211,7 +1211,6 @@ static void imx_dsp_rproc_remove(struct platform_device *pdev)
struct imx_dsp_rproc *priv = rproc->priv;
pm_runtime_disable(&pdev->dev);
- rproc_del(rproc);
}
/* pm runtime functions */
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
2025-10-31 9:08 ` [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling Peng Fan
2025-10-31 9:08 ` [PATCH 02/11] remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 18:49 ` Frank Li
2025-10-31 9:08 ` [PATCH 04/11] remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors Peng Fan
` (9 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Replace manual pm_runtime_enable() with devm_pm_runtime_enable() to
leverage device-managed cleanup and simplify resource handling.
pm_runtime_disable_action() not only calls pm_runtime_disable(), but
also calls pm_runtime_dont_use_autosuspend(). The current driver
only calls pm_runtime_disable(). But this should be fine here to use
devm_pm_runtime_enable().
As a result, the .remove callback is no longer needed, reducing boilerplate
code.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index df6a4126538d22ff6e02145edb5ac13c2d72c949..f5d0aec52c56664d6074272e276edb0c4175c9ea 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -1200,17 +1200,7 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_XTENSA);
- pm_runtime_enable(dev);
-
- return 0;
-}
-
-static void imx_dsp_rproc_remove(struct platform_device *pdev)
-{
- struct rproc *rproc = platform_get_drvdata(pdev);
- struct imx_dsp_rproc *priv = rproc->priv;
-
- pm_runtime_disable(&pdev->dev);
+ return devm_pm_runtime_enable(dev);
}
/* pm runtime functions */
@@ -1361,7 +1351,6 @@ MODULE_DEVICE_TABLE(of, imx_dsp_rproc_of_match);
static struct platform_driver imx_dsp_rproc_driver = {
.probe = imx_dsp_rproc_probe,
- .remove = imx_dsp_rproc_remove,
.driver = {
.name = "imx-dsp-rproc",
.of_match_table = imx_dsp_rproc_of_match,
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 04/11] remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (2 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 18:50 ` Frank Li
2025-10-31 9:08 ` [PATCH 05/11] remoteproc: imx_dsp_rproc: Drop extra space Peng Fan
` (8 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Replace error logging and return handling in rproc_of_parse_firmware() and
imx_dsp_rproc_detect_mode() with dev_err_probe() to streamline error
reporting and improve consistency.
Reduces boilerplate and aligns with modern kernel error handling practices.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index f5d0aec52c56664d6074272e276edb0c4175c9ea..87f4a026c05fbf1c9371058290b2d33cb94b9e54 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -1150,11 +1150,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
return -ENODEV;
ret = rproc_of_parse_firmware(dev, 0, &fw_name);
- if (ret) {
- dev_err(dev, "failed to parse firmware-name property, ret = %d\n",
- ret);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to parse firmware-name property\n");
rproc = devm_rproc_alloc(dev, "imx-dsp-rproc", &imx_dsp_rproc_ops,
fw_name, sizeof(*priv));
@@ -1177,10 +1174,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
INIT_WORK(&priv->rproc_work, imx_dsp_rproc_vq_work);
ret = imx_dsp_rproc_detect_mode(priv);
- if (ret) {
- dev_err(dev, "failed on imx_dsp_rproc_detect_mode\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(dev, ret, "failed on imx_dsp_rproc_detect_mode\n");
/* There are multiple power domains required by DSP on some platform */
ret = imx_dsp_attach_pm_domains(priv);
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 05/11] remoteproc: imx_dsp_rproc: Drop extra space
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (3 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 04/11] remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 18:51 ` Frank Li
2025-10-31 9:08 ` [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg Peng Fan
` (7 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Drop extra space between return and zero.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 87f4a026c05fbf1c9371058290b2d33cb94b9e54..1726aaa1eafb9ac1a913e3e2caea73801b86dc09 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -784,7 +784,7 @@ static int imx_dsp_rproc_prepare(struct rproc *rproc)
pm_runtime_get_sync(dev);
- return 0;
+ return 0;
}
/* Unprepare function for rproc_ops */
@@ -792,7 +792,7 @@ static int imx_dsp_rproc_unprepare(struct rproc *rproc)
{
pm_runtime_put_sync(rproc->dev.parent);
- return 0;
+ return 0;
}
/* Kick function for rproc_ops */
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (4 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 05/11] remoteproc: imx_dsp_rproc: Drop extra space Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 19:04 ` Frank Li
2025-10-31 9:08 ` [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match Peng Fan
` (6 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Allow each platform to provide its own implementation of start/stop/
detect_mode operations, and prepare to eliminate the need for multiple
switch-case statements.
Improve code readability and maintainability by encapsulating
platform-specific behavior.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 1726aaa1eafb9ac1a913e3e2caea73801b86dc09..833b1bd4019614157f0bedf09bd348caab802eef 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -404,6 +404,11 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
struct device *dev = rproc->dev.parent;
int ret;
+ if (dcfg->ops && dcfg->ops->start) {
+ ret = dcfg->ops->start(rproc);
+ goto start_ret;
+ }
+
switch (dcfg->method) {
case IMX_RPROC_MMIO:
ret = regmap_update_bits(priv->regmap,
@@ -424,6 +429,7 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
return -EOPNOTSUPP;
}
+start_ret:
if (ret)
dev_err(dev, "Failed to enable remote core!\n");
else if (priv->flags & WAIT_FW_READY)
@@ -449,6 +455,11 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
return 0;
}
+ if (dcfg->ops && dcfg->ops->stop) {
+ ret = dcfg->ops->stop(rproc);
+ goto stop_ret;
+ }
+
switch (dcfg->method) {
case IMX_RPROC_MMIO:
ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
@@ -467,6 +478,7 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
return -EOPNOTSUPP;
}
+stop_ret:
if (ret)
dev_err(dev, "Failed to stop remote core\n");
else
@@ -1085,10 +1097,14 @@ static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
{
const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
+ const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
struct device *dev = priv->rproc->dev.parent;
struct regmap *regmap;
int ret = 0;
+ if (dcfg->ops && dcfg->ops->detect_mode)
+ return dcfg->ops->detect_mode(priv->rproc);
+
switch (dsp_dcfg->dcfg->method) {
case IMX_RPROC_SCU_API:
ret = imx_scu_get_handle(&priv->ipc_handle);
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (5 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 19:05 ` Frank Li
2025-10-31 9:08 ` [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
` (5 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Move the imx_dsp_rproc_dcfg structure definitions closer to
imx_dsp_rproc_of_match to prepare for adding start/stop/detect_mode ops for
each i.MX variant.
Avoids the need to declare function prototypes such as
'static int imx_dsp_rproc_mbox_init(struct imx_dsp_rproc *priv)' at the
beginning of the file, improving code organization and readability.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 100 ++++++++++++++++++-------------------
1 file changed, 50 insertions(+), 50 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 833b1bd4019614157f0bedf09bd348caab802eef..f28d25cab3f1d89e5cde37a04b528870a59abeed 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -261,56 +261,6 @@ static int imx8ulp_dsp_reset(struct imx_dsp_rproc *priv)
return 0;
}
-/* Specific configuration for i.MX8MP */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
- .att = imx_dsp_rproc_att_imx8mp,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
- .method = IMX_RPROC_RESET_CONTROLLER,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
- .dcfg = &dsp_rproc_cfg_imx8mp,
- .reset = imx8mp_dsp_reset,
-};
-
-/* Specific configuration for i.MX8ULP */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
- .src_reg = IMX8ULP_SIM_LPAV_REG_SYSCTRL0,
- .src_mask = IMX8ULP_SYSCTRL0_DSP_STALL,
- .src_start = 0,
- .src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
- .att = imx_dsp_rproc_att_imx8ulp,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
- .method = IMX_RPROC_MMIO,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
- .dcfg = &dsp_rproc_cfg_imx8ulp,
- .reset = imx8ulp_dsp_reset,
-};
-
-/* Specific configuration for i.MX8QXP */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
- .att = imx_dsp_rproc_att_imx8qxp,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
- .method = IMX_RPROC_SCU_API,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
- .dcfg = &dsp_rproc_cfg_imx8qxp,
-};
-
-/* Specific configuration for i.MX8QM */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
- .att = imx_dsp_rproc_att_imx8qm,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
- .method = IMX_RPROC_SCU_API,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
- .dcfg = &dsp_rproc_cfg_imx8qm,
-};
-
static int imx_dsp_rproc_ready(struct rproc *rproc)
{
struct imx_dsp_rproc *priv = rproc->priv;
@@ -1351,6 +1301,56 @@ static const struct dev_pm_ops imx_dsp_rproc_pm_ops = {
RUNTIME_PM_OPS(imx_dsp_runtime_suspend, imx_dsp_runtime_resume, NULL)
};
+/* Specific configuration for i.MX8MP */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
+ .att = imx_dsp_rproc_att_imx8mp,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
+ .method = IMX_RPROC_RESET_CONTROLLER,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
+ .dcfg = &dsp_rproc_cfg_imx8mp,
+ .reset = imx8mp_dsp_reset,
+};
+
+/* Specific configuration for i.MX8ULP */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
+ .src_reg = IMX8ULP_SIM_LPAV_REG_SYSCTRL0,
+ .src_mask = IMX8ULP_SYSCTRL0_DSP_STALL,
+ .src_start = 0,
+ .src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
+ .att = imx_dsp_rproc_att_imx8ulp,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
+ .method = IMX_RPROC_MMIO,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
+ .dcfg = &dsp_rproc_cfg_imx8ulp,
+ .reset = imx8ulp_dsp_reset,
+};
+
+/* Specific configuration for i.MX8QXP */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
+ .att = imx_dsp_rproc_att_imx8qxp,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
+ .method = IMX_RPROC_SCU_API,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
+ .dcfg = &dsp_rproc_cfg_imx8qxp,
+};
+
+/* Specific configuration for i.MX8QM */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
+ .att = imx_dsp_rproc_att_imx8qm,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
+ .method = IMX_RPROC_SCU_API,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
+ .dcfg = &dsp_rproc_cfg_imx8qm,
+};
+
static const struct of_device_id imx_dsp_rproc_of_match[] = {
{ .compatible = "fsl,imx8qxp-hifi4", .data = &imx_dsp_rproc_cfg_imx8qxp },
{ .compatible = "fsl,imx8qm-hifi4", .data = &imx_dsp_rproc_cfg_imx8qm },
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (6 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 19:09 ` Frank Li
2025-10-31 9:08 ` [PATCH 09/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API " Peng Fan
` (4 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Introduce imx_dsp_rproc_mmio_{start, stop, detect_mode}() helper functions
for i.MX variants using IMX_RPROC_MMIO to manage remote processors.
Allows the removal of the IMX_RPROC_MMIO switch-case blocks from
imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and more
maintainable code.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 63 +++++++++++++++++++++++++-------------
drivers/remoteproc/imx_rproc.h | 2 --
2 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index f28d25cab3f1d89e5cde37a04b528870a59abeed..456a46f163d3d823a25d16d11fb79fa9fceb2ddb 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -338,6 +338,15 @@ static int imx_dsp_rproc_handle_rsc(struct rproc *rproc, u32 rsc_type,
return RSC_HANDLED;
}
+static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+ const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
+ const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
+
+ return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
+}
+
/*
* Start function for rproc_ops
*
@@ -360,12 +369,6 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
}
switch (dcfg->method) {
- case IMX_RPROC_MMIO:
- ret = regmap_update_bits(priv->regmap,
- dcfg->src_reg,
- dcfg->src_mask,
- dcfg->src_start);
- break;
case IMX_RPROC_SCU_API:
ret = imx_sc_pm_cpu_start(priv->ipc_handle,
IMX_SC_R_DSP,
@@ -388,6 +391,15 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
return ret;
}
+static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+ const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
+ const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
+
+ return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
+}
+
/*
* Stop function for rproc_ops
* It clears the REMOTE_IS_READY flags
@@ -411,10 +423,6 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
}
switch (dcfg->method) {
- case IMX_RPROC_MMIO:
- ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
- dcfg->src_stop);
- break;
case IMX_RPROC_SCU_API:
ret = imx_sc_pm_cpu_start(priv->ipc_handle,
IMX_SC_R_DSP,
@@ -1032,6 +1040,23 @@ static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
return devm_pm_domain_attach_list(dev, NULL, &priv->pd_list);
}
+static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+ struct device *dev = rproc->dev.parent;
+ struct regmap *regmap;
+
+ regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,dsp-ctrl");
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "failed to find syscon\n");
+ return PTR_ERR(regmap);
+ }
+
+ priv->regmap = regmap;
+
+ return 0;
+}
+
/**
* imx_dsp_rproc_detect_mode() - detect DSP control mode
* @priv: private data pointer
@@ -1049,7 +1074,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
struct device *dev = priv->rproc->dev.parent;
- struct regmap *regmap;
int ret = 0;
if (dcfg->ops && dcfg->ops->detect_mode)
@@ -1061,15 +1085,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
if (ret)
return ret;
break;
- case IMX_RPROC_MMIO:
- regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,dsp-ctrl");
- if (IS_ERR(regmap)) {
- dev_err(dev, "failed to find syscon\n");
- return PTR_ERR(regmap);
- }
-
- priv->regmap = regmap;
- break;
case IMX_RPROC_RESET_CONTROLLER:
priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
if (IS_ERR(priv->run_stall)) {
@@ -1301,6 +1316,12 @@ static const struct dev_pm_ops imx_dsp_rproc_pm_ops = {
RUNTIME_PM_OPS(imx_dsp_runtime_suspend, imx_dsp_runtime_resume, NULL)
};
+static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
+ .start = imx_dsp_rproc_mmio_start,
+ .stop = imx_dsp_rproc_mmio_stop,
+ .detect_mode = imx_dsp_rproc_mmio_detect_mode,
+};
+
/* Specific configuration for i.MX8MP */
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
.att = imx_dsp_rproc_att_imx8mp,
@@ -1321,7 +1342,7 @@ static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
.src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
.att = imx_dsp_rproc_att_imx8ulp,
.att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
- .method = IMX_RPROC_MMIO,
+ .ops = &imx_dsp_rproc_ops_mmio,
};
static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
index aeed08bdfb5619c7afd7201589f417cfd6745818..912827c39c0dedeed76c13740efd42a8e7cf9c45 100644
--- a/drivers/remoteproc/imx_rproc.h
+++ b/drivers/remoteproc/imx_rproc.h
@@ -18,8 +18,6 @@ struct imx_rproc_att {
/* Remote core start/stop method */
enum imx_rproc_method {
IMX_RPROC_NONE,
- /* Through syscon regmap */
- IMX_RPROC_MMIO,
/* Through ARM SMCCC */
IMX_RPROC_SMC,
/* Through System Control Unit API */
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 09/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API switch case
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (7 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 19:12 ` Frank Li
2025-10-31 9:08 ` [PATCH 10/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER " Peng Fan
` (3 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Introduce imx_dsp_rproc_scu_api_{start, stop, detect_mode}() helper
functions for i.MX variants using IMX_RPROC_SCU_API to manage remote
processors.
Allows the removal of the IMX_RPROC_SCU_API switch-case blocks from
imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and more
maintainable code.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 48 +++++++++++++++++++++++---------------
drivers/remoteproc/imx_rproc.h | 2 --
2 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 456a46f163d3d823a25d16d11fb79fa9fceb2ddb..56e94754d5c5feba112227c45b0f99a4fe868926 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -347,6 +347,13 @@ static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
}
+static int imx_dsp_rproc_scu_api_start(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+
+ return imx_sc_pm_cpu_start(priv->ipc_handle, IMX_SC_R_DSP, true, rproc->bootaddr);
+}
+
/*
* Start function for rproc_ops
*
@@ -369,12 +376,6 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
}
switch (dcfg->method) {
- case IMX_RPROC_SCU_API:
- ret = imx_sc_pm_cpu_start(priv->ipc_handle,
- IMX_SC_R_DSP,
- true,
- rproc->bootaddr);
- break;
case IMX_RPROC_RESET_CONTROLLER:
ret = reset_control_deassert(priv->run_stall);
break;
@@ -400,6 +401,13 @@ static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
}
+static int imx_dsp_rproc_scu_api_stop(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+
+ return imx_sc_pm_cpu_start(priv->ipc_handle, IMX_SC_R_DSP, false, rproc->bootaddr);
+}
+
/*
* Stop function for rproc_ops
* It clears the REMOTE_IS_READY flags
@@ -423,12 +431,6 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
}
switch (dcfg->method) {
- case IMX_RPROC_SCU_API:
- ret = imx_sc_pm_cpu_start(priv->ipc_handle,
- IMX_SC_R_DSP,
- false,
- rproc->bootaddr);
- break;
case IMX_RPROC_RESET_CONTROLLER:
ret = reset_control_assert(priv->run_stall);
break;
@@ -1057,6 +1059,13 @@ static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
return 0;
}
+static int imx_dsp_rproc_scu_api_detect_mode(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+
+ return imx_scu_get_handle(&priv->ipc_handle);
+}
+
/**
* imx_dsp_rproc_detect_mode() - detect DSP control mode
* @priv: private data pointer
@@ -1080,11 +1089,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
return dcfg->ops->detect_mode(priv->rproc);
switch (dsp_dcfg->dcfg->method) {
- case IMX_RPROC_SCU_API:
- ret = imx_scu_get_handle(&priv->ipc_handle);
- if (ret)
- return ret;
- break;
case IMX_RPROC_RESET_CONTROLLER:
priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
if (IS_ERR(priv->run_stall)) {
@@ -1322,6 +1326,12 @@ static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
.detect_mode = imx_dsp_rproc_mmio_detect_mode,
};
+static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
+ .start = imx_dsp_rproc_scu_api_start,
+ .stop = imx_dsp_rproc_scu_api_stop,
+ .detect_mode = imx_dsp_rproc_scu_api_detect_mode,
+};
+
/* Specific configuration for i.MX8MP */
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
.att = imx_dsp_rproc_att_imx8mp,
@@ -1354,7 +1364,7 @@ static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
.att = imx_dsp_rproc_att_imx8qxp,
.att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
- .method = IMX_RPROC_SCU_API,
+ .ops = &imx_dsp_rproc_ops_scu_api,
};
static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
@@ -1365,7 +1375,7 @@ static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
.att = imx_dsp_rproc_att_imx8qm,
.att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
- .method = IMX_RPROC_SCU_API,
+ .ops = &imx_dsp_rproc_ops_scu_api,
};
static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
index 912827c39c0dedeed76c13740efd42a8e7cf9c45..a6b4625e8be76c6eb6a5d8ef45eb5f3aec5fe375 100644
--- a/drivers/remoteproc/imx_rproc.h
+++ b/drivers/remoteproc/imx_rproc.h
@@ -20,8 +20,6 @@ enum imx_rproc_method {
IMX_RPROC_NONE,
/* Through ARM SMCCC */
IMX_RPROC_SMC,
- /* Through System Control Unit API */
- IMX_RPROC_SCU_API,
/* Through Reset Controller API */
IMX_RPROC_RESET_CONTROLLER,
};
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 10/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER switch case
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (8 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 09/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API " Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 19:13 ` Frank Li
2025-10-31 9:08 ` [PATCH 11/11] remoteproc: imx_rproc: Remove enum imx_rproc_method Peng Fan
` (2 subsequent siblings)
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
Introduce imx_dsp_rproc_reset_ctr_{start, stop, detect_mode}() helper
functions for i.MX variants using IMX_RPROC_RESET_CONTROLLER to manage
remote processors.
Allows the removal of the IMX_RPROC_RESET_CONTROLLER switch-case blocks
from imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and
more maintainable code.
No functional changes.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 69 +++++++++++++++++++++-----------------
drivers/remoteproc/imx_rproc.h | 2 --
2 files changed, 38 insertions(+), 33 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 56e94754d5c5feba112227c45b0f99a4fe868926..009e08df8fd42e1bf6ca00393e940071d33ec518 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -347,6 +347,13 @@ static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
}
+static int imx_dsp_rproc_reset_ctrl_start(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+
+ return reset_control_deassert(priv->run_stall);
+}
+
static int imx_dsp_rproc_scu_api_start(struct rproc *rproc)
{
struct imx_dsp_rproc *priv = rproc->priv;
@@ -375,13 +382,7 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
goto start_ret;
}
- switch (dcfg->method) {
- case IMX_RPROC_RESET_CONTROLLER:
- ret = reset_control_deassert(priv->run_stall);
- break;
- default:
- return -EOPNOTSUPP;
- }
+ return -EOPNOTSUPP;
start_ret:
if (ret)
@@ -401,6 +402,13 @@ static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
}
+static int imx_dsp_rproc_reset_ctrl_stop(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+
+ return reset_control_assert(priv->run_stall);
+}
+
static int imx_dsp_rproc_scu_api_stop(struct rproc *rproc)
{
struct imx_dsp_rproc *priv = rproc->priv;
@@ -430,13 +438,7 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
goto stop_ret;
}
- switch (dcfg->method) {
- case IMX_RPROC_RESET_CONTROLLER:
- ret = reset_control_assert(priv->run_stall);
- break;
- default:
- return -EOPNOTSUPP;
- }
+ return -EOPNOTSUPP;
stop_ret:
if (ret)
@@ -1059,6 +1061,20 @@ static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
return 0;
}
+static int imx_dsp_rproc_reset_ctrl_detect_mode(struct rproc *rproc)
+{
+ struct imx_dsp_rproc *priv = rproc->priv;
+ struct device *dev = rproc->dev.parent;
+
+ priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
+ if (IS_ERR(priv->run_stall)) {
+ dev_err(dev, "Failed to get DSP runstall reset control\n");
+ return PTR_ERR(priv->run_stall);
+ }
+
+ return 0;
+}
+
static int imx_dsp_rproc_scu_api_detect_mode(struct rproc *rproc)
{
struct imx_dsp_rproc *priv = rproc->priv;
@@ -1082,26 +1098,11 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
{
const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
- struct device *dev = priv->rproc->dev.parent;
- int ret = 0;
if (dcfg->ops && dcfg->ops->detect_mode)
return dcfg->ops->detect_mode(priv->rproc);
- switch (dsp_dcfg->dcfg->method) {
- case IMX_RPROC_RESET_CONTROLLER:
- priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
- if (IS_ERR(priv->run_stall)) {
- dev_err(dev, "Failed to get DSP runstall reset control\n");
- return PTR_ERR(priv->run_stall);
- }
- break;
- default:
- ret = -EOPNOTSUPP;
- break;
- }
-
- return ret;
+ return -EOPNOTSUPP;
}
static const char *imx_dsp_clks_names[DSP_RPROC_CLK_MAX] = {
@@ -1326,6 +1327,12 @@ static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
.detect_mode = imx_dsp_rproc_mmio_detect_mode,
};
+static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_reset_ctrl = {
+ .start = imx_dsp_rproc_reset_ctrl_start,
+ .stop = imx_dsp_rproc_reset_ctrl_stop,
+ .detect_mode = imx_dsp_rproc_reset_ctrl_detect_mode,
+};
+
static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
.start = imx_dsp_rproc_scu_api_start,
.stop = imx_dsp_rproc_scu_api_stop,
@@ -1336,7 +1343,7 @@ static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
.att = imx_dsp_rproc_att_imx8mp,
.att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
- .method = IMX_RPROC_RESET_CONTROLLER,
+ .ops = &imx_dsp_rproc_ops_reset_ctrl,
};
static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
index a6b4625e8be76c6eb6a5d8ef45eb5f3aec5fe375..6a7359f05178a937d02b027fe4166319068bd65c 100644
--- a/drivers/remoteproc/imx_rproc.h
+++ b/drivers/remoteproc/imx_rproc.h
@@ -20,8 +20,6 @@ enum imx_rproc_method {
IMX_RPROC_NONE,
/* Through ARM SMCCC */
IMX_RPROC_SMC,
- /* Through Reset Controller API */
- IMX_RPROC_RESET_CONTROLLER,
};
/* dcfg flags */
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [PATCH 11/11] remoteproc: imx_rproc: Remove enum imx_rproc_method
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (9 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 10/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER " Peng Fan
@ 2025-10-31 9:08 ` Peng Fan
2025-10-31 19:15 ` Frank Li
2025-11-05 8:04 ` [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Shengjiu Wang
2025-11-05 9:31 ` Daniel Baluta
12 siblings, 1 reply; 29+ messages in thread
From: Peng Fan @ 2025-10-31 9:08 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan
There is no user of enum imx_rproc_method after moved to ops based
method. Remove it.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_rproc.h | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
index 6a7359f05178a937d02b027fe4166319068bd65c..1b2d9f4d6d19dcdc215be97f7e2ab3488281916a 100644
--- a/drivers/remoteproc/imx_rproc.h
+++ b/drivers/remoteproc/imx_rproc.h
@@ -15,13 +15,6 @@ struct imx_rproc_att {
int flags;
};
-/* Remote core start/stop method */
-enum imx_rproc_method {
- IMX_RPROC_NONE,
- /* Through ARM SMCCC */
- IMX_RPROC_SMC,
-};
-
/* dcfg flags */
#define IMX_RPROC_NEED_SYSTEM_OFF BIT(0)
#define IMX_RPROC_NEED_CLKS BIT(1)
@@ -42,7 +35,6 @@ struct imx_rproc_dcfg {
u32 gpr_wait;
const struct imx_rproc_att *att;
size_t att_size;
- enum imx_rproc_method method;
u32 flags;
const struct imx_rproc_plat_ops *ops;
};
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling
2025-10-31 9:08 ` [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling Peng Fan
@ 2025-10-31 18:46 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 18:46 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:30PM +0800, Peng Fan wrote:
> Refactor imx_dsp_attach_pm_domains() to use devm_pm_domain_attach_list()
> directly, removing manual detach logic and simplifying resource management.
>
> Also replace verbose error handling in imx_dsp_rproc_probe() with
> dev_err_probe() for cleaner and more consistent error reporting.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/remoteproc/imx_dsp_rproc.c | 29 ++++++++---------------------
> 1 file changed, 8 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 6e78a01755c7bdc28cd93f00fe6f74affc3d96b0..c466363debbebe8f91b908b3bffaa32e9bf8b9a6 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -1062,14 +1062,12 @@ static const struct rproc_ops imx_dsp_rproc_ops = {
> static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
> {
> struct device *dev = priv->rproc->dev.parent;
> - int ret;
>
> /* A single PM domain is already attached. */
> if (dev->pm_domain)
> return 0;
>
> - ret = dev_pm_domain_attach_list(dev, NULL, &priv->pd_list);
> - return ret < 0 ? ret : 0;
> + return devm_pm_domain_attach_list(dev, NULL, &priv->pd_list);
> }
>
> /**
> @@ -1186,35 +1184,25 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
>
> /* There are multiple power domains required by DSP on some platform */
> ret = imx_dsp_attach_pm_domains(priv);
> - if (ret) {
> - dev_err(dev, "failed on imx_dsp_attach_pm_domains\n");
> - return ret;
> - }
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "failed on imx_dsp_attach_pm_domains\n");
> +
> /* Get clocks */
> ret = imx_dsp_rproc_clk_get(priv);
> - if (ret) {
> - dev_err(dev, "failed on imx_dsp_rproc_clk_get\n");
> - goto err_detach_domains;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed on imx_dsp_rproc_clk_get\n");
>
> init_completion(&priv->pm_comp);
> rproc->auto_boot = false;
> ret = rproc_add(rproc);
> - if (ret) {
> - dev_err(dev, "rproc_add failed\n");
> - goto err_detach_domains;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "rproc_add failed\n");
>
> rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_XTENSA);
>
> pm_runtime_enable(dev);
>
> return 0;
> -
> -err_detach_domains:
> - dev_pm_domain_detach_list(priv->pd_list);
> -
> - return ret;
> }
>
> static void imx_dsp_rproc_remove(struct platform_device *pdev)
> @@ -1224,7 +1212,6 @@ static void imx_dsp_rproc_remove(struct platform_device *pdev)
>
> pm_runtime_disable(&pdev->dev);
> rproc_del(rproc);
> - dev_pm_domain_detach_list(priv->pd_list);
> }
>
> /* pm runtime functions */
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 02/11] remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper
2025-10-31 9:08 ` [PATCH 02/11] remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper Peng Fan
@ 2025-10-31 18:47 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 18:47 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:31PM +0800, Peng Fan wrote:
> Replace manual rproc_add() and cleanup logic with devm_rproc_add(), which
> ties the remoteproc lifecycle to the device's lifecycle. This simplifies
> error handling and ensures proper cleanup.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/remoteproc/imx_dsp_rproc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index c466363debbebe8f91b908b3bffaa32e9bf8b9a6..df6a4126538d22ff6e02145edb5ac13c2d72c949 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -1194,7 +1194,7 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
>
> init_completion(&priv->pm_comp);
> rproc->auto_boot = false;
> - ret = rproc_add(rproc);
> + ret = devm_rproc_add(dev, rproc);
> if (ret)
> return dev_err_probe(dev, ret, "rproc_add failed\n");
>
> @@ -1211,7 +1211,6 @@ static void imx_dsp_rproc_remove(struct platform_device *pdev)
> struct imx_dsp_rproc *priv = rproc->priv;
>
> pm_runtime_disable(&pdev->dev);
> - rproc_del(rproc);
> }
>
> /* pm runtime functions */
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper
2025-10-31 9:08 ` [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper Peng Fan
@ 2025-10-31 18:49 ` Frank Li
2025-11-05 9:24 ` Daniel Baluta
0 siblings, 1 reply; 29+ messages in thread
From: Frank Li @ 2025-10-31 18:49 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:32PM +0800, Peng Fan wrote:
> Replace manual pm_runtime_enable() with devm_pm_runtime_enable() to
> leverage device-managed cleanup and simplify resource handling.
>
> pm_runtime_disable_action() not only calls pm_runtime_disable(), but
> also calls pm_runtime_dont_use_autosuspend(). The current driver
> only calls pm_runtime_disable(). But this should be fine here to use
> devm_pm_runtime_enable().
looks like this paragaph is reduntant.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> As a result, the .remove callback is no longer needed, reducing boilerplate
> code.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index df6a4126538d22ff6e02145edb5ac13c2d72c949..f5d0aec52c56664d6074272e276edb0c4175c9ea 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -1200,17 +1200,7 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
>
> rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_XTENSA);
>
> - pm_runtime_enable(dev);
> -
> - return 0;
> -}
> -
> -static void imx_dsp_rproc_remove(struct platform_device *pdev)
> -{
> - struct rproc *rproc = platform_get_drvdata(pdev);
> - struct imx_dsp_rproc *priv = rproc->priv;
> -
> - pm_runtime_disable(&pdev->dev);
> + return devm_pm_runtime_enable(dev);
> }
>
> /* pm runtime functions */
> @@ -1361,7 +1351,6 @@ MODULE_DEVICE_TABLE(of, imx_dsp_rproc_of_match);
>
> static struct platform_driver imx_dsp_rproc_driver = {
> .probe = imx_dsp_rproc_probe,
> - .remove = imx_dsp_rproc_remove,
> .driver = {
> .name = "imx-dsp-rproc",
> .of_match_table = imx_dsp_rproc_of_match,
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 04/11] remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors
2025-10-31 9:08 ` [PATCH 04/11] remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors Peng Fan
@ 2025-10-31 18:50 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 18:50 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:33PM +0800, Peng Fan wrote:
> Replace error logging and return handling in rproc_of_parse_firmware() and
> imx_dsp_rproc_detect_mode() with dev_err_probe() to streamline error
> reporting and improve consistency.
>
> Reduces boilerplate and aligns with modern kernel error handling practices.
You can simple said
Use dev_err_probe() to simple code.
Frank
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index f5d0aec52c56664d6074272e276edb0c4175c9ea..87f4a026c05fbf1c9371058290b2d33cb94b9e54 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -1150,11 +1150,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
> return -ENODEV;
>
> ret = rproc_of_parse_firmware(dev, 0, &fw_name);
> - if (ret) {
> - dev_err(dev, "failed to parse firmware-name property, ret = %d\n",
> - ret);
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to parse firmware-name property\n");
>
> rproc = devm_rproc_alloc(dev, "imx-dsp-rproc", &imx_dsp_rproc_ops,
> fw_name, sizeof(*priv));
> @@ -1177,10 +1174,8 @@ static int imx_dsp_rproc_probe(struct platform_device *pdev)
> INIT_WORK(&priv->rproc_work, imx_dsp_rproc_vq_work);
>
> ret = imx_dsp_rproc_detect_mode(priv);
> - if (ret) {
> - dev_err(dev, "failed on imx_dsp_rproc_detect_mode\n");
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev, ret, "failed on imx_dsp_rproc_detect_mode\n");
>
> /* There are multiple power domains required by DSP on some platform */
> ret = imx_dsp_attach_pm_domains(priv);
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 05/11] remoteproc: imx_dsp_rproc: Drop extra space
2025-10-31 9:08 ` [PATCH 05/11] remoteproc: imx_dsp_rproc: Drop extra space Peng Fan
@ 2025-10-31 18:51 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 18:51 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:34PM +0800, Peng Fan wrote:
> Drop extra space between return and zero.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/remoteproc/imx_dsp_rproc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 87f4a026c05fbf1c9371058290b2d33cb94b9e54..1726aaa1eafb9ac1a913e3e2caea73801b86dc09 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -784,7 +784,7 @@ static int imx_dsp_rproc_prepare(struct rproc *rproc)
>
> pm_runtime_get_sync(dev);
>
> - return 0;
> + return 0;
> }
>
> /* Unprepare function for rproc_ops */
> @@ -792,7 +792,7 @@ static int imx_dsp_rproc_unprepare(struct rproc *rproc)
> {
> pm_runtime_put_sync(rproc->dev.parent);
>
> - return 0;
> + return 0;
> }
>
> /* Kick function for rproc_ops */
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg
2025-10-31 9:08 ` [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg Peng Fan
@ 2025-10-31 19:04 ` Frank Li
2025-11-04 4:24 ` Peng Fan
0 siblings, 1 reply; 29+ messages in thread
From: Frank Li @ 2025-10-31 19:04 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:35PM +0800, Peng Fan wrote:
> Allow each platform to provide its own implementation of start/stop/
> detect_mode operations, and prepare to eliminate the need for multiple
> switch-case statements.
>
> Improve code readability and maintainability by encapsulating
> platform-specific behavior.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 1726aaa1eafb9ac1a913e3e2caea73801b86dc09..833b1bd4019614157f0bedf09bd348caab802eef 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -404,6 +404,11 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
> struct device *dev = rproc->dev.parent;
> int ret;
>
> + if (dcfg->ops && dcfg->ops->start) {
> + ret = dcfg->ops->start(rproc);
> + goto start_ret;
not sure if error message is important, maybe
return dcfg->ops->start(rproc);
Frank
> + }
> +
> switch (dcfg->method) {
> case IMX_RPROC_MMIO:
> ret = regmap_update_bits(priv->regmap,
> @@ -424,6 +429,7 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
> return -EOPNOTSUPP;
> }
>
> +start_ret:
> if (ret)
> dev_err(dev, "Failed to enable remote core!\n");
> else if (priv->flags & WAIT_FW_READY)
> @@ -449,6 +455,11 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
> return 0;
> }
>
> + if (dcfg->ops && dcfg->ops->stop) {
> + ret = dcfg->ops->stop(rproc);
> + goto stop_ret;
> + }
> +
> switch (dcfg->method) {
> case IMX_RPROC_MMIO:
> ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
> @@ -467,6 +478,7 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
> return -EOPNOTSUPP;
> }
>
> +stop_ret:
> if (ret)
> dev_err(dev, "Failed to stop remote core\n");
> else
> @@ -1085,10 +1097,14 @@ static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
> static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
> {
> const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
> + const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
> struct device *dev = priv->rproc->dev.parent;
> struct regmap *regmap;
> int ret = 0;
>
> + if (dcfg->ops && dcfg->ops->detect_mode)
> + return dcfg->ops->detect_mode(priv->rproc);
> +
> switch (dsp_dcfg->dcfg->method) {
> case IMX_RPROC_SCU_API:
> ret = imx_scu_get_handle(&priv->ipc_handle);
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match
2025-10-31 9:08 ` [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match Peng Fan
@ 2025-10-31 19:05 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 19:05 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:36PM +0800, Peng Fan wrote:
> Move the imx_dsp_rproc_dcfg structure definitions closer to
> imx_dsp_rproc_of_match to prepare for adding start/stop/detect_mode ops for
> each i.MX variant.
>
> Avoids the need to declare function prototypes such as
> 'static int imx_dsp_rproc_mbox_init(struct imx_dsp_rproc *priv)' at the
> beginning of the file, improving code organization and readability.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 100 ++++++++++++++++++-------------------
> 1 file changed, 50 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 833b1bd4019614157f0bedf09bd348caab802eef..f28d25cab3f1d89e5cde37a04b528870a59abeed 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -261,56 +261,6 @@ static int imx8ulp_dsp_reset(struct imx_dsp_rproc *priv)
> return 0;
> }
>
> -/* Specific configuration for i.MX8MP */
> -static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
> - .att = imx_dsp_rproc_att_imx8mp,
> - .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
> - .method = IMX_RPROC_RESET_CONTROLLER,
> -};
> -
> -static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
> - .dcfg = &dsp_rproc_cfg_imx8mp,
> - .reset = imx8mp_dsp_reset,
> -};
> -
> -/* Specific configuration for i.MX8ULP */
> -static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
> - .src_reg = IMX8ULP_SIM_LPAV_REG_SYSCTRL0,
> - .src_mask = IMX8ULP_SYSCTRL0_DSP_STALL,
> - .src_start = 0,
> - .src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
> - .att = imx_dsp_rproc_att_imx8ulp,
> - .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
> - .method = IMX_RPROC_MMIO,
> -};
> -
> -static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
> - .dcfg = &dsp_rproc_cfg_imx8ulp,
> - .reset = imx8ulp_dsp_reset,
> -};
> -
> -/* Specific configuration for i.MX8QXP */
> -static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
> - .att = imx_dsp_rproc_att_imx8qxp,
> - .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
> - .method = IMX_RPROC_SCU_API,
> -};
> -
> -static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
> - .dcfg = &dsp_rproc_cfg_imx8qxp,
> -};
> -
> -/* Specific configuration for i.MX8QM */
> -static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
> - .att = imx_dsp_rproc_att_imx8qm,
> - .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
> - .method = IMX_RPROC_SCU_API,
> -};
> -
> -static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
> - .dcfg = &dsp_rproc_cfg_imx8qm,
> -};
> -
> static int imx_dsp_rproc_ready(struct rproc *rproc)
> {
> struct imx_dsp_rproc *priv = rproc->priv;
> @@ -1351,6 +1301,56 @@ static const struct dev_pm_ops imx_dsp_rproc_pm_ops = {
> RUNTIME_PM_OPS(imx_dsp_runtime_suspend, imx_dsp_runtime_resume, NULL)
> };
>
> +/* Specific configuration for i.MX8MP */
> +static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
> + .att = imx_dsp_rproc_att_imx8mp,
> + .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
> + .method = IMX_RPROC_RESET_CONTROLLER,
> +};
> +
> +static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
> + .dcfg = &dsp_rproc_cfg_imx8mp,
> + .reset = imx8mp_dsp_reset,
> +};
> +
> +/* Specific configuration for i.MX8ULP */
> +static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
> + .src_reg = IMX8ULP_SIM_LPAV_REG_SYSCTRL0,
> + .src_mask = IMX8ULP_SYSCTRL0_DSP_STALL,
> + .src_start = 0,
> + .src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
> + .att = imx_dsp_rproc_att_imx8ulp,
> + .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
> + .method = IMX_RPROC_MMIO,
> +};
> +
> +static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
> + .dcfg = &dsp_rproc_cfg_imx8ulp,
> + .reset = imx8ulp_dsp_reset,
> +};
> +
> +/* Specific configuration for i.MX8QXP */
> +static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
> + .att = imx_dsp_rproc_att_imx8qxp,
> + .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
> + .method = IMX_RPROC_SCU_API,
> +};
> +
> +static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
> + .dcfg = &dsp_rproc_cfg_imx8qxp,
> +};
> +
> +/* Specific configuration for i.MX8QM */
> +static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
> + .att = imx_dsp_rproc_att_imx8qm,
> + .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
> + .method = IMX_RPROC_SCU_API,
> +};
> +
> +static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
> + .dcfg = &dsp_rproc_cfg_imx8qm,
> +};
> +
> static const struct of_device_id imx_dsp_rproc_of_match[] = {
> { .compatible = "fsl,imx8qxp-hifi4", .data = &imx_dsp_rproc_cfg_imx8qxp },
> { .compatible = "fsl,imx8qm-hifi4", .data = &imx_dsp_rproc_cfg_imx8qm },
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case
2025-10-31 9:08 ` [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
@ 2025-10-31 19:09 ` Frank Li
2025-11-04 4:25 ` Peng Fan
0 siblings, 1 reply; 29+ messages in thread
From: Frank Li @ 2025-10-31 19:09 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:37PM +0800, Peng Fan wrote:
> Introduce imx_dsp_rproc_mmio_{start, stop, detect_mode}() helper functions
> for i.MX variants using IMX_RPROC_MMIO to manage remote processors.
>
> Allows the removal of the IMX_RPROC_MMIO switch-case blocks from
> imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and more
> maintainable code.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 63 +++++++++++++++++++++++++-------------
> drivers/remoteproc/imx_rproc.h | 2 --
> 2 files changed, 42 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index f28d25cab3f1d89e5cde37a04b528870a59abeed..456a46f163d3d823a25d16d11fb79fa9fceb2ddb 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -338,6 +338,15 @@ static int imx_dsp_rproc_handle_rsc(struct rproc *rproc, u32 rsc_type,
> return RSC_HANDLED;
> }
>
> +static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> + const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
> + const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
> +
> + return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
> +}
> +
> /*
> * Start function for rproc_ops
> *
> @@ -360,12 +369,6 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
> }
>
> switch (dcfg->method) {
> - case IMX_RPROC_MMIO:
> - ret = regmap_update_bits(priv->regmap,
> - dcfg->src_reg,
> - dcfg->src_mask,
> - dcfg->src_start);
> - break;
> case IMX_RPROC_SCU_API:
> ret = imx_sc_pm_cpu_start(priv->ipc_handle,
> IMX_SC_R_DSP,
> @@ -388,6 +391,15 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
> return ret;
> }
>
> +static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> + const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
> + const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
can you add helper macro convert rproc to dcfg to avoid duplicate above
3 line codes.
Frank
> +
> + return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
> +}
> +
> /*
> * Stop function for rproc_ops
> * It clears the REMOTE_IS_READY flags
> @@ -411,10 +423,6 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
> }
>
> switch (dcfg->method) {
> - case IMX_RPROC_MMIO:
> - ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
> - dcfg->src_stop);
> - break;
> case IMX_RPROC_SCU_API:
> ret = imx_sc_pm_cpu_start(priv->ipc_handle,
> IMX_SC_R_DSP,
> @@ -1032,6 +1040,23 @@ static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
> return devm_pm_domain_attach_list(dev, NULL, &priv->pd_list);
> }
>
> +static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> + struct device *dev = rproc->dev.parent;
> + struct regmap *regmap;
> +
> + regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,dsp-ctrl");
> + if (IS_ERR(regmap)) {
> + dev_err(dev, "failed to find syscon\n");
> + return PTR_ERR(regmap);
> + }
> +
> + priv->regmap = regmap;
> +
> + return 0;
> +}
> +
> /**
> * imx_dsp_rproc_detect_mode() - detect DSP control mode
> * @priv: private data pointer
> @@ -1049,7 +1074,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
> const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
> const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
> struct device *dev = priv->rproc->dev.parent;
> - struct regmap *regmap;
> int ret = 0;
>
> if (dcfg->ops && dcfg->ops->detect_mode)
> @@ -1061,15 +1085,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
> if (ret)
> return ret;
> break;
> - case IMX_RPROC_MMIO:
> - regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,dsp-ctrl");
> - if (IS_ERR(regmap)) {
> - dev_err(dev, "failed to find syscon\n");
> - return PTR_ERR(regmap);
> - }
> -
> - priv->regmap = regmap;
> - break;
> case IMX_RPROC_RESET_CONTROLLER:
> priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
> if (IS_ERR(priv->run_stall)) {
> @@ -1301,6 +1316,12 @@ static const struct dev_pm_ops imx_dsp_rproc_pm_ops = {
> RUNTIME_PM_OPS(imx_dsp_runtime_suspend, imx_dsp_runtime_resume, NULL)
> };
>
> +static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
> + .start = imx_dsp_rproc_mmio_start,
> + .stop = imx_dsp_rproc_mmio_stop,
> + .detect_mode = imx_dsp_rproc_mmio_detect_mode,
> +};
> +
> /* Specific configuration for i.MX8MP */
> static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
> .att = imx_dsp_rproc_att_imx8mp,
> @@ -1321,7 +1342,7 @@ static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
> .src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
> .att = imx_dsp_rproc_att_imx8ulp,
> .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
> - .method = IMX_RPROC_MMIO,
> + .ops = &imx_dsp_rproc_ops_mmio,
> };
>
> static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
> diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
> index aeed08bdfb5619c7afd7201589f417cfd6745818..912827c39c0dedeed76c13740efd42a8e7cf9c45 100644
> --- a/drivers/remoteproc/imx_rproc.h
> +++ b/drivers/remoteproc/imx_rproc.h
> @@ -18,8 +18,6 @@ struct imx_rproc_att {
> /* Remote core start/stop method */
> enum imx_rproc_method {
> IMX_RPROC_NONE,
> - /* Through syscon regmap */
> - IMX_RPROC_MMIO,
> /* Through ARM SMCCC */
> IMX_RPROC_SMC,
> /* Through System Control Unit API */
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 09/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API switch case
2025-10-31 9:08 ` [PATCH 09/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API " Peng Fan
@ 2025-10-31 19:12 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 19:12 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:38PM +0800, Peng Fan wrote:
> Introduce imx_dsp_rproc_scu_api_{start, stop, detect_mode}() helper
> functions for i.MX variants using IMX_RPROC_SCU_API to manage remote
> processors.
>
> Allows the removal of the IMX_RPROC_SCU_API switch-case blocks from
> imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and more
> maintainable code.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/remoteproc/imx_dsp_rproc.c | 48 +++++++++++++++++++++++---------------
> drivers/remoteproc/imx_rproc.h | 2 --
> 2 files changed, 29 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 456a46f163d3d823a25d16d11fb79fa9fceb2ddb..56e94754d5c5feba112227c45b0f99a4fe868926 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -347,6 +347,13 @@ static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
> return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
> }
>
> +static int imx_dsp_rproc_scu_api_start(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> +
> + return imx_sc_pm_cpu_start(priv->ipc_handle, IMX_SC_R_DSP, true, rproc->bootaddr);
> +}
> +
> /*
> * Start function for rproc_ops
> *
> @@ -369,12 +376,6 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
> }
>
> switch (dcfg->method) {
> - case IMX_RPROC_SCU_API:
> - ret = imx_sc_pm_cpu_start(priv->ipc_handle,
> - IMX_SC_R_DSP,
> - true,
> - rproc->bootaddr);
> - break;
> case IMX_RPROC_RESET_CONTROLLER:
> ret = reset_control_deassert(priv->run_stall);
> break;
> @@ -400,6 +401,13 @@ static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
> return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
> }
>
> +static int imx_dsp_rproc_scu_api_stop(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> +
> + return imx_sc_pm_cpu_start(priv->ipc_handle, IMX_SC_R_DSP, false, rproc->bootaddr);
> +}
> +
> /*
> * Stop function for rproc_ops
> * It clears the REMOTE_IS_READY flags
> @@ -423,12 +431,6 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
> }
>
> switch (dcfg->method) {
> - case IMX_RPROC_SCU_API:
> - ret = imx_sc_pm_cpu_start(priv->ipc_handle,
> - IMX_SC_R_DSP,
> - false,
> - rproc->bootaddr);
> - break;
> case IMX_RPROC_RESET_CONTROLLER:
> ret = reset_control_assert(priv->run_stall);
> break;
> @@ -1057,6 +1059,13 @@ static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
> return 0;
> }
>
> +static int imx_dsp_rproc_scu_api_detect_mode(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> +
> + return imx_scu_get_handle(&priv->ipc_handle);
> +}
> +
> /**
> * imx_dsp_rproc_detect_mode() - detect DSP control mode
> * @priv: private data pointer
> @@ -1080,11 +1089,6 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
> return dcfg->ops->detect_mode(priv->rproc);
>
> switch (dsp_dcfg->dcfg->method) {
> - case IMX_RPROC_SCU_API:
> - ret = imx_scu_get_handle(&priv->ipc_handle);
> - if (ret)
> - return ret;
> - break;
> case IMX_RPROC_RESET_CONTROLLER:
> priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
> if (IS_ERR(priv->run_stall)) {
> @@ -1322,6 +1326,12 @@ static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
> .detect_mode = imx_dsp_rproc_mmio_detect_mode,
> };
>
> +static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
> + .start = imx_dsp_rproc_scu_api_start,
> + .stop = imx_dsp_rproc_scu_api_stop,
> + .detect_mode = imx_dsp_rproc_scu_api_detect_mode,
> +};
> +
> /* Specific configuration for i.MX8MP */
> static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
> .att = imx_dsp_rproc_att_imx8mp,
> @@ -1354,7 +1364,7 @@ static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
> static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
> .att = imx_dsp_rproc_att_imx8qxp,
> .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
> - .method = IMX_RPROC_SCU_API,
> + .ops = &imx_dsp_rproc_ops_scu_api,
> };
>
> static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
> @@ -1365,7 +1375,7 @@ static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
> static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
> .att = imx_dsp_rproc_att_imx8qm,
> .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
> - .method = IMX_RPROC_SCU_API,
> + .ops = &imx_dsp_rproc_ops_scu_api,
> };
>
> static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
> diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
> index 912827c39c0dedeed76c13740efd42a8e7cf9c45..a6b4625e8be76c6eb6a5d8ef45eb5f3aec5fe375 100644
> --- a/drivers/remoteproc/imx_rproc.h
> +++ b/drivers/remoteproc/imx_rproc.h
> @@ -20,8 +20,6 @@ enum imx_rproc_method {
> IMX_RPROC_NONE,
> /* Through ARM SMCCC */
> IMX_RPROC_SMC,
> - /* Through System Control Unit API */
> - IMX_RPROC_SCU_API,
> /* Through Reset Controller API */
> IMX_RPROC_RESET_CONTROLLER,
> };
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 10/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER switch case
2025-10-31 9:08 ` [PATCH 10/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER " Peng Fan
@ 2025-10-31 19:13 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 19:13 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:39PM +0800, Peng Fan wrote:
> Introduce imx_dsp_rproc_reset_ctr_{start, stop, detect_mode}() helper
> functions for i.MX variants using IMX_RPROC_RESET_CONTROLLER to manage
> remote processors.
>
> Allows the removal of the IMX_RPROC_RESET_CONTROLLER switch-case blocks
> from imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and
> more maintainable code.
>
> No functional changes.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/remoteproc/imx_dsp_rproc.c | 69 +++++++++++++++++++++-----------------
> drivers/remoteproc/imx_rproc.h | 2 --
> 2 files changed, 38 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 56e94754d5c5feba112227c45b0f99a4fe868926..009e08df8fd42e1bf6ca00393e940071d33ec518 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -347,6 +347,13 @@ static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
> return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
> }
>
> +static int imx_dsp_rproc_reset_ctrl_start(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> +
> + return reset_control_deassert(priv->run_stall);
> +}
> +
> static int imx_dsp_rproc_scu_api_start(struct rproc *rproc)
> {
> struct imx_dsp_rproc *priv = rproc->priv;
> @@ -375,13 +382,7 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
> goto start_ret;
> }
>
> - switch (dcfg->method) {
> - case IMX_RPROC_RESET_CONTROLLER:
> - ret = reset_control_deassert(priv->run_stall);
> - break;
> - default:
> - return -EOPNOTSUPP;
> - }
> + return -EOPNOTSUPP;
>
> start_ret:
> if (ret)
> @@ -401,6 +402,13 @@ static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
> return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_stop);
> }
>
> +static int imx_dsp_rproc_reset_ctrl_stop(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> +
> + return reset_control_assert(priv->run_stall);
> +}
> +
> static int imx_dsp_rproc_scu_api_stop(struct rproc *rproc)
> {
> struct imx_dsp_rproc *priv = rproc->priv;
> @@ -430,13 +438,7 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
> goto stop_ret;
> }
>
> - switch (dcfg->method) {
> - case IMX_RPROC_RESET_CONTROLLER:
> - ret = reset_control_assert(priv->run_stall);
> - break;
> - default:
> - return -EOPNOTSUPP;
> - }
> + return -EOPNOTSUPP;
>
> stop_ret:
> if (ret)
> @@ -1059,6 +1061,20 @@ static int imx_dsp_rproc_mmio_detect_mode(struct rproc *rproc)
> return 0;
> }
>
> +static int imx_dsp_rproc_reset_ctrl_detect_mode(struct rproc *rproc)
> +{
> + struct imx_dsp_rproc *priv = rproc->priv;
> + struct device *dev = rproc->dev.parent;
> +
> + priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
> + if (IS_ERR(priv->run_stall)) {
> + dev_err(dev, "Failed to get DSP runstall reset control\n");
> + return PTR_ERR(priv->run_stall);
> + }
> +
> + return 0;
> +}
> +
> static int imx_dsp_rproc_scu_api_detect_mode(struct rproc *rproc)
> {
> struct imx_dsp_rproc *priv = rproc->priv;
> @@ -1082,26 +1098,11 @@ static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
> {
> const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
> const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
> - struct device *dev = priv->rproc->dev.parent;
> - int ret = 0;
>
> if (dcfg->ops && dcfg->ops->detect_mode)
> return dcfg->ops->detect_mode(priv->rproc);
>
> - switch (dsp_dcfg->dcfg->method) {
> - case IMX_RPROC_RESET_CONTROLLER:
> - priv->run_stall = devm_reset_control_get_exclusive(dev, "runstall");
> - if (IS_ERR(priv->run_stall)) {
> - dev_err(dev, "Failed to get DSP runstall reset control\n");
> - return PTR_ERR(priv->run_stall);
> - }
> - break;
> - default:
> - ret = -EOPNOTSUPP;
> - break;
> - }
> -
> - return ret;
> + return -EOPNOTSUPP;
> }
>
> static const char *imx_dsp_clks_names[DSP_RPROC_CLK_MAX] = {
> @@ -1326,6 +1327,12 @@ static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_mmio = {
> .detect_mode = imx_dsp_rproc_mmio_detect_mode,
> };
>
> +static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_reset_ctrl = {
> + .start = imx_dsp_rproc_reset_ctrl_start,
> + .stop = imx_dsp_rproc_reset_ctrl_stop,
> + .detect_mode = imx_dsp_rproc_reset_ctrl_detect_mode,
> +};
> +
> static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
> .start = imx_dsp_rproc_scu_api_start,
> .stop = imx_dsp_rproc_scu_api_stop,
> @@ -1336,7 +1343,7 @@ static const struct imx_rproc_plat_ops imx_dsp_rproc_ops_scu_api = {
> static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
> .att = imx_dsp_rproc_att_imx8mp,
> .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
> - .method = IMX_RPROC_RESET_CONTROLLER,
> + .ops = &imx_dsp_rproc_ops_reset_ctrl,
> };
>
> static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
> diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
> index a6b4625e8be76c6eb6a5d8ef45eb5f3aec5fe375..6a7359f05178a937d02b027fe4166319068bd65c 100644
> --- a/drivers/remoteproc/imx_rproc.h
> +++ b/drivers/remoteproc/imx_rproc.h
> @@ -20,8 +20,6 @@ enum imx_rproc_method {
> IMX_RPROC_NONE,
> /* Through ARM SMCCC */
> IMX_RPROC_SMC,
> - /* Through Reset Controller API */
> - IMX_RPROC_RESET_CONTROLLER,
> };
>
> /* dcfg flags */
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 11/11] remoteproc: imx_rproc: Remove enum imx_rproc_method
2025-10-31 9:08 ` [PATCH 11/11] remoteproc: imx_rproc: Remove enum imx_rproc_method Peng Fan
@ 2025-10-31 19:15 ` Frank Li
0 siblings, 0 replies; 29+ messages in thread
From: Frank Li @ 2025-10-31 19:15 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Daniel Baluta, Iuliana Prodan, linux-remoteproc,
imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 05:08:40PM +0800, Peng Fan wrote:
> There is no user of enum imx_rproc_method after moved to ops based
> method. Remove it.
Nit: Remove unused field imx_rproc_method after switched to ops based method.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/remoteproc/imx_rproc.h | 8 --------
> 1 file changed, 8 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_rproc.h b/drivers/remoteproc/imx_rproc.h
> index 6a7359f05178a937d02b027fe4166319068bd65c..1b2d9f4d6d19dcdc215be97f7e2ab3488281916a 100644
> --- a/drivers/remoteproc/imx_rproc.h
> +++ b/drivers/remoteproc/imx_rproc.h
> @@ -15,13 +15,6 @@ struct imx_rproc_att {
> int flags;
> };
>
> -/* Remote core start/stop method */
> -enum imx_rproc_method {
> - IMX_RPROC_NONE,
> - /* Through ARM SMCCC */
> - IMX_RPROC_SMC,
> -};
> -
> /* dcfg flags */
> #define IMX_RPROC_NEED_SYSTEM_OFF BIT(0)
> #define IMX_RPROC_NEED_CLKS BIT(1)
> @@ -42,7 +35,6 @@ struct imx_rproc_dcfg {
> u32 gpr_wait;
> const struct imx_rproc_att *att;
> size_t att_size;
> - enum imx_rproc_method method;
> u32 flags;
> const struct imx_rproc_plat_ops *ops;
> };
>
> --
> 2.37.1
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg
2025-10-31 19:04 ` Frank Li
@ 2025-11-04 4:24 ` Peng Fan
0 siblings, 0 replies; 29+ messages in thread
From: Peng Fan @ 2025-11-04 4:24 UTC (permalink / raw)
To: Frank Li
Cc: Peng Fan, Bjorn Andersson, Mathieu Poirier, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Philipp Zabel, Shengjiu Wang, Daniel Baluta, Iuliana Prodan,
linux-remoteproc, imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 03:04:39PM -0400, Frank Li wrote:
>On Fri, Oct 31, 2025 at 05:08:35PM +0800, Peng Fan wrote:
>> Allow each platform to provide its own implementation of start/stop/
>> detect_mode operations, and prepare to eliminate the need for multiple
>> switch-case statements.
>>
>> Improve code readability and maintainability by encapsulating
>> platform-specific behavior.
>>
>> No functional changes.
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>> drivers/remoteproc/imx_dsp_rproc.c | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
>> index 1726aaa1eafb9ac1a913e3e2caea73801b86dc09..833b1bd4019614157f0bedf09bd348caab802eef 100644
>> --- a/drivers/remoteproc/imx_dsp_rproc.c
>> +++ b/drivers/remoteproc/imx_dsp_rproc.c
>> @@ -404,6 +404,11 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>> struct device *dev = rproc->dev.parent;
>> int ret;
>>
>> + if (dcfg->ops && dcfg->ops->start) {
>> + ret = dcfg->ops->start(rproc);
>> + goto start_ret;
>
>not sure if error message is important, maybe
I would like to keep the error message. Since this patch is just to prepare
for ops introducton, I would not change the original behavior.
Thanks,
Peng
>
> return dcfg->ops->start(rproc);
>
>Frank
>> + }
>> +
>> switch (dcfg->method) {
>> case IMX_RPROC_MMIO:
>> ret = regmap_update_bits(priv->regmap,
>> @@ -424,6 +429,7 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>> return -EOPNOTSUPP;
>> }
>>
>> +start_ret:
>> if (ret)
>> dev_err(dev, "Failed to enable remote core!\n");
>> else if (priv->flags & WAIT_FW_READY)
>> @@ -449,6 +455,11 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
>> return 0;
>> }
>>
>> + if (dcfg->ops && dcfg->ops->stop) {
>> + ret = dcfg->ops->stop(rproc);
>> + goto stop_ret;
>> + }
>> +
>> switch (dcfg->method) {
>> case IMX_RPROC_MMIO:
>> ret = regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask,
>> @@ -467,6 +478,7 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
>> return -EOPNOTSUPP;
>> }
>>
>> +stop_ret:
>> if (ret)
>> dev_err(dev, "Failed to stop remote core\n");
>> else
>> @@ -1085,10 +1097,14 @@ static int imx_dsp_attach_pm_domains(struct imx_dsp_rproc *priv)
>> static int imx_dsp_rproc_detect_mode(struct imx_dsp_rproc *priv)
>> {
>> const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
>> + const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
>> struct device *dev = priv->rproc->dev.parent;
>> struct regmap *regmap;
>> int ret = 0;
>>
>> + if (dcfg->ops && dcfg->ops->detect_mode)
>> + return dcfg->ops->detect_mode(priv->rproc);
>> +
>> switch (dsp_dcfg->dcfg->method) {
>> case IMX_RPROC_SCU_API:
>> ret = imx_scu_get_handle(&priv->ipc_handle);
>>
>> --
>> 2.37.1
>>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case
2025-10-31 19:09 ` Frank Li
@ 2025-11-04 4:25 ` Peng Fan
0 siblings, 0 replies; 29+ messages in thread
From: Peng Fan @ 2025-11-04 4:25 UTC (permalink / raw)
To: Frank Li
Cc: Peng Fan, Bjorn Andersson, Mathieu Poirier, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Philipp Zabel, Shengjiu Wang, Daniel Baluta, Iuliana Prodan,
linux-remoteproc, imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 03:09:17PM -0400, Frank Li wrote:
>On Fri, Oct 31, 2025 at 05:08:37PM +0800, Peng Fan wrote:
>> Introduce imx_dsp_rproc_mmio_{start, stop, detect_mode}() helper functions
>> for i.MX variants using IMX_RPROC_MMIO to manage remote processors.
>>
>> Allows the removal of the IMX_RPROC_MMIO switch-case blocks from
>> imx_dsp_rproc_[start,stop,detect_mode](), resulting in cleaner and more
>> maintainable code.
>>
>> No functional changes.
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>> drivers/remoteproc/imx_dsp_rproc.c | 63 +++++++++++++++++++++++++-------------
>> drivers/remoteproc/imx_rproc.h | 2 --
>> 2 files changed, 42 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
>> index f28d25cab3f1d89e5cde37a04b528870a59abeed..456a46f163d3d823a25d16d11fb79fa9fceb2ddb 100644
>> --- a/drivers/remoteproc/imx_dsp_rproc.c
>> +++ b/drivers/remoteproc/imx_dsp_rproc.c
>> @@ -338,6 +338,15 @@ static int imx_dsp_rproc_handle_rsc(struct rproc *rproc, u32 rsc_type,
>> return RSC_HANDLED;
>> }
>>
>> +static int imx_dsp_rproc_mmio_start(struct rproc *rproc)
>> +{
>> + struct imx_dsp_rproc *priv = rproc->priv;
>> + const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
>> + const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
>> +
>> + return regmap_update_bits(priv->regmap, dcfg->src_reg, dcfg->src_mask, dcfg->src_start);
>> +}
>> +
>> /*
>> * Start function for rproc_ops
>> *
>> @@ -360,12 +369,6 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>> }
>>
>> switch (dcfg->method) {
>> - case IMX_RPROC_MMIO:
>> - ret = regmap_update_bits(priv->regmap,
>> - dcfg->src_reg,
>> - dcfg->src_mask,
>> - dcfg->src_start);
>> - break;
>> case IMX_RPROC_SCU_API:
>> ret = imx_sc_pm_cpu_start(priv->ipc_handle,
>> IMX_SC_R_DSP,
>> @@ -388,6 +391,15 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>> return ret;
>> }
>>
>> +static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
>> +{
>> + struct imx_dsp_rproc *priv = rproc->priv;
>> + const struct imx_dsp_rproc_dcfg *dsp_dcfg = priv->dsp_dcfg;
>> + const struct imx_rproc_dcfg *dcfg = dsp_dcfg->dcfg;
>
>can you add helper macro convert rproc to dcfg to avoid duplicate above
>3 line codes.
Update in next version.
Thanks,
Peng
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (10 preceding siblings ...)
2025-10-31 9:08 ` [PATCH 11/11] remoteproc: imx_rproc: Remove enum imx_rproc_method Peng Fan
@ 2025-11-05 8:04 ` Shengjiu Wang
2025-11-05 9:31 ` Daniel Baluta
12 siblings, 0 replies; 29+ messages in thread
From: Shengjiu Wang @ 2025-11-05 8:04 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan,
linux-remoteproc, imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 5:14 PM Peng Fan <peng.fan@nxp.com> wrote:
>
> This patchset aligns imx_dsp_rproc with the cleanup and modernization
> previously applied to imx_rproc.c. The goal is to simplify the driver by
> transitioning to the new ops-based method, eliminating the legacy
> switch-case logic for a cleaner and more maintainable design.
>
> Patches 1–5: General cleanup, including code simplification and adoption
> of the devres API.
> Patches 6–10: Transition to the new ops-based approach, removing the
> switch-case structure.
> Patch 11: Remove the obsolete enum imx_rproc_method.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Best regards
Shengjiu wang
> ---
> Peng Fan (11):
> remoteproc: imx_dsp_rproc: simplify power domain attach and error handling
> remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper
> remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper
> remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors
> remoteproc: imx_dsp_rproc: Drop extra space
> remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg
> remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match
> remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case
> remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API switch case
> remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER switch case
> remoteproc: imx_rproc: Remove enum imx_rproc_method
>
> drivers/remoteproc/imx_dsp_rproc.c | 344 ++++++++++++++++++++-----------------
> drivers/remoteproc/imx_rproc.h | 14 --
> 2 files changed, 184 insertions(+), 174 deletions(-)
> ---
> base-commit: 131f3d9446a6075192cdd91f197989d98302faa6
> change-id: 20251031-imx-dsp-2025-10-31-260b2b979258
>
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
>
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper
2025-10-31 18:49 ` Frank Li
@ 2025-11-05 9:24 ` Daniel Baluta
0 siblings, 0 replies; 29+ messages in thread
From: Daniel Baluta @ 2025-11-05 9:24 UTC (permalink / raw)
To: Frank Li
Cc: Peng Fan, Bjorn Andersson, Mathieu Poirier, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Philipp Zabel, Shengjiu Wang, Daniel Baluta, Iuliana Prodan,
linux-remoteproc, imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 8:50 PM Frank Li <Frank.li@nxp.com> wrote:
>
> On Fri, Oct 31, 2025 at 05:08:32PM +0800, Peng Fan wrote:
> > Replace manual pm_runtime_enable() with devm_pm_runtime_enable() to
> > leverage device-managed cleanup and simplify resource handling.
> >
> > pm_runtime_disable_action() not only calls pm_runtime_disable(), but
> > also calls pm_runtime_dont_use_autosuspend(). The current driver
> > only calls pm_runtime_disable(). But this should be fine here to use
> > devm_pm_runtime_enable().
>
> looks like this paragaph is reduntant.
This is not redundant! But it can be phrased better.
```
Current code on the cleanup path just disables runtime PM for a device.
Using resource managed version devm_pm_runtime_enable registers a
cleanup callback that
sets autosuspend to false and then disables runtime PM for a device.
So, basically the same
functionality as we don't use autosuspend anyway.
```
thanks,
Daniel.
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
` (11 preceding siblings ...)
2025-11-05 8:04 ` [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Shengjiu Wang
@ 2025-11-05 9:31 ` Daniel Baluta
12 siblings, 0 replies; 29+ messages in thread
From: Daniel Baluta @ 2025-11-05 9:31 UTC (permalink / raw)
To: Peng Fan
Cc: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Shengjiu Wang, Frank Li, Daniel Baluta, Iuliana Prodan,
linux-remoteproc, imx, linux-arm-kernel, linux-kernel
On Fri, Oct 31, 2025 at 11:20 AM Peng Fan <peng.fan@nxp.com> wrote:
>
> This patchset aligns imx_dsp_rproc with the cleanup and modernization
> previously applied to imx_rproc.c. The goal is to simplify the driver by
> transitioning to the new ops-based method, eliminating the legacy
> switch-case logic for a cleaner and more maintainable design.
>
> Patches 1–5: General cleanup, including code simplification and adoption
> of the devres API.
> Patches 6–10: Transition to the new ops-based approach, removing the
> switch-case structure.
> Patch 11: Remove the obsolete enum imx_rproc_method.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> Peng Fan (11):
> remoteproc: imx_dsp_rproc: simplify power domain attach and error handling
> remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper
> remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper
> remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors
> remoteproc: imx_dsp_rproc: Drop extra space
> remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg
> remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match
> remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case
> remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API switch case
> remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER switch case
> remoteproc: imx_rproc: Remove enum imx_rproc_method
Thanks Peng patchseries looks good to me.
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
^ permalink raw reply [flat|nested] 29+ messages in thread
* [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match
2025-11-06 3:30 Peng Fan
@ 2025-11-06 3:30 ` Peng Fan
0 siblings, 0 replies; 29+ messages in thread
From: Peng Fan @ 2025-11-06 3:30 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, Philipp Zabel,
Daniel Baluta, Shengjiu Wang, Frank Li, Iuliana Prodan
Cc: linux-remoteproc, imx, linux-arm-kernel, linux-kernel, Peng Fan,
Frank Li
Move the imx_dsp_rproc_dcfg structure definitions closer to
imx_dsp_rproc_of_match to prepare for adding start/stop/detect_mode ops for
each i.MX variant.
Avoids the need to declare function prototypes such as
'static int imx_dsp_rproc_mbox_init(struct imx_dsp_rproc *priv)' at the
beginning of the file, improving code organization and readability.
No functional changes.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 100 ++++++++++++++++++-------------------
1 file changed, 50 insertions(+), 50 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 833b1bd4019614157f0bedf09bd348caab802eef..f28d25cab3f1d89e5cde37a04b528870a59abeed 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -261,56 +261,6 @@ static int imx8ulp_dsp_reset(struct imx_dsp_rproc *priv)
return 0;
}
-/* Specific configuration for i.MX8MP */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
- .att = imx_dsp_rproc_att_imx8mp,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
- .method = IMX_RPROC_RESET_CONTROLLER,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
- .dcfg = &dsp_rproc_cfg_imx8mp,
- .reset = imx8mp_dsp_reset,
-};
-
-/* Specific configuration for i.MX8ULP */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
- .src_reg = IMX8ULP_SIM_LPAV_REG_SYSCTRL0,
- .src_mask = IMX8ULP_SYSCTRL0_DSP_STALL,
- .src_start = 0,
- .src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
- .att = imx_dsp_rproc_att_imx8ulp,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
- .method = IMX_RPROC_MMIO,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
- .dcfg = &dsp_rproc_cfg_imx8ulp,
- .reset = imx8ulp_dsp_reset,
-};
-
-/* Specific configuration for i.MX8QXP */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
- .att = imx_dsp_rproc_att_imx8qxp,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
- .method = IMX_RPROC_SCU_API,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
- .dcfg = &dsp_rproc_cfg_imx8qxp,
-};
-
-/* Specific configuration for i.MX8QM */
-static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
- .att = imx_dsp_rproc_att_imx8qm,
- .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
- .method = IMX_RPROC_SCU_API,
-};
-
-static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
- .dcfg = &dsp_rproc_cfg_imx8qm,
-};
-
static int imx_dsp_rproc_ready(struct rproc *rproc)
{
struct imx_dsp_rproc *priv = rproc->priv;
@@ -1351,6 +1301,56 @@ static const struct dev_pm_ops imx_dsp_rproc_pm_ops = {
RUNTIME_PM_OPS(imx_dsp_runtime_suspend, imx_dsp_runtime_resume, NULL)
};
+/* Specific configuration for i.MX8MP */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8mp = {
+ .att = imx_dsp_rproc_att_imx8mp,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8mp),
+ .method = IMX_RPROC_RESET_CONTROLLER,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8mp = {
+ .dcfg = &dsp_rproc_cfg_imx8mp,
+ .reset = imx8mp_dsp_reset,
+};
+
+/* Specific configuration for i.MX8ULP */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8ulp = {
+ .src_reg = IMX8ULP_SIM_LPAV_REG_SYSCTRL0,
+ .src_mask = IMX8ULP_SYSCTRL0_DSP_STALL,
+ .src_start = 0,
+ .src_stop = IMX8ULP_SYSCTRL0_DSP_STALL,
+ .att = imx_dsp_rproc_att_imx8ulp,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8ulp),
+ .method = IMX_RPROC_MMIO,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8ulp = {
+ .dcfg = &dsp_rproc_cfg_imx8ulp,
+ .reset = imx8ulp_dsp_reset,
+};
+
+/* Specific configuration for i.MX8QXP */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qxp = {
+ .att = imx_dsp_rproc_att_imx8qxp,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qxp),
+ .method = IMX_RPROC_SCU_API,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qxp = {
+ .dcfg = &dsp_rproc_cfg_imx8qxp,
+};
+
+/* Specific configuration for i.MX8QM */
+static const struct imx_rproc_dcfg dsp_rproc_cfg_imx8qm = {
+ .att = imx_dsp_rproc_att_imx8qm,
+ .att_size = ARRAY_SIZE(imx_dsp_rproc_att_imx8qm),
+ .method = IMX_RPROC_SCU_API,
+};
+
+static const struct imx_dsp_rproc_dcfg imx_dsp_rproc_cfg_imx8qm = {
+ .dcfg = &dsp_rproc_cfg_imx8qm,
+};
+
static const struct of_device_id imx_dsp_rproc_of_match[] = {
{ .compatible = "fsl,imx8qxp-hifi4", .data = &imx_dsp_rproc_cfg_imx8qxp },
{ .compatible = "fsl,imx8qm-hifi4", .data = &imx_dsp_rproc_cfg_imx8qm },
--
2.37.1
^ permalink raw reply related [flat|nested] 29+ messages in thread
end of thread, other threads:[~2025-11-06 3:31 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-31 9:08 [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Peng Fan
2025-10-31 9:08 ` [PATCH 01/11] remoteproc: imx_dsp_rproc: simplify power domain attach and error handling Peng Fan
2025-10-31 18:46 ` Frank Li
2025-10-31 9:08 ` [PATCH 02/11] remoteproc: imx_dsp_rproc: Use devm_rproc_add() helper Peng Fan
2025-10-31 18:47 ` Frank Li
2025-10-31 9:08 ` [PATCH 03/11] remoteproc: imx_dsp_rproc: Use devm_pm_runtime_enable() helper Peng Fan
2025-10-31 18:49 ` Frank Li
2025-11-05 9:24 ` Daniel Baluta
2025-10-31 9:08 ` [PATCH 04/11] remoteproc: imx_dsp_rproc: Use dev_err_probe() for firmware and mode errors Peng Fan
2025-10-31 18:50 ` Frank Li
2025-10-31 9:08 ` [PATCH 05/11] remoteproc: imx_dsp_rproc: Drop extra space Peng Fan
2025-10-31 18:51 ` Frank Li
2025-10-31 9:08 ` [PATCH 06/11] remoteproc: imx_dsp_rproc: Use start/stop/detect_mode ops from imx_rproc_dcfg Peng Fan
2025-10-31 19:04 ` Frank Li
2025-11-04 4:24 ` Peng Fan
2025-10-31 9:08 ` [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match Peng Fan
2025-10-31 19:05 ` Frank Li
2025-10-31 9:08 ` [PATCH 08/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_MMIO switch case Peng Fan
2025-10-31 19:09 ` Frank Li
2025-11-04 4:25 ` Peng Fan
2025-10-31 9:08 ` [PATCH 09/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_SCU_API " Peng Fan
2025-10-31 19:12 ` Frank Li
2025-10-31 9:08 ` [PATCH 10/11] remoteproc: imx_dsp_rproc: Simplify IMX_RPROC_RESET_CONTROLLER " Peng Fan
2025-10-31 19:13 ` Frank Li
2025-10-31 9:08 ` [PATCH 11/11] remoteproc: imx_rproc: Remove enum imx_rproc_method Peng Fan
2025-10-31 19:15 ` Frank Li
2025-11-05 8:04 ` [PATCH 00/11] remoteproc: imx_dsp_rproc: Refactor to use new ops and remove switch-case logic Shengjiu Wang
2025-11-05 9:31 ` Daniel Baluta
-- strict thread matches above, loose matches on Subject: below --
2025-11-06 3:30 Peng Fan
2025-11-06 3:30 ` [PATCH 07/11] remoteproc: imx_dsp_rproc: Move imx_dsp_rproc_dcfg closer to imx_dsp_rproc_of_match Peng Fan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox