mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Beleswar Prasad Padhi <b-padhi@ti.com>
To: Andrew Davis <afd@ti.com>, <andersson@kernel.org>,
	<mathieu.poirier@linaro.org>
Cc: <hnagalla@ti.com>, <u-kumar1@ti.com>, <jan.kiszka@siemens.com>,
	<christophe.jaillet@wanadoo.fr>,
	<linux-remoteproc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/5] remoteproc: k3-r5: Add devm action to release tsp
Date: Wed, 18 Dec 2024 13:52:03 +0530	[thread overview]
Message-ID: <220b906c-3f16-44d9-b5c3-ad002057e20b@ti.com> (raw)
In-Reply-To: <85dc5e05-5d54-4d0f-a7e2-24134a5392f5@ti.com>

Hi Andrew,

On 17/12/24 21:30, Andrew Davis wrote:
> On 12/4/24 5:11 AM, Beleswar Padhi wrote:
>> Use a device lifecycle managed action to release tsp ti_sci_proc handle.
>> This helps prevent mistakes like releasing out of order in cleanup
>> functions and forgetting to release on error paths.
>>
>> Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
>> ---
>>   drivers/remoteproc/ti_k3_r5_remoteproc.c | 17 +++++++++++------
>>   1 file changed, 11 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c 
>> b/drivers/remoteproc/ti_k3_r5_remoteproc.c
>> index 0753a5c35c7e..2966cb210403 100644
>> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
>> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
>> @@ -1513,6 +1513,13 @@ static int 
>> k3_r5_core_of_get_sram_memories(struct platform_device *pdev,
>>       return 0;
>>   }
>>   +static void k3_r5_release_tsp(void *data)
>> +{
>> +    struct ti_sci_proc *tsp = data;
>> +
>> +    ti_sci_proc_release(tsp);
>> +}
>> +
>>   static int k3_r5_core_of_init(struct platform_device *pdev)
>>   {
>>       struct device *dev = &pdev->dev;
>> @@ -1606,6 +1613,10 @@ static int k3_r5_core_of_init(struct 
>> platform_device *pdev)
>>           goto err;
>>       }
>>   +    ret = devm_add_action_or_reset(dev, k3_r5_release_tsp, 
>> core->tsp);
>> +    if (ret)
>> +        goto err;
>> +
>>       platform_set_drvdata(pdev, core);
>>       devres_close_group(dev, k3_r5_core_of_init);
>>   @@ -1622,13 +1633,7 @@ static int k3_r5_core_of_init(struct 
>> platform_device *pdev)
>>    */
>>   static void k3_r5_core_of_exit(struct platform_device *pdev)
>>   {
>> -    struct k3_r5_core *core = platform_get_drvdata(pdev);
>>       struct device *dev = &pdev->dev;
>> -    int ret;
>> -
>> -    ret = ti_sci_proc_release(core->tsp);
>> -    if (ret)
>> -        dev_err(dev, "failed to release proc, ret = %d\n", ret);
>
> One thing to remember is devm unrolling happens after remove(). So
> here you are changing the order things happen. ti_sci_proc_release()
> now will get called after the below functions. This most likely
> isn't wrong, but to make review easier it helps to start from the
> last called function in remove() and work backwards so nothing
> is reordered.


That's a great insight! Will send out v2 following this order.

Thanks,
Beleswar

>
> Andrew
>
>>       platform_set_drvdata(pdev, NULL);
>>       devres_release_group(dev, k3_r5_core_of_init);

  reply	other threads:[~2024-12-18  8:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04 11:11 [PATCH 0/5] Use Device Lifecycle managed functions in TI R5 Remoteproc Beleswar Padhi
2024-12-04 11:11 ` [PATCH 1/5] remoteproc: k3-r5: Add devm action to release reserved memory Beleswar Padhi
2024-12-04 11:11 ` [PATCH 2/5] remoteproc: k3-r5: Use devm_kcalloc() helper Beleswar Padhi
2024-12-04 11:11 ` [PATCH 3/5] remoteproc: k3-r5: Add devm action to release tsp Beleswar Padhi
2024-12-17 16:00   ` Andrew Davis
2024-12-18  8:22     ` Beleswar Prasad Padhi [this message]
2024-12-04 11:11 ` [PATCH 4/5] remoteproc: k3-r5: Use devm_ioremap_wc() helper Beleswar Padhi
2024-12-17 16:03   ` Andrew Davis
2024-12-18  8:23     ` Beleswar Prasad Padhi
2024-12-04 11:11 ` [PATCH 5/5] remoteproc: k3-r5: Use devm_rproc_add() helper Beleswar Padhi
2024-12-16 16:55 ` [PATCH 0/5] Use Device Lifecycle managed functions in TI R5 Remoteproc Mathieu Poirier

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=220b906c-3f16-44d9-b5c3-ad002057e20b@ti.com \
    --to=b-padhi@ti.com \
    --cc=afd@ti.com \
    --cc=andersson@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=hnagalla@ti.com \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=u-kumar1@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®