2020-06-02 05:51:13

by Navid Emamdoost

[permalink] [raw]
Subject: [PATCH] media: staging: tegra-vde: add missing pm_runtime_put_autosuspend

Call to pm_runtime_get_sync increments counter even in case of
failure leading to incorrect ref count.
Call pm_runtime_put_autosuspend if pm_runtime_get_sync fails.

Signed-off-by: Navid Emamdoost <[email protected]>
---
drivers/staging/media/tegra-vde/vde.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c
index d3e63512a765..52cdd4a91e93 100644
--- a/drivers/staging/media/tegra-vde/vde.c
+++ b/drivers/staging/media/tegra-vde/vde.c
@@ -776,8 +776,10 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
goto release_dpb_frames;

ret = pm_runtime_get_sync(dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_autosuspend(dev);
goto unlock;
+ }

/*
* We rely on the VDE registers reset value, otherwise VDE
--
2.17.1


2020-06-02 10:26:26

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH] media: staging: tegra-vde: add missing pm_runtime_put_autosuspend

> Call to pm_runtime_get_sync increments counter even in case of
> failure leading to incorrect ref count.
> Call pm_runtime_put_autosuspend if pm_runtime_get_sync fails.

How do you think about a wording variant like the following?

Change description:
The PM runtime reference counter is generally incremented by a call of
the function “pm_runtime_get_sync”.
Thus call the function “pm_runtime_put_autosuspend” also in one error case
to keep the reference counting consistent.


Would you like to add the tag “Fixes” to the commit message?

Regards,
Markus

2020-06-05 06:03:16

by Jon Hunter

[permalink] [raw]
Subject: Re: [PATCH] media: staging: tegra-vde: add missing pm_runtime_put_autosuspend


On 02/06/2020 06:48, Navid Emamdoost wrote:
> Call to pm_runtime_get_sync increments counter even in case of
> failure leading to incorrect ref count.
> Call pm_runtime_put_autosuspend if pm_runtime_get_sync fails.
>
> Signed-off-by: Navid Emamdoost <[email protected]>
> ---
> drivers/staging/media/tegra-vde/vde.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c
> index d3e63512a765..52cdd4a91e93 100644
> --- a/drivers/staging/media/tegra-vde/vde.c
> +++ b/drivers/staging/media/tegra-vde/vde.c
> @@ -776,8 +776,10 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
> goto release_dpb_frames;
>
> ret = pm_runtime_get_sync(dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_autosuspend(dev);
> goto unlock;
> + }
>
> /*
> * We rely on the VDE registers reset value, otherwise VDE

Please use the put in the error path.

Jon

--
nvpublic

2020-06-05 14:10:37

by Dmitry Osipenko

[permalink] [raw]
Subject: Re: [PATCH] media: staging: tegra-vde: add missing pm_runtime_put_autosuspend

05.06.2020 09:00, Jon Hunter пишет:
>
> On 02/06/2020 06:48, Navid Emamdoost wrote:
>> Call to pm_runtime_get_sync increments counter even in case of
>> failure leading to incorrect ref count.
>> Call pm_runtime_put_autosuspend if pm_runtime_get_sync fails.
>>
>> Signed-off-by: Navid Emamdoost <[email protected]>
>> ---
>> drivers/staging/media/tegra-vde/vde.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c
>> index d3e63512a765..52cdd4a91e93 100644
>> --- a/drivers/staging/media/tegra-vde/vde.c
>> +++ b/drivers/staging/media/tegra-vde/vde.c
>> @@ -776,8 +776,10 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
>> goto release_dpb_frames;
>>
>> ret = pm_runtime_get_sync(dev);
>> - if (ret < 0)
>> + if (ret < 0) {
>> + pm_runtime_put_autosuspend(dev);
>> goto unlock;
>> + }
>>
>> /*
>> * We rely on the VDE registers reset value, otherwise VDE
>
> Please use the put in the error path.

This is a third version of the patch [1][2].

[1]
https://patchwork.ozlabs.org/project/linux-tegra/patch/[email protected]/
[2]
https://patchwork.ozlabs.org/project/linux-tegra/patch/[email protected]/

I'd prefer to stick with my variant of the patch [1] because in my
opinion it's most straightforward variant and I actually tested that it
works properly.

Navid, anyways thank you for the patch. Next time please check if
somebody else already sent similar patches before you.