Re: [PATCH v2 6/9] media: camss: video: check that a buffer is DMA contiguous and add a prepare hook
From: Bryan O'Donoghue
Date: Wed Oct 28 2026 - 08:36:21 EST
On 28/10/2026 09:30, Qianhui Xu wrote:
The write master of the newer VFE generations can only be programmed with
a buffer whose payload is physically contiguous, because the frame
increment registers describe one linear address range. Check that the DMA
mapping of every plane is contiguous for at least sizeimage bytes and
reject the buffer otherwise, instead of silently writing past the end of
the first scatterlist entry.
Also let the SoC code add its own alignment requirements to a queued
buffer through a new prepare_buffer() video operation, which runs after
the generic checks.
Signed-off-by: Qianhui Xu<xiaqinghuan@xxxxxxxxxxxxxxxx>
---
.../media/platform/qcom/camss/camss-video.c | 18 +++++++++++++++++-
.../media/platform/qcom/camss/camss-video.h | 1 +
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 0852eb6f1..027cf024f 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -155,7 +155,10 @@ static int video_buf_init(struct vb2_buffer *vb)
const struct v4l2_pix_format_mplane *format =
&video->active_fmt.fmt.pix_mp;
struct sg_table *sgt;
- unsigned int i;
+ struct scatterlist *sg;
+ dma_addr_t end;
+ unsigned int i, j;
+ size_t contiguous;
for (i = 0; i < format->num_planes; i++) {
sgt = vb2_dma_sg_plane_desc(vb, i);
@@ -163,6 +166,16 @@ static int video_buf_init(struct vb2_buffer *vb)
return -EFAULT;
buffer->addr[i] = sg_dma_address(sgt->sgl);
+ end = buffer->addr[i];
+ contiguous = 0;
+ for_each_sgtable_dma_sg(sgt, sg, j) {
+ if (sg_dma_address(sg) != end)
+ break;
+ contiguous += sg_dma_len(sg);
+ end += sg_dma_len(sg);
+ }
+ if (contiguous < format->plane_fmt[i].sizeimage)
+ return -EINVAL;
}
Is it really the case we can only do physically contiguous on sm8750 ?
Hrmm, first I've heard of this, it would be a gigantic step backwards too.
Can you cite some sources to prove this out ?
---
bod