* [PATCH v0 1/4] media: chips-media: wave5: Guard bit depth check with initial_info_obtained
2026-06-04 2:01 [PATCH v0 0/4] bug fixes Jackson.lee
@ 2026-06-04 2:01 ` Jackson.lee
2026-06-04 2:01 ` [PATCH v0 2/4] media: chips-media: wave5: Set inst->std during default format initialization Jackson.lee
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jackson.lee @ 2026-06-04 2:01 UTC (permalink / raw)
To: mchehab, hverkuil-cisco, nicolas.dufresne, bob.beckett
Cc: linux-media, linux-kernel, jackson.lee, lafley.kim, b-brnich,
hverkuil, nas.chung, stable
From: Jackson Lee <jackson.lee@chipsnmedia.com>
When CAPTURE STREAMON is called before the VPU has completed sequence
initialization (initial_info_obtained == false), the initial_info fields
contain uninitialized data. The driver checks
luma_bitdepth and rejects anything other than 8-bit, so garbage values
(e.g. 15) cause STREAMON to fail spuriously.
This is reproducible with the following multi-threaded test scenario:
1. Allocate 2 CAPTURE buffers.
2. Call STREAMON on the CAPTURE queue.
3. Call DQBUF, which blocks waiting for a decoded frame.
4. A second thread calls STREAMOFF on the CAPTURE queue.
5. The blocked DQBUF should be released, allowing graceful termination.
At step 2, STREAMON reads uninitialized luma_bitdepth and rejects the
stream, causing the test to fail.
Fix this by checking initial_info_obtained before accessing the bit
depth fields, so the validation is only performed when the sequence
info has actually been parsed by the VPU.
Fixes: 035371c9e509 ("media: chips-media: wave5: Fix timeout while testing 10bit hevc fluster")
Cc: stable@vger.kernel.org
Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
---
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
index bb2ba9204a83..01d1368b2965 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -1403,6 +1403,7 @@ static int wave5_vpu_dec_start_streaming(struct vb2_queue *q, unsigned int count
} else if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
struct dec_initial_info *initial_info =
&inst->codec_info->dec_info.initial_info;
+ struct dec_info *p_dec_info = &inst->codec_info->dec_info;
if (inst->state == VPU_INST_STATE_STOP)
ret = switch_state(inst, VPU_INST_STATE_INIT_SEQ);
@@ -1410,6 +1411,7 @@ static int wave5_vpu_dec_start_streaming(struct vb2_queue *q, unsigned int count
goto return_buffers;
if (inst->state == VPU_INST_STATE_INIT_SEQ &&
+ p_dec_info->initial_info_obtained &&
inst->dev->product_code == WAVE521C_CODE) {
if (initial_info->luma_bitdepth != 8) {
dev_info(inst->dev->dev, "%s: no support for %d bit depth",
@@ -1418,7 +1420,6 @@ static int wave5_vpu_dec_start_streaming(struct vb2_queue *q, unsigned int count
goto return_buffers;
}
}
-
}
pm_runtime_put_autosuspend(inst->dev->dev);
return ret;
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v0 2/4] media: chips-media: wave5: Set inst->std during default format initialization
2026-06-04 2:01 [PATCH v0 0/4] bug fixes Jackson.lee
2026-06-04 2:01 ` [PATCH v0 1/4] media: chips-media: wave5: Guard bit depth check with initial_info_obtained Jackson.lee
@ 2026-06-04 2:01 ` Jackson.lee
2026-06-04 2:01 ` [PATCH v0 3/4] media: chips-media: wave5: avoid skipping device_run while VPU has work Jackson.lee
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Jackson.lee @ 2026-06-04 2:01 UTC (permalink / raw)
To: mchehab, hverkuil-cisco, nicolas.dufresne, bob.beckett
Cc: linux-media, linux-kernel, jackson.lee, lafley.kim, b-brnich,
hverkuil, nas.chung, stable
From: Jackson Lee <jackson.lee@chipsnmedia.com>
When the encoder is opened, wave5_set_default_format() sets up the
default capture format (e.g. H.264) but does not initialize inst->std.
As a result, inst->std remains zero, which does not match any valid
encoder codec.
If STREAMON is called before the user explicitly calls S_FMT on the
capture queue — as v4l2-compliance does in testBlockingDQBuf — the
codec/product check in wave5_vpu_enc_init_seq() fails with
"Unsupported encoder-codec & product combination" because inst->std
is neither W_HEVC_ENC nor W_AVC_ENC, returning -EOPNOTSUPP.
Fix this by setting inst->std via wave5_to_vpu_std() in
wave5_set_default_format(), so that the codec type is always consistent
with the default capture pixel format from the moment the instance is
opened.
Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
Cc: stable@vger.kernel.org
Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
---
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
index e6c94b6f2671..f9fcdf4c224b 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
@@ -1494,7 +1494,8 @@ static const struct vb2_ops wave5_vpu_enc_vb2_ops = {
.stop_streaming = wave5_vpu_enc_stop_streaming,
};
-static void wave5_set_default_format(struct v4l2_pix_format_mplane *src_fmt,
+static void wave5_set_default_format(struct vpu_instance *inst,
+ struct v4l2_pix_format_mplane *src_fmt,
struct v4l2_pix_format_mplane *dst_fmt)
{
src_fmt->pixelformat = enc_fmt_list[VPU_FMT_TYPE_RAW][0].v4l2_pix_fmt;
@@ -1506,6 +1507,7 @@ static void wave5_set_default_format(struct v4l2_pix_format_mplane *src_fmt,
wave5_update_pix_fmt(dst_fmt, VPU_FMT_TYPE_CODEC,
W5_DEF_ENC_PIC_WIDTH, W5_DEF_ENC_PIC_HEIGHT,
&enc_frmsize[VPU_FMT_TYPE_CODEC]);
+ inst->std = wave5_to_vpu_std(dst_fmt->pixelformat, inst->type);
}
static int wave5_vpu_enc_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_queue *dst_vq)
@@ -1770,7 +1772,7 @@ static int wave5_vpu_open_enc(struct file *filp)
inst->v4l2_fh.ctrl_handler = v4l2_ctrl_hdl;
v4l2_ctrl_handler_setup(v4l2_ctrl_hdl);
- wave5_set_default_format(&inst->src_fmt, &inst->dst_fmt);
+ wave5_set_default_format(inst, &inst->src_fmt, &inst->dst_fmt);
inst->conf_win.width = inst->dst_fmt.width;
inst->conf_win.height = inst->dst_fmt.height;
inst->colorspace = V4L2_COLORSPACE_REC709;
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v0 3/4] media: chips-media: wave5: avoid skipping device_run while VPU has work
2026-06-04 2:01 [PATCH v0 0/4] bug fixes Jackson.lee
2026-06-04 2:01 ` [PATCH v0 1/4] media: chips-media: wave5: Guard bit depth check with initial_info_obtained Jackson.lee
2026-06-04 2:01 ` [PATCH v0 2/4] media: chips-media: wave5: Set inst->std during default format initialization Jackson.lee
@ 2026-06-04 2:01 ` Jackson.lee
2026-06-04 2:01 ` [PATCH v0 4/4] media: chips-media: wave5: Add interrupt timeout while stop_streaming Jackson.lee
2026-06-08 14:16 ` [PATCH v0 0/4] bug fixes Brandon Brnich
4 siblings, 0 replies; 7+ messages in thread
From: Jackson.lee @ 2026-06-04 2:01 UTC (permalink / raw)
To: mchehab, hverkuil-cisco, nicolas.dufresne, bob.beckett
Cc: linux-media, linux-kernel, jackson.lee, lafley.kim, b-brnich,
hverkuil, nas.chung, stable
From: Jackson Lee <jackson.lee@chipsnmedia.com>
The decoder stalls because empty_queue is set to true even when the
m2m context still has pending commands. As a result, device_run is
never invoked, the m2m source queue fills up, and userspace (e.g.
Chromium) can no longer queue new bitstream buffers to the V4L2
driver.
Fix this by querying the VPU queue status via DEC_GET_QUEUE_STATUS
before deciding whether to skip device_run. Only skip when the
VPU's instance_queue_count equals the number of ready source
buffers in the v4l2-m2m context, which indicates that there is
genuinely no new work to perform. Otherwise, proceed with issuing
a decode command so that the VPU can continue draining its internal
queue.
Fixes: a176ac5e701f ("media: chips-media: wave5: Improve performance of decoder")
Cc: stable@vger.kernel.org
Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
---
.../media/platform/chips-media/wave5/wave5-vpu-dec.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
index 01d1368b2965..b7fa19ea2aac 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -1663,9 +1663,15 @@ static void wave5_vpu_dec_device_run(void *priv)
} else if (!inst->eos &&
inst->queuing_num == 0 &&
inst->state == VPU_INST_STATE_PIC_RUN) {
- dev_dbg(inst->dev->dev, "%s: no bitstream for feeding, so skip ", __func__);
- inst->empty_queue = true;
- goto finish_job_and_return;
+ struct queue_status_info q_status;
+
+ wave5_vpu_dec_give_command(inst, DEC_GET_QUEUE_STATUS, &q_status);
+ if (q_status.instance_queue_count == v4l2_m2m_num_src_bufs_ready(m2m_ctx)) {
+ dev_dbg(inst->dev->dev, "%s: no bitstream, skip\n",
+ __func__);
+ inst->empty_queue = true;
+ goto finish_job_and_return;
+ }
}
}
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v0 4/4] media: chips-media: wave5: Add interrupt timeout while stop_streaming
2026-06-04 2:01 [PATCH v0 0/4] bug fixes Jackson.lee
` (2 preceding siblings ...)
2026-06-04 2:01 ` [PATCH v0 3/4] media: chips-media: wave5: avoid skipping device_run while VPU has work Jackson.lee
@ 2026-06-04 2:01 ` Jackson.lee
2026-06-08 14:16 ` [PATCH v0 0/4] bug fixes Brandon Brnich
4 siblings, 0 replies; 7+ messages in thread
From: Jackson.lee @ 2026-06-04 2:01 UTC (permalink / raw)
To: mchehab, hverkuil-cisco, nicolas.dufresne, bob.beckett
Cc: linux-media, linux-kernel, jackson.lee, lafley.kim, b-brnich,
hverkuil, nas.chung, stable
From: Jackson Lee <jackson.lee@chipsnmedia.com>
When stop_streaming is called, an infinite loop may occur in some cases.
To prevent this, add a timeout based on interrupt status before calling
get_result. If no further interrupts are received, the loop should exit.
Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
Cc: stable@vger.kernel.org
Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
---
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 5 +++++
drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
index b7fa19ea2aac..52ff1ac82e7b 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
@@ -1543,6 +1543,7 @@ static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)
dev_dbg(inst->dev->dev, "%s: type: %u\n", __func__, q->type);
pm_runtime_resume_and_get(inst->dev->dev);
inst->empty_queue = true;
+
while (check_cmd) {
struct queue_status_info q_status;
struct dec_output_info dec_output_info;
@@ -1554,6 +1555,10 @@ static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)
q_status.report_queue_count == 0)
break;
+ if (q_status.instance_queue_count > 0 &&
+ wave5_vpu_wait_interrupt(inst, VPU_DEC_STOP_TIMEOUT) < 0)
+ break;
+
if (wave5_vpu_dec_get_output_info(inst, &dec_output_info))
dev_dbg(inst->dev->dev, "there is no output info\n");
}
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h b/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h
index 4ebd48d5550e..e04f2dbf3b65 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h
@@ -59,7 +59,7 @@
// application specific configuration
#define VPU_ENC_TIMEOUT 60000
#define VPU_DEC_TIMEOUT 60000
-#define VPU_DEC_STOP_TIMEOUT 10
+#define VPU_DEC_STOP_TIMEOUT 300
// for WAVE encoder
#define USE_SRC_PRP_AXI 0
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v0 0/4] bug fixes
2026-06-04 2:01 [PATCH v0 0/4] bug fixes Jackson.lee
` (3 preceding siblings ...)
2026-06-04 2:01 ` [PATCH v0 4/4] media: chips-media: wave5: Add interrupt timeout while stop_streaming Jackson.lee
@ 2026-06-08 14:16 ` Brandon Brnich
2026-06-09 0:31 ` jackson.lee
4 siblings, 1 reply; 7+ messages in thread
From: Brandon Brnich @ 2026-06-08 14:16 UTC (permalink / raw)
To: Jackson.lee, mchehab, hverkuil-cisco, nicolas.dufresne, bob.beckett
Cc: linux-media, linux-kernel, lafley.kim, hverkuil, nas.chung
Hi Jackson,
On 6/3/26 21:01, Jackson.lee wrote:
> From: Jackson Lee <jackson.lee@chipsnmedia.com>
>
> A few independent fixes for the Wave5 VPU driver, covering decode
> setup, m2m scheduling and stop_streaming robustness.
This series appears to fix some issues in v4l2-compliance report, can
you add the updated report in the next iteration of this series to make
sure everything is now fixed with latest v4l2-compliance tag?
Best,
Brandon
>
> Jackson Lee (4):
> media: chips-media: wave5: Guard bit depth check with
> initial_info_obtained
> media: chips-media: wave5: Set inst->std during default format
> initialization
> media: chips-media: wave5: avoid skipping device_run while VPU has
> work
> media: chips-media: wave5: Add interrupt timeout while stop_streaming
>
> .../chips-media/wave5/wave5-vpu-dec.c | 20 +++++++++++++++----
> .../chips-media/wave5/wave5-vpu-enc.c | 6 ++++--
> .../chips-media/wave5/wave5-vpuconfig.h | 2 +-
> 3 files changed, 21 insertions(+), 7 deletions(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread* RE: [PATCH v0 0/4] bug fixes
2026-06-08 14:16 ` [PATCH v0 0/4] bug fixes Brandon Brnich
@ 2026-06-09 0:31 ` jackson.lee
0 siblings, 0 replies; 7+ messages in thread
From: jackson.lee @ 2026-06-09 0:31 UTC (permalink / raw)
To: Brandon Brnich, mchehab, hverkuil-cisco, nicolas.dufresne, bob.beckett
Cc: linux-media, linux-kernel, lafley.kim, hverkuil, Nas Chung
Hi Brandon
> -----Original Message-----
> From: Brandon Brnich <b-brnich@ti.com>
> Sent: Monday, June 8, 2026 11:16 PM
> To: jackson.lee <jackson.lee@chipsnmedia.com>; mchehab@kernel.org;
> hverkuil-cisco@xs4all.nl; nicolas.dufresne@collabora.com;
> bob.beckett@collabora.com
> Cc: linux-media@vger.kernel.org; linux-kernel@vger.kernel.org; lafley.kim
> <lafley.kim@chipsnmedia.com>; hverkuil@xs4all.nl; Nas Chung
> <nas.chung@chipsnmedia.com>
> Subject: Re: [PATCH v0 0/4] bug fixes
>
> Hi Jackson,
>
> On 6/3/26 21:01, Jackson.lee wrote:
> > From: Jackson Lee <jackson.lee@chipsnmedia.com>
> >
> > A few independent fixes for the Wave5 VPU driver, covering decode
> > setup, m2m scheduling and stop_streaming robustness.
>
> This series appears to fix some issues in v4l2-compliance report, can you
> add the updated report in the next iteration of this series to make sure
> everything is now fixed with latest v4l2-compliance tag?
I'll add the test report in the next version of the patch series.
Thanks
>
> Best,
> Brandon
>
> >
> > Jackson Lee (4):
> > media: chips-media: wave5: Guard bit depth check with
> > initial_info_obtained
> > media: chips-media: wave5: Set inst->std during default format
> > initialization
> > media: chips-media: wave5: avoid skipping device_run while VPU has
> > work
> > media: chips-media: wave5: Add interrupt timeout while
> > stop_streaming
> >
> > .../chips-media/wave5/wave5-vpu-dec.c | 20 +++++++++++++++----
> > .../chips-media/wave5/wave5-vpu-enc.c | 6 ++++--
> > .../chips-media/wave5/wave5-vpuconfig.h | 2 +-
> > 3 files changed, 21 insertions(+), 7 deletions(-)
> >
^ permalink raw reply [flat|nested] 7+ messages in thread