From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Ming Qian <ming.qian@oss.nxp.com>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Hans Verkuil <hverkuil+cisco@kernel.org>,
Sasha Levin <sashal@kernel.org>,
ming.qian@nxp.com, eagle.zhou@nxp.com,
linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 6.19-6.1] media: amphion: Clear last_buffer_dequeued flag for DEC_CMD_START
Date: Fri, 13 Feb 2026 19:58:10 -0500 [thread overview]
Message-ID: <20260214010245.3671907-10-sashal@kernel.org> (raw)
In-Reply-To: <20260214010245.3671907-1-sashal@kernel.org>
From: Ming Qian <ming.qian@oss.nxp.com>
[ Upstream commit d85f3207d75df6d7a08be6526b15ff398668206c ]
The V4L2_DEC_CMD_START command may be used to handle the dynamic source
change, which will triggers an implicit decoder drain.
The last_buffer_dequeued flag is set in the implicit decoder drain,
so driver need to clear it to continue the following decoding flow.
Signed-off-by: Ming Qian <ming.qian@oss.nxp.com>
Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
## Analysis of commit: "media: amphion: Clear last_buffer_dequeued flag
for DEC_CMD_START"
### 1. Commit Message Analysis
The commit message clearly describes a bug fix:
- When `V4L2_DEC_CMD_START` is used to handle dynamic source changes, an
implicit decoder drain is triggered
- The drain sets the `last_buffer_dequeued` flag
- This flag is never cleared, which **breaks the subsequent decoding
flow**
- The fix clears the flag when `DEC_CMD_START` is issued, allowing
decoding to continue
Keywords: "need to clear it to continue the following decoding flow" —
this indicates the decoder becomes stuck/non-functional without this
fix.
### 2. Code Change Analysis
The change is a **single line addition**:
```c
vb2_clear_last_buffer_dequeued(v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx));
```
This is added in the `V4L2_DEC_CMD_START` case of `vdec_decoder_cmd()`,
right after the existing `vdec_cmd_start(inst)` call.
**What the bug mechanism is:**
- `last_buffer_dequeued` is a flag in the vb2 (Video Buffer 2) queue
framework
- When set, it signals that the last buffer has been dequeued and no
more buffers will come
- During dynamic source change handling, an implicit drain sets this
flag
- Without clearing it on `DEC_CMD_START`, the capture queue thinks it's
done and won't deliver any more buffers
- This effectively **breaks video decoding** after a source change event
**The fix uses well-known V4L2 APIs:**
- `vb2_clear_last_buffer_dequeued()` — standard V4L2 helper function
- `v4l2_m2m_get_dst_vq()` — standard M2M helper to get the destination
(capture) queue
### 3. Classification
This is a **clear bug fix**. Without this patch, the amphion video
decoder becomes non-functional after handling a dynamic source change
event. The decoder gets stuck because the capture queue won't deliver
any more buffers.
### 4. Scope and Risk Assessment
- **Lines changed:** 1 line added
- **Files touched:** 1 file (`drivers/media/platform/amphion/vdec.c`)
- **Complexity:** Extremely low — calls a standard framework function
- **Risk of regression:** Very low — this is a targeted fix in a
specific command handler, using a well-established API
- **Subsystem:** Media/V4L2 driver for NXP amphion video decoder
### 5. User Impact
- **Who is affected:** Users of NXP i.MX8 SoCs (common in
embedded/industrial applications) that use the amphion video decoder
- **Severity:** The bug causes the video decoder to stop working after a
dynamic source change — this is a functional failure, not a minor
issue
- **Real-world scenario:** Dynamic source changes happen when video
stream parameters change mid-stream (resolution change, codec
reconfiguration). This is a normal operational scenario in media
playback.
### 6. Stability Indicators
- **Reviewed-by:** Nicolas Dufresne (Collabora, well-known V4L2
contributor)
- **Signed-off-by:** Hans Verkuil (V4L2 subsystem maintainer)
- The patch is obviously correct — it follows the same pattern used by
other V4L2 M2M drivers
### 7. Dependency Check
- The fix uses `vb2_clear_last_buffer_dequeued()` and
`v4l2_m2m_get_dst_vq()`, which are long-standing V4L2 framework
functions available in all stable trees that contain the amphion
driver
- No dependency on other patches — this is a self-contained one-line fix
### Summary
This is a textbook stable backport candidate:
- **Obviously correct:** Single line calling a standard API at the right
place
- **Fixes a real bug:** Decoder stops working after dynamic source
change
- **Small and contained:** 1 line, 1 file
- **No new features:** Just fixes existing functionality
- **Low risk:** Uses established framework API, reviewed by subsystem
maintainer
- **Real user impact:** Video decoding breaks without it
**YES**
drivers/media/platform/amphion/vdec.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c
index c0d2aabb9e0e3..f25dbcebdccf6 100644
--- a/drivers/media/platform/amphion/vdec.c
+++ b/drivers/media/platform/amphion/vdec.c
@@ -724,6 +724,7 @@ static int vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd
switch (cmd->cmd) {
case V4L2_DEC_CMD_START:
vdec_cmd_start(inst);
+ vb2_clear_last_buffer_dequeued(v4l2_m2m_get_dst_vq(inst->fh.m2m_ctx));
break;
case V4L2_DEC_CMD_STOP:
vdec_cmd_stop(inst);
--
2.51.0
next prev parent reply other threads:[~2026-02-14 1:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-14 0:58 [PATCH AUTOSEL 6.19-6.12] media: ipu6: Close firmware streams on streaming enable failure Sasha Levin
2026-02-14 0:58 ` [PATCH AUTOSEL 6.19-6.12] media: chips-media: wave5: Fix conditional in start_streaming Sasha Levin
2026-02-14 0:58 ` [PATCH AUTOSEL 6.19-6.12] media: mt9m114: Avoid a reset low spike during probe() Sasha Levin
2026-02-14 0:58 ` Sasha Levin [this message]
2026-02-14 0:58 ` [PATCH AUTOSEL 6.19-5.10] media: adv7180: fix frame interval in progressive mode Sasha Levin
2026-02-14 0:58 ` [PATCH AUTOSEL 6.19-6.6] media: v4l2-async: Fix error handling on steps after finding a match Sasha Levin
2026-02-14 0:58 ` [PATCH AUTOSEL 6.19-6.1] media: rkisp1: Fix filter mode register configuration Sasha Levin
2026-02-14 0:58 ` [PATCH AUTOSEL 6.19-6.12] media: ipu6: Ensure stream_mutex is acquired when dealing with node list Sasha Levin
2026-02-14 0:58 ` [PATCH AUTOSEL 6.19-6.12] media: mt9m114: Return -EPROBE_DEFER if no endpoint is found Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-6.18] media: uvcvideo: Create an ID namespace for streaming output terminals Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-6.12] media: ipu6: Always close firmware stream Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-6.18] media: qcom: camss: Do not enable cpas fast ahb clock for SM8550 VFE lite Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-5.10] media: solo6x10: Check for out of bounds chip_id Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-6.18] drm/amdgpu: Refactor amdgpu_gem_va_ioctl for Handling Last Fence Update and Timeline Management v4 Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-6.12] media: chips-media: wave5: Process ready frames when CMD_STOP sent to Encoder Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-5.10] media: pvrusb2: fix URB leak in pvr2_send_request_ex Sasha Levin
2026-02-14 0:59 ` [PATCH AUTOSEL 6.19-5.10] media: dvb-core: dmxdevfilter must always flush bufs 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=20260214010245.3671907-10-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=eagle.zhou@nxp.com \
--cc=hverkuil+cisco@kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=ming.qian@nxp.com \
--cc=ming.qian@oss.nxp.com \
--cc=nicolas.dufresne@collabora.com \
--cc=patches@lists.linux.dev \
--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