linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/25] media: use pm_runtime_resume_and_get() on non-i2c drivers
@ 2021-05-06 15:25 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
                   ` (24 more replies)
  0 siblings, 25 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Alexandre Torgue,
	Andrzej Hajda, Andy Gross, Benoit Parrot, Bingbu Cao,
	Bjorn Andersson, Chen-Yu Tsai, Dafna Hirschfeld, Dan Scally,
	Dmitry Osipenko, Ezequiel Garcia, Fabio Estevam, Heiko Stuebner,
	Helen Koike, Jacob Chen, Jernej Skrabec, Jonathan Hunter,
	Matthias Brugger, Mauro Carvalho Chehab, Maxime Coquelin,
	Maxime Ripard, NXP Linux Team, Paul Kocialkowski,
	Pengutronix Kernel Team, Philipp Zabel, Robert Foss,
	Rui Miguel Silva, Sakari Ailus, Sascha Hauer, Shawn Guo,
	Sowjanya Komatineni, Stanimir Varbanov, Steve Longerbeam,
	Sylwester Nawrocki, Thierry Reding, Tianshu Qiu, Todor Tomov,
	Yong Zhi, linux-arm-kernel, linux-arm-msm, linux-kernel,
	linux-media, linux-mediatek, linux-renesas-soc, linux-rockchip,
	linux-samsung-soc, linux-staging, linux-stm32, linux-sunxi,
	linux-tegra

Dealing with PM runtime (RPM) is different than dealing with other kAPIs used
on media, as most pm_runtime_get_*() functions won't return to the the state
before the call if an error rises. They, instead, increment an usage_count.

Due to that, there were several bugs on media. Just on this review, we found
24 such errors.

So, let's use pm_runtime_resume_and_get() whenever possible, as it
has two advantages over :

1. On errors, it decrements the usage count;
2. It always return zero on success or an error code. This prevents a
   common error pattern of checking if ret is not zero to identify
   for errors.

There are however a few places where calls to pm_runtime_get_sync()
are kept. On several of those, a comment was added, in order to
help preventing trivial patches that could try to change them.

PS.: This series was submitted already together with the fix patches
at:

   	https://lore.kernel.org/linux-media/cover.1619621413.git.mchehab+huawei@kernel.org/

I opted to break it on 3 parts, in order to make easier to review.

This is the third (and final) part.

Mauro Carvalho Chehab (25):
  staging: media: imx7-mipi-csis: use pm_runtime_resume_and_get()
  staging: media: atomisp: use pm_runtime_resume_and_get()
  staging: media: ipu3: use pm_runtime_resume_and_get()
  staging: media: cedrus_video: use pm_runtime_resume_and_get()
  staging: media: tegra-vde: use pm_runtime_resume_and_get()
  staging: media: tegra-video: use pm_runtime_resume_and_get()
  media: rockchip/rga: use pm_runtime_resume_and_get()
  media: sti/hva: use pm_runtime_resume_and_get()
  media: ipu3: use pm_runtime_resume_and_get()
  media: coda: use pm_runtime_resume_and_get()
  media: mtk-jpeg: use pm_runtime_resume_and_get()
  media: camss: use pm_runtime_resume_and_get()
  media: venus: core: use pm_runtime_resume_and_get()
  media: venus: vdec: use pm_runtime_resume_and_get()
  media: venus: venc: use pm_runtime_resume_and_get()
  media: rcar-fcp: use pm_runtime_resume_and_get()
  media: rkisp1: use pm_runtime_resume_and_get()
  media: s3c-camif: use pm_runtime_resume_and_get()
  media: s5p-mfc: use pm_runtime_resume_and_get()
  media: stm32: use pm_runtime_resume_and_get()
  media: sunxi: use pm_runtime_resume_and_get()
  media: ti-vpe: use pm_runtime_resume_and_get()
  media: vsp1: use pm_runtime_resume_and_get()
  media: rcar-vin: use pm_runtime_resume_and_get()
  media: hantro: use pm_runtime_resume_and_get()

 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c |  3 +--
 drivers/media/platform/coda/coda-common.c     |  7 ++++---
 .../media/platform/mtk-jpeg/mtk_jpeg_core.c   |  4 ++--
 .../media/platform/qcom/camss/camss-csid.c    |  6 ++----
 .../media/platform/qcom/camss/camss-csiphy.c  |  6 ++----
 .../media/platform/qcom/camss/camss-ispif.c   |  6 ++----
 drivers/media/platform/qcom/camss/camss-vfe.c |  5 +++--
 .../media/platform/qcom/venus/pm_helpers.c    |  3 +--
 drivers/media/platform/qcom/venus/vdec.c      |  6 +++---
 drivers/media/platform/qcom/venus/venc.c      |  5 +++--
 drivers/media/platform/rcar-fcp.c             |  8 +------
 drivers/media/platform/rcar-vin/rcar-csi2.c   | 15 ++++++++++---
 drivers/media/platform/rcar-vin/rcar-dma.c    |  6 ++----
 drivers/media/platform/rcar-vin/rcar-v4l2.c   |  6 ++----
 drivers/media/platform/rockchip/rga/rga-buf.c |  3 +--
 drivers/media/platform/rockchip/rga/rga.c     |  4 +++-
 .../platform/rockchip/rkisp1/rkisp1-capture.c |  3 +--
 .../media/platform/s3c-camif/camif-capture.c  |  2 +-
 drivers/media/platform/s3c-camif/camif-core.c |  5 +++--
 drivers/media/platform/s5p-mfc/s5p_mfc_pm.c   |  6 ++----
 drivers/media/platform/sti/hva/hva-hw.c       | 17 ++++++++-------
 drivers/media/platform/stm32/stm32-dcmi.c     |  5 +++--
 .../platform/sunxi/sun4i-csi/sun4i_v4l2.c     |  6 ++++--
 drivers/media/platform/ti-vpe/cal-video.c     |  4 +++-
 drivers/media/platform/ti-vpe/cal.c           |  8 ++++---
 drivers/media/platform/ti-vpe/vpe.c           |  8 +++----
 drivers/media/platform/vsp1/vsp1_drv.c        | 10 +--------
 .../staging/media/atomisp/pci/atomisp_fops.c  |  6 +++---
 drivers/staging/media/hantro/hantro_drv.c     |  5 ++---
 drivers/staging/media/imx/imx7-mipi-csis.c    |  7 +++----
 drivers/staging/media/ipu3/ipu3.c             |  3 +--
 .../staging/media/sunxi/cedrus/cedrus_video.c |  6 ++----
 drivers/staging/media/tegra-vde/vde.c         | 21 ++++++++++++++++---
 drivers/staging/media/tegra-video/csi.c       |  3 +--
 drivers/staging/media/tegra-video/vi.c        |  3 +--
 35 files changed, 110 insertions(+), 111 deletions(-)

-- 
2.30.2



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

* [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
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 38+ 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] 38+ 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
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 38+ 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] 38+ 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
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 38+ 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] 38+ 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
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 38+ 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] 38+ 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
                   ` (19 subsequent siblings)
  24 siblings, 1 reply; 38+ 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] 38+ 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:25 ` [PATCH v5 07/25] media: rockchip/rga: " Mauro Carvalho Chehab
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 38+ 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] 38+ messages in thread

* [PATCH v5 07/25] media: rockchip/rga: 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:25 ` Mauro Carvalho Chehab
  2021-05-13 22:38   ` Heiko Stuebner
  2021-05-06 15:25 ` [PATCH v5 08/25] media: sti/hva: " Mauro Carvalho Chehab
                   ` (17 subsequent siblings)
  24 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Ezequiel Garcia,
	Heiko Stuebner, Jacob Chen, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-kernel, linux-media, linux-rockchip

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: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/rockchip/rga/rga-buf.c | 3 +--
 drivers/media/platform/rockchip/rga/rga.c     | 4 +++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c
index bf9a75b75083..81508ed5abf3 100644
--- a/drivers/media/platform/rockchip/rga/rga-buf.c
+++ b/drivers/media/platform/rockchip/rga/rga-buf.c
@@ -79,9 +79,8 @@ static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count)
 	struct rockchip_rga *rga = ctx->rga;
 	int ret;
 
-	ret = pm_runtime_get_sync(rga->dev);
+	ret = pm_runtime_resume_and_get(rga->dev);
 	if (ret < 0) {
-		pm_runtime_put_noidle(rga->dev);
 		rga_buf_return_buffers(q, VB2_BUF_STATE_QUEUED);
 		return ret;
 	}
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index 9d122429706e..bf3fd71ec3af 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -866,7 +866,9 @@ static int rga_probe(struct platform_device *pdev)
 		goto unreg_video_dev;
 	}
 
-	pm_runtime_get_sync(rga->dev);
+	ret = pm_runtime_resume_and_get(rga->dev);
+	if (ret < 0)
+		goto unreg_video_dev;
 
 	rga->version.major = (rga_read(rga, RGA_VERSION_INFO) >> 24) & 0xFF;
 	rga->version.minor = (rga_read(rga, RGA_VERSION_INFO) >> 20) & 0x0F;
-- 
2.30.2


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

* [PATCH v5 08/25] media: sti/hva: 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
                   ` (6 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 07/25] media: rockchip/rga: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 09/25] media: ipu3: " Mauro Carvalho Chehab
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Jean-Christophe Trotin, Mauro Carvalho Chehab, linux-kernel,
	linux-media, 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.

