Commit d078fd9b authored by Dmitry Osipenko's avatar Dmitry Osipenko

dma-buf: Move dma_buf_mmap() to dynamic locking specification

Move dma_buf_mmap() function to the dynamic locking specification by
taking the reservation lock. Neither of the today's drivers take the
reservation lock within the mmap() callback, hence it's safe to enforce
the locking.
Acked-by: default avatarSumit Semwal <sumit.semwal@linaro.org>
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221017172229.42269-19-dmitry.osipenko@collabora.com
parent 47e982d5
...@@ -1390,6 +1390,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_end_cpu_access, DMA_BUF); ...@@ -1390,6 +1390,8 @@ EXPORT_SYMBOL_NS_GPL(dma_buf_end_cpu_access, DMA_BUF);
int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
unsigned long pgoff) unsigned long pgoff)
{ {
int ret;
if (WARN_ON(!dmabuf || !vma)) if (WARN_ON(!dmabuf || !vma))
return -EINVAL; return -EINVAL;
...@@ -1410,7 +1412,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma, ...@@ -1410,7 +1412,11 @@ int dma_buf_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma,
vma_set_file(vma, dmabuf->file); vma_set_file(vma, dmabuf->file);
vma->vm_pgoff = pgoff; vma->vm_pgoff = pgoff;
return dmabuf->ops->mmap(dmabuf, vma); dma_resv_lock(dmabuf->resv, NULL);
ret = dmabuf->ops->mmap(dmabuf, vma);
dma_resv_unlock(dmabuf->resv);
return ret;
} }
EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, DMA_BUF); EXPORT_SYMBOL_NS_GPL(dma_buf_mmap, DMA_BUF);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment