[PATCH 02/15] drm: Add |struct drm_gem_ttm_object| callbacks for |struct ttm_bo_driver|

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


The provided helpers can be used for the respective callback functions
in |struct ttm_bo_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 d52d3c439917..af3487137822 100644
--- a/drivers/gpu/drm/drm_gem_ttm_helper.c
+++ b/drivers/gpu/drm/drm_gem_ttm_helper.c
@@ -365,3 +365,42 @@ bool drm_is_gem_ttm(struct ttm_buffer_object *bo)
 	return (bo->destroy == ttm_buffer_object_destroy);
 }
 EXPORT_SYMBOL(drm_is_gem_ttm);
+
+/*
+ * Helpers for struct ttm_bo_driver
+ */
+
+/**
+ * drm_gem_ttm_bo_driver_evict_flags - \
+	Implements struct ttm_bo_driver.evict_flags
+ */
+void drm_gem_ttm_bo_driver_evict_flags(struct ttm_buffer_object *bo,
+				       struct ttm_placement *pl)
+{
+	struct drm_gem_ttm_object *gbo;
+
+	/* TODO: This test used to be performed by drivers, but can
+	 * this actually happen? If so, should we put the check into
+	 * drm_gem_ttm_of_gem()? */
+	if (!drm_is_gem_ttm(bo))
+		return;
+
+	gbo = drm_gem_ttm_of_bo(bo);
+	drm_gem_ttm_placement(gbo, TTM_PL_FLAG_SYSTEM);
+	*pl = gbo->placement;
+}
+EXPORT_SYMBOL(drm_gem_ttm_bo_driver_evict_flags);
+
+/**
+ * drm_gem_ttm_bo_driver_verify_access - \
+	Implements struct ttm_bo_driver.verify_access
+ */
+int drm_gem_ttm_bo_driver_verify_access(struct ttm_buffer_object *bo,
+					struct file *filp)
+{
+	struct drm_gem_ttm_object *gbo = drm_gem_ttm_of_bo(bo);
+
+	return drm_vma_node_verify_access(&gbo->gem.vma_node,
+					  filp->private_data);
+}
+EXPORT_SYMBOL(drm_gem_ttm_bo_driver_verify_access);
diff --git a/include/drm/drm_gem_ttm_helper.h b/include/drm/drm_gem_ttm_helper.h
index 662dcb8d4770..c1c4bd757f4b 100644
--- a/include/drm/drm_gem_ttm_helper.h
+++ b/include/drm/drm_gem_ttm_helper.h
@@ -88,4 +88,14 @@ void drm_gem_ttm_kunmap(struct drm_gem_ttm_object *gbo);
 
 bool drm_is_gem_ttm(struct ttm_buffer_object *bo);
 
+/*
+ * Helpers for struct ttm_bo_driver
+ */
+
+void drm_gem_ttm_bo_driver_evict_flags(struct ttm_buffer_object *bo,
+				       struct ttm_placement *pl);
+
+int drm_gem_ttm_bo_driver_verify_access(struct ttm_buffer_object *bo,
+					struct file *filp);
+
 #endif
-- 
2.21.0



More information about the dri-devel mailing list