While the hva driver does it right, there are lots of errors
on other drivers due to its misusage. So, let's change
this driver to also use pm_runtime_resume_and_get(), as we're
doing similar changes all over the media subsystem.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/sti/hva/hva-hw.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c
index f59811e27f51..77b8bfa5e0c5 100644
--- a/drivers/media/platform/sti/hva/hva-hw.c
+++ b/drivers/media/platform/sti/hva/hva-hw.c
@@ -270,9 +270,8 @@ static unsigned long int hva_hw_get_ip_version(struct hva_dev *hva)
 	struct device *dev = hva_to_dev(hva);
 	unsigned long int version;
 
-	if (pm_runtime_get_sync(dev) < 0) {
+	if (pm_runtime_resume_and_get(dev) < 0) {
 		dev_err(dev, "%s     failed to get pm_runtime\n", HVA_PREFIX);
-		pm_runtime_put_noidle(dev);
 		mutex_unlock(&hva->protect_mutex);
 		return -EFAULT;
 	}
@@ -386,10 +385,10 @@ int hva_hw_probe(struct platform_device *pdev, struct hva_dev *hva)
 	pm_runtime_set_suspended(dev);
 	pm_runtime_enable(dev);
 
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0) {
 		dev_err(dev, "%s     failed to set PM\n", HVA_PREFIX);
-		goto err_pm;
+		goto err_clk;
 	}
 
 	/* check IP hardware version */
@@ -462,6 +461,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
 	u8 client_id = ctx->id;
 	int ret;
 	u32 reg = 0;
+	bool got_pm = false;
 
 	mutex_lock(&hva->protect_mutex);
 
@@ -469,12 +469,13 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
 	enable_irq(hva->irq_its);
 	enable_irq(hva->irq_err);
 
