* [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper
@ 2025-08-14 13:55 Andrew Davis
2025-08-14 13:55 ` [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory Andrew Davis
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Andrew Davis @ 2025-08-14 13:55 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Hari Nagalla, Beleswar Padhi
Cc: linux-remoteproc, linux-kernel, Andrew Davis
Use the device lifecycle managed allocation function. This helps prevent
mistakes like freeing out of order in cleanup functions and forgetting to
free on error paths.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/remoteproc/da8xx_remoteproc.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 93031f0867d10..47df21bea5254 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -276,8 +276,8 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
return dev_err_probe(dev, ret, "device does not have specific CMA pool\n");
}
- rproc = rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
- sizeof(*drproc));
+ rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
+ sizeof(*drproc));
if (!rproc) {
ret = -ENOMEM;
goto free_mem;
@@ -294,7 +294,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
ret = da8xx_rproc_get_internal_memories(pdev, drproc);
if (ret)
- goto free_rproc;
+ goto free_mem;
platform_set_drvdata(pdev, rproc);
@@ -304,7 +304,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
rproc);
if (ret) {
dev_err(dev, "devm_request_threaded_irq error: %d\n", ret);
- goto free_rproc;
+ goto free_mem;
}
/*
@@ -314,7 +314,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
*/
ret = reset_control_assert(dsp_reset);
if (ret)
- goto free_rproc;
+ goto free_mem;
drproc->chipsig = chipsig;
drproc->bootreg = bootreg;
@@ -325,13 +325,11 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
ret = rproc_add(rproc);
if (ret) {
dev_err(dev, "rproc_add failed: %d\n", ret);
- goto free_rproc;
+ goto free_mem;
}
return 0;
-free_rproc:
- rproc_free(rproc);
free_mem:
if (dev->of_node)
of_reserved_mem_device_release(dev);
@@ -352,7 +350,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev)
disable_irq(drproc->irq);
rproc_del(rproc);
- rproc_free(rproc);
if (dev->of_node)
of_reserved_mem_device_release(dev);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory
2025-08-14 13:55 [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Andrew Davis
@ 2025-08-14 13:55 ` Andrew Davis
2025-08-25 17:04 ` Mathieu Poirier
2025-08-14 13:55 ` [PATCH 3/3] remoteproc: da8xx: Use devm_rproc_add() helper Andrew Davis
2025-08-25 17:01 ` [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Mathieu Poirier
2 siblings, 1 reply; 7+ messages in thread
From: Andrew Davis @ 2025-08-14 13:55 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Hari Nagalla, Beleswar Padhi
Cc: linux-remoteproc, linux-kernel, Andrew Davis
This helps prevent mistakes like freeing out of order in cleanup functions
and forgetting to free on error paths.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/remoteproc/da8xx_remoteproc.c | 30 +++++++++++++--------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 47df21bea5254..58b4f05283d92 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -233,6 +233,13 @@ static int da8xx_rproc_get_internal_memories(struct platform_device *pdev,
return 0;
}
+static void da8xx_rproc_mem_release(void *data)
+{
+ struct device *dev = data;
+
+ of_reserved_mem_device_release(dev);
+}
+
static int da8xx_rproc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -274,14 +281,13 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
ret = of_reserved_mem_device_init(dev);
if (ret)
return dev_err_probe(dev, ret, "device does not have specific CMA pool\n");
+ devm_add_action_or_reset(&pdev->dev, da8xx_rproc_mem_release, &pdev->dev);
}
rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
sizeof(*drproc));
- if (!rproc) {
- ret = -ENOMEM;
- goto free_mem;
- }
+ if (!rproc)
+ return -ENOMEM;
/* error recovery is not supported at present */
rproc->recovery_disabled = true;
@@ -294,7 +300,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
ret = da8xx_rproc_get_internal_memories(pdev, drproc);
if (ret)
- goto free_mem;
+ return ret;
platform_set_drvdata(pdev, rproc);
@@ -304,7 +310,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
rproc);
if (ret) {
dev_err(dev, "devm_request_threaded_irq error: %d\n", ret);
- goto free_mem;
+ return ret;
}
/*
@@ -314,7 +320,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
*/
ret = reset_control_assert(dsp_reset);
if (ret)
- goto free_mem;
+ return ret;
drproc->chipsig = chipsig;
drproc->bootreg = bootreg;
@@ -325,22 +331,16 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
ret = rproc_add(rproc);
if (ret) {
dev_err(dev, "rproc_add failed: %d\n", ret);
- goto free_mem;
+ return ret;
}
return 0;
-
-free_mem:
- if (dev->of_node)
- of_reserved_mem_device_release(dev);
- return ret;
}
static void da8xx_rproc_remove(struct platform_device *pdev)
{
struct rproc *rproc = platform_get_drvdata(pdev);
struct da8xx_rproc *drproc = rproc->priv;
- struct device *dev = &pdev->dev;
/*
* The devm subsystem might end up releasing things before
@@ -350,8 +350,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev)
disable_irq(drproc->irq);
rproc_del(rproc);
- if (dev->of_node)
- of_reserved_mem_device_release(dev);
}
static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = {
--
2.39.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] remoteproc: da8xx: Use devm_rproc_add() helper
2025-08-14 13:55 [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Andrew Davis
2025-08-14 13:55 ` [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory Andrew Davis
@ 2025-08-14 13:55 ` Andrew Davis
2025-08-25 17:01 ` [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Mathieu Poirier
2 siblings, 0 replies; 7+ messages in thread
From: Andrew Davis @ 2025-08-14 13:55 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Hari Nagalla, Beleswar Padhi
Cc: linux-remoteproc, linux-kernel, Andrew Davis
Use the device lifecycle managed add function. This helps prevent mistakes
like deleting out of order in cleanup functions and forgetting to delete
on error paths.
As this now makes the IRQ free ordered correctly, we can drop that from
the remove() callback, which is now empty and can also be removed.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/remoteproc/da8xx_remoteproc.c | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 58b4f05283d92..e418a2bf5d2ee 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -302,8 +302,6 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
if (ret)
return ret;
- platform_set_drvdata(pdev, rproc);
-
/* everything the ISR needs is now setup, so hook it up */
ret = devm_request_threaded_irq(dev, irq, da8xx_rproc_callback,
handle_event, 0, "da8xx-remoteproc",
@@ -328,7 +326,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
drproc->irq_data = irq_data;
drproc->irq = irq;
- ret = rproc_add(rproc);
+ ret = devm_rproc_add(dev, rproc);
if (ret) {
dev_err(dev, "rproc_add failed: %d\n", ret);
return ret;
@@ -337,21 +335,6 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
return 0;
}
-static void da8xx_rproc_remove(struct platform_device *pdev)
-{
- struct rproc *rproc = platform_get_drvdata(pdev);
- struct da8xx_rproc *drproc = rproc->priv;
-
- /*
- * The devm subsystem might end up releasing things before
- * freeing the irq, thus allowing an interrupt to sneak in while
- * the device is being removed. This should prevent that.
- */
- disable_irq(drproc->irq);
-
- rproc_del(rproc);
-}
-
static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = {
{ .compatible = "ti,da850-dsp", },
{ /* sentinel */ },
@@ -360,7 +343,6 @@ MODULE_DEVICE_TABLE(of, davinci_rproc_of_match);
static struct platform_driver da8xx_rproc_driver = {
.probe = da8xx_rproc_probe,
- .remove = da8xx_rproc_remove,
.driver = {
.name = "davinci-rproc",
.of_match_table = of_match_ptr(davinci_rproc_of_match),
--
2.39.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper
2025-08-14 13:55 [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Andrew Davis
2025-08-14 13:55 ` [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory Andrew Davis
2025-08-14 13:55 ` [PATCH 3/3] remoteproc: da8xx: Use devm_rproc_add() helper Andrew Davis
@ 2025-08-25 17:01 ` Mathieu Poirier
2 siblings, 0 replies; 7+ messages in thread
From: Mathieu Poirier @ 2025-08-25 17:01 UTC (permalink / raw)
To: Andrew Davis
Cc: Bjorn Andersson, Hari Nagalla, Beleswar Padhi, linux-remoteproc,
linux-kernel
On Thu, Aug 14, 2025 at 08:55:30AM -0500, Andrew Davis wrote:
> Use the device lifecycle managed allocation function. This helps prevent
> mistakes like freeing out of order in cleanup functions and forgetting to
> free on error paths.
>
> Signed-off-by: Andrew Davis <afd@ti.com>
> ---
> drivers/remoteproc/da8xx_remoteproc.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
Applied.
> diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
> index 93031f0867d10..47df21bea5254 100644
> --- a/drivers/remoteproc/da8xx_remoteproc.c
> +++ b/drivers/remoteproc/da8xx_remoteproc.c
> @@ -276,8 +276,8 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> return dev_err_probe(dev, ret, "device does not have specific CMA pool\n");
> }
>
> - rproc = rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
> - sizeof(*drproc));
> + rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
> + sizeof(*drproc));
> if (!rproc) {
> ret = -ENOMEM;
> goto free_mem;
> @@ -294,7 +294,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
>
> ret = da8xx_rproc_get_internal_memories(pdev, drproc);
> if (ret)
> - goto free_rproc;
> + goto free_mem;
>
> platform_set_drvdata(pdev, rproc);
>
> @@ -304,7 +304,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> rproc);
> if (ret) {
> dev_err(dev, "devm_request_threaded_irq error: %d\n", ret);
> - goto free_rproc;
> + goto free_mem;
> }
>
> /*
> @@ -314,7 +314,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> */
> ret = reset_control_assert(dsp_reset);
> if (ret)
> - goto free_rproc;
> + goto free_mem;
>
> drproc->chipsig = chipsig;
> drproc->bootreg = bootreg;
> @@ -325,13 +325,11 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> ret = rproc_add(rproc);
> if (ret) {
> dev_err(dev, "rproc_add failed: %d\n", ret);
> - goto free_rproc;
> + goto free_mem;
> }
>
> return 0;
>
> -free_rproc:
> - rproc_free(rproc);
> free_mem:
> if (dev->of_node)
> of_reserved_mem_device_release(dev);
> @@ -352,7 +350,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev)
> disable_irq(drproc->irq);
>
> rproc_del(rproc);
> - rproc_free(rproc);
> if (dev->of_node)
> of_reserved_mem_device_release(dev);
> }
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory
2025-08-14 13:55 ` [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory Andrew Davis
@ 2025-08-25 17:04 ` Mathieu Poirier
2025-08-25 18:29 ` Andrew Davis
0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Poirier @ 2025-08-25 17:04 UTC (permalink / raw)
To: Andrew Davis
Cc: Bjorn Andersson, Hari Nagalla, Beleswar Padhi, linux-remoteproc,
linux-kernel
On Thu, Aug 14, 2025 at 08:55:31AM -0500, Andrew Davis wrote:
> This helps prevent mistakes like freeing out of order in cleanup functions
> and forgetting to free on error paths.
>
> Signed-off-by: Andrew Davis <afd@ti.com>
> ---
> drivers/remoteproc/da8xx_remoteproc.c | 30 +++++++++++++--------------
> 1 file changed, 14 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
> index 47df21bea5254..58b4f05283d92 100644
> --- a/drivers/remoteproc/da8xx_remoteproc.c
> +++ b/drivers/remoteproc/da8xx_remoteproc.c
> @@ -233,6 +233,13 @@ static int da8xx_rproc_get_internal_memories(struct platform_device *pdev,
> return 0;
> }
>
> +static void da8xx_rproc_mem_release(void *data)
> +{
> + struct device *dev = data;
> +
The check for dev->of_node from "free_mem" is missing. I can add it if you
agree.
> + of_reserved_mem_device_release(dev);
> +}
> +
> static int da8xx_rproc_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -274,14 +281,13 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> ret = of_reserved_mem_device_init(dev);
> if (ret)
> return dev_err_probe(dev, ret, "device does not have specific CMA pool\n");
> + devm_add_action_or_reset(&pdev->dev, da8xx_rproc_mem_release, &pdev->dev);
> }
>
> rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
> sizeof(*drproc));
> - if (!rproc) {
> - ret = -ENOMEM;
> - goto free_mem;
> - }
> + if (!rproc)
> + return -ENOMEM;
>
> /* error recovery is not supported at present */
> rproc->recovery_disabled = true;
> @@ -294,7 +300,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
>
> ret = da8xx_rproc_get_internal_memories(pdev, drproc);
> if (ret)
> - goto free_mem;
> + return ret;
>
> platform_set_drvdata(pdev, rproc);
>
> @@ -304,7 +310,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> rproc);
> if (ret) {
> dev_err(dev, "devm_request_threaded_irq error: %d\n", ret);
> - goto free_mem;
> + return ret;
> }
>
> /*
> @@ -314,7 +320,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> */
> ret = reset_control_assert(dsp_reset);
> if (ret)
> - goto free_mem;
> + return ret;
>
> drproc->chipsig = chipsig;
> drproc->bootreg = bootreg;
> @@ -325,22 +331,16 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> ret = rproc_add(rproc);
> if (ret) {
> dev_err(dev, "rproc_add failed: %d\n", ret);
> - goto free_mem;
> + return ret;
> }
>
> return 0;
> -
> -free_mem:
> - if (dev->of_node)
> - of_reserved_mem_device_release(dev);
> - return ret;
> }
>
> static void da8xx_rproc_remove(struct platform_device *pdev)
> {
> struct rproc *rproc = platform_get_drvdata(pdev);
> struct da8xx_rproc *drproc = rproc->priv;
> - struct device *dev = &pdev->dev;
>
> /*
> * The devm subsystem might end up releasing things before
> @@ -350,8 +350,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev)
> disable_irq(drproc->irq);
>
> rproc_del(rproc);
> - if (dev->of_node)
> - of_reserved_mem_device_release(dev);
> }
>
> static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = {
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory
2025-08-25 17:04 ` Mathieu Poirier
@ 2025-08-25 18:29 ` Andrew Davis
2025-08-26 18:48 ` Mathieu Poirier
0 siblings, 1 reply; 7+ messages in thread
From: Andrew Davis @ 2025-08-25 18:29 UTC (permalink / raw)
To: Mathieu Poirier
Cc: Bjorn Andersson, Hari Nagalla, Beleswar Padhi, linux-remoteproc,
linux-kernel
On 8/25/25 12:04 PM, Mathieu Poirier wrote:
> On Thu, Aug 14, 2025 at 08:55:31AM -0500, Andrew Davis wrote:
>> This helps prevent mistakes like freeing out of order in cleanup functions
>> and forgetting to free on error paths.
>>
>> Signed-off-by: Andrew Davis <afd@ti.com>
>> ---
>> drivers/remoteproc/da8xx_remoteproc.c | 30 +++++++++++++--------------
>> 1 file changed, 14 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
>> index 47df21bea5254..58b4f05283d92 100644
>> --- a/drivers/remoteproc/da8xx_remoteproc.c
>> +++ b/drivers/remoteproc/da8xx_remoteproc.c
>> @@ -233,6 +233,13 @@ static int da8xx_rproc_get_internal_memories(struct platform_device *pdev,
>> return 0;
>> }
>>
>> +static void da8xx_rproc_mem_release(void *data)
>> +{
>> + struct device *dev = data;
>> +
>
> The check for dev->of_node from "free_mem" is missing. I can add it if you
> agree.
>
It should not be needed, this devm_action callback is added inside a if(dev->of_node)
block below, so this will only be called iff dev->of_node is not null.
Andrew
>> + of_reserved_mem_device_release(dev);
>> +}
>> +
>> static int da8xx_rproc_probe(struct platform_device *pdev)
>> {
>> struct device *dev = &pdev->dev;
>> @@ -274,14 +281,13 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
>> ret = of_reserved_mem_device_init(dev);
>> if (ret)
>> return dev_err_probe(dev, ret, "device does not have specific CMA pool\n");
>> + devm_add_action_or_reset(&pdev->dev, da8xx_rproc_mem_release, &pdev->dev);
>> }
>>
>> rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
>> sizeof(*drproc));
>> - if (!rproc) {
>> - ret = -ENOMEM;
>> - goto free_mem;
>> - }
>> + if (!rproc)
>> + return -ENOMEM;
>>
>> /* error recovery is not supported at present */
>> rproc->recovery_disabled = true;
>> @@ -294,7 +300,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
>>
>> ret = da8xx_rproc_get_internal_memories(pdev, drproc);
>> if (ret)
>> - goto free_mem;
>> + return ret;
>>
>> platform_set_drvdata(pdev, rproc);
>>
>> @@ -304,7 +310,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
>> rproc);
>> if (ret) {
>> dev_err(dev, "devm_request_threaded_irq error: %d\n", ret);
>> - goto free_mem;
>> + return ret;
>> }
>>
>> /*
>> @@ -314,7 +320,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
>> */
>> ret = reset_control_assert(dsp_reset);
>> if (ret)
>> - goto free_mem;
>> + return ret;
>>
>> drproc->chipsig = chipsig;
>> drproc->bootreg = bootreg;
>> @@ -325,22 +331,16 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
>> ret = rproc_add(rproc);
>> if (ret) {
>> dev_err(dev, "rproc_add failed: %d\n", ret);
>> - goto free_mem;
>> + return ret;
>> }
>>
>> return 0;
>> -
>> -free_mem:
>> - if (dev->of_node)
>> - of_reserved_mem_device_release(dev);
>> - return ret;
>> }
>>
>> static void da8xx_rproc_remove(struct platform_device *pdev)
>> {
>> struct rproc *rproc = platform_get_drvdata(pdev);
>> struct da8xx_rproc *drproc = rproc->priv;
>> - struct device *dev = &pdev->dev;
>>
>> /*
>> * The devm subsystem might end up releasing things before
>> @@ -350,8 +350,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev)
>> disable_irq(drproc->irq);
>>
>> rproc_del(rproc);
>> - if (dev->of_node)
>> - of_reserved_mem_device_release(dev);
>> }
>>
>> static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = {
>> --
>> 2.39.2
>>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory
2025-08-25 18:29 ` Andrew Davis
@ 2025-08-26 18:48 ` Mathieu Poirier
0 siblings, 0 replies; 7+ messages in thread
From: Mathieu Poirier @ 2025-08-26 18:48 UTC (permalink / raw)
To: Andrew Davis
Cc: Bjorn Andersson, Hari Nagalla, Beleswar Padhi, linux-remoteproc,
linux-kernel
On Mon, Aug 25, 2025 at 01:29:26PM -0500, Andrew Davis wrote:
> On 8/25/25 12:04 PM, Mathieu Poirier wrote:
> > On Thu, Aug 14, 2025 at 08:55:31AM -0500, Andrew Davis wrote:
> > > This helps prevent mistakes like freeing out of order in cleanup functions
> > > and forgetting to free on error paths.
> > >
> > > Signed-off-by: Andrew Davis <afd@ti.com>
> > > ---
> > > drivers/remoteproc/da8xx_remoteproc.c | 30 +++++++++++++--------------
> > > 1 file changed, 14 insertions(+), 16 deletions(-)
> > >
> > > diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
> > > index 47df21bea5254..58b4f05283d92 100644
> > > --- a/drivers/remoteproc/da8xx_remoteproc.c
> > > +++ b/drivers/remoteproc/da8xx_remoteproc.c
> > > @@ -233,6 +233,13 @@ static int da8xx_rproc_get_internal_memories(struct platform_device *pdev,
> > > return 0;
> > > }
> > > +static void da8xx_rproc_mem_release(void *data)
> > > +{
> > > + struct device *dev = data;
> > > +
> >
> > The check for dev->of_node from "free_mem" is missing. I can add it if you
> > agree.
> >
>
> It should not be needed, this devm_action callback is added inside a if(dev->of_node)
> block below, so this will only be called iff dev->of_node is not null.
I agree with your assessment. This set has been applied, along with the other
two with similar aim.
>
> Andrew
>
> > > + of_reserved_mem_device_release(dev);
> > > +}
> > > +
> > > static int da8xx_rproc_probe(struct platform_device *pdev)
> > > {
> > > struct device *dev = &pdev->dev;
> > > @@ -274,14 +281,13 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> > > ret = of_reserved_mem_device_init(dev);
> > > if (ret)
> > > return dev_err_probe(dev, ret, "device does not have specific CMA pool\n");
> > > + devm_add_action_or_reset(&pdev->dev, da8xx_rproc_mem_release, &pdev->dev);
> > > }
> > > rproc = devm_rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
> > > sizeof(*drproc));
> > > - if (!rproc) {
> > > - ret = -ENOMEM;
> > > - goto free_mem;
> > > - }
> > > + if (!rproc)
> > > + return -ENOMEM;
> > > /* error recovery is not supported at present */
> > > rproc->recovery_disabled = true;
> > > @@ -294,7 +300,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> > > ret = da8xx_rproc_get_internal_memories(pdev, drproc);
> > > if (ret)
> > > - goto free_mem;
> > > + return ret;
> > > platform_set_drvdata(pdev, rproc);
> > > @@ -304,7 +310,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> > > rproc);
> > > if (ret) {
> > > dev_err(dev, "devm_request_threaded_irq error: %d\n", ret);
> > > - goto free_mem;
> > > + return ret;
> > > }
> > > /*
> > > @@ -314,7 +320,7 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> > > */
> > > ret = reset_control_assert(dsp_reset);
> > > if (ret)
> > > - goto free_mem;
> > > + return ret;
> > > drproc->chipsig = chipsig;
> > > drproc->bootreg = bootreg;
> > > @@ -325,22 +331,16 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
> > > ret = rproc_add(rproc);
> > > if (ret) {
> > > dev_err(dev, "rproc_add failed: %d\n", ret);
> > > - goto free_mem;
> > > + return ret;
> > > }
> > > return 0;
> > > -
> > > -free_mem:
> > > - if (dev->of_node)
> > > - of_reserved_mem_device_release(dev);
> > > - return ret;
> > > }
> > > static void da8xx_rproc_remove(struct platform_device *pdev)
> > > {
> > > struct rproc *rproc = platform_get_drvdata(pdev);
> > > struct da8xx_rproc *drproc = rproc->priv;
> > > - struct device *dev = &pdev->dev;
> > > /*
> > > * The devm subsystem might end up releasing things before
> > > @@ -350,8 +350,6 @@ static void da8xx_rproc_remove(struct platform_device *pdev)
> > > disable_irq(drproc->irq);
> > > rproc_del(rproc);
> > > - if (dev->of_node)
> > > - of_reserved_mem_device_release(dev);
> > > }
> > > static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = {
> > > --
> > > 2.39.2
> > >
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-26 18:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 13:55 [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Andrew Davis
2025-08-14 13:55 ` [PATCH 2/3] remoteproc: da8xx: Use devm action to release reserved memory Andrew Davis
2025-08-25 17:04 ` Mathieu Poirier
2025-08-25 18:29 ` Andrew Davis
2025-08-26 18:48 ` Mathieu Poirier
2025-08-14 13:55 ` [PATCH 3/3] remoteproc: da8xx: Use devm_rproc_add() helper Andrew Davis
2025-08-25 17:01 ` [PATCH 1/3] remoteproc: da8xx: Use devm_rproc_alloc() helper Mathieu Poirier
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).