OSDN Git Service

udmabuf: add vmap and vunmap methods to udmabuf_ops
authorLukasz Wiecaszek <lukasz.wiecaszek@googlemail.com>
Thu, 17 Nov 2022 17:18:09 +0000 (18:18 +0100)
committerChristian König <christian.koenig@amd.com>
Fri, 18 Nov 2022 09:57:26 +0000 (10:57 +0100)
commit7ae2e684854cd955eff8daceff84fea33a1c94be
treea01a22ab3e792ecca06d4fc5173e7b87dfb6c7a4
parenta189b2ee938f6b15ad9f95bdef63f95a3a092418
udmabuf: add vmap and vunmap methods to udmabuf_ops

The reason behind that patch is associated with videobuf2 subsystem
(or more genrally with v4l2 framework) and user created
dma buffers (udmabuf). In some circumstances
when dealing with V4L2_MEMORY_DMABUF buffers videobuf2 subsystem
wants to use dma_buf_vmap() method on the attached dma buffer.
As udmabuf does not have .vmap operation implemented,
such dma_buf_vmap() natually fails.

videobuf2_common: __vb2_queue_alloc: allocated 3 buffers, 1 plane(s) each
videobuf2_common: __prepare_dmabuf: buffer for plane 0 changed
videobuf2_common: __prepare_dmabuf: failed to map dmabuf for plane 0
videobuf2_common: __buf_prepare: buffer preparation failed: -14

The patch itself seems to be strighforward.
It adds implementation of .vmap and .vunmap methods
to 'struct dma_buf_ops udmabuf_ops'.
.vmap method itself uses vm_map_ram() to map pages linearly
into the kernel virtual address space.
.vunmap removes mapping created earlier by .vmap.
All locking and 'vmapping counting' is done in dma_buf.c
so it seems to be redundant/unnecessary in .vmap/.vunmap.

Signed-off-by: Lukasz Wiecaszek <lukasz.wiecaszek@gmail.com>
Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221117171810.75637-1-lukasz.wiecaszek@gmail.com
Signed-off-by: Christian König <christian.koenig@amd.com>
drivers/dma-buf/udmabuf.c