media: use pm_runtime_resume_and_get() on non-i2c drivers
Subsystems (24)
v5 cover media: use pm_runtime_resume_and_get() on non-i2c drivers
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/[email protected]/
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(-)
Signature · 1 line
2.30.2
PATCH v5 1/25 staging: media: imx7-mipi-csis: use pm_runtime_resume_and_get()
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.
--- drivers/staging/media/imx/imx7-mipi-csis.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +3 -4
@@ -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;
Signature · 1 line
2.30.2
PATCH v5 2/25 staging: media: atomisp: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/staging/media/atomisp/pci/atomisp_fops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +3 -3
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 3/25 staging: media: ipu3: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/staging/media/ipu3/ipu3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/ipu3/ipu3.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 4/25 staging: media: cedrus_video: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/staging/media/sunxi/cedrus/cedrus_video.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/sunxi/cedrus/cedrus_video.c +2 -4
@@ -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);
Signature · 1 line
2.30.2
PATCH v5 5/25 staging: media: tegra-vde: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/staging/media/tegra-vde/vde.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/staging/media/tegra-vde/vde.c +18 -3
@@ -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);
Signature · 1 line
2.30.2
Re: [PATCH v5 05/25] staging: media: tegra-vde: use pm_runtime_resume_and_get()
drivers/staging/media/tegra-vde/vde.c static int tegra_vde_probe(struct platform_device *pdev) · line 1075
Quoted 7 lines · Mauro Carvalho Chehab
drivers/staging/media/tegra-vde/vde.c +2
-1@@ -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.
Quoted 4 lines
drivers/staging/media/tegra-vde/vde.c +1
-0+pm_runtime_put (dev);return 0 ;
drivers/staging/media/tegra-vde/vde.c static int tegra_vde_probe(struct platform_device *pdev) · line 1089
Quoted 10 lines
drivers/staging/media/tegra-vde/vde.c +6
-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
Re: [PATCH v5 05/25] staging: media: tegra-vde: use pm_runtime_resume_and_get()
07.05.2021 08:13, Dan Carpenter пишет:
Quoted 11 lines · Mauro Carvalho Chehab
drivers/staging/media/tegra-vde/vde.c static int tegra_vde_probe(struct platform_device *pdev) · line 1075
Quoted 7 lines
drivers/staging/media/tegra-vde/vde.c +2
-1@@ -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.
PATCH v5 6/25 staging: media: tegra-video: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/staging/media/tegra-video/csi.c | 3 +-- drivers/staging/media/tegra-video/vi.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/tegra-video/csi.c +1 -2
@@ -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; }
drivers/staging/media/tegra-video/vi.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 7/25 media: rockchip/rga: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/rockchip/rga/rga-buf.c | 3 +-- drivers/media/platform/rockchip/rga/rga.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/rockchip/rga/rga-buf.c +1 -2
@@ -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; }
drivers/media/platform/rockchip/rga/rga.c +3 -1
@@ -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 ;
Signature · 1 line
2.30.2
Re: [PATCH v5 07/25] media: rockchip/rga: use pm_runtime_resume_and_get()
Am Donnerstag, 6. Mai 2021, 17:25:45 CEST schrieb Mauro Carvalho Chehab:
Quoted 18 lines
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Reviewed-by Ezequiel Garcia <[email protected]>Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/rockchip/rga/rga-buf.c | 3 +-- drivers/media/platform/rockchip/rga/rga.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-)drivers/media/platform/rockchip/rga/rga-buf.c +0
-0
drivers/media/platform/rockchip/rga/rga-buf.c static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count) · line 86
Quoted 10 lines
drivers/media/platform/rockchip/rga/rga-buf.c +1
-2@@ -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
Quoted 5 lines
drivers/media/platform/rockchip/rga/rga.c +0
-0
drivers/media/platform/rockchip/rga/rga.c static int rga_probe(struct platform_device *pdev) · line 874
Quoted 10 lines
drivers/media/platform/rockchip/rga/rga.c +3
-1@@ -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
PATCH v5 8/25 media: sti/hva: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/sti/hva/hva-hw.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/media/platform/sti/hva/hva-hw.c +9 -8
@@ -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 ; }
Signature · 1 line
2.30.2
PATCH v5 9/25 media: ipu3: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
PATCH v5 10/25 media: coda: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/coda/coda-common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/coda/coda-common.c +4 -3
@@ -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:
Signature · 1 line
2.30.2
PATCH v5 11/25 media: mtk-jpeg: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +2 -2
@@ -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;
Signature · 1 line
2.30.2
PATCH v5 12/25 media: camss: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- 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(-)
drivers/media/platform/qcom/camss/camss-csid.c +2 -4
@@ -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 ) {
drivers/media/platform/qcom/camss/camss-csiphy.c +2 -4
@@ -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 ) {
drivers/media/platform/qcom/camss/camss-ispif.c +2 -4
@@ -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 ) {
drivers/media/platform/qcom/camss/camss-vfe.c +3 -2
@@ -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:
Signature · 1 line
2.30.2
PATCH v5 13/25 media: venus: core: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/qcom/venus/pm_helpers.c +1 -2
@@ -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; } }
Signature · 1 line
2.30.2
Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
Quoted 10 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 17 lines
drivers/media/platform/qcom/venus/pm_helpers.c +1
-2@@ -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; } }
Signature · 2 lines
regards, Stan
Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
Hi Mauro,
Quoted 9 lines · Stanimir Varbanov
Quoted 6 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Quoted 8 lines
Quoted 4 lines
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Tested-by Stanimir Varbanov <[email protected]>
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?
Quoted 18 lines
Quoted 17 lines
drivers/media/platform/qcom/venus/pm_helpers.c +1
-2@@ -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; } }
Signature · 2 lines
regards, Stan
Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
Em Mon, 17 May 2021 18:26:14 +0300
Stanimir Varbanov <[email protected]> escreveu:
Quoted 17 lines
Hi Mauro,
Quoted 14 lines · Stanimir Varbanov
Quoted 10 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 6 lines
Quoted 3 lines
Tested-by Stanimir Varbanov <[email protected]>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
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/media/platform/qcom/venus/pm_helpers.c +0
-0@@ -990,9 +990,8 @@ static int core_power_v4(struct venus_core *core, int on)
Quoted 12 lines
Quoted 11 lines
drivers/media/platform/qcom/venus/pm_helpers.c static int core_power_v4(struct venus_core *core, int on) · line 997
Quoted 10 lines
drivers/media/platform/qcom/venus/pm_helpers.c +1
-2if (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
Re: [PATCH v5 13/25] media: venus: core: use pm_runtime_resume_and_get()
Hi Mauro,
Quoted 24 lines · Mauro Carvalho Chehab
Em Mon, 17 May 2021 18:26:14 +0300
Stanimir Varbanov <[email protected]> escreveu:Quoted 21 lines
Hi Mauro,
Quoted 17 lines · Stanimir Varbanov
Quoted 10 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/qcom/venus/pm_helpers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Tested-by Stanimir Varbanov <[email protected]>
Quoted 6 lines
Quoted 2 lines
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!
Signature · 2 lines
regards, Stan
PATCH v5 14/25 media: venus: vdec: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/qcom/venus/vdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +3 -3
@@ -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;
Signature · 1 line
2.30.2
Re: [PATCH v5 14/25] media: venus: vdec: use pm_runtime_resume_and_get()
Quoted 6 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Quoted 7 lines
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 <[email protected]>--- drivers/media/platform/qcom/venus/vdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 2 lines
regards, Stan
PATCH v5 15/25 media: venus: venc: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/qcom/venus/venc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/venc.c +3 -2
@@ -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; }
Signature · 1 line
2.30.2
Re: [PATCH v5 15/25] media: venus: venc: use pm_runtime_resume_and_get()
Quoted 10 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Signed-off-by Mauro Carvalho Chehab <[email protected]>--- drivers/media/platform/qcom/venus/venc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 2 lines
regards, Stan
PATCH v5 16/25 media: rcar-fcp: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/rcar-fcp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/media/platform/rcar-fcp.c +1 -7
@@ -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);
Signature · 1 line
2.30.2
Re: [PATCH v5 16/25] media: rcar-fcp: use pm_runtime_resume_and_get()
Hi Mauro,
Thank you for the patch.
Quoted 10 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement 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 <[email protected]>
Quoted 23 lines
--- drivers/media/platform/rcar-fcp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/media/platform/rcar-fcp.c +1
-7@@ -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);
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v5 17/25 media: rkisp1: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +1 -2
@@ -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; }
Signature · 1 line
2.30.2
Re: [PATCH v5 17/25] media: rkisp1: use pm_runtime_resume_and_get()
Am Donnerstag, 6. Mai 2021, 17:25:55 CEST schrieb Mauro Carvalho Chehab:
Quoted 7 lines
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement on errors.Use the new API, in order to cleanup the error check logic.
Signed-off-by Mauro Carvalho Chehab <[email protected]>
PATCH v5 18/25 media: s3c-camif: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- 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(-)
drivers/media/platform/s3c-camif/camif-capture.c +1 -1
@@ -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;
drivers/media/platform/s3c-camif/camif-core.c +3 -2
@@ -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:
Signature · 1 line
2.30.2
PATCH v5 19/25 media: s5p-mfc: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/s5p-mfc/s5p_mfc_pm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/media/platform/s5p-mfc/s5p_mfc_pm.c +2 -4
@@ -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++) {
Signature · 1 line
2.30.2
PATCH v5 20/25 media: stm32: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/stm32/stm32-dcmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/stm32/stm32-dcmi.c +3 -2
@@ -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.
Signature · 1 line
2.30.2
PATCH v5 21/25 media: sunxi: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c +4 -2
@@ -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;
Signature · 1 line
2.30.2
PATCH v5 22/25 media: ti-vpe: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- 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(-)
drivers/media/platform/ti-vpe/cal-video.c +3 -1
@@ -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);
drivers/media/platform/ti-vpe/cal.c +5 -3
@@ -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 ;
drivers/media/platform/ti-vpe/vpe.c +3 -5
@@ -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 */
Signature · 1 line
2.30.2
PATCH v5 23/25 media: vsp1: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/media/platform/vsp1/vsp1_drv.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/media/platform/vsp1/vsp1_drv.c +1 -9
@@ -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); }/*
Signature · 1 line
2.30.2
Re: [PATCH v5 23/25] media: vsp1: use pm_runtime_resume_and_get()
Hi Mauro,
Thank you for the patch.
Quoted 10 lines · Mauro Carvalho Chehab
Commit
dd8088d5a896("PM: runtime: Addpm_runtime_resume_and_getto deal with usage counter") addedpm_runtime_resume_and_get()in order to automatically handledev->power.usage_countdecrement 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 <[email protected]>
Quoted 25 lines
--- drivers/media/platform/vsp1/vsp1_drv.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)drivers/media/platform/vsp1/vsp1_drv.c +1
-9@@ -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); }/*
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v5 24/25 media: rcar-vin: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- 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(-)
drivers/media/platform/rcar-vin/rcar-csi2.c +12 -3
@@ -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) {
drivers/media/platform/rcar-vin/rcar-dma.c +2 -4
@@ -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 );
drivers/media/platform/rcar-vin/rcar-v4l2.c +2 -4
@@ -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)
Signature · 1 line
2.30.2
PATCH v5 25/25 media: hantro: use pm_runtime_resume_and_get()
In reply to Mauro Carvalho ChehabCommit 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.
--- drivers/staging/media/hantro/hantro_drv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/media/hantro/hantro_drv.c +2 -3
@@ -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; }
Signature · 1 line
2.30.2