* [PATCH v5 01/25] staging: media: imx7-mipi-csis: use pm_runtime_resume_and_get()
2021-05-06 15:25 [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 02/25] staging: media: atomisp: " Mauro Carvalho Chehab
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Fabio Estevam,
Greg Kroah-Hartman, Mauro Carvalho Chehab, NXP Linux Team,
Pengutronix Kernel Team, Philipp Zabel, Rui Miguel Silva,
Sascha Hauer, Shawn Guo, Steve Longerbeam, linux-arm-kernel,
linux-kernel, linux-media, linux-staging
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.
Use the new API, in order to cleanup the error check logic.
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/media/imx/imx7-mipi-csis.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index 025fdc488bd6..1dc680d94a46 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -695,11 +695,10 @@ static int mipi_csis_s_stream(struct v4l2_subdev *mipi_sd, int enable)
mipi_csis_clear_counters(state);
- ret = pm_runtime_get_sync(&state->pdev->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(&state->pdev->dev);
+ ret = pm_runtime_resume_and_get(&state->pdev->dev);
+ if (ret < 0)
return ret;
- }
+
ret = v4l2_subdev_call(state->src_sd, core, s_power, 1);
if (ret < 0 && ret != -ENOIOCTLCMD)
goto done;
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 02/25] staging: media: atomisp: use pm_runtime_resume_and_get()
2021-05-06 15:25 [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 01/25] staging: media: imx7-mipi-csis: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 03/25] staging: media: ipu3: " Mauro Carvalho Chehab
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Mauro Carvalho Chehab, Sakari Ailus,
linux-kernel, linux-media, linux-staging
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.
Use the new API, in order to cleanup the error check logic.
Besides that, the de-init order in case of css error was wrong.
This change should also fix that.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/media/atomisp/pci/atomisp_fops.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_fops.c b/drivers/staging/media/atomisp/pci/atomisp_fops.c
index f1e6b2597853..26d05474a035 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_fops.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_fops.c
@@ -837,7 +837,7 @@ static int atomisp_open(struct file *file)
}
/* runtime power management, turn on ISP */
- ret = pm_runtime_get_sync(vdev->v4l2_dev->dev);
+ ret = pm_runtime_resume_and_get(vdev->v4l2_dev->dev);
if (ret < 0) {
dev_err(isp->dev, "Failed to power on device\n");
goto error;
@@ -881,9 +881,9 @@ static int atomisp_open(struct file *file)
css_error:
atomisp_css_uninit(isp);
-error:
- hmm_pool_unregister(HMM_POOL_TYPE_DYNAMIC);
pm_runtime_put(vdev->v4l2_dev->dev);
+error:
+ hmm_pool_unregister(HMM_POOL_TYPE_DYNAMIC);
rt_mutex_unlock(&isp->mutex);
return ret;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 03/25] staging: media: ipu3: use pm_runtime_resume_and_get()
2021-05-06 15:25 [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 01/25] staging: media: imx7-mipi-csis: use pm_runtime_resume_and_get() Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 02/25] staging: media: atomisp: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 04/25] staging: media: cedrus_video: " Mauro Carvalho Chehab
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bingbu Cao,
Greg Kroah-Hartman, Mauro Carvalho Chehab, Sakari Ailus,
Tianshu Qiu, linux-kernel, linux-media, linux-staging,
Jonathan Cameron
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.
Use the new API, in order to cleanup the error check logic.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/media/ipu3/ipu3.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c
index ee1bba6bdcac..8e1e9e46e604 100644
--- a/drivers/staging/media/ipu3/ipu3.c
+++ b/drivers/staging/media/ipu3/ipu3.c
@@ -392,10 +392,9 @@ int imgu_s_stream(struct imgu_device *imgu, int enable)
}
/* Set Power */
- r = pm_runtime_get_sync(dev);
+ r = pm_runtime_resume_and_get(dev);
if (r < 0) {
dev_err(dev, "failed to set imgu power\n");
- pm_runtime_put(dev);
return r;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 04/25] staging: media: cedrus_video: use pm_runtime_resume_and_get()
2021-05-06 15:25 [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers Mauro Carvalho Chehab
` (2 preceding siblings ...)
2021-05-06 15:25 ` [PATCH v5 03/25] staging: media: ipu3: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 05/25] staging: media: tegra-vde: " Mauro Carvalho Chehab
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Chen-Yu Tsai,
Greg Kroah-Hartman, Jernej Skrabec, Mauro Carvalho Chehab,
Maxime Ripard, Paul Kocialkowski, linux-arm-kernel, linux-kernel,
linux-media, linux-staging, linux-sunxi, Jonathan Cameron
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.
Use the new API, in order to cleanup the error check logic.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
index b62eb8e84057..9ddd789d0b1f 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
@@ -490,11 +490,9 @@ static int cedrus_start_streaming(struct vb2_queue *vq, unsigned int count)
}
if (V4L2_TYPE_IS_OUTPUT(vq->type)) {
- ret = pm_runtime_get_sync(dev->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(dev->dev);
+ ret = pm_runtime_resume_and_get(dev->dev);
+ if (ret < 0)
goto err_cleanup;
- }
if (dev->dec_ops[ctx->current_codec]->start) {
ret = dev->dec_ops[ctx->current_codec]->start(ctx);
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 05/25] staging: media: tegra-vde: use pm_runtime_resume_and_get()
2021-05-06 15:25 [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers Mauro Carvalho Chehab
` (3 preceding siblings ...)
2021-05-06 15:25 ` [PATCH v5 04/25] staging: media: cedrus_video: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
2021-05-07 5:13 ` Dan Carpenter
2021-05-06 15:25 ` [PATCH v5 06/25] staging: media: tegra-video: " Mauro Carvalho Chehab
2021-05-06 15:26 ` [PATCH v5 25/25] media: hantro: " Mauro Carvalho Chehab
6 siblings, 1 reply; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dmitry Osipenko,
Greg Kroah-Hartman, Jonathan Hunter, Mauro Carvalho Chehab,
Thierry Reding, linux-kernel, linux-media, linux-staging,
linux-tegra
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.
Use the new API, in order to cleanup the error check logic.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/media/tegra-vde/vde.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c
index 28845b5bafaf..e025b69776f2 100644
--- a/drivers/staging/media/tegra-vde/vde.c
+++ b/drivers/staging/media/tegra-vde/vde.c
@@ -775,9 +775,9 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
if (ret)
goto release_dpb_frames;
- ret = pm_runtime_get_sync(dev);
+ ret = pm_runtime_resume_and_get(dev);
if (ret < 0)
- goto put_runtime_pm;
+ goto unlock;
/*
* We rely on the VDE registers reset value, otherwise VDE
@@ -843,6 +843,8 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
put_runtime_pm:
pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
+
+unlock:
mutex_unlock(&vde->lock);
release_dpb_frames:
@@ -1069,11 +1071,19 @@ static int tegra_vde_probe(struct platform_device *pdev)
* power-cycle it in order to put hardware into a predictable lower
* power state.
*/
- pm_runtime_get_sync(dev);
+ if (pm_runtime_resume_and_get(dev) < 0)
+ goto err_pm_runtime;
+
pm_runtime_put(dev);
return 0;
+err_pm_runtime:
+ misc_deregister(&vde->miscdev);
+
+ pm_runtime_dont_use_autosuspend(dev);
+ pm_runtime_disable(dev);
+
err_deinit_iommu:
tegra_vde_iommu_deinit(vde);
@@ -1089,7 +1099,12 @@ static int tegra_vde_remove(struct platform_device *pdev)
struct tegra_vde *vde = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
+ /*
+ * As it increments RPM usage_count even on errors, we don't need to
+ * check the returned code here.
+ */
pm_runtime_get_sync(dev);
+
pm_runtime_dont_use_autosuspend(dev);
pm_runtime_disable(dev);
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v5 05/25] staging: media: tegra-vde: use pm_runtime_resume_and_get()
2021-05-06 15:25 ` [PATCH v5 05/25] staging: media: tegra-vde: " Mauro Carvalho Chehab
@ 2021-05-07 5:13 ` Dan Carpenter
2021-05-10 12:26 ` Dmitry Osipenko
0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2021-05-07 5:13 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: linuxarm, mauro.chehab, Dmitry Osipenko, Greg Kroah-Hartman,
Jonathan Hunter, Mauro Carvalho Chehab, Thierry Reding,
linux-kernel, linux-media, linux-staging, linux-tegra
On Thu, May 06, 2021 at 05:25:43PM +0200, Mauro Carvalho Chehab wrote:
> @@ -1069,11 +1071,19 @@ static int tegra_vde_probe(struct platform_device *pdev)
> * power-cycle it in order to put hardware into a predictable lower
> * power state.
> */
> - pm_runtime_get_sync(dev);
> + if (pm_runtime_resume_and_get(dev) < 0)
> + goto err_pm_runtime;
Needs an error code on this path. These days the kbuild bot will send
a warning for this eventually.
> +
> pm_runtime_put(dev);
>
> return 0;
>
> +err_pm_runtime:
> + misc_deregister(&vde->miscdev);
> +
> + pm_runtime_dont_use_autosuspend(dev);
> + pm_runtime_disable(dev);
> +
> err_deinit_iommu:
> tegra_vde_iommu_deinit(vde);
>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 05/25] staging: media: tegra-vde: use pm_runtime_resume_and_get()
2021-05-07 5:13 ` Dan Carpenter
@ 2021-05-10 12:26 ` Dmitry Osipenko
0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Osipenko @ 2021-05-10 12:26 UTC (permalink / raw)
To: Dan Carpenter, Mauro Carvalho Chehab
Cc: linuxarm, mauro.chehab, Greg Kroah-Hartman, Jonathan Hunter,
Mauro Carvalho Chehab, Thierry Reding, linux-kernel, linux-media,
linux-staging, linux-tegra
07.05.2021 08:13, Dan Carpenter пишет:
> On Thu, May 06, 2021 at 05:25:43PM +0200, Mauro Carvalho Chehab wrote:
>> @@ -1069,11 +1071,19 @@ static int tegra_vde_probe(struct platform_device *pdev)
>> * power-cycle it in order to put hardware into a predictable lower
>> * power state.
>> */
>> - pm_runtime_get_sync(dev);
>> + if (pm_runtime_resume_and_get(dev) < 0)
>> + goto err_pm_runtime;
>
> Needs an error code on this path. These days the kbuild bot will send
> a warning for this eventually.
Good catch, thank you.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 06/25] staging: media: tegra-video: use pm_runtime_resume_and_get()
2021-05-06 15:25 [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers Mauro Carvalho Chehab
` (4 preceding siblings ...)
2021-05-06 15:25 ` [PATCH v5 05/25] staging: media: tegra-vde: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
2021-05-06 15:26 ` [PATCH v5 25/25] media: hantro: " Mauro Carvalho Chehab
6 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Jonathan Hunter, Mauro Carvalho Chehab,
Sowjanya Komatineni, Thierry Reding, linux-kernel, linux-media,
linux-staging, linux-tegra, Jonathan Cameron
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.
Use the new API, in order to cleanup the error check logic.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/media/tegra-video/csi.c | 3 +--
drivers/staging/media/tegra-video/vi.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/tegra-video/csi.c b/drivers/staging/media/tegra-video/csi.c
index 033a6935c26d..e938bf4c48b6 100644
--- a/drivers/staging/media/tegra-video/csi.c
+++ b/drivers/staging/media/tegra-video/csi.c
@@ -298,10 +298,9 @@ static int tegra_csi_enable_stream(struct v4l2_subdev *subdev)
struct tegra_csi *csi = csi_chan->csi;
int ret, err;
- ret = pm_runtime_get_sync(csi->dev);
+ ret = pm_runtime_resume_and_get(csi->dev);
if (ret < 0) {
dev_err(csi->dev, "failed to get runtime PM: %d\n", ret);
- pm_runtime_put_noidle(csi->dev);
return ret;
}
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index 7a09061cda57..1298740a9c6c 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -297,10 +297,9 @@ static int tegra_channel_start_streaming(struct vb2_queue *vq, u32 count)
struct tegra_vi_channel *chan = vb2_get_drv_priv(vq);
int ret;
- ret = pm_runtime_get_sync(chan->vi->dev);
+ ret = pm_runtime_resume_and_get(chan->vi->dev);
if (ret < 0) {
dev_err(chan->vi->dev, "failed to get runtime PM: %d\n", ret);
- pm_runtime_put_noidle(chan->vi->dev);
return ret;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 25/25] media: hantro: use pm_runtime_resume_and_get()
2021-05-06 15:25 [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers Mauro Carvalho Chehab
` (5 preceding siblings ...)
2021-05-06 15:25 ` [PATCH v5 06/25] staging: media: tegra-video: " Mauro Carvalho Chehab
@ 2021-05-06 15:26 ` Mauro Carvalho Chehab
6 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:26 UTC (permalink / raw)
Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Ezequiel Garcia,
Greg Kroah-Hartman, Mauro Carvalho Chehab, Philipp Zabel,
linux-kernel, linux-media, linux-rockchip, linux-staging
Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter")
added pm_runtime_resume_and_get() in order to automatically handle
dev->power.usage_count decrement on errors.
While there's nothing wrong with the current usage on this driver,
as we're getting rid of the pm_runtime_get_sync() call all over
the media subsystem, let's remove the last occurrence on this
driver.
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/staging/media/hantro/hantro_drv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c
index eea2009fa17b..74d6545395f9 100644
--- a/drivers/staging/media/hantro/hantro_drv.c
+++ b/drivers/staging/media/hantro/hantro_drv.c
@@ -160,9 +160,8 @@ static void device_run(void *priv)
src = hantro_get_src_buf(ctx);
dst = hantro_get_dst_buf(ctx);
- ret = pm_runtime_get_sync(ctx->dev->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(ctx->dev->dev);
+ ret = pm_runtime_resume_and_get(ctx->dev->dev);
+ if (ret < 0)
goto err_cancel_job;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread