drm/exynos: support mmap from dma-buf
authorJoonyoung Shim <jy0922.shim@samsung.com>
Tue, 22 Dec 2015 00:50:10 +0000 (09:50 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 31 Mar 2016 07:59:38 +0000 (16:59 +0900)
This allows exported dma-bufs to be mapped in exynos drm.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
[jy0922.shim: Be backported from upstream but not posted]

Change-Id: Ic3bf3153707e2e57c1d930487428b6a83b96d658

drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
drivers/gpu/drm/exynos/exynos_drm_gem.c
drivers/gpu/drm/exynos/exynos_drm_gem.h

index cd485c091b30dcf3219ef1edc778a1aa17c4fdfa..0bb4c9dd87ac0b6a7276a0be8b10e25ebc123355 100644 (file)
@@ -165,7 +165,18 @@ static void exynos_gem_dmabuf_kunmap(struct dma_buf *dma_buf,
 static int exynos_gem_dmabuf_mmap(struct dma_buf *dma_buf,
        struct vm_area_struct *vma)
 {
-       return -ENOTTY;
+
+       struct drm_gem_object *obj = dma_buf->priv;
+       struct drm_device *dev = obj->dev;
+       int ret;
+
+       mutex_lock(&dev->struct_mutex);
+       ret = drm_gem_mmap_obj(obj, obj->size, vma);
+       mutex_unlock(&dev->struct_mutex);
+       if (ret < 0)
+               return ret;
+
+       return exynos_drm_gem_mmap_obj(obj, vma);
 }
 
 static struct dma_buf_ops exynos_dmabuf_ops = {
index 81fb8a5d6ae7c08fc54fe89fc85c573312a76403..a1c573990294db41a5d3abf401add7f9224f5ea4 100644 (file)
@@ -622,20 +622,12 @@ int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        return convert_to_vm_err_msg(ret);
 }
 
-int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
+int exynos_drm_gem_mmap_obj(struct drm_gem_object *obj,
+                           struct vm_area_struct *vma)
 {
-       struct exynos_drm_gem_obj *exynos_gem_obj;
-       struct drm_gem_object *obj;
+       struct exynos_drm_gem_obj *exynos_gem_obj = to_exynos_gem_obj(obj);
        int ret;
 
-       /* set vm_area_struct. */
-       ret = drm_gem_mmap(filp, vma);
-       if (ret < 0) {
-               DRM_ERROR("failed to mmap.\n");
-               return ret;
-       }
-
-       obj = vma->vm_private_data;
        exynos_gem_obj = to_exynos_gem_obj(obj);
 
        ret = check_gem_flags(exynos_gem_obj->flags);
@@ -655,3 +647,20 @@ err_close_vm:
 
        return ret;
 }
+
+int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+       struct drm_gem_object *obj;
+       int ret;
+
+       /* set vm_area_struct. */
+       ret = drm_gem_mmap(filp, vma);
+       if (ret < 0) {
+               DRM_ERROR("failed to mmap.\n");
+               return ret;
+       }
+
+       obj = vma->vm_private_data;
+
+       return exynos_drm_gem_mmap_obj(obj, vma);
+}
index 8c9f84b6af21640094495a022c3d43ef75a6b616..9ae862ec3bff77928b2de7812e749a3e622afe47 100644 (file)
@@ -148,6 +148,9 @@ int exynos_drm_gem_dumb_map_offset(struct drm_file *file_priv,
 /* page fault handler and mmap fault address(virtual) to physical memory. */
 int exynos_drm_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 
+int exynos_drm_gem_mmap_obj(struct drm_gem_object *obj,
+                           struct vm_area_struct *vma);
+
 /* set vm_flags and we can change the vm attribute to other one at here. */
 int exynos_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);