From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Martin Kepplinger <martin.kepplinger@puri.sm>,
Rui Miguel Silva <rmfrfs@gmail.com>,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Sasha Levin <sashal@kernel.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH AUTOSEL 5.13 093/219] media: imx: imx7-media-csi: Fix buffer return upon stream start failure
Date: Thu, 9 Sep 2021 07:44:29 -0400 [thread overview]
Message-ID: <20210909114635.143983-93-sashal@kernel.org> (raw)
In-Reply-To: <20210909114635.143983-1-sashal@kernel.org>
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
[ Upstream commit 0ada1697ed4256b38225319c9896661142a3572d ]
When the stream fails to start, the first two buffers in the queue have
been moved to the active_vb2_buf array and are returned to vb2 by
imx7_csi_dma_unsetup_vb2_buf(). The function is called with the buffer
state set to VB2_BUF_STATE_ERROR unconditionally, which is correct when
stopping the stream, but not when the start operation fails. In that
case, the state should be set to VB2_BUF_STATE_QUEUED. Fix it.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/staging/media/imx/imx7-media-csi.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
index f85a2f5f1413..ad1bca3fe047 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -361,6 +361,7 @@ static void imx7_csi_dma_unsetup_vb2_buf(struct imx7_csi *csi,
vb->timestamp = ktime_get_ns();
vb2_buffer_done(vb, return_status);
+ csi->active_vb2_buf[i] = NULL;
}
}
}
@@ -386,9 +387,10 @@ static int imx7_csi_dma_setup(struct imx7_csi *csi)
return 0;
}
-static void imx7_csi_dma_cleanup(struct imx7_csi *csi)
+static void imx7_csi_dma_cleanup(struct imx7_csi *csi,
+ enum vb2_buffer_state return_status)
{
- imx7_csi_dma_unsetup_vb2_buf(csi, VB2_BUF_STATE_ERROR);
+ imx7_csi_dma_unsetup_vb2_buf(csi, return_status);
imx_media_free_dma_buf(csi->dev, &csi->underrun_buf);
}
@@ -537,9 +539,10 @@ static int imx7_csi_init(struct imx7_csi *csi)
return 0;
}
-static void imx7_csi_deinit(struct imx7_csi *csi)
+static void imx7_csi_deinit(struct imx7_csi *csi,
+ enum vb2_buffer_state return_status)
{
- imx7_csi_dma_cleanup(csi);
+ imx7_csi_dma_cleanup(csi, return_status);
imx7_csi_init_default(csi);
imx7_csi_dmareq_rff_disable(csi);
clk_disable_unprepare(csi->mclk);
@@ -702,7 +705,7 @@ static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable)
ret = v4l2_subdev_call(csi->src_sd, video, s_stream, 1);
if (ret < 0) {
- imx7_csi_deinit(csi);
+ imx7_csi_deinit(csi, VB2_BUF_STATE_QUEUED);
goto out_unlock;
}
@@ -712,7 +715,7 @@ static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable)
v4l2_subdev_call(csi->src_sd, video, s_stream, 0);
- imx7_csi_deinit(csi);
+ imx7_csi_deinit(csi, VB2_BUF_STATE_ERROR);
}
csi->is_streaming = !!enable;
--
2.30.2
next prev parent reply other threads:[~2021-09-09 12:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210909114635.143983-1-sashal@kernel.org>
2021-09-09 11:43 ` [PATCH AUTOSEL 5.13 008/219] media: dib8000: rewrite the init prbs logic Sasha Levin
2021-09-09 11:43 ` [PATCH AUTOSEL 5.13 009/219] media: ti-vpe: cal: fix error handling in cal_camerarx_create Sasha Levin
2021-09-09 11:43 ` [PATCH AUTOSEL 5.13 010/219] media: ti-vpe: cal: fix queuing of the initial buffer Sasha Levin
2021-09-09 11:43 ` [PATCH AUTOSEL 5.13 045/219] media: hantro: vp8: Move noisy WARN_ON to vpu_debug Sasha Levin
2021-09-09 11:43 ` [PATCH AUTOSEL 5.13 046/219] media: platform: stm32: unprepare clocks at handling errors in probe Sasha Levin
2021-09-09 11:43 ` [PATCH AUTOSEL 5.13 047/219] media: atomisp: Fix runtime PM imbalance in atomisp_pci_probe Sasha Levin
2021-09-09 11:43 ` [PATCH AUTOSEL 5.13 048/219] media: atomisp: pci: fix error return code in atomisp_pci_probe() Sasha Levin
2021-09-09 11:44 ` [PATCH AUTOSEL 5.13 091/219] media: imx258: Rectify mismatch of VTS value Sasha Levin
2021-09-09 11:44 ` [PATCH AUTOSEL 5.13 092/219] media: imx258: Limit the max analogue gain to 480 Sasha Levin
2021-09-09 11:44 ` Sasha Levin [this message]
2021-09-09 11:44 ` [PATCH AUTOSEL 5.13 094/219] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Sasha Levin
2021-09-09 11:44 ` [PATCH AUTOSEL 5.13 095/219] media: TDA1997x: fix tda1997x_query_dv_timings() return value Sasha Levin
2021-09-09 11:44 ` [PATCH AUTOSEL 5.13 096/219] media: tegra-cec: Handle errors of clk_prepare_enable() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210909114635.143983-93-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=martin.kepplinger@puri.sm \
--cc=mchehab+huawei@kernel.org \
--cc=rmfrfs@gmail.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).