]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: videobuf2: use sgtable-based scatterlist wrappers
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 7 May 2025 16:09:11 +0000 (18:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:11:18 +0000 (11:11 +0100)
commit a704a3c503ae1cfd9de8a2e2d16a0c9430e98162 upstream.

Use common wrappers operating directly on the struct sg_table objects to
fix incorrect use of scatterlists sync calls. dma_sync_sg_for_*()
functions have to be called with the number of elements originally passed
to dma_map_sg_*() function, not the one returned in sgt->nents.

Fixes: d4db5eb57cab ("media: videobuf2: add begin/end cpu_access callbacks to dma-sg")
CC: stable@vger.kernel.org
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Acked-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/common/videobuf2/videobuf2-dma-sg.c

index 6975a71d740f6d70c139eca739ae665d51007af2..a5aa6a2a028cb2b70667e0960f7a874f7b64a131 100644 (file)
@@ -469,7 +469,7 @@ vb2_dma_sg_dmabuf_ops_begin_cpu_access(struct dma_buf *dbuf,
        struct vb2_dma_sg_buf *buf = dbuf->priv;
        struct sg_table *sgt = buf->dma_sgt;
 
-       dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
+       dma_sync_sgtable_for_cpu(buf->dev, sgt, buf->dma_dir);
        return 0;
 }
 
@@ -480,7 +480,7 @@ vb2_dma_sg_dmabuf_ops_end_cpu_access(struct dma_buf *dbuf,
        struct vb2_dma_sg_buf *buf = dbuf->priv;
        struct sg_table *sgt = buf->dma_sgt;
 
-       dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->nents, buf->dma_dir);
+       dma_sync_sgtable_for_device(buf->dev, sgt, buf->dma_dir);
        return 0;
 }