[PATCH v4 04/18] media: verisilicon: Copy the buffer metadata before a job can fail

From: Arun Iyengar via B4 Relay

Date: Sun Dec 06 2026 - 00:58:02 EST


From: Arun Iyengar <aiyengar1990@xxxxxxxxx>

device_run() copies the OUTPUT buffer metadata to the CAPTURE buffer
only after pm_runtime_resume_and_get(). If that fails, the CAPTURE
buffer is returned with the error flag and a stale timestamp, so
userspace that matches buffers by timestamp drops the wrong frame.

Copy the metadata first.

Fixes: 6c2eb77bf566 ("media: hantro: Move copy_metadata() before doing a decode operation")
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/media/platform/verisilicon/hantro_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
index fa867168b947..40ff60dd098a 100644
--- a/drivers/media/platform/verisilicon/hantro_drv.c
+++ b/drivers/media/platform/verisilicon/hantro_drv.c
@@ -202,12 +202,12 @@ static void device_run(void *priv)
src = hantro_get_src_buf(ctx);
dst = hantro_get_dst_buf(ctx);

+ v4l2_m2m_buf_copy_metadata(src, dst);
+
ret = pm_runtime_resume_and_get(vpu->dev);
if (ret < 0)
goto err_cancel_job;

- v4l2_m2m_buf_copy_metadata(src, dst);
-
ret = ctx->codec_ops->run(ctx);
if (ret)
hantro_job_finish(ctx, VB2_BUF_STATE_ERROR);

--
2.55.0