2022-01-05 11:55:22

by Miaoqian Lin

[permalink] [raw]
Subject: [PATCH] media: st-delta: Fix PM disable depth imbalance in delta_probe

The pm_runtime_enable will increase power disable depth.
If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable().

Fixes: f386509 ("[media] st-delta: STiH4xx multi-format video decoder v4l2 driver")
Signed-off-by: Miaoqian Lin <[email protected]>
---
drivers/media/platform/sti/delta/delta-v4l2.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
index c887a31ebb54..dbcfd0484da4 100644
--- a/drivers/media/platform/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/sti/delta/delta-v4l2.c
@@ -1898,6 +1898,8 @@ static int delta_probe(struct platform_device *pdev)
destroy_workqueue(delta->work_queue);
err_v4l2:
v4l2_device_unregister(&delta->v4l2_dev);
+disable_pm_runtime:
+ pm_runtime_disable(dev);
err:
return ret;
}
--
2.17.1



2022-03-01 05:31:22

by Miaoqian Lin

[permalink] [raw]
Subject: [PATCH v2] media: st-delta: Fix PM disable depth imbalance in delta_probe

The pm_runtime_enable will increase power disable depth.
If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable().

Fixes: f386509 ("[media] st-delta: STiH4xx multi-format video decoder v4l2 driver")
Signed-off-by: Miaoqian Lin <[email protected]>
---
changes in v2:
- remove unused label.
---
drivers/media/platform/sti/delta/delta-v4l2.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
index c887a31ebb54..36ce0775f3f9 100644
--- a/drivers/media/platform/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/sti/delta/delta-v4l2.c
@@ -1899,6 +1899,7 @@ static int delta_probe(struct platform_device *pdev)
err_v4l2:
v4l2_device_unregister(&delta->v4l2_dev);
err:
+ pm_runtime_disable(dev);
return ret;
}

--
2.17.1

2022-03-07 08:04:49

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2] media: st-delta: Fix PM disable depth imbalance in delta_probe

Hi Miaoqian Lin,

On 3/1/22 04:12, Miaoqian Lin wrote:
> The pm_runtime_enable will increase power disable depth.
> If the probe fails, we should use pm_runtime_disable() to balance
> pm_runtime_enable().
>
> Fixes: f386509 ("[media] st-delta: STiH4xx multi-format video decoder v4l2 driver")
> Signed-off-by: Miaoqian Lin <[email protected]>
> ---
> changes in v2:
> - remove unused label.
> ---
> drivers/media/platform/sti/delta/delta-v4l2.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
> index c887a31ebb54..36ce0775f3f9 100644
> --- a/drivers/media/platform/sti/delta/delta-v4l2.c
> +++ b/drivers/media/platform/sti/delta/delta-v4l2.c
> @@ -1899,6 +1899,7 @@ static int delta_probe(struct platform_device *pdev)
> err_v4l2:
> v4l2_device_unregister(&delta->v4l2_dev);
> err:
> + pm_runtime_disable(dev);

This isn't right. If the devm_kzalloc at the beginning fails, then it also jump
to this label, but at that time no pm_runtime_enable() has been called yet,
so this patch will just introduce another imbalance.

You *do* need a new label here (like you did in v1 of this patch), and update
the 'goto err;' instances after the call to pm_runtime_enable() to go to that
new label.

Regards,

Hans

> return ret;
> }
>

2022-03-07 09:46:31

by Miaoqian Lin

[permalink] [raw]
Subject: [PATCH v3] media: st-delta: Fix PM disable depth imbalance in delta_probe

The pm_runtime_enable will decrease power disable depth.
If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable().

Fixes: f386509 ("[media] st-delta: STiH4xx multi-format video decoder v4l2 driver")
Signed-off-by: Miaoqian Lin <[email protected]>
---
changes in v2:
- remove unused label.
changes in v3:
- add err_pm_disable label and update related 'goto err'.
- update commit message
---
drivers/media/platform/sti/delta/delta-v4l2.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
index c887a31ebb54..420ad4d8df5d 100644
--- a/drivers/media/platform/sti/delta/delta-v4l2.c
+++ b/drivers/media/platform/sti/delta/delta-v4l2.c
@@ -1859,7 +1859,7 @@ static int delta_probe(struct platform_device *pdev)
if (ret) {
dev_err(delta->dev, "%s failed to initialize firmware ipc channel\n",
DELTA_PREFIX);
- goto err;
+ goto err_pm_disable;
}

/* register all available decoders */
@@ -1873,7 +1873,7 @@ static int delta_probe(struct platform_device *pdev)
if (ret) {
dev_err(delta->dev, "%s failed to register V4L2 device\n",
DELTA_PREFIX);
- goto err;
+ goto err_pm_disable;
}

delta->work_queue = create_workqueue(DELTA_NAME);
@@ -1898,6 +1898,8 @@ static int delta_probe(struct platform_device *pdev)
destroy_workqueue(delta->work_queue);
err_v4l2:
v4l2_device_unregister(&delta->v4l2_dev);
+err_pm_disable:
+ pm_runtime_disable(dev);
err:
return ret;
}
--
2.17.1

2022-03-10 18:35:00

by Hugues Fruchet

[permalink] [raw]
Subject: Re: [PATCH v3] media: st-delta: Fix PM disable depth imbalance in delta_probe

Hi Miaoqian Lin,

Thanks for the patch !

Acked-by: Hugues Fruchet <[email protected]>

BR,
Hugues.

On 3/7/22 9:08 AM, Miaoqian Lin wrote:
> The pm_runtime_enable will decrease power disable depth.
> If the probe fails, we should use pm_runtime_disable() to balance
> pm_runtime_enable().
>
> Fixes: f386509 ("[media] st-delta: STiH4xx multi-format video decoder v4l2 driver")
> Signed-off-by: Miaoqian Lin <[email protected]>
> ---
> changes in v2:
> - remove unused label.
> changes in v3:
> - add err_pm_disable label and update related 'goto err'.
> - update commit message
> ---
> drivers/media/platform/sti/delta/delta-v4l2.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c
> index c887a31ebb54..420ad4d8df5d 100644
> --- a/drivers/media/platform/sti/delta/delta-v4l2.c
> +++ b/drivers/media/platform/sti/delta/delta-v4l2.c
> @@ -1859,7 +1859,7 @@ static int delta_probe(struct platform_device *pdev)
> if (ret) {
> dev_err(delta->dev, "%s failed to initialize firmware ipc channel\n",
> DELTA_PREFIX);
> - goto err;
> + goto err_pm_disable;
> }
>
> /* register all available decoders */
> @@ -1873,7 +1873,7 @@ static int delta_probe(struct platform_device *pdev)
> if (ret) {
> dev_err(delta->dev, "%s failed to register V4L2 device\n",
> DELTA_PREFIX);
> - goto err;
> + goto err_pm_disable;
> }
>
> delta->work_queue = create_workqueue(DELTA_NAME);
> @@ -1898,6 +1898,8 @@ static int delta_probe(struct platform_device *pdev)
> destroy_workqueue(delta->work_queue);
> err_v4l2:
> v4l2_device_unregister(&delta->v4l2_dev);
> +err_pm_disable:
> + pm_runtime_disable(dev);
> err:
> return ret;
> }
>