Linux Media Controller development
 help / color / mirror / Atom feed
From: Christian Cortner <ccortner@gmail.com>
To: Bryan O'Donoghue <bod@kernel.org>,
	Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
	Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>
Cc: Abhinav Kumar <abhinav.kumar@linux.dev>,
	Birk Skyum <birk.skyum@pm.me>,
	linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: [RFC PATCH 1/5] media: iris: Don't flag an empty source change LAST buffer as an error
Date: Mon, 26 Oct 2026 21:19:30 -0500	[thread overview]
Message-ID: <20261027021934.22113-2-ccortner@gmail.com> (raw)
In-Reply-To: <20261027021934.22113-1-ccortner@gmail.com>

When the firmware completes a source change, it returns the last capture
buffer from before the change flagged HFI_BUF_FW_FLAG_PSC_LAST, and that
buffer can be empty. iris_hfi_gen2_handle_output_buffer() sets
V4L2_BUF_FLAG_ERROR on every empty capture buffer returned while
streaming unless it carries HFI_BUF_FW_FLAG_LAST, the flag that ends a
drain, so the empty buffer that ends a source change reaches the client
flagged both LAST and ERROR.

The stateful decoder interface says of this buffer, as it does of the
one that ends a drain, that it "may be empty (with v4l2_buffer bytesused
= 0) and in that case it must be ignored by the client, as it does not
contain a decoded frame". With the ERROR flag, ffmpeg's h264_v4l2m2m
decoder reports "capture: driver decode error" and outputs a corrupted
frame.

Exempt HFI_BUF_FW_FLAG_PSC_LAST as well.

Fixes: 7adc11e6abf6 ("media: iris: Send V4L2_BUF_FLAG_ERROR for capture buffers with 0 filled length")
Cc: stable@vger.kernel.org
Assisted-by: LLM sparse smatch
---
Reference only, not for merging (no Signed-off-by); see the cover
letter.

 drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
index f0782c4b1e6e..b4fe9066fcb8 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_gen2_response.c
@@ -390,8 +390,13 @@ static int iris_hfi_gen2_handle_output_buffer(struct iris_inst *inst,
 
 	buf->flags = iris_hfi_gen2_get_driver_buffer_flags(inst, hfi_buffer->flags);
 
+	/*
+	 * The empty buffer that ends a drain (LAST) or a source change
+	 * (PSC_LAST) is not an error, the client just ignores it.
+	 */
 	if (!buf->data_size && inst->state == IRIS_INST_STREAMING &&
-	    !(hfi_buffer->flags & HFI_BUF_FW_FLAG_LAST)) {
+	    !(hfi_buffer->flags &
+	      (HFI_BUF_FW_FLAG_LAST | HFI_BUF_FW_FLAG_PSC_LAST))) {
 		buf->flags |= V4L2_BUF_FLAG_ERROR;
 	}
 
-- 
2.56.0


  reply	other threads:[~2026-10-27  2:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <NKVWOXEaC2RjmCRG3wt6Y-1_CZxSqp_rpkiLIJV8xQg9k4sZGi5C2lZ4oIQ0qsI-Fk-wDDfmYsiCOiqKaDFnzQ==@protonmail.internalid>
2026-10-26 16:09 ` [BUG] media: iris: resolution change handling stops ffmpeg's h264_v4l2m2m decoder on glymur Christian Cortner
2026-10-26 17:50   ` Birk Skyum
2026-10-26 21:13     ` Birk Skyum
2026-10-26 22:31   ` Bryan O'Donoghue
2026-10-27  2:19     ` Christian Cortner
2026-10-27  2:19       ` [RFC PATCH 0/5] media: iris: ffmpeg decoder flow changes, for reference only Christian Cortner
2026-10-27  2:19         ` Christian Cortner [this message]
2026-10-27 22:26           ` [RFC PATCH 1/5] media: iris: Don't flag an empty source change LAST buffer as an error Bryan O'Donoghue
2026-10-27  2:19         ` [RFC PATCH 2/5] media: iris: Update the CAPTURE stride and size on S_FMT(OUTPUT) Christian Cortner
2026-10-27 22:36           ` Bryan O'Donoghue
2026-10-27  2:19         ` [RFC PATCH 3/5] media: iris: Signal V4L2_EVENT_EOS only at the end of a drain Christian Cortner
2026-10-27 22:44           ` Bryan O'Donoghue
2026-10-27  2:19         ` [RFC PATCH 4/5] media: iris: Let a resolution change drain before stopping CAPTURE Christian Cortner
2026-10-27 22:59           ` Bryan O'Donoghue
2026-10-27  2:19         ` [RFC PATCH 5/5] media: iris: Resume the first source change if it fits the CAPTURE setup Christian Cortner
2026-10-27 23:04           ` Bryan O'Donoghue
2026-10-27 12:43       ` [BUG] media: iris: resolution change handling stops ffmpeg's h264_v4l2m2m decoder on glymur Birk Skyum
2026-10-27 18:14         ` Christian Cortner

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=20261027021934.22113-2-ccortner@gmail.com \
    --to=ccortner@gmail.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=birk.skyum@pm.me \
    --cc=bod@kernel.org \
    --cc=dikshita.agarwal@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=vikash.garodia@oss.qualcomm.com \
    /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