[PATCH v2 1/5] media: iris: Add dma sync calls for input and output buffers
From: Vishnu Reddy
Date: Tue Aug 18 2026 - 11:56:08 EST
While testing with some higher resolution clips, the venus hardware
triggers a fault due to wrong input data being received. Corruption
was also observed in the captured output when the client dumped it
to a file.
On debugging, found that DMA buffers shared between the CPU and the
venus video hardware/controller are not in sync. CPU writes to an input
buffer can remain in CPU cache without being visible to the video
hardware when it reads the same buffer, so the hardware receives input
data that does not match what the CPU wrote. Likewise, on the capture
path, data written by the video hardware to the output buffer may not
be visible to the CPU, so the client reads stale or partial data,
resulting in corruption.
Add dma sync API calls to synchronize the data between the CPU cache
and the venus hardware/controller.
Signed-off-by: Vishnu Reddy <busanna.reddy@xxxxxxxxxxxxxxxx>
---
drivers/media/platform/qcom/iris/iris_buffer.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
index eb8de60c1177..c7a664426187 100644
--- a/drivers/media/platform/qcom/iris/iris_buffer.c
+++ b/drivers/media/platform/qcom/iris/iris_buffer.c
@@ -585,6 +585,13 @@ int iris_queue_buffer(struct iris_inst *inst, struct iris_buffer *buf)
const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
int ret;
+ if (buf->type == BUF_INPUT)
+ dma_sync_single_for_device(inst->core->dev, buf->device_addr,
+ buf->data_size, DMA_TO_DEVICE);
+ else if (buf->type == BUF_OUTPUT)
+ dma_sync_single_for_cpu(inst->core->dev, buf->device_addr,
+ buf->data_size, DMA_FROM_DEVICE);
+
ret = hfi_ops->session_queue_buf(inst, buf);
if (ret)
return ret;
--
2.34.1