[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190620061547.8664-2-kraxel@redhat.com>
Date: Thu, 20 Jun 2019 08:15:45 +0200
From: Gerd Hoffmann <kraxel@...hat.com>
To: dri-devel@...ts.freedesktop.org
Cc: Gerd Hoffmann <kraxel@...hat.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <maxime.ripard@...tlin.com>,
Sean Paul <sean@...rly.run>, David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH 1/3] drm: add mmap() to drm_gem_object_funcs
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@...hat.com>
---
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
Powered by blists - more mailing lists