[PATCH 03/15] drm: Add |struct drm_gem_ttm_object| callbacks for |struct drm_driver|

Thomas Zimmermann tzimmermann at suse.de
Mon Apr 8 09:21:32 UTC 2019


The provided helpers can be used for the respective callback functions
in |struct drm_driver|.

Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
 drivers/gpu/drm/drm_gem_ttm_helper.c | 39 ++++++++++++++++++++++++++++
 include/drm/drm_gem_ttm_helper.h     | 10 +++++++
 2 files changed, 49 insertions(+)

diff --git a/drivers/gpu/drm/drm_gem_ttm_helper.c b/drivers/gpu/drm/drm_gem_ttm_helper.c
index af3487137822..d4950517e357 100644
--- a/drivers/gpu/drm/drm_gem_ttm_helper.c
+++ b/drivers/gpu/drm/drm_gem_ttm_helper.c
@@ -404,3 +404,42 @@ int drm_gem_ttm_bo_driver_verify_access(struct ttm_buffer_object *bo,
 					  filp->private_data);
 }
 EXPORT_SYMBOL(drm_gem_ttm_bo_driver_verify_access);
+
+/*
+ * Helpers for struct drm_driver
+ */
+
+/**
+ * drm_gem_ttm_driver_gem_free_object_unlocked() - \
+	Implements struct drm_driver.gem_free_object_unlocked
+ */
+void drm_gem_ttm_driver_gem_free_object_unlocked(struct drm_gem_object *gem)
+{
+	struct drm_gem_ttm_object *gbo = drm_gem_ttm_of_gem(gem);
+	drm_gem_ttm_put(gbo);
+}
+EXPORT_SYMBOL(drm_gem_ttm_driver_gem_free_object_unlocked);
+
+/**
+ * drm_gem_ttm_driver_dumb_mmap_offset() - \
+	Implements struct drm_driver.dumb_mmap_offset
+ */
+int drm_gem_ttm_driver_dumb_mmap_offset(struct drm_file *file,
+					struct drm_device *dev,
+		     			uint32_t handle, uint64_t *offset)
+{
+	struct drm_gem_object *gem;
+	struct drm_gem_ttm_object *gbo;
+
+	gem = drm_gem_object_lookup(file, handle);
+	if (!gem)
+		return -ENOENT;
+
+	gbo = drm_gem_ttm_of_gem(gem);
+	*offset = drm_gem_ttm_mmap_offset(gbo);
+
+	drm_gem_object_put_unlocked(gem);
+
+	return 0;
+}
+EXPORT_SYMBOL(drm_gem_ttm_driver_dumb_mmap_offset);
diff --git a/include/drm/drm_gem_ttm_helper.h b/include/drm/drm_gem_ttm_helper.h
index c1c4bd757f4b..edc2093588ff 100644
--- a/include/drm/drm_gem_ttm_helper.h
+++ b/include/drm/drm_gem_ttm_helper.h
@@ -98,4 +98,14 @@ void drm_gem_ttm_bo_driver_evict_flags(struct ttm_buffer_object *bo,
 int drm_gem_ttm_bo_driver_verify_access(struct ttm_buffer_object *bo,
 					struct file *filp);
 
+/*
+ * Helpers for struct drm_driver
+ */
+
+void drm_gem_ttm_driver_gem_free_object_unlocked(struct drm_gem_object *gem);
+
+int drm_gem_ttm_driver_dumb_mmap_offset(struct drm_file *file,
+					struct drm_device *dev,
+		     			uint32_t handle, uint64_t *offset);
+
 #endif
-- 
2.21.0



More information about the dri-devel mailing list