[PATCH 1/3] drm: add mmap() to drm_gem_object_funcs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



drm_gem_object_funcs->vm_ops alone can't handle
everything mmap() needs.  Add a new callback for it.

Signed-off-by: Gerd Hoffmann <kraxel@xxxxxxxxxx>
---
 include/drm/drm_gem.h     | 9 +++++++++
 drivers/gpu/drm/drm_gem.c | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index a9121fe66ea2..2e680a065470 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -144,6 +144,15 @@ struct drm_gem_object_funcs {
 	 */
 	void (*vunmap)(struct drm_gem_object *obj, void *vaddr);
 
+	/**
+	 * @mmap:
+	 *
+	 * Called by drm_gem_mmap() for additional checks/setup.
+	 *
+	 * This callback is optional.
+	 */
+	int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
+
 	/**
 	 * @vm_ops:
 	 *
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index a8c4468f03d9..1deae1b70f39 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1192,6 +1192,10 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	ret = drm_gem_mmap_obj(obj, drm_vma_node_size(node) << PAGE_SHIFT,
 			       vma);
 
+	if (ret == 0)
+		if (obj->funcs->mmap)
+			ret = obj->funcs->mmap(obj, vma);
+
 	drm_gem_object_put_unlocked(obj);
 
 	return ret;
-- 
2.18.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux