Merge tag 'drm-misc-next-2020-10-27' of git://anongit.freedesktop.org/drm/drm-misc...
[sfrench/cifs-2.6.git] / drivers / media / common / videobuf2 / videobuf2-vmalloc.c
index bf5ac63a5742b7437b53855a75eaf669db4239bb..83f95258ec8c68e4443d898a356786bd8a4f7e50 100644 (file)
@@ -314,11 +314,13 @@ static void vb2_vmalloc_dmabuf_ops_release(struct dma_buf *dbuf)
        vb2_vmalloc_put(dbuf->priv);
 }
 
-static void *vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf)
+static int vb2_vmalloc_dmabuf_ops_vmap(struct dma_buf *dbuf, struct dma_buf_map *map)
 {
        struct vb2_vmalloc_buf *buf = dbuf->priv;
 
-       return buf->vaddr;
+       dma_buf_map_set_vaddr(map, buf->vaddr);
+
+       return 0;
 }
 
 static int vb2_vmalloc_dmabuf_ops_mmap(struct dma_buf *dbuf,
@@ -370,26 +372,33 @@ static struct dma_buf *vb2_vmalloc_get_dmabuf(void *buf_priv, unsigned long flag
 static int vb2_vmalloc_map_dmabuf(void *mem_priv)
 {
        struct vb2_vmalloc_buf *buf = mem_priv;
+       struct dma_buf_map map;
+       int ret;
 
-       buf->vaddr = dma_buf_vmap(buf->dbuf);
+       ret = dma_buf_vmap(buf->dbuf, &map);
+       if (ret)
+               return -EFAULT;
+       buf->vaddr = map.vaddr;
 
-       return buf->vaddr ? 0 : -EFAULT;
+       return 0;
 }
 
 static void vb2_vmalloc_unmap_dmabuf(void *mem_priv)
 {
        struct vb2_vmalloc_buf *buf = mem_priv;
+       struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);
 
-       dma_buf_vunmap(buf->dbuf, buf->vaddr);
+       dma_buf_vunmap(buf->dbuf, &map);
        buf->vaddr = NULL;
 }
 
 static void vb2_vmalloc_detach_dmabuf(void *mem_priv)
 {
        struct vb2_vmalloc_buf *buf = mem_priv;
+       struct dma_buf_map map = DMA_BUF_MAP_INIT_VADDR(buf->vaddr);
 
        if (buf->vaddr)
-               dma_buf_vunmap(buf->dbuf, buf->vaddr);
+               dma_buf_vunmap(buf->dbuf, &map);
 
        kfree(buf);
 }