| From 8c5a74a24cbbba9142e38c463c96435d316149ce Mon Sep 17 00:00:00 2001 |
| From: Jackson Lee <jackson.lee@chipsnmedia.com> |
| Date: Fri, 26 Jun 2026 10:22:28 +0900 |
| Subject: media: chips-media: wave5: avoid skipping device_run while VPU has work |
| |
| From: Jackson Lee <jackson.lee@chipsnmedia.com> |
| |
| commit 8c5a74a24cbbba9142e38c463c96435d316149ce upstream. |
| |
| 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> |
| 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| .../media/platform/chips-media/wave5/wave5-vpu-dec.c | 10 +++++++--- |
| 1 file changed, 7 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..6c6e86b09b40 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,13 @@ 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; |
| + 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.55.0 |
| |