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

dma-buf/heaps: 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
solved by moving the lock down to exporters. This patch prepares dma-buf
heaps for the locking policy update.

Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230529223935.2672495-3-dmitry.osipenko@collabora.com

-6
-3
drivers/dma-buf/heaps/cma_heap.c
··· 13 13 #include <linux/dma-buf.h> 14 14 #include <linux/dma-heap.h> 15 15 #include <linux/dma-map-ops.h> 16 - #include <linux/dma-resv.h> 17 16 #include <linux/err.h> 18 17 #include <linux/highmem.h> 19 18 #include <linux/io.h> ··· 181 182 static int cma_heap_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) 182 183 { 183 184 struct cma_heap_buffer *buffer = dmabuf->priv; 184 - 185 - dma_resv_assert_held(dmabuf->resv); 186 185 187 186 if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) 188 187 return -EINVAL;
-3
drivers/dma-buf/heaps/system_heap.c
··· 13 13 #include <linux/dma-buf.h> 14 14 #include <linux/dma-mapping.h> 15 15 #include <linux/dma-heap.h> 16 - #include <linux/dma-resv.h> 17 16 #include <linux/err.h> 18 17 #include <linux/highmem.h> 19 18 #include <linux/mm.h> ··· 199 200 unsigned long addr = vma->vm_start; 200 201 struct sg_page_iter piter; 201 202 int ret; 202 - 203 - dma_resv_assert_held(dmabuf->resv); 204 203 205 204 for_each_sgtable_page(table, &piter, vma->vm_pgoff) { 206 205 struct page *page = sg_page_iter_page(&piter);