[PATCH v2 10/20] drm/ast: implement mmap access managament

David Herrmann dh.herrmann at gmail.com
Sun Jul 7 10:17:26 PDT 2013


Correctly allow and revoke buffer access on each open/close via the new
VMA offset manager.

Cc: Dave Airlie <airlied at redhat.com>
Signed-off-by: David Herrmann <dh.herrmann at gmail.com>
---
 drivers/gpu/drm/ast/ast_drv.c  |  2 ++
 drivers/gpu/drm/ast/ast_drv.h  |  4 ++++
 drivers/gpu/drm/ast/ast_main.c | 15 +++++++++++++++
 3 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index df0d0a0..1060f9c 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -214,6 +214,8 @@ static struct drm_driver driver = {
 
 	.gem_init_object = ast_gem_init_object,
 	.gem_free_object = ast_gem_free_object,
+	.gem_open_object = ast_gem_open_object,
+	.gem_close_object = ast_gem_close_object,
 	.dumb_create = ast_dumb_create,
 	.dumb_map_offset = ast_dumb_mmap_offset,
 	.dumb_destroy = ast_dumb_destroy,
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 622d4ae..f35946b 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -328,6 +328,10 @@ extern int ast_dumb_destroy(struct drm_file *file,
 
 extern int ast_gem_init_object(struct drm_gem_object *obj);
 extern void ast_gem_free_object(struct drm_gem_object *obj);
+extern int ast_gem_open_object(struct drm_gem_object *obj,
+			       struct drm_file *file_priv);
+extern void ast_gem_close_object(struct drm_gem_object *obj,
+				 struct drm_file *file_priv);
 extern int ast_dumb_mmap_offset(struct drm_file *file,
 				struct drm_device *dev,
 				uint32_t handle,
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index c195dc2..f9efcf8 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -484,6 +484,21 @@ void ast_gem_free_object(struct drm_gem_object *obj)
 	ast_bo_unref(&ast_bo);
 }
 
+int ast_gem_open_object(struct drm_gem_object *obj,
+			struct drm_file *file_priv)
+{
+	struct ast_bo *ast_bo = gem_to_ast_bo(obj);
+
+	return drm_vma_node_allow(&ast_bo->bo.vma_node, file_priv->filp);
+}
+
+void ast_gem_close_object(struct drm_gem_object *obj,
+			  struct drm_file *file_priv)
+{
+	struct ast_bo *ast_bo = gem_to_ast_bo(obj);
+
+	drm_vma_node_revoke(&ast_bo->bo.vma_node, file_priv->filp);
+}
 
 static inline u64 ast_bo_mmap_offset(struct ast_bo *bo)
 {
-- 
1.8.3.2



More information about the dri-devel mailing list