linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: venus: core: Fix runtime PM imbalance in venus_probe
@ 2020-05-24  5:29 Dinghao Liu
  2020-06-23  9:48 ` Stanimir Varbanov
  0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2020-05-24  5:29 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Stanimir Varbanov, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, linux-media, linux-arm-msm, linux-kernel

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced. For other error
paths after this call, things are the same.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/media/platform/qcom/venus/core.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
index 194b10b98767..37db3b594dca 100644
--- a/drivers/media/platform/qcom/venus/core.c
+++ b/drivers/media/platform/qcom/venus/core.c
@@ -289,18 +289,24 @@ static int venus_probe(struct platform_device *pdev)
 		goto err_core_deinit;
 
 	ret = pm_runtime_put_sync(dev);
-	if (ret)
-		goto err_dev_unregister;
+	if (ret) {
+		v4l2_device_unregister(&core->v4l2_dev);
+		hfi_core_deinit(core, false);
+		venus_shutdown(core);
+		pm_runtime_set_suspended(dev);
+		pm_runtime_disable(dev);
+		hfi_destroy(core);
+		return ret;
+	}
 
 	return 0;
 
-err_dev_unregister:
-	v4l2_device_unregister(&core->v4l2_dev);
 err_core_deinit:
 	hfi_core_deinit(core, false);
 err_venus_shutdown:
 	venus_shutdown(core);
 err_runtime_disable:
+	pm_runtime_put_noidle(dev);
 	pm_runtime_set_suspended(dev);
 	pm_runtime_disable(dev);
 	hfi_destroy(core);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: venus: core: Fix runtime PM imbalance in venus_probe
  2020-05-24  5:29 [PATCH] media: venus: core: Fix runtime PM imbalance in venus_probe Dinghao Liu
@ 2020-06-23  9:48 ` Stanimir Varbanov
  2020-06-24  6:18   ` dinghao.liu
  0 siblings, 1 reply; 3+ messages in thread
From: Stanimir Varbanov @ 2020-06-23  9:48 UTC (permalink / raw)
  To: Dinghao Liu, kjlu
  Cc: Stanimir Varbanov, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, linux-media, linux-arm-msm, linux-kernel

Hi Dinghao,

Thanks for the patch!

On 5/24/20 8:29 AM, Dinghao Liu wrote:
> pm_runtime_get_sync() increments the runtime PM usage counter even
> when it returns an error code. Thus a pairing decrement is needed on
> the error handling path to keep the counter balanced. For other error
> paths after this call, things are the same.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/media/platform/qcom/venus/core.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/core.c b/drivers/media/platform/qcom/venus/core.c
> index 194b10b98767..37db3b594dca 100644
> --- a/drivers/media/platform/qcom/venus/core.c
> +++ b/drivers/media/platform/qcom/venus/core.c
> @@ -289,18 +289,24 @@ static int venus_probe(struct platform_device *pdev)
>  		goto err_core_deinit;
>  
>  	ret = pm_runtime_put_sync(dev);
> -	if (ret)
> -		goto err_dev_unregister;
> +	if (ret) {
> +		v4l2_device_unregister(&core->v4l2_dev);
> +		hfi_core_deinit(core, false);
> +		venus_shutdown(core);
> +		pm_runtime_set_suspended(dev);
> +		pm_runtime_disable(dev);
> +		hfi_destroy(core);
> +		return ret;

Could you just reorder error labels below instead of releasing
everything here?

> +	}
>  
>  	return 0;
>  
> -err_dev_unregister:
> -	v4l2_device_unregister(&core->v4l2_dev);
>  err_core_deinit:
>  	hfi_core_deinit(core, false);
>  err_venus_shutdown:
>  	venus_shutdown(core);
>  err_runtime_disable:
> +	pm_runtime_put_noidle(dev);
>  	pm_runtime_set_suspended(dev);
>  	pm_runtime_disable(dev);
>  	hfi_destroy(core);
> 

-- 
regards,
Stan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: [PATCH] media: venus: core: Fix runtime PM imbalance in venus_probe
  2020-06-23  9:48 ` Stanimir Varbanov
@ 2020-06-24  6:18   ` dinghao.liu
  0 siblings, 0 replies; 3+ messages in thread
From: dinghao.liu @ 2020-06-24  6:18 UTC (permalink / raw)
  To: Stanimir Varbanov
  Cc: kjlu, Andy Gross, Bjorn Andersson, Mauro Carvalho Chehab,
	linux-media, linux-arm-msm, linux-kernel

> 
> Could you just reorder error labels below instead of releasing
> everything here?

Thank you for your advice! I'll fix this in the next version of patch.

Regards,
Dinghao


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-24  6:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-24  5:29 [PATCH] media: venus: core: Fix runtime PM imbalance in venus_probe Dinghao Liu
2020-06-23  9:48 ` Stanimir Varbanov
2020-06-24  6:18   ` dinghao.liu

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).