aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ast
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2018-10-19 07:49:05 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-11-05 14:21:18 -0500
commit27eb1fa9130a98edd2b321d4dbce5c8b244ee7af (patch)
treeb94c90b1cec5a325161051012797155964ce0331 /drivers/gpu/drm/ast
parent7e07834c12b96214e95a473f7b14fc03b20e2e7a (diff)
drm/ttm: use a static ttm_mem_global instance
As the name says we only need one global instance of ttm_mem_global. Drop all the driver initialization and just use a single exported instance which is initialized during BO global initialization. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/ast')
-rw-r--r--drivers/gpu/drm/ast/ast_drv.h1
-rw-r--r--drivers/gpu/drm/ast/ast_ttm.c32
2 files changed, 2 insertions, 31 deletions
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index e6c4cd3dc50e..6ae11a477643 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -104,7 +104,6 @@ struct ast_private {
104 int fb_mtrr; 104 int fb_mtrr;
105 105
106 struct { 106 struct {
107 struct drm_global_reference mem_global_ref;
108 struct ttm_bo_global_ref bo_global_ref; 107 struct ttm_bo_global_ref bo_global_ref;
109 struct ttm_bo_device bdev; 108 struct ttm_bo_device bdev;
110 } ttm; 109 } ttm;
diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index d21fbd26785a..8a59d6fc1160 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -36,37 +36,11 @@ ast_bdev(struct ttm_bo_device *bd)
36 return container_of(bd, struct ast_private, ttm.bdev); 36 return container_of(bd, struct ast_private, ttm.bdev);
37} 37}
38 38
39static int
40ast_ttm_mem_global_init(struct drm_global_reference *ref)
41{
42 return ttm_mem_global_init(ref->object);
43}
44
45static void
46ast_ttm_mem_global_release(struct drm_global_reference *ref)
47{
48 ttm_mem_global_release(ref->object);
49}
50
51static int ast_ttm_global_init(struct ast_private *ast) 39static int ast_ttm_global_init(struct ast_private *ast)
52{ 40{
53 struct drm_global_reference *global_ref; 41 struct drm_global_reference *global_ref;
54 int r; 42 int r;
55 43
56 global_ref = &ast->ttm.mem_global_ref;
57 global_ref->global_type = DRM_GLOBAL_TTM_MEM;
58 global_ref->size = sizeof(struct ttm_mem_global);
59 global_ref->init = &ast_ttm_mem_global_init;
60 global_ref->release = &ast_ttm_mem_global_release;
61 r = drm_global_item_ref(global_ref);
62 if (r != 0) {
63 DRM_ERROR("Failed setting up TTM memory accounting "
64 "subsystem.\n");
65 return r;
66 }
67
68 ast->ttm.bo_global_ref.mem_glob =
69 ast->ttm.mem_global_ref.object;
70 global_ref = &ast->ttm.bo_global_ref.ref; 44 global_ref = &ast->ttm.bo_global_ref.ref;
71 global_ref->global_type = DRM_GLOBAL_TTM_BO; 45 global_ref->global_type = DRM_GLOBAL_TTM_BO;
72 global_ref->size = sizeof(struct ttm_bo_global); 46 global_ref->size = sizeof(struct ttm_bo_global);
@@ -75,7 +49,6 @@ static int ast_ttm_global_init(struct ast_private *ast)
75 r = drm_global_item_ref(global_ref); 49 r = drm_global_item_ref(global_ref);
76 if (r != 0) { 50 if (r != 0) {
77 DRM_ERROR("Failed setting up TTM BO subsystem.\n"); 51 DRM_ERROR("Failed setting up TTM BO subsystem.\n");
78 drm_global_item_unref(&ast->ttm.mem_global_ref);
79 return r; 52 return r;
80 } 53 }
81 return 0; 54 return 0;
@@ -84,12 +57,11 @@ static int ast_ttm_global_init(struct ast_private *ast)
84static void 57static void
85ast_ttm_global_release(struct ast_private *ast) 58ast_ttm_global_release(struct ast_private *ast)
86{ 59{
87 if (ast->ttm.mem_global_ref.release == NULL) 60 if (ast->ttm.bo_global_ref.ref.release == NULL)
88 return; 61 return;
89 62
90 drm_global_item_unref(&ast->ttm.bo_global_ref.ref); 63 drm_global_item_unref(&ast->ttm.bo_global_ref.ref);
91 drm_global_item_unref(&ast->ttm.mem_global_ref); 64 ast->ttm.bo_global_ref.ref.release = NULL;
92 ast->ttm.mem_global_ref.release = NULL;
93} 65}
94 66
95 67