-	if (pm_runtime_get_sync(dev) < 0) {
+	if (pm_runtime_resume_and_get(dev) < 0) {
 		dev_err(dev, "%s     failed to get pm_runtime\n", ctx->name);
 		ctx->sys_errors++;
 		ret = -EFAULT;
 		goto out;
 	}
+	got_pm = true;
 
 	reg = readl_relaxed(hva->regs + HVA_HIF_REG_CLK_GATING);
 	switch (cmd) {
@@ -537,7 +538,8 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd,
 		dev_dbg(dev, "%s     unknown command 0x%x\n", ctx->name, cmd);
 	}
 
-	pm_runtime_put_autosuspend(dev);
+	if (got_pm)
+		pm_runtime_put_autosuspend(dev);
 	mutex_unlock(&hva->protect_mutex);
 
 	return ret;
@@ -553,9 +555,8 @@ void hva_hw_dump_regs(struct hva_dev *hva, struct seq_file *s)
 
 	mutex_lock(&hva->protect_mutex);
 
-	if (pm_runtime_get_sync(dev) < 0) {
+	if (pm_runtime_resume_and_get(dev) < 0) {
 		seq_puts(s, "Cannot wake up IP\n");
-		pm_runtime_put_noidle(dev);
 		mutex_unlock(&hva->protect_mutex);
 		return;
 	}
-- 
2.30.2


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

* [PATCH v5 09/25] 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
                   ` (7 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 08/25] media: sti/hva: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 10/25] media: coda: " Mauro Carvalho Chehab
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bingbu Cao,
	Dan Scally, Mauro Carvalho Chehab, Sakari Ailus, Tianshu Qiu,
	Yong Zhi, linux-kernel, linux-media

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/media/pci/intel/ipu3/ipu3-cio2-main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index fecef85bd62e..ca8040d1a725 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -975,10 +975,9 @@ static int cio2_vb2_start_streaming(struct vb2_queue *vq, unsigned int count)
 	cio2->cur_queue = q;
 	atomic_set(&q->frame_sequence, 0);
 
-	r = pm_runtime_get_sync(&cio2->pci_dev->dev);
+	r = pm_runtime_resume_and_get(&cio2->pci_dev->dev);
 	if (r < 0) {
 		dev_info(&cio2->pci_dev->dev, "failed to set power %d\n", r);
-		pm_runtime_put_noidle(&cio2->pci_dev->dev);
 		return r;
 	}
 
-- 
2.30.2


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

* [PATCH v5 10/25] media: coda: 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
                   ` (8 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 09/25] media: ipu3: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 11/25] media: mtk-jpeg: " Mauro Carvalho Chehab
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Philipp Zabel, linux-kernel, linux-media

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.

While here, as noted by Phillip, the labels at the coda_open()
function are currently named after what operation failed,
instead of what they do in response. So, change the name of
the error label that it is called when clk_enable fails,
in order to be consistent.

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/coda/coda-common.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index bd666c858fa1..2017de85713e 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -2660,7 +2660,7 @@ static int coda_open(struct file *file)
 	ctx->use_vdoa = false;
 
 	/* Power up and upload firmware if necessary */
-	ret = pm_runtime_get_sync(dev->dev);
+	ret = pm_runtime_resume_and_get(dev->dev);
 	if (ret < 0) {
 		v4l2_err(&dev->v4l2_dev, "failed to power up: %d\n", ret);
 		goto err_pm_get;
@@ -2668,7 +2668,7 @@ static int coda_open(struct file *file)
 
 	ret = clk_prepare_enable(dev->clk_per);
 	if (ret)
-		goto err_pm_get;
+		goto err_clk_enable;
 
 	ret = clk_prepare_enable(dev->clk_ahb);
 	if (ret)
@@ -2707,8 +2707,9 @@ static int coda_open(struct file *file)
 	clk_disable_unprepare(dev->clk_ahb);
 err_clk_ahb:
 	clk_disable_unprepare(dev->clk_per);
+err_clk_enable:
+	pm_runtime_put_sync(dev->dev);
 err_pm_get:
-	pm_runtime_put_sync(dev->dev);
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
 err_coda_name_init:
-- 
2.30.2


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

* [PATCH v5 11/25] media: mtk-jpeg: 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
                   ` (9 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 10/25] media: coda: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 12/25] media: camss: " Mauro Carvalho Chehab
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Bin Liu,
	Matthias Brugger, Mauro Carvalho Chehab, Rick Chang,
	linux-arm-kernel, linux-kernel, linux-media, linux-mediatek

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/media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
index 88a23bce569d..a89c7b206eef 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
@@ -920,7 +920,7 @@ static void mtk_jpeg_enc_device_run(void *priv)
 	src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx);
 	dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx);
 
-	ret = pm_runtime_get_sync(jpeg->dev);
+	ret = pm_runtime_resume_and_get(jpeg->dev);
 	if (ret < 0)
 		goto enc_end;
 
@@ -973,7 +973,7 @@ static void mtk_jpeg_dec_device_run(void *priv)
 		return;
 	}
 
-	ret = pm_runtime_get_sync(jpeg->dev);
+	ret = pm_runtime_resume_and_get(jpeg->dev);
 	if (ret < 0)
 		goto dec_end;
 
-- 
2.30.2


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

* [PATCH v5 12/25] media: camss: 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
                   ` (10 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 11/25] media: mtk-jpeg: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 13/25] media: venus: core: " Mauro Carvalho Chehab
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andy Gross,
	Bjorn Andersson, Mauro Carvalho Chehab, Robert Foss, Todor Tomov,
	linux-arm-msm, linux-kernel, linux-media

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: Robert Foss <robert.foss@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/qcom/camss/camss-csid.c   | 6 ++----
 drivers/media/platform/qcom/camss/camss-csiphy.c | 6 ++----
 drivers/media/platform/qcom/camss/camss-ispif.c  | 6 ++----
 drivers/media/platform/qcom/camss/camss-vfe.c    | 5 +++--
 4 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index cc11fbfdae13..d2a7f2a64f26 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -156,11 +156,9 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)
 	int ret;
 
 	if (on) {
-		ret = pm_runtime_get_sync(dev);
-		if (ret < 0) {
-			pm_runtime_put_sync(dev);
+		ret = pm_runtime_resume_and_get(dev);
+		if (ret < 0)
 			return ret;
-		}
 
 		ret = regulator_enable(csid->vdda);
 		if (ret < 0) {
diff --git a/drivers/media/platform/qcom/camss/camss-csiphy.c b/drivers/media/platform/qcom/camss/camss-csiphy.c
index b3c3bf19e522..8e18b8e668cf 100644
--- a/drivers/media/platform/qcom/camss/camss-csiphy.c
+++ b/drivers/media/platform/qcom/camss/camss-csiphy.c
@@ -197,11 +197,9 @@ static int csiphy_set_power(struct v4l2_subdev *sd, int on)
 	if (on) {
 		int ret;
 
-		ret = pm_runtime_get_sync(dev);
-		if (ret < 0) {
-			pm_runtime_put_sync(dev);
+		ret = pm_runtime_resume_and_get(dev);
+		if (ret < 0)
 			return ret;
-		}
 
 		ret = csiphy_set_clock_rates(csiphy);
 		if (ret < 0) {
diff --git a/drivers/media/platform/qcom/camss/camss-ispif.c b/drivers/media/platform/qcom/camss/camss-ispif.c
index 37611c8861da..d9907742ba79 100644
--- a/drivers/media/platform/qcom/camss/camss-ispif.c
+++ b/drivers/media/platform/qcom/camss/camss-ispif.c
@@ -372,11 +372,9 @@ static int ispif_set_power(struct v4l2_subdev *sd, int on)
 			goto exit;
 		}
 
-		ret = pm_runtime_get_sync(dev);
-		if (ret < 0) {
-			pm_runtime_put_sync(dev);
+		ret = pm_runtime_resume_and_get(dev);
+		if (ret < 0)
 			goto exit;
-		}
 
 		ret = camss_enable_clocks(ispif->nclocks, ispif->clock, dev);
 		if (ret < 0) {
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index 15695fd466c4..cf743e61f798 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -584,9 +584,9 @@ static int vfe_get(struct vfe_device *vfe)
 		if (ret < 0)
 			goto error_pm_domain;
 
-		ret = pm_runtime_get_sync(vfe->camss->dev);
+		ret = pm_runtime_resume_and_get(vfe->camss->dev);
 		if (ret < 0)
-			goto error_pm_runtime_get;
+			goto error_domain_off;
 
 		ret = vfe_set_clock_rates(vfe);
 		if (ret < 0)
@@ -620,6 +620,7 @@ static int vfe_get(struct vfe_device *vfe)
 
 error_pm_runtime_get:
 	pm_runtime_put_sync(vfe->camss->dev);
+error_domain_off:
 	vfe->ops->pm_domain_off(vfe);
 
 error_pm_domain:
-- 
2.30.2


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

* [PATCH v5 13/25] media: venus: core: 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
                   ` (11 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 12/25] media: camss: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-10 13:54   ` Stanimir Varbanov
  2021-05-06 15:25 ` [PATCH v5 14/25] media: venus: vdec: " Mauro Carvalho Chehab
                   ` (11 subsequent siblings)
  24 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andy Gross,
	Bjorn Andersson, Mauro Carvalho Chehab, Stanimir Varbanov,
	linux-arm-msm, linux-kernel, linux-media

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/media/platform/qcom/venus/pm_helpers.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
index c7e1ebec47ee..d0fddf5e9a69 100644
--- a/drivers/media/platform/qcom/venus/pm_helpers.c
+++ b/drivers/media/platform/qcom/venus/pm_helpers.c
@@ -990,9 +990,8 @@ static int core_power_v4(struct venus_core *core, int on)
 
 	if (on == POWER_ON) {
 		if (pmctrl) {
-			ret = pm_runtime_get_sync(pmctrl);
+			ret = pm_runtime_resume_and_get(pmctrl);
 			if (ret < 0) {
-				pm_runtime_put_noidle(pmctrl);
 				return ret;
 			}
 		}
-- 
2.30.2


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

* [PATCH v5 14/25] media: venus: vdec: 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
                   ` (12 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 13/25] media: venus: core: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-10 13:55   ` Stanimir Varbanov
  2021-05-06 15:25 ` [PATCH v5 15/25] media: venus: venc: " Mauro Carvalho Chehab
                   ` (10 subsequent siblings)
  24 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andy Gross,
	Bjorn Andersson, Mauro Carvalho Chehab, Stanimir Varbanov,
	linux-arm-msm, linux-kernel, linux-media

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.

As a bonus, there's no need to check if ret == 1, as
pm_runtime_resume_and_get() always return 0 on success.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/qcom/venus/vdec.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index ddb7cd39424e..198e47eb63f4 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -568,10 +568,10 @@ static int vdec_pm_get(struct venus_inst *inst)
 	int ret;
 
 	mutex_lock(&core->pm_lock);
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	mutex_unlock(&core->pm_lock);
 
-	return ret < 0 ? ret : 0;
+	return ret;
 }
 
 static int vdec_pm_put(struct venus_inst *inst, bool autosuspend)
@@ -601,7 +601,7 @@ static int vdec_pm_get_put(struct venus_inst *inst)
 	mutex_lock(&core->pm_lock);
 
 	if (pm_runtime_suspended(dev)) {
-		ret = pm_runtime_get_sync(dev);
+		ret = pm_runtime_resume_and_get(dev);
 		if (ret < 0)
 			goto error;
 
-- 
2.30.2


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

* [PATCH v5 15/25] media: venus: venc: 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
                   ` (13 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 14/25] media: venus: vdec: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-10 13:55   ` Stanimir Varbanov
  2021-05-06 15:25 ` [PATCH v5 16/25] media: rcar-fcp: " Mauro Carvalho Chehab
                   ` (9 subsequent siblings)
  24 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andy Gross,
	Bjorn Andersson, Mauro Carvalho Chehab, Stanimir Varbanov,
	linux-arm-msm, linux-kernel, linux-media

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/media/platform/qcom/venus/venc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 4a7291f934b6..8dd49d4f124c 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -1205,9 +1205,9 @@ static int venc_open(struct file *file)
 
 	venus_helper_init_instance(inst);
 
-	ret = pm_runtime_get_sync(core->dev_enc);
+	ret = pm_runtime_resume_and_get(core->dev_enc);
 	if (ret < 0)
-		goto err_put_sync;
+		goto err_free;
 
 	ret = venc_ctrl_init(inst);
 	if (ret)
@@ -1252,6 +1252,7 @@ static int venc_open(struct file *file)
 	venc_ctrl_deinit(inst);
 err_put_sync:
 	pm_runtime_put_sync(core->dev_enc);
+err_free:
 	kfree(inst);
 	return ret;
 }
-- 
2.30.2


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

* [PATCH v5 16/25] media: rcar-fcp: 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
                   ` (14 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 15/25] media: venus: venc: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 16:05   ` Laurent Pinchart
  2021-05-06 15:25 ` [PATCH v5 17/25] media: rkisp1: " Mauro Carvalho Chehab
                   ` (8 subsequent siblings)
  24 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Laurent Pinchart,
	Mauro Carvalho Chehab, linux-kernel, linux-media,
	linux-renesas-soc

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.

As a bonus, pm_runtime_resume_and_get() always return 0 on success.
So, the code can be simplified.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/rcar-fcp.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c
index 5c03318ae07b..a3a7afc03d7b 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -101,13 +101,7 @@ int rcar_fcp_enable(struct rcar_fcp_device *fcp)
 	if (!fcp)
 		return 0;
 
-	ret = pm_runtime_get_sync(fcp->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(fcp->dev);
-		return ret;
-	}
-
-	return 0;
+	return pm_runtime_resume_and_get(fcp->dev);
 }
 EXPORT_SYMBOL_GPL(rcar_fcp_enable);
 
-- 
2.30.2


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

* [PATCH v5 17/25] media: rkisp1: 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
                   ` (15 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 16/25] media: rcar-fcp: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-13 22:27   ` Heiko Stuebner
  2021-05-06 15:25 ` [PATCH v5 18/25] media: s3c-camif: " Mauro Carvalho Chehab
                   ` (7 subsequent siblings)
  24 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dafna Hirschfeld,
	Heiko Stuebner, Helen Koike, Mauro Carvalho Chehab,
	linux-arm-kernel, linux-kernel, linux-media, linux-rockchip

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/media/platform/rockchip/rkisp1/rkisp1-capture.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
index 5f6c9d1623e4..3730376897d9 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c
@@ -1003,9 +1003,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
 	if (ret)
 		goto err_pipeline_stop;
 
-	ret = pm_runtime_get_sync(cap->rkisp1->dev);
+	ret = pm_runtime_resume_and_get(cap->rkisp1->dev);
 	if (ret < 0) {
-		pm_runtime_put_noidle(cap->rkisp1->dev);
 		dev_err(cap->rkisp1->dev, "power up failed %d\n", ret);
 		goto err_destroy_dummy;
 	}
-- 
2.30.2


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

* [PATCH v5 18/25] media: s3c-camif: 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
                   ` (16 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 17/25] media: rkisp1: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 19/25] media: s5p-mfc: " Mauro Carvalho Chehab
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Mauro Carvalho Chehab, Sylwester Nawrocki, linux-kernel,
	linux-media, linux-samsung-soc, Sylwester Nawrocki

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: Sylwester Nawrocki <snawrocki@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/s3c-camif/camif-capture.c | 2 +-
 drivers/media/platform/s3c-camif/camif-core.c    | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
index 9ca49af29542..62241ec3b978 100644
--- a/drivers/media/platform/s3c-camif/camif-capture.c
+++ b/drivers/media/platform/s3c-camif/camif-capture.c
@@ -547,7 +547,7 @@ static int s3c_camif_open(struct file *file)
 	if (ret < 0)
 		goto unlock;
 
-	ret = pm_runtime_get_sync(camif->dev);
+	ret = pm_runtime_resume_and_get(camif->dev);
 	if (ret < 0)
 		goto err_pm;
 
diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index 4c3c00d59c92..e1d51fd3e700 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -460,9 +460,9 @@ static int s3c_camif_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(dev);
 
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0)
-		goto err_pm;
+		goto err_disable;
 
 	ret = camif_media_dev_init(camif);
 	if (ret < 0)
@@ -502,6 +502,7 @@ static int s3c_camif_probe(struct platform_device *pdev)
 	camif_unregister_media_entities(camif);
 err_pm:
 	pm_runtime_put(dev);
+err_disable:
 	pm_runtime_disable(dev);
 	camif_clk_put(camif);
 err_clk:
-- 
2.30.2


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

* [PATCH v5 19/25] media: s5p-mfc: 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
                   ` (17 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 18/25] media: s3c-camif: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 20/25] media: stm32: " Mauro Carvalho Chehab
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Andrzej Hajda,
	Mauro Carvalho Chehab, linux-arm-kernel, linux-kernel,
	linux-media, Sylwester Nawrocki

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: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
index 62d2320a7218..88b7d33c9197 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
@@ -78,11 +78,9 @@ int s5p_mfc_power_on(void)
 {
 	int i, ret = 0;
 
-	ret = pm_runtime_get_sync(pm->device);
-	if (ret < 0) {
-		pm_runtime_put_noidle(pm->device);
+	ret = pm_runtime_resume_and_get(pm->device);
+	if (ret < 0)
 		return ret;
-	}
 
 	/* clock control */
 	for (i = 0; i < pm->num_clocks; i++) {
-- 
2.30.2


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

* [PATCH v5 20/25] media: stm32: 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
                   ` (18 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 19/25] media: s5p-mfc: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:25 ` [PATCH v5 21/25] media: sunxi: " Mauro Carvalho Chehab
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:25 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Alexandre Torgue,
	Hugues Fruchet, Mauro Carvalho Chehab, Maxime Coquelin,
	linux-arm-kernel, linux-kernel, linux-media, linux-stm32

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/media/platform/stm32/stm32-dcmi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index d9b4ad0abf0c..b33c6e7ae0a1 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -723,11 +723,11 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
 	u32 val = 0;
 	int ret;
 
-	ret = pm_runtime_get_sync(dcmi->dev);
+	ret = pm_runtime_resume_and_get(dcmi->dev);
 	if (ret < 0) {
 		dev_err(dcmi->dev, "%s: Failed to start streaming, cannot get sync (%d)\n",
 			__func__, ret);
-		goto err_pm_put;
+		goto err_unlocked;
 	}
 
 	ret = media_pipeline_start(&dcmi->vdev->entity, &dcmi->pipeline);
@@ -848,6 +848,7 @@ static int dcmi_start_streaming(struct vb2_queue *vq, unsigned int count)
 
 err_pm_put:
 	pm_runtime_put(dcmi->dev);
+err_unlocked:
 	spin_lock_irq(&dcmi->irqlock);
 	/*
 	 * Return all buffers to vb2 in QUEUED state.
-- 
2.30.2


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

* [PATCH v5 21/25] media: sunxi: 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
                   ` (19 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 20/25] media: stm32: " Mauro Carvalho Chehab
@ 2021-05-06 15:25 ` Mauro Carvalho Chehab
  2021-05-06 15:26 ` [PATCH v5 22/25] media: ti-vpe: " Mauro Carvalho Chehab
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 38+ 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,
	Jernej Skrabec, Mauro Carvalho Chehab, Maxime Ripard,
	linux-arm-kernel, linux-kernel, linux-media, linux-sunxi

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/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
index 4785faddf630..54b909987caa 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
@@ -206,9 +206,9 @@ static int sun4i_csi_open(struct file *file)
 	if (ret)
 		return ret;
 
-	ret = pm_runtime_get_sync(csi->dev);
+	ret = pm_runtime_resume_and_get(csi->dev);
 	if (ret < 0)
-		goto err_pm_put;
+		goto err_unlock;
 
 	ret = v4l2_pipeline_pm_get(&csi->vdev.entity);
 	if (ret)
@@ -227,6 +227,8 @@ static int sun4i_csi_open(struct file *file)
 
 err_pm_put:
 	pm_runtime_put(csi->dev);
+
+err_unlock:
 	mutex_unlock(&csi->lock);
 
 	return ret;
-- 
2.30.2


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

* [PATCH v5 22/25] media: ti-vpe: 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
                   ` (20 preceding siblings ...)
  2021-05-06 15:25 ` [PATCH v5 21/25] media: sunxi: " Mauro Carvalho Chehab
@ 2021-05-06 15:26 ` Mauro Carvalho Chehab
  2021-05-06 15:26 ` [PATCH v5 23/25] media: vsp1: " Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:26 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Benoit Parrot,
	Mauro Carvalho Chehab, linux-kernel, linux-media

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/media/platform/ti-vpe/cal-video.c | 4 +++-
 drivers/media/platform/ti-vpe/cal.c       | 8 +++++---
 drivers/media/platform/ti-vpe/vpe.c       | 8 +++-----
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti-vpe/cal-video.c
index 7b7436a355ee..15fb5360cf13 100644
--- a/drivers/media/platform/ti-vpe/cal-video.c
+++ b/drivers/media/platform/ti-vpe/cal-video.c
@@ -700,7 +700,9 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
 
 	addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0);
 
-	pm_runtime_get_sync(ctx->cal->dev);
+	ret = pm_runtime_resume_and_get(ctx->cal->dev);
+	if (ret < 0)
+		goto error_pipeline;
 
 	cal_ctx_set_dma_addr(ctx, addr);
 	cal_ctx_start(ctx);
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 2e2bef91b2b0..76fe7a8b33f6 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1024,7 +1024,7 @@ static int cal_probe(struct platform_device *pdev)
 
 	/* Read the revision and hardware info to verify hardware access. */
 	pm_runtime_enable(&pdev->dev);
-	ret = pm_runtime_get_sync(&pdev->dev);
+	ret = pm_runtime_resume_and_get(&pdev->dev);
 	if (ret)
 		goto error_pm_runtime;
 
@@ -1098,10 +1098,11 @@ static int cal_remove(struct platform_device *pdev)
 {
 	struct cal_dev *cal = platform_get_drvdata(pdev);
 	unsigned int i;
+	int ret;
 
 	cal_dbg(1, cal, "Removing %s\n", CAL_MODULE_NAME);
 
-	pm_runtime_get_sync(&pdev->dev);
+	ret = pm_runtime_resume_and_get(&pdev->dev);
 
 	cal_media_unregister(cal);
 
@@ -1115,7 +1116,8 @@ static int cal_remove(struct platform_device *pdev)
 	for (i = 0; i < cal->data->num_csi2_phy; i++)
 		cal_camerarx_destroy(cal->phy[i]);
 
-	pm_runtime_put_sync(&pdev->dev);
+	if (ret >= 0)
+		pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
 	return 0;
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti-vpe/vpe.c
index 10251b787674..5b1c5d96a407 100644
--- a/drivers/media/platform/ti-vpe/vpe.c
+++ b/drivers/media/platform/ti-vpe/vpe.c
@@ -2471,11 +2471,9 @@ static int vpe_runtime_get(struct platform_device *pdev)
 
 	dev_dbg(&pdev->dev, "vpe_runtime_get\n");
 
-	r = pm_runtime_get_sync(&pdev->dev);
+	r = pm_runtime_resume_and_get(&pdev->dev);
 	WARN_ON(r < 0);
-	if (r)
-		pm_runtime_put_noidle(&pdev->dev);
-	return r < 0 ? r : 0;
+	return r;
 }
 
 static void vpe_runtime_put(struct platform_device *pdev)
@@ -2580,7 +2578,7 @@ static int vpe_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 
 	ret = vpe_runtime_get(pdev);
-	if (ret)
+	if (ret < 0)
 		goto rel_m2m;
 
 	/* Perform clk enable followed by reset */
-- 
2.30.2


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

* [PATCH v5 23/25] media: vsp1: 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
                   ` (21 preceding siblings ...)
  2021-05-06 15:26 ` [PATCH v5 22/25] media: ti-vpe: " Mauro Carvalho Chehab
@ 2021-05-06 15:26 ` Mauro Carvalho Chehab
  2021-05-06 16:06   ` Laurent Pinchart
  2021-05-06 15:26 ` [PATCH v5 24/25] media: rcar-vin: " Mauro Carvalho Chehab
  2021-05-06 15:26 ` [PATCH v5 25/25] media: hantro: " Mauro Carvalho Chehab
  24 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:26 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Kieran Bingham,
	Laurent Pinchart, Mauro Carvalho Chehab, linux-kernel,
	linux-media, linux-renesas-soc

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.

As a bonus, pm_runtime_resume_and_get() always return 0 on success.
So, the code can be simplified.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/vsp1/vsp1_drv.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index aa66e4f5f3f3..de442d6c9926 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -559,15 +559,7 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
  */
 int vsp1_device_get(struct vsp1_device *vsp1)
 {
-	int ret;
-
-	ret = pm_runtime_get_sync(vsp1->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(vsp1->dev);
-		return ret;
-	}
-
-	return 0;
+	return pm_runtime_resume_and_get(vsp1->dev);
 }
 
 /*
-- 
2.30.2


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

* [PATCH v5 24/25] media: rcar-vin: 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
                   ` (22 preceding siblings ...)
  2021-05-06 15:26 ` [PATCH v5 23/25] media: vsp1: " Mauro Carvalho Chehab
@ 2021-05-06 15:26 ` Mauro Carvalho Chehab
  2021-05-06 15:26 ` [PATCH v5 25/25] media: hantro: " Mauro Carvalho Chehab
  24 siblings, 0 replies; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-06 15:26 UTC (permalink / raw)
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab,
	Niklas Söderlund, Mauro Carvalho Chehab, linux-kernel,
	linux-media, linux-renesas-soc, Niklas Söderlund

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: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/platform/rcar-vin/rcar-csi2.c | 15 ++++++++++++---
 drivers/media/platform/rcar-vin/rcar-dma.c  |  6 ++----
 drivers/media/platform/rcar-vin/rcar-v4l2.c |  6 ++----
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index e06cd512aba2..99bf814eb2a7 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -406,10 +406,17 @@ static void rcsi2_enter_standby(struct rcar_csi2 *priv)
 	pm_runtime_put(priv->dev);
 }
 
-static void rcsi2_exit_standby(struct rcar_csi2 *priv)
+static int rcsi2_exit_standby(struct rcar_csi2 *priv)
 {
-	pm_runtime_get_sync(priv->dev);
+	int ret;
+
+	ret = pm_runtime_resume_and_get(priv->dev);
+	if (ret < 0)
+		return ret;
+
 	reset_control_deassert(priv->rstc);
+
+	return 0;
 }
 
 static int rcsi2_wait_phy_start(struct rcar_csi2 *priv,
@@ -657,7 +664,9 @@ static int rcsi2_start(struct rcar_csi2 *priv)
 {
 	int ret;
 
-	rcsi2_exit_standby(priv);
+	ret = rcsi2_exit_standby(priv);
+	if (ret < 0)
+		return ret;
 
 	ret = rcsi2_start_receiver(priv);
 	if (ret) {
diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
index f30dafbdf61c..f5f722ab1d4e 100644
--- a/drivers/media/platform/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/rcar-vin/rcar-dma.c
@@ -1458,11 +1458,9 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel)
 	u32 vnmc;
 	int ret;
 
-	ret = pm_runtime_get_sync(vin->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(vin->dev);
+	ret = pm_runtime_resume_and_get(vin->dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	/* Make register writes take effect immediately. */
 	vnmc = rvin_read(vin, VNMC_REG);
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 457a65bf6b66..b1e9f86caa5c 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -870,11 +870,9 @@ static int rvin_open(struct file *file)
 	struct rvin_dev *vin = video_drvdata(file);
 	int ret;
 
-	ret = pm_runtime_get_sync(vin->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(vin->dev);
+	ret = pm_runtime_resume_and_get(vin->dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	ret = mutex_lock_interruptible(&vin->lock);
 	if (ret)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 38+ 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
                   ` (23 preceding siblings ...)
  2021-05-06 15:26 ` [PATCH v5 24/25] media: rcar-vin: " Mauro Carvalho Chehab
@ 2021-05-06 15:26 ` Mauro Carvalho Chehab
  24 siblings, 0 replies; 38+ 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] 38+ messages in thread

* Re: [PATCH v5 16/25] media: rcar-fcp: use pm_runtime_resume_and_get()
  2021-05-06 15:25 ` [PATCH v5 16/25] media: rcar-fcp: " Mauro Carvalho Chehab
@ 2021-05-06 16:05   ` Laurent Pinchart
  0 siblings, 0 replies; 38+ messages in thread
From: Laurent Pinchart @ 2021-05-06 16:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, linux-kernel,
	linux-media, linux-renesas-soc

Hi Mauro,

Thank you for the patch.

On Thu, May 06, 2021 at 05:25:54PM +0200, Mauro Carvalho Chehab wrote:
> 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.
> 
> As a bonus, pm_runtime_resume_and_get() always return 0 on success.
> So, the code can be simplified.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/platform/rcar-fcp.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c
> index 5c03318ae07b..a3a7afc03d7b 100644
> --- a/drivers/media/platform/rcar-fcp.c
> +++ b/drivers/media/platform/rcar-fcp.c
> @@ -101,13 +101,7 @@ int rcar_fcp_enable(struct rcar_fcp_device *fcp)
>  	if (!fcp)
>  		return 0;
>  
> -	ret = pm_runtime_get_sync(fcp->dev);
> -	if (ret < 0) {
> -		pm_runtime_put_noidle(fcp->dev);
> -		return ret;
> -	}
> -
> -	return 0;
> +	return pm_runtime_resume_and_get(fcp->dev);
>  }
>  EXPORT_SYMBOL_GPL(rcar_fcp_enable);
>  

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH v5 23/25] media: vsp1: use pm_runtime_resume_and_get()
  2021-05-06 15:26 ` [PATCH v5 23/25] media: vsp1: " Mauro Carvalho Chehab
@ 2021-05-06 16:06   ` Laurent Pinchart
  0 siblings, 0 replies; 38+ messages in thread
From: Laurent Pinchart @ 2021-05-06 16:06 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Kieran Bingham, Mauro Carvalho Chehab,
	linux-kernel, linux-media, linux-renesas-soc

Hi Mauro,

Thank you for the patch.

On Thu, May 06, 2021 at 05:26:01PM +0200, Mauro Carvalho Chehab wrote:
> 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.
> 
> As a bonus, pm_runtime_resume_and_get() always return 0 on success.
> So, the code can be simplified.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/platform/vsp1/vsp1_drv.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
> index aa66e4f5f3f3..de442d6c9926 100644
> --- a/drivers/media/platform/vsp1/vsp1_drv.c
> +++ b/drivers/media/platform/vsp1/vsp1_drv.c
> @@ -559,15 +559,7 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
>   */
>  int vsp1_device_get(struct vsp1_device *vsp1)
>  {
> -	int ret;
> -
> -	ret = pm_runtime_get_sync(vsp1->dev);
> -	if (ret < 0) {
> -		pm_runtime_put_noidle(vsp1->dev);
> -		return ret;
> -	}
> -
> -	return 0;
> +	return pm_runtime_resume_and_get(vsp1->dev);
>  }
>  
>  /*

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 38+ 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; 38+ 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] 38+ 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; 38+ 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] 38+ messages in thread

* Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
  2021-05-06 15:25 ` [PATCH v5 13/25] media: venus: core: " Mauro Carvalho Chehab
@ 2021-05-10 13:54   ` Stanimir Varbanov
  2021-05-17 15:26     ` Stanimir Varbanov
  0 siblings, 1 reply; 38+ messages in thread
From: Stanimir Varbanov @ 2021-05-10 13:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, Stanimir Varbanov, linux-arm-msm,
	linux-kernel, linux-media



On 5/6/21 6:25 PM, Mauro Carvalho Chehab wrote:
> 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/media/platform/qcom/venus/pm_helpers.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>

> 
> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
> index c7e1ebec47ee..d0fddf5e9a69 100644
> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
> @@ -990,9 +990,8 @@ static int core_power_v4(struct venus_core *core, int on)
>  
>  	if (on == POWER_ON) {
>  		if (pmctrl) {
> -			ret = pm_runtime_get_sync(pmctrl);
> +			ret = pm_runtime_resume_and_get(pmctrl);
>  			if (ret < 0) {
> -				pm_runtime_put_noidle(pmctrl);
>  				return ret;
>  			}
>  		}
> 

-- 
regards,
Stan

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

* Re: [PATCH v5 14/25] media: venus: vdec: use pm_runtime_resume_and_get()
  2021-05-06 15:25 ` [PATCH v5 14/25] media: venus: vdec: " Mauro Carvalho Chehab
@ 2021-05-10 13:55   ` Stanimir Varbanov
  0 siblings, 0 replies; 38+ messages in thread
From: Stanimir Varbanov @ 2021-05-10 13:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, Stanimir Varbanov, linux-arm-msm,
	linux-kernel, linux-media



On 5/6/21 6:25 PM, Mauro Carvalho Chehab wrote:
> 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.
> 
> As a bonus, there's no need to check if ret == 1, as
> pm_runtime_resume_and_get() always return 0 on success.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  drivers/media/platform/qcom/venus/vdec.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>


-- 
regards,
Stan

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

* Re: [PATCH v5 15/25] media: venus: venc: use pm_runtime_resume_and_get()
  2021-05-06 15:25 ` [PATCH v5 15/25] media: venus: venc: " Mauro Carvalho Chehab
@ 2021-05-10 13:55   ` Stanimir Varbanov
  0 siblings, 0 replies; 38+ messages in thread
From: Stanimir Varbanov @ 2021-05-10 13:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, Stanimir Varbanov, linux-arm-msm,
	linux-kernel, linux-media



On 5/6/21 6:25 PM, Mauro Carvalho Chehab wrote:
> 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/media/platform/qcom/venus/venc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>


-- 
regards,
Stan

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

* Re: [PATCH v5 17/25] media: rkisp1: use pm_runtime_resume_and_get()
  2021-05-06 15:25 ` [PATCH v5 17/25] media: rkisp1: " Mauro Carvalho Chehab
@ 2021-05-13 22:27   ` Heiko Stuebner
  0 siblings, 0 replies; 38+ messages in thread
From: Heiko Stuebner @ 2021-05-13 22:27 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Dafna Hirschfeld,
	Helen Koike, Mauro Carvalho Chehab, linux-arm-kernel,
	linux-kernel, linux-media, linux-rockchip

Am Donnerstag, 6. Mai 2021, 17:25:55 CEST schrieb Mauro Carvalho Chehab:
> 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>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>



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

* Re: [PATCH v5 07/25] media: rockchip/rga: use pm_runtime_resume_and_get()
  2021-05-06 15:25 ` [PATCH v5 07/25] media: rockchip/rga: " Mauro Carvalho Chehab
@ 2021-05-13 22:38   ` Heiko Stuebner
  0 siblings, 0 replies; 38+ messages in thread
From: Heiko Stuebner @ 2021-05-13 22:38 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Mauro Carvalho Chehab, Ezequiel Garcia,
	Jacob Chen, Mauro Carvalho Chehab, linux-arm-kernel,
	linux-kernel, linux-media, linux-rockchip

Am Donnerstag, 6. Mai 2021, 17:25:45 CEST schrieb Mauro Carvalho Chehab:
> 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: Ezequiel Garcia <ezequiel@collabora.com>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  drivers/media/platform/rockchip/rga/rga-buf.c | 3 +--
>  drivers/media/platform/rockchip/rga/rga.c     | 4 +++-
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c
> index bf9a75b75083..81508ed5abf3 100644
> --- a/drivers/media/platform/rockchip/rga/rga-buf.c
> +++ b/drivers/media/platform/rockchip/rga/rga-buf.c
> @@ -79,9 +79,8 @@ static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count)
>  	struct rockchip_rga *rga = ctx->rga;
>  	int ret;
>  
> -	ret = pm_runtime_get_sync(rga->dev);
> +	ret = pm_runtime_resume_and_get(rga->dev);
>  	if (ret < 0) {
> -		pm_runtime_put_noidle(rga->dev);
>  		rga_buf_return_buffers(q, VB2_BUF_STATE_QUEUED);
>  		return ret;
>  	}

looks ok

> diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
> index 9d122429706e..bf3fd71ec3af 100644
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -866,7 +866,9 @@ static int rga_probe(struct platform_device *pdev)
>  		goto unreg_video_dev;
>  	}
>  
> -	pm_runtime_get_sync(rga->dev);
> +	ret = pm_runtime_resume_and_get(rga->dev);
> +	if (ret < 0)
> +		goto unreg_video_dev;
>  
>  	rga->version.major = (rga_read(rga, RGA_VERSION_INFO) >> 24) & 0xFF;
>  	rga->version.minor = (rga_read(rga, RGA_VERSION_INFO) >> 20) & 0x0F;

hmm, the whole error handling in rga_probe looks fishy to my untrained eyes.

But I guess the easiest will be to apply your patch first and then
investigate and clean up the non-matching alloc - releae calls, so

Reviewed-by: Heiko Stuebner <heiko@sntech.de>




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

* Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
  2021-05-10 13:54   ` Stanimir Varbanov
@ 2021-05-17 15:26     ` Stanimir Varbanov
  2021-05-18 15:20       ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 38+ messages in thread
From: Stanimir Varbanov @ 2021-05-17 15:26 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, linux-arm-msm, linux-kernel, linux-media

Hi Mauro,

On 5/10/21 4:54 PM, Stanimir Varbanov wrote:
> 
> 
> On 5/6/21 6:25 PM, Mauro Carvalho Chehab wrote:
>> 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/media/platform/qcom/venus/pm_helpers.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> 

What is the plan for these venus patches. Do I need to take them through
my Venus pull request for v5.14 or you will take them directly?

>>
>> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
>> index c7e1ebec47ee..d0fddf5e9a69 100644
>> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
>> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
>> @@ -990,9 +990,8 @@ static int core_power_v4(struct venus_core *core, int on)
>>  
>>  	if (on == POWER_ON) {
>>  		if (pmctrl) {
>> -			ret = pm_runtime_get_sync(pmctrl);
>> +			ret = pm_runtime_resume_and_get(pmctrl);
>>  			if (ret < 0) {
>> -				pm_runtime_put_noidle(pmctrl);
>>  				return ret;
>>  			}
>>  		}
>>
> 

-- 
regards,
Stan

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

* Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
  2021-05-17 15:26     ` Stanimir Varbanov
@ 2021-05-18 15:20       ` Mauro Carvalho Chehab
  2021-05-18 15:49         ` Stanimir Varbanov
  0 siblings, 1 reply; 38+ messages in thread
From: Mauro Carvalho Chehab @ 2021-05-18 15:20 UTC (permalink / raw)
  To: Stanimir Varbanov
  Cc: linuxarm, mauro.chehab, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, linux-arm-msm, linux-kernel, linux-media

Em Mon, 17 May 2021 18:26:14 +0300
Stanimir Varbanov <stanimir.varbanov@linaro.org> escreveu:

> Hi Mauro,
> 
> On 5/10/21 4:54 PM, Stanimir Varbanov wrote:
> > 
> > 
> > On 5/6/21 6:25 PM, Mauro Carvalho Chehab wrote:  
> >> 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/media/platform/qcom/venus/pm_helpers.c | 3 +--
> >>  1 file changed, 1 insertion(+), 2 deletions(-)  
> > 
> > Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> > Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> >   
> 
> What is the plan for these venus patches. Do I need to take them through
> my Venus pull request for v5.14 or you will take them directly?

Whatever works best for you. In principle, I should apply them on my
tree probably tomorrow, if ok for you.

Regards,
Mauro

> 
> >>
> >> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
> >> index c7e1ebec47ee..d0fddf5e9a69 100644
> >> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
> >> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c
> >> @@ -990,9 +990,8 @@ static int core_power_v4(struct venus_core *core, int on)
> >>  
> >>  	if (on == POWER_ON) {
> >>  		if (pmctrl) {
> >> -			ret = pm_runtime_get_sync(pmctrl);
> >> +			ret = pm_runtime_resume_and_get(pmctrl);
> >>  			if (ret < 0) {
> >> -				pm_runtime_put_noidle(pmctrl);
> >>  				return ret;
> >>  			}
> >>  		}
> >>  
> >   
> 



Thanks,
Mauro

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

* Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
  2021-05-18 15:20       ` Mauro Carvalho Chehab
@ 2021-05-18 15:49         ` Stanimir Varbanov
  0 siblings, 0 replies; 38+ messages in thread
From: Stanimir Varbanov @ 2021-05-18 15:49 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: linuxarm, mauro.chehab, Andy Gross, Bjorn Andersson,
	Mauro Carvalho Chehab, linux-arm-msm, linux-kernel, linux-media

Hi Mauro,

On 5/18/21 6:20 PM, Mauro Carvalho Chehab wrote:
> Em Mon, 17 May 2021 18:26:14 +0300
> Stanimir Varbanov <stanimir.varbanov@linaro.org> escreveu:
> 
>> Hi Mauro,
>>
>> On 5/10/21 4:54 PM, Stanimir Varbanov wrote:
>>>
>>>
>>> On 5/6/21 6:25 PM, Mauro Carvalho Chehab wrote:  
>>>> 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/media/platform/qcom/venus/pm_helpers.c | 3 +--
>>>>  1 file changed, 1 insertion(+), 2 deletions(-)  
>>>
>>> Tested-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
>>> Acked-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
>>>   
>>
>> What is the plan for these venus patches. Do I need to take them through
>> my Venus pull request for v5.14 or you will take them directly?
> 
> Whatever works best for you. In principle, I should apply them on my
> tree probably tomorrow, if ok for you.
> 

It is perfectly fine, please apply them. Thank you!

-- 
regards,
Stan

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

end of thread, other threads:[~2021-05-18 15:49 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v5 03/25] staging: media: ipu3: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 04/25] staging: media: cedrus_video: " Mauro Carvalho Chehab
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
2021-05-06 15:25 ` [PATCH v5 06/25] staging: media: tegra-video: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 07/25] media: rockchip/rga: " Mauro Carvalho Chehab
2021-05-13 22:38   ` Heiko Stuebner
2021-05-06 15:25 ` [PATCH v5 08/25] media: sti/hva: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 09/25] media: ipu3: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 10/25] media: coda: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 11/25] media: mtk-jpeg: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 12/25] media: camss: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 13/25] media: venus: core: " Mauro Carvalho Chehab
2021-05-10 13:54   ` Stanimir Varbanov
2021-05-17 15:26     ` Stanimir Varbanov
2021-05-18 15:20       ` Mauro Carvalho Chehab
2021-05-18 15:49         ` Stanimir Varbanov
2021-05-06 15:25 ` [PATCH v5 14/25] media: venus: vdec: " Mauro Carvalho Chehab
2021-05-10 13:55   ` Stanimir Varbanov
2021-05-06 15:25 ` [PATCH v5 15/25] media: venus: venc: " Mauro Carvalho Chehab
2021-05-10 13:55   ` Stanimir Varbanov
2021-05-06 15:25 ` [PATCH v5 16/25] media: rcar-fcp: " Mauro Carvalho Chehab
2021-05-06 16:05   ` Laurent Pinchart
2021-05-06 15:25 ` [PATCH v5 17/25] media: rkisp1: " Mauro Carvalho Chehab
2021-05-13 22:27   ` Heiko Stuebner
2021-05-06 15:25 ` [PATCH v5 18/25] media: s3c-camif: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 19/25] media: s5p-mfc: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 20/25] media: stm32: " Mauro Carvalho Chehab
2021-05-06 15:25 ` [PATCH v5 21/25] media: sunxi: " Mauro Carvalho Chehab
2021-05-06 15:26 ` [PATCH v5 22/25] media: ti-vpe: " Mauro Carvalho Chehab
2021-05-06 15:26 ` [PATCH v5 23/25] media: vsp1: " Mauro Carvalho Chehab
2021-05-06 16:06   ` Laurent Pinchart
2021-05-06 15:26 ` [PATCH v5 24/25] media: rcar-vin: " Mauro Carvalho Chehab
2021-05-06 15:26 ` [PATCH v5 25/25] media: hantro: " Mauro Carvalho Chehab

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