From 51af9979aa4f3fa8adc547d02af3fc5c43a69969 Mon Sep 17 00:00:00 2001 From: "Guoniu.Zhou" Date: Tue, 31 Jul 2018 15:58:41 +0800 Subject: [PATCH] MLK-19108: ISI: fix isi hang issue when open it many times When one ISI channel is receiving data, if an other process just open it at the same time and then close, it will lead to this channel hang. The reason is soft reset in release callback, so it make the channel stop work. Add an counter for open isi channel and really soft reset the channel when the counter equal to zero. Signed-off-by: Guoniu.Zhou Reviewed-by: Robby.Cai --- drivers/media/platform/imx8/mxc-isi-cap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/imx8/mxc-isi-cap.c b/drivers/media/platform/imx8/mxc-isi-cap.c index 988403a54720..f6917a42c3d5 100644 --- a/drivers/media/platform/imx8/mxc-isi-cap.c +++ b/drivers/media/platform/imx8/mxc-isi-cap.c @@ -651,6 +651,8 @@ static int mxc_isi_capture_open(struct file *file) dev_dbg(&mxc_isi->pdev->dev, "%s, ISI%d\n", __func__, mxc_isi->id); + atomic_inc(&mxc_isi->open_count); + /* Get remote source pad */ source_pad = mxc_isi_get_remote_source_pad(mxc_isi); if (source_pad == NULL) { @@ -716,7 +718,8 @@ static int mxc_isi_capture_release(struct file *file) } mutex_unlock(&mxc_isi->lock); - mxc_isi_channel_deinit(mxc_isi); + if (atomic_dec_and_test(&mxc_isi->open_count)) + mxc_isi_channel_deinit(mxc_isi); ret = v4l2_subdev_call(sd, core, s_power, 0); if (ret < 0 && ret != -ENOIOCTLCMD) { -- 2.17.1