From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Andrew Davis <afd@ti.com>
Cc: Hari Nagalla <hnagalla@ti.com>,
Bjorn Andersson <andersson@kernel.org>,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/7] remoteproc: keystone: Use devm action to release reserved memory
Date: Tue, 13 Aug 2024 09:55:05 -0600 [thread overview]
Message-ID: <ZruB2VhA78GRWG9X@p14s> (raw)
In-Reply-To: <20240802182300.244055-3-afd@ti.com>
On Fri, Aug 02, 2024 at 01:22:56PM -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/keystone_remoteproc.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/remoteproc/keystone_remoteproc.c b/drivers/remoteproc/keystone_remoteproc.c
> index 8f0f7a4cfef26..033e573544fef 100644
> --- a/drivers/remoteproc/keystone_remoteproc.c
> +++ b/drivers/remoteproc/keystone_remoteproc.c
> @@ -358,6 +358,13 @@ static int keystone_rproc_of_get_dev_syscon(struct platform_device *pdev,
> return 0;
> }
>
> +static void keystone_rproc_mem_release(void *data)
> +{
> + struct device *dev = data;
> +
> + of_reserved_mem_device_release(dev);
> +}
> +
> static int keystone_rproc_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -434,8 +441,14 @@ static int keystone_rproc_probe(struct platform_device *pdev)
> goto disable_clk;
> }
>
> - if (of_reserved_mem_device_init(dev))
> + ret = of_reserved_mem_device_init(dev);
> + if (ret) {
> dev_warn(dev, "device does not have specific CMA pool\n");
> + } else {
> + ret = devm_add_action_or_reset(dev, keystone_rproc_mem_release, dev);
> + if (ret)
> + return ret;
It gets sorted out in the next patches but we still need to "goto disable_clk"
to avoid git-bisect problems.
I have applied the first two patches of this set so no need to resend them.
Thanks,
Mathieu
> + }
>
> /* ensure the DSP is in reset before loading firmware */
> ret = reset_control_status(ksproc->reset);
> @@ -459,7 +472,6 @@ static int keystone_rproc_probe(struct platform_device *pdev)
> return 0;
>
> release_mem:
> - of_reserved_mem_device_release(dev);
> gpiod_put(ksproc->kick_gpio);
> disable_clk:
> pm_runtime_put_sync(dev);
> @@ -476,7 +488,6 @@ static void keystone_rproc_remove(struct platform_device *pdev)
> gpiod_put(ksproc->kick_gpio);
> pm_runtime_put_sync(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> - of_reserved_mem_device_release(&pdev->dev);
> }
>
> static const struct of_device_id keystone_rproc_of_match[] = {
> --
> 2.39.2
>
next prev parent reply other threads:[~2024-08-13 15:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 18:22 [PATCH 1/7] remoteproc: keystone: Use devm_kasprintf() to build name string Andrew Davis
2024-08-02 18:22 ` [PATCH 2/7] remoteproc: keystone: Use devm_rproc_alloc() helper Andrew Davis
2024-08-02 18:22 ` [PATCH 3/7] remoteproc: keystone: Use devm action to release reserved memory Andrew Davis
2024-08-13 15:55 ` Mathieu Poirier [this message]
2024-08-02 18:22 ` [PATCH 4/7] remoteproc: keystone: Use devm_pm_runtime_enable() helper Andrew Davis
2024-08-02 18:22 ` [PATCH 5/7] remoteproc: keystone: Use devm action to call PM runtime put sync Andrew Davis
2024-08-02 18:22 ` [PATCH 6/7] remoteproc: keystone: Use devm_gpiod_get() helper Andrew Davis
2024-08-02 18:23 ` [PATCH 7/7] remoteproc: keystone: Use devm_rproc_add() helper Andrew Davis
2024-08-08 11:34 ` [PATCH 1/7] remoteproc: keystone: Use devm_kasprintf() to build name string Hari Nagalla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZruB2VhA78GRWG9X@p14s \
--to=mathieu.poirier@linaro.org \
--cc=afd@ti.com \
--cc=andersson@kernel.org \
--cc=hnagalla@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.