[PATCH 17/18] drm/ttm: Implement struct ttm_global with struct ttm_global_ref

Thomas Zimmermann tzimmermann at suse.de
Fri Oct 19 08:54:22 UTC 2018


Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
 drivers/gpu/drm/ttm/ttm_global.c | 28 +++++++++++++++-------------
 include/drm/ttm/ttm_global.h     |  5 ++---
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_global.c b/drivers/gpu/drm/ttm/ttm_global.c
index 1e5c2f5eeca0..93d268daf97b 100644
--- a/drivers/gpu/drm/ttm/ttm_global.c
+++ b/drivers/gpu/drm/ttm/ttm_global.c
@@ -129,19 +129,21 @@ static void ttm_global_item_unref(
  * struct ttm_global
  */
 
-static int ttm_global_init_mem(struct drm_global_reference *ref)
+static DEFINE_TTM_GLOBAL_ITEM_ARRAY(global_items);
+
+static int ttm_global_init_mem(struct ttm_global_ref *ref)
 {
 	BUG_ON(!ref->object);
 	return ttm_mem_global_init(ref->object);
 }
 
-static void ttm_global_release_mem(struct drm_global_reference *ref)
+static void ttm_global_release_mem(struct ttm_global_ref *ref)
 {
 	BUG_ON(!ref->object);
 	ttm_mem_global_release(ref->object);
 }
 
-static int ttm_global_init_bo(struct drm_global_reference *ref)
+static int ttm_global_init_bo(struct ttm_global_ref *ref)
 {
 	struct ttm_global *glob =
 		container_of(ref, struct ttm_global, bo_ref);
@@ -150,7 +152,7 @@ static int ttm_global_init_bo(struct drm_global_reference *ref)
 	return ttm_bo_global_init(ref->object, glob->mem_ref.object);
 }
 
-static void ttm_global_release_bo(struct drm_global_reference *ref)
+static void ttm_global_release_bo(struct ttm_global_ref *ref)
 {
 	BUG_ON(!ref->object);
 	ttm_bo_global_release(ref->object);
@@ -160,28 +162,28 @@ int ttm_global_init(struct ttm_global *glob)
 {
 	int ret;
 
-	glob->mem_ref.global_type = DRM_GLOBAL_TTM_MEM;
+	glob->mem_ref.global_type = TTM_GLOBAL_MEM;
 	glob->mem_ref.size = sizeof(struct ttm_mem_global);
 	glob->bo_ref.object = NULL;
 	glob->mem_ref.init = &ttm_global_init_mem;
 	glob->mem_ref.release = &ttm_global_release_mem;
-	ret = drm_global_item_ref(&glob->mem_ref);
+	ret = ttm_global_item_ref(global_items, &glob->mem_ref);
 	if (ret)
 		return ret;
 
-	glob->bo_ref.global_type = DRM_GLOBAL_TTM_BO;
+	glob->bo_ref.global_type = TTM_GLOBAL_BO;
 	glob->bo_ref.size = sizeof(struct ttm_bo_global);
 	glob->bo_ref.object = NULL;
 	glob->bo_ref.init = &ttm_global_init_bo;
 	glob->bo_ref.release = &ttm_global_release_bo;
-	ret = drm_global_item_ref(&glob->bo_ref);
+	ret = ttm_global_item_ref(global_items, &glob->bo_ref);
 	if (ret)
-		goto err_drm_global_item_unref_mem;
+		goto err_ttm_global_item_unref;
 
 	return 0;
 
-err_drm_global_item_unref_mem:
-	drm_global_item_unref(&glob->mem_ref);
+err_ttm_global_item_unref:
+	ttm_global_item_unref(global_items, &glob->mem_ref);
 	return ret;
 }
 
@@ -189,8 +191,8 @@ EXPORT_SYMBOL(ttm_global_init);
 
 void ttm_global_release(struct ttm_global *glob)
 {
-	drm_global_item_unref(&glob->bo_ref);
-	drm_global_item_unref(&glob->mem_ref);
+	ttm_global_item_unref(global_items, &glob->bo_ref);
+	ttm_global_item_unref(global_items, &glob->mem_ref);
 }
 
 EXPORT_SYMBOL(ttm_global_release);
diff --git a/include/drm/ttm/ttm_global.h b/include/drm/ttm/ttm_global.h
index 9aa0ddbbe2ef..8dedac053611 100644
--- a/include/drm/ttm/ttm_global.h
+++ b/include/drm/ttm/ttm_global.h
@@ -28,7 +28,6 @@
 #ifndef _TTM_GLOBAL_H_
 #define _TTM_GLOBAL_H_
 
-#include <drm/drm_global.h>
 #include <linux/mutex.h>
 #include <linux/types.h>
 
@@ -58,8 +57,8 @@ struct ttm_bo_global;
  * struct ttm_global - Stores references to global TTM state
  */
 struct ttm_global {
-	struct drm_global_reference mem_ref;
-	struct drm_global_reference bo_ref;
+	struct ttm_global_ref mem_ref;
+	struct ttm_global_ref bo_ref;
 };
 
 /**
-- 
2.19.1



More information about the amd-gfx mailing list