media: venus: use contig vb2 ops
authorAlexandre Courbot <acourbot@chromium.org>
Mon, 14 Dec 2020 12:57:03 +0000 (13:57 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 12 Jan 2021 17:26:17 +0000 (18:26 +0100)
This driver uses the SG vb2 ops, but effectively only ever accesses the
first entry of the SG table, indicating that it expects a flat layout.
Switch it to use the contiguous ops to make sure this expected invariant
is always enforced. Since the device is supposed to be behind an IOMMU
this should have little to none practical consequences beyond making the
driver not rely on a particular behavior of the SG implementation.

Reported-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/Kconfig
drivers/media/platform/qcom/venus/helpers.c
drivers/media/platform/qcom/venus/vdec.c
drivers/media/platform/qcom/venus/venc.c

index e419b18..f0c6295 100644 (file)
@@ -548,7 +548,7 @@ config VIDEO_QCOM_VENUS
        depends on INTERCONNECT || !INTERCONNECT
        select QCOM_MDT_LOADER if ARCH_QCOM
        select QCOM_SCM if ARCH_QCOM
-       select VIDEOBUF2_DMA_SG
+       select VIDEOBUF2_DMA_CONTIG
        select V4L2_MEM2MEM_DEV
        help
          This is a V4L2 driver for Qualcomm Venus video accelerator
index 50439eb..859d260 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/mutex.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
-#include <media/videobuf2-dma-sg.h>
+#include <media/videobuf2-dma-contig.h>
 #include <media/v4l2-mem2mem.h>
 #include <asm/div64.h>
 
@@ -1284,14 +1284,9 @@ int venus_helper_vb2_buf_init(struct vb2_buffer *vb)
        struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue);
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct venus_buffer *buf = to_venus_buffer(vbuf);
-       struct sg_table *sgt;
-
-       sgt = vb2_dma_sg_plane_desc(vb, 0);
-       if (!sgt)
-               return -EFAULT;
 
        buf->size = vb2_plane_size(vb, 0);
-       buf->dma_addr = sg_dma_address(sgt->sgl);
+       buf->dma_addr = vb2_dma_contig_plane_dma_addr(vb, 0);
 
        if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
                list_add_tail(&buf->reg_list, &inst->registeredbufs);
index 8488411..3fb277c 100644 (file)
@@ -13,7 +13,7 @@
 #include <media/v4l2-event.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-mem2mem.h>
-#include <media/videobuf2-dma-sg.h>
+#include <media/videobuf2-dma-contig.h>
 
 #include "hfi_venus_io.h"
 #include "hfi_parser.h"
@@ -1461,7 +1461,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        src_vq->io_modes = VB2_MMAP | VB2_DMABUF;
        src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
        src_vq->ops = &vdec_vb2_ops;
-       src_vq->mem_ops = &vb2_dma_sg_memops;
+       src_vq->mem_ops = &vb2_dma_contig_memops;
        src_vq->drv_priv = inst;
        src_vq->buf_struct_size = sizeof(struct venus_buffer);
        src_vq->allow_zero_bytesused = 1;
@@ -1475,7 +1475,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        dst_vq->io_modes = VB2_MMAP | VB2_DMABUF;
        dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
        dst_vq->ops = &vdec_vb2_ops;
-       dst_vq->mem_ops = &vb2_dma_sg_memops;
+       dst_vq->mem_ops = &vb2_dma_contig_memops;
        dst_vq->drv_priv = inst;
        dst_vq->buf_struct_size = sizeof(struct venus_buffer);
        dst_vq->allow_zero_bytesused = 1;
index 1c61602..a09550c 100644 (file)
@@ -10,7 +10,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <media/v4l2-mem2mem.h>
-#include <media/videobuf2-dma-sg.h>
+#include <media/videobuf2-dma-contig.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-event.h>
 #include <media/v4l2-ctrls.h>
@@ -1001,7 +1001,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        src_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
        src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
        src_vq->ops = &venc_vb2_ops;
-       src_vq->mem_ops = &vb2_dma_sg_memops;
+       src_vq->mem_ops = &vb2_dma_contig_memops;
        src_vq->drv_priv = inst;
        src_vq->buf_struct_size = sizeof(struct venus_buffer);
        src_vq->allow_zero_bytesused = 1;
@@ -1017,7 +1017,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
        dst_vq->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
        dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
        dst_vq->ops = &venc_vb2_ops;
-       dst_vq->mem_ops = &vb2_dma_sg_memops;
+       dst_vq->mem_ops = &vb2_dma_contig_memops;
        dst_vq->drv_priv = inst;
        dst_vq->buf_struct_size = sizeof(struct venus_buffer);
        dst_vq->allow_zero_bytesused = 1;