Commit 8fc707d1 authored by Dikshita Agarwal's avatar Dikshita Agarwal Committed by Hans Verkuil
Browse files

media: iris: remove v4l2_m2m_ioctl_{de,en}coder_cmd API usage during STOP handling



Currently v4l2_m2m_ioctl_{de,enc}coder_cmd is being invoked during STOP
command handling. However, this is not required as the iris driver has
its own drain and stop handling mechanism in place.

Using the m2m command API in this context leads to incorrect behavior,
where the LAST flag is prematurely attached to a capture buffer,
when there are no buffers in m2m source queue. But, in this scenario
even though the source buffers are returned to client, hardware might
still need to process the pending capture buffers.

Attaching LAST flag prematurely can result in the capture buffer being
removed from the destination queue before the hardware has finished
processing it, causing issues when the buffer is eventually returned by
the hardware.

To prevent this, remove the m2m API usage in stop handling.

Fixes: d0910076 ("media: iris: add support for drain sequence")
Fixes: 75db90ae ("media: iris: Add support for drain sequence in encoder video device")
Signed-off-by: default avatarDikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Reviewed-by: default avatarVikash Garodia <vikash.garodia@oss.qualcomm.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarBryan O'Donoghue <bod@kernel.org>
Signed-off-by: default avatarHans Verkuil <hverkuil+cisco@kernel.org>
parent 4980721c
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -573,9 +573,10 @@ static int iris_dec_cmd(struct file *filp, void *fh,

	mutex_lock(&inst->lock);

	ret = v4l2_m2m_ioctl_decoder_cmd(filp, fh, dec);
	if (ret)
	if (dec->cmd != V4L2_DEC_CMD_STOP && dec->cmd != V4L2_DEC_CMD_START) {
		ret = -EINVAL;
		goto unlock;
	}

	if (inst->state == IRIS_INST_DEINIT)
		goto unlock;
@@ -606,9 +607,10 @@ static int iris_enc_cmd(struct file *filp, void *fh,

	mutex_lock(&inst->lock);

	ret = v4l2_m2m_ioctl_encoder_cmd(filp, fh, enc);
	if (ret)
	if (enc->cmd != V4L2_ENC_CMD_STOP && enc->cmd != V4L2_ENC_CMD_START) {
		ret = -EINVAL;
		goto unlock;
	}

	if (inst->state == IRIS_INST_DEINIT)
		goto unlock;