drm/shmem-helpers: Redirect mmap for imported dma-buf
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 11 May 2020 09:35:52 +0000 (11:35 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 3 Jun 2020 13:07:40 +0000 (15:07 +0200)
Currently this seems to work by converting the sgt into a pages array,
and then treating it like a native object. Do the right thing and
redirect mmap to the exporter.

With this nothing is calling get_pages anymore on imported dma-buf,
and we can start to remove the use of the ->pages array for that case.

v2: Rebase

Tested-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200511093554.211493-8-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_gem_shmem_helper.c

index 0aac83ed9f5d54bc1c18fc6f06dc977ff354c6de..afe9668f1750c46c328c73f6465e62cfc1799655 100644 (file)
@@ -551,6 +551,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
        /* Remove the fake offset */
        vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
 
+       if (obj->import_attach)
+               return dma_buf_mmap(obj->dma_buf, vma, 0);
+
        shmem = to_drm_gem_shmem_obj(obj);
 
        ret = drm_gem_shmem_get_pages(shmem);