* [RFC PATCH] remoteproc: imx_dsp_rproc: Fix multiple start/stop commands
@ 2025-12-09 14:04 Daniel Baluta
2025-12-09 15:27 ` Rob Herring
2025-12-10 0:24 ` Iuliana Prodan
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Baluta @ 2025-12-09 14:04 UTC (permalink / raw)
To: andersson, mathieu.poirier
Cc: m.szyprowski, shawnguo, kernel, festevam, arnaud.pouliquen, robh,
geert+renesas, linux-remoteproc, imx, linux-arm-kernel,
linux-kernel, Daniel Baluta
After commit 67a7bc7f0358 ("remoteproc: Use of reserved_mem_region_*
functions for "memory-region"") following commands with
imx-dsp-rproc started to fail:
$ echo zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
$ echo start > /sys/class/remoteproc/remoteproc0/state
$ echo stop > /sys/class/remoteproc/remoteproc0/state
$ echo start > /sys/class/remoteproc/remoteproc0/state #! This fails
-sh: echo: write error: Device or resource busy
This happens because aforementioned commit replaced devm_ioremap_wc with
devm_ioremap_resource_wc which will "reserve" the memory region with the
first start and then will fail at the second start if the memory
region is already reserved.
So prefer using devm_ioremap_wc as there is no easy way to undo
devm_iormep_resource_wc manually.
Fixes: 67a7bc7f0358 ("remoteproc: Use of_reserved_mem_region_* functions for "memory-region"")
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
drivers/remoteproc/imx_dsp_rproc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
index 5130a35214c9..79d5c15319f3 100644
--- a/drivers/remoteproc/imx_dsp_rproc.c
+++ b/drivers/remoteproc/imx_dsp_rproc.c
@@ -709,10 +709,10 @@ static int imx_dsp_rproc_add_carveout(struct imx_dsp_rproc *priv)
if (imx_dsp_rproc_sys_to_da(priv, res.start, resource_size(&res), &da))
return -EINVAL;
- cpu_addr = devm_ioremap_resource_wc(dev, &res);
- if (IS_ERR(cpu_addr)) {
+ cpu_addr = devm_ioremap_wc(dev, res.start, resource_size(&res));
+ if (!cpu_addr) {
dev_err(dev, "failed to map memory %pR\n", &res);
- return PTR_ERR(cpu_addr);
+ return -ENOMEM;
}
/* Register memory region */
--
2.45.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] remoteproc: imx_dsp_rproc: Fix multiple start/stop commands
2025-12-09 14:04 [RFC PATCH] remoteproc: imx_dsp_rproc: Fix multiple start/stop commands Daniel Baluta
@ 2025-12-09 15:27 ` Rob Herring
2025-12-10 12:56 ` Daniel Baluta
2025-12-10 0:24 ` Iuliana Prodan
1 sibling, 1 reply; 4+ messages in thread
From: Rob Herring @ 2025-12-09 15:27 UTC (permalink / raw)
To: Daniel Baluta
Cc: andersson, mathieu.poirier, m.szyprowski, shawnguo, kernel,
festevam, arnaud.pouliquen, geert+renesas, linux-remoteproc, imx,
linux-arm-kernel, linux-kernel
On Tue, Dec 09, 2025 at 04:04:25PM +0200, Daniel Baluta wrote:
> After commit 67a7bc7f0358 ("remoteproc: Use of reserved_mem_region_*
> functions for "memory-region"") following commands with
> imx-dsp-rproc started to fail:
>
> $ echo zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
> $ echo start > /sys/class/remoteproc/remoteproc0/state
> $ echo stop > /sys/class/remoteproc/remoteproc0/state
> $ echo start > /sys/class/remoteproc/remoteproc0/state #! This fails
> -sh: echo: write error: Device or resource busy
So unlike Marek's case, the first time works. Can you confirm your
region is fixed address?
> This happens because aforementioned commit replaced devm_ioremap_wc with
> devm_ioremap_resource_wc which will "reserve" the memory region with the
> first start and then will fail at the second start if the memory
> region is already reserved.
>
> So prefer using devm_ioremap_wc as there is no easy way to undo
> devm_iormep_resource_wc manually.
>
> Fixes: 67a7bc7f0358 ("remoteproc: Use of_reserved_mem_region_* functions for "memory-region"")
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 5130a35214c9..79d5c15319f3 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -709,10 +709,10 @@ static int imx_dsp_rproc_add_carveout(struct imx_dsp_rproc *priv)
> if (imx_dsp_rproc_sys_to_da(priv, res.start, resource_size(&res), &da))
> return -EINVAL;
>
> - cpu_addr = devm_ioremap_resource_wc(dev, &res);
> - if (IS_ERR(cpu_addr)) {
> + cpu_addr = devm_ioremap_wc(dev, res.start, resource_size(&res));
Best case this is reusing the same mapping and we just have unnecessary
ioremap and iounmap calls and devm entries. Worst case, we get a new
virtual mapping every time. IIRC, arm32 will reuse existing mapping, but
arm64 does not. But that's 10+ years ago I looked into it.
Seems like devres is not the right lifetime. This should be just
ioremap_wc() instead.
Rob
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] remoteproc: imx_dsp_rproc: Fix multiple start/stop commands
2025-12-09 14:04 [RFC PATCH] remoteproc: imx_dsp_rproc: Fix multiple start/stop commands Daniel Baluta
2025-12-09 15:27 ` Rob Herring
@ 2025-12-10 0:24 ` Iuliana Prodan
1 sibling, 0 replies; 4+ messages in thread
From: Iuliana Prodan @ 2025-12-10 0:24 UTC (permalink / raw)
To: Daniel Baluta, andersson, mathieu.poirier
Cc: m.szyprowski, shawnguo, kernel, festevam, arnaud.pouliquen, robh,
geert+renesas, linux-remoteproc, imx, linux-arm-kernel,
linux-kernel
On 12/9/2025 4:04 PM, Daniel Baluta wrote:
> After commit 67a7bc7f0358 ("remoteproc: Use of reserved_mem_region_*
> functions for "memory-region"") following commands with
> imx-dsp-rproc started to fail:
>
> $ echo zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
> $ echo start > /sys/class/remoteproc/remoteproc0/state
> $ echo stop > /sys/class/remoteproc/remoteproc0/state
> $ echo start > /sys/class/remoteproc/remoteproc0/state #! This fails
> -sh: echo: write error: Device or resource busy
>
> This happens because aforementioned commit replaced devm_ioremap_wc with
> devm_ioremap_resource_wc which will "reserve" the memory region with the
> first start and then will fail at the second start if the memory
> region is already reserved.
>
> So prefer using devm_ioremap_wc as there is no easy way to undo
> devm_iormep_resource_wc manually.
>
> Fixes: 67a7bc7f0358 ("remoteproc: Use of_reserved_mem_region_* functions for "memory-region"")
> Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
> ---
> drivers/remoteproc/imx_dsp_rproc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 5130a35214c9..79d5c15319f3 100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -709,10 +709,10 @@ static int imx_dsp_rproc_add_carveout(struct imx_dsp_rproc *priv)
> if (imx_dsp_rproc_sys_to_da(priv, res.start, resource_size(&res), &da))
> return -EINVAL;
>
> - cpu_addr = devm_ioremap_resource_wc(dev, &res);
> - if (IS_ERR(cpu_addr)) {
> + cpu_addr = devm_ioremap_wc(dev, res.start, resource_size(&res));
While this patch technically "works", it’s more of a workaround because:
- it removes important resource protection;
- it doesn’t address the root cause.
The real issue is likely that:
- resources should be released on stop but aren’t;
- or the mapping should happen once during probe, not on every start.
Better alterntives:
1. move the devm_ioremap_resource_wc() to probe() and keep it mapped for
the device lifetime. This is the typical pattern for remoteproc drivers.
2. use non-devm versions in start/stop callbacks:
/* In start callback */
cpu_addr = ioremap_wc(res.start, resource_size(&res));
/* In stop callback */
iounmap(cpu_addr);
My vote goes for option 1.
> + if (!cpu_addr) {
> dev_err(dev, "failed to map memory %pR\n", &res);
> - return PTR_ERR(cpu_addr);
> + return -ENOMEM;
> }
>
> /* Register memory region */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH] remoteproc: imx_dsp_rproc: Fix multiple start/stop commands
2025-12-09 15:27 ` Rob Herring
@ 2025-12-10 12:56 ` Daniel Baluta
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Baluta @ 2025-12-10 12:56 UTC (permalink / raw)
To: Rob Herring
Cc: Daniel Baluta, andersson, mathieu.poirier, m.szyprowski, shawnguo,
kernel, festevam, arnaud.pouliquen, geert+renesas,
linux-remoteproc, imx, linux-arm-kernel, linux-kernel
On Tue, Dec 9, 2025 at 5:27 PM Rob Herring <robh@kernel.org> wrote:
>
> On Tue, Dec 09, 2025 at 04:04:25PM +0200, Daniel Baluta wrote:
> > After commit 67a7bc7f0358 ("remoteproc: Use of reserved_mem_region_*
> > functions for "memory-region"") following commands with
> > imx-dsp-rproc started to fail:
> >
> > $ echo zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
> > $ echo start > /sys/class/remoteproc/remoteproc0/state
> > $ echo stop > /sys/class/remoteproc/remoteproc0/state
> > $ echo start > /sys/class/remoteproc/remoteproc0/state #! This fails
> > -sh: echo: write error: Device or resource busy
>
> So unlike Marek's case, the first time works. Can you confirm your
> region is fixed address?
Yes, all regions are fixed addresses.
> > + cpu_addr = devm_ioremap_wc(dev, res.start, resource_size(&res));
>
> Best case this is reusing the same mapping and we just have unnecessary
> ioremap and iounmap calls and devm entries. Worst case, we get a new
> virtual mapping every time. IIRC, arm32 will reuse existing mapping, but
> arm64 does not. But that's 10+ years ago I looked into it.
>
> Seems like devres is not the right lifetime. This should be just
> ioremap_wc() instead.
Yes, looks like for arm64 (imx8mp-evk) will not reuse existing mapping
but creates a new one.
Best course of action would be as Iulia suggested to move the operation
at probe instead of prepare.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-10 12:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-09 14:04 [RFC PATCH] remoteproc: imx_dsp_rproc: Fix multiple start/stop commands Daniel Baluta
2025-12-09 15:27 ` Rob Herring
2025-12-10 12:56 ` Daniel Baluta
2025-12-10 0:24 ` Iuliana Prodan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).