[PATCH v1 3/9] media: chips-media: wave5: wait before retrying a refused flush
From: Jackson.lee
Date: Tue Oct 06 2026 - 22:02:50 EST
From: Jackson Lee <jackson.lee@xxxxxxxxxxxxxxx>
wave5_vpu_flush_instance() repeats FLUSH until it is accepted but never
waits between attempts, so the whole retry budget is spent in a few hundred
microseconds - far less than a large frame takes to decode. A flush issued
while a picture is in flight is refused every time and gives up:
Flush of DECODER instance with id: 0 timed out!
streamoff_output() then returns -ETIMEDOUT without resetting the ring
buffer and the instance never decodes again.
Sleep 1-2 ms between attempts, and only use dec_info when the call that
filled it succeeded: otherwise index_frame_display would set a display flag
on an arbitrary frame buffer. With a flushing seek every 500 ms the decoder
stopped after 519 frames before this change and ran past 2072 with it.
Fixes: 45d1a2b93277 ("media: chips-media: wave5: Add vpuapi layer")
Fixes: a2c75e964e51 ("media: chips-media: wave5: Fix a hang after seeking")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jackson Lee <jackson.lee@xxxxxxxxxxxxxxx>
Signed-off-by: Nas Chung <nas.chung@xxxxxxxxxxxxxxx>
---
.../platform/chips-media/wave5/wave5-vpuapi.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
index f77abd5e122a..397da200a9ed 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
@@ -78,13 +78,27 @@ int wave5_vpu_flush_instance(struct vpu_instance *inst)
return -ETIMEDOUT;
} else if (ret == -EBUSY) {
struct dec_output_info dec_info;
+ int info_ret;
mutex_unlock(&inst->dev->hw_lock);
- wave5_vpu_dec_get_output_info(inst, &dec_info);
+ info_ret = wave5_vpu_dec_get_output_info(inst, &dec_info);
+ if (info_ret) {
+ /*
+ * A flush is refused while a picture is still
+ * being decoded, and there is no result to
+ * collect yet either. Retrying straight away
+ * spends the whole retry budget in microseconds,
+ * far less than a large frame takes to decode, so
+ * the flush times out and streamoff_output() bails
+ * out before resetting the ring buffer. Give the
+ * decode time to land instead.
+ */
+ usleep_range(1000, 2000);
+ }
mutex_ret = mutex_lock_interruptible(&inst->dev->hw_lock);
if (mutex_ret)
return mutex_ret;
- if (dec_info.index_frame_display >= 0) {
+ if (!info_ret && dec_info.index_frame_display >= 0) {
mutex_unlock(&inst->dev->hw_lock);
wave5_vpu_dec_set_disp_flag(inst, dec_info.index_frame_display);
mutex_ret = mutex_lock_interruptible(&inst->dev->hw_lock);
--
2.43.0