diff mbox

[v2,12/20] drm/mgag200: implement mmap access managament

Message ID 1373217456-32282-13-git-send-email-dh.herrmann@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Herrmann July 7, 2013, 5:17 p.m. UTC
Correctly allow and revoke buffer access on each open/close via the new
VMA offset manager.

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/mgag200/mgag200_drv.c  |  2 ++
 drivers/gpu/drm/mgag200/mgag200_drv.h  |  4 ++++
 drivers/gpu/drm/mgag200/mgag200_main.c | 15 +++++++++++++++
 3 files changed, 21 insertions(+)
diff mbox

Patch

diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c
index 122b571..d26a244 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -102,6 +102,8 @@  static struct drm_driver driver = {
 
 	.gem_init_object = mgag200_gem_init_object,
 	.gem_free_object = mgag200_gem_free_object,
+	.gem_open_object = mgag200_gem_open_object,
+	.gem_close_object = mgag200_gem_close_object,
 	.dumb_create = mgag200_dumb_create,
 	.dumb_map_offset = mgag200_dumb_mmap_offset,
 	.dumb_destroy = mgag200_dumb_destroy,
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h
index 12e2499..4e674be 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.h
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.h
@@ -268,6 +268,10 @@  int mgag200_dumb_destroy(struct drm_file *file,
 			 struct drm_device *dev,
 			 uint32_t handle);
 void mgag200_gem_free_object(struct drm_gem_object *obj);
+int mgag200_gem_open_object(struct drm_gem_object *obj,
+			    struct drm_file *file_priv);
+void mgag200_gem_close_object(struct drm_gem_object *obj,
+			      struct drm_file *file_priv);
 int
 mgag200_dumb_mmap_offset(struct drm_file *file,
 			 struct drm_device *dev,
diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 1a75ea3..26bee28 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -346,6 +346,21 @@  void mgag200_gem_free_object(struct drm_gem_object *obj)
 	mgag200_bo_unref(&mgag200_bo);
 }
 
+int mgag200_gem_open_object(struct drm_gem_object *obj,
+			    struct drm_file *file_priv)
+{
+	struct mgag200_bo *bo = gem_to_mga_bo(obj);
+
+	return drm_vma_node_allow(&bo->bo.vma_node, file_priv->filp);
+}
+
+void mgag200_gem_close_object(struct drm_gem_object *obj,
+			      struct drm_file *file_priv)
+{
+	struct mgag200_bo *bo = gem_to_mga_bo(obj);
+
+	drm_vma_node_revoke(&bo->bo.vma_node, file_priv->filp);
+}
 
 static inline u64 mgag200_bo_mmap_offset(struct mgag200_bo *bo)
 {