Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: videobuf2: Don't assert held reservation lock for dma-buf mmapping

Don't assert held dma-buf reservation lock on memory mapping of exported
buffer.

We're going to change dma-buf mmap() locking policy such that exporters
will have to handle the lock. The previous locking policy caused deadlock
problem for DRM drivers in a case of self-imported dma-bufs once these
drivers are moved to use reservation lock universally. The problem is
solved by moving the lock down to exporters. This patch prepares videobuf2
for the locking policy update.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230529223935.2672495-2-dmitry.osipenko@collabora.com

-9
-3
drivers/media/common/videobuf2/videobuf2-dma-contig.c
··· 11 11 */ 12 12 13 13 #include <linux/dma-buf.h> 14 - #include <linux/dma-resv.h> 15 14 #include <linux/module.h> 16 15 #include <linux/refcount.h> 17 16 #include <linux/scatterlist.h> ··· 455 456 static int vb2_dc_dmabuf_ops_mmap(struct dma_buf *dbuf, 456 457 struct vm_area_struct *vma) 457 458 { 458 - dma_resv_assert_held(dbuf->resv); 459 - 460 459 return vb2_dc_mmap(dbuf->priv, vma); 461 460 } 462 461
-3
drivers/media/common/videobuf2/videobuf2-dma-sg.c
··· 10 10 * the Free Software Foundation. 11 11 */ 12 12 13 - #include <linux/dma-resv.h> 14 13 #include <linux/module.h> 15 14 #include <linux/mm.h> 16 15 #include <linux/refcount.h> ··· 497 498 static int vb2_dma_sg_dmabuf_ops_mmap(struct dma_buf *dbuf, 498 499 struct vm_area_struct *vma) 499 500 { 500 - dma_resv_assert_held(dbuf->resv); 501 - 502 501 return vb2_dma_sg_mmap(dbuf->priv, vma); 503 502 } 504 503
-3
drivers/media/common/videobuf2/videobuf2-vmalloc.c
··· 10 10 * the Free Software Foundation. 11 11 */ 12 12 13 - #include <linux/dma-resv.h> 14 13 #include <linux/io.h> 15 14 #include <linux/module.h> 16 15 #include <linux/mm.h> ··· 318 319 static int vb2_vmalloc_dmabuf_ops_mmap(struct dma_buf *dbuf, 319 320 struct vm_area_struct *vma) 320 321 { 321 - dma_resv_assert_held(dbuf->resv); 322 - 323 322 return vb2_vmalloc_mmap(dbuf->priv, vma); 324 323 } 325 324