media: rockchip: vicap: add mutex lock for v4l2 pipeline get/put

Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: Ia989121b9320a33f94bb51b7692ac56dbbae3d36
This commit is contained in:
Zefa Chen
2022-12-02 17:25:15 +08:00
committed by Tao Huang
parent 66eaffb030
commit bd548c0a79
3 changed files with 14 additions and 4 deletions

View File

@@ -5626,7 +5626,11 @@ static int rkcif_fh_open(struct file *filp)
ret = v4l2_fh_open(filp);
if (!ret) {
mutex_lock(&cifdev->stream_lock);
ret = v4l2_pipeline_pm_get(&vnode->vdev.entity);
v4l2_info(vdev, "open video, entity use_countt %d\n",
vnode->vdev.entity.use_count);
mutex_unlock(&cifdev->stream_lock);
if (ret < 0)
vb2_fop_release(filp);
}
@@ -5655,8 +5659,13 @@ static int rkcif_fh_release(struct file *filp)
int i = 0;
ret = vb2_fop_release(filp);
if (!ret)
if (!ret) {
mutex_lock(&cifdev->stream_lock);
v4l2_pipeline_pm_put(&vnode->vdev.entity);
v4l2_info(vdev, "close video, entity use_count %d\n",
vnode->vdev.entity.use_count);
mutex_unlock(&cifdev->stream_lock);
}
pm_runtime_put_sync(cifdev->dev);
if (cifdev->sditf_cnt > 1) {

View File

@@ -2135,7 +2135,6 @@ static int __maybe_unused rkcif_runtime_suspend(struct device *dev)
if (atomic_dec_return(&cif_dev->power_cnt))
return 0;
v4l2_pipeline_pm_put(&cif_dev->stream[0].vnode.vdev.entity);
mutex_lock(&cif_dev->hw_dev->dev_lock);
ret = pm_runtime_put_sync(cif_dev->hw_dev->dev);
mutex_unlock(&cif_dev->hw_dev->dev_lock);
@@ -2150,8 +2149,6 @@ static int __maybe_unused rkcif_runtime_resume(struct device *dev)
if (atomic_inc_return(&cif_dev->power_cnt) > 1)
return 0;
v4l2_pipeline_pm_get(&cif_dev->stream[0].vnode.vdev.entity);
mutex_lock(&cif_dev->hw_dev->dev_lock);
ret = pm_runtime_resume_and_get(cif_dev->hw_dev->dev);
mutex_unlock(&cif_dev->hw_dev->dev_lock);

View File

@@ -703,6 +703,7 @@ static int sditf_s_power(struct v4l2_subdev *sd, int on)
v4l2_dbg(3, rkcif_debug, &cif_dev->v4l2_dev,
"%s, toisp mode %d, hdr %d, set power %d\n",
__func__, priv->toisp_inf.link_mode, priv->hdr_cfg.hdr_mode, on);
mutex_lock(&cif_dev->stream_lock);
if (on) {
ret = pm_runtime_resume_and_get(cif_dev->dev);
ret |= v4l2_pipeline_pm_get(&node->vdev.entity);
@@ -710,6 +711,9 @@ static int sditf_s_power(struct v4l2_subdev *sd, int on)
v4l2_pipeline_pm_put(&node->vdev.entity);
pm_runtime_put_sync(cif_dev->dev);
}
v4l2_info(&node->vdev, "s_power %d, entity use_count %d\n",
on, node->vdev.entity.use_count);
mutex_unlock(&cif_dev->stream_lock);
}
return ret;
}