diff options
author | Christian König <christian.koenig@amd.com> | 2018-10-19 07:49:05 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-11-05 14:21:18 -0500 |
commit | 27eb1fa9130a98edd2b321d4dbce5c8b244ee7af (patch) | |
tree | b94c90b1cec5a325161051012797155964ce0331 /drivers/gpu | |
parent | 7e07834c12b96214e95a473f7b14fc03b20e2e7a (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')
25 files changed, 28 insertions, 347 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 3a6802846698..fda252022b15 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | |||
@@ -66,33 +66,6 @@ static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev); | |||
66 | */ | 66 | */ |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * amdgpu_ttm_mem_global_init - Initialize and acquire reference to | ||
70 | * memory object | ||
71 | * | ||
72 | * @ref: Object for initialization. | ||
73 | * | ||
74 | * This is called by drm_global_item_ref() when an object is being | ||
75 | * initialized. | ||
76 | */ | ||
77 | static int amdgpu_ttm_mem_global_init(struct drm_global_reference *ref) | ||
78 | { | ||
79 | return ttm_mem_global_init(ref->object); | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * amdgpu_ttm_mem_global_release - Drop reference to a memory object | ||
84 | * | ||
85 | * @ref: Object being removed | ||
86 | * | ||
87 | * This is called by drm_global_item_unref() when an object is being | ||
88 | * released. | ||
89 | */ | ||
90 | static void amdgpu_ttm_mem_global_release(struct drm_global_reference *ref) | ||
91 | { | ||
92 | ttm_mem_global_release(ref->object); | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * amdgpu_ttm_global_init - Initialize global TTM memory reference structures. | 69 | * amdgpu_ttm_global_init - Initialize global TTM memory reference structures. |
97 | * | 70 | * |
98 | * @adev: AMDGPU device for which the global structures need to be registered. | 71 | * @adev: AMDGPU device for which the global structures need to be registered. |
@@ -108,20 +81,6 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
108 | /* ensure reference is false in case init fails */ | 81 | /* ensure reference is false in case init fails */ |
109 | adev->mman.mem_global_referenced = false; | 82 | adev->mman.mem_global_referenced = false; |
110 | 83 | ||
111 | global_ref = &adev->mman.mem_global_ref; | ||
112 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | ||
113 | global_ref->size = sizeof(struct ttm_mem_global); | ||
114 | global_ref->init = &amdgpu_ttm_mem_global_init; | ||
115 | global_ref->release = &amdgpu_ttm_mem_global_release; | ||
116 | r = drm_global_item_ref(global_ref); | ||
117 | if (r) { | ||
118 | DRM_ERROR("Failed setting up TTM memory accounting " | ||
119 | "subsystem.\n"); | ||
120 | goto error_mem; | ||
121 | } | ||
122 | |||
123 | adev->mman.bo_global_ref.mem_glob = | ||
124 | adev->mman.mem_global_ref.object; | ||
125 | global_ref = &adev->mman.bo_global_ref.ref; | 84 | global_ref = &adev->mman.bo_global_ref.ref; |
126 | global_ref->global_type = DRM_GLOBAL_TTM_BO; | 85 | global_ref->global_type = DRM_GLOBAL_TTM_BO; |
127 | global_ref->size = sizeof(struct ttm_bo_global); | 86 | global_ref->size = sizeof(struct ttm_bo_global); |
@@ -140,8 +99,6 @@ static int amdgpu_ttm_global_init(struct amdgpu_device *adev) | |||
140 | return 0; | 99 | return 0; |
141 | 100 | ||
142 | error_bo: | 101 | error_bo: |
143 | drm_global_item_unref(&adev->mman.mem_global_ref); | ||
144 | error_mem: | ||
145 | return r; | 102 | return r; |
146 | } | 103 | } |
147 | 104 | ||
@@ -150,7 +107,6 @@ static void amdgpu_ttm_global_fini(struct amdgpu_device *adev) | |||
150 | if (adev->mman.mem_global_referenced) { | 107 | if (adev->mman.mem_global_referenced) { |
151 | mutex_destroy(&adev->mman.gtt_window_lock); | 108 | mutex_destroy(&adev->mman.gtt_window_lock); |
152 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); | 109 | drm_global_item_unref(&adev->mman.bo_global_ref.ref); |
153 | drm_global_item_unref(&adev->mman.mem_global_ref); | ||
154 | adev->mman.mem_global_referenced = false; | 110 | adev->mman.mem_global_referenced = false; |
155 | } | 111 | } |
156 | } | 112 | } |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h index fe8f276e9811..e114f209b701 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | |||
@@ -40,7 +40,6 @@ | |||
40 | 40 | ||
41 | struct amdgpu_mman { | 41 | struct amdgpu_mman { |
42 | struct ttm_bo_global_ref bo_global_ref; | 42 | struct ttm_bo_global_ref bo_global_ref; |
43 | struct drm_global_reference mem_global_ref; | ||
44 | struct ttm_bo_device bdev; | 43 | struct ttm_bo_device bdev; |
45 | bool mem_global_referenced; | 44 | bool mem_global_referenced; |
46 | bool initialized; | 45 | bool initialized; |
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 | ||
39 | static int | ||
40 | ast_ttm_mem_global_init(struct drm_global_reference *ref) | ||
41 | { | ||
42 | return ttm_mem_global_init(ref->object); | ||
43 | } | ||
44 | |||
45 | static void | ||
46 | ast_ttm_mem_global_release(struct drm_global_reference *ref) | ||
47 | { | ||
48 | ttm_mem_global_release(ref->object); | ||
49 | } | ||
50 | |||
51 | static int ast_ttm_global_init(struct ast_private *ast) | 39 | static 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) | |||
84 | static void | 57 | static void |
85 | ast_ttm_global_release(struct ast_private *ast) | 58 | ast_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 | ||
diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h index e7a69077e45a..a035257d1b56 100644 --- a/drivers/gpu/drm/bochs/bochs.h +++ b/drivers/gpu/drm/bochs/bochs.h | |||
@@ -76,7 +76,6 @@ struct bochs_device { | |||
76 | 76 | ||
77 | /* ttm */ | 77 | /* ttm */ |
78 | struct { | 78 | struct { |
79 | struct drm_global_reference mem_global_ref; | ||
80 | struct ttm_bo_global_ref bo_global_ref; | 79 | struct ttm_bo_global_ref bo_global_ref; |
81 | struct ttm_bo_device bdev; | 80 | struct ttm_bo_device bdev; |
82 | bool initialized; | 81 | bool initialized; |
diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c index 2d36179c0e83..c697d456656f 100644 --- a/drivers/gpu/drm/bochs/bochs_mm.c +++ b/drivers/gpu/drm/bochs/bochs_mm.c | |||
@@ -16,35 +16,11 @@ static inline struct bochs_device *bochs_bdev(struct ttm_bo_device *bd) | |||
16 | return container_of(bd, struct bochs_device, ttm.bdev); | 16 | return container_of(bd, struct bochs_device, ttm.bdev); |
17 | } | 17 | } |
18 | 18 | ||
19 | static int bochs_ttm_mem_global_init(struct drm_global_reference *ref) | ||
20 | { | ||
21 | return ttm_mem_global_init(ref->object); | ||
22 | } | ||
23 | |||
24 | static void bochs_ttm_mem_global_release(struct drm_global_reference *ref) | ||
25 | { | ||
26 | ttm_mem_global_release(ref->object); | ||
27 | } | ||
28 | |||
29 | static int bochs_ttm_global_init(struct bochs_device *bochs) | 19 | static int bochs_ttm_global_init(struct bochs_device *bochs) |
30 | { | 20 | { |
31 | struct drm_global_reference *global_ref; | 21 | struct drm_global_reference *global_ref; |
32 | int r; | 22 | int r; |
33 | 23 | ||
34 | global_ref = &bochs->ttm.mem_global_ref; | ||
35 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | ||
36 | global_ref->size = sizeof(struct ttm_mem_global); | ||
37 | global_ref->init = &bochs_ttm_mem_global_init; | ||
38 | global_ref->release = &bochs_ttm_mem_global_release; | ||
39 | r = drm_global_item_ref(global_ref); | ||
40 | if (r != 0) { | ||
41 | DRM_ERROR("Failed setting up TTM memory accounting " | ||
42 | "subsystem.\n"); | ||
43 | return r; | ||
44 | } | ||
45 | |||
46 | bochs->ttm.bo_global_ref.mem_glob = | ||
47 | bochs->ttm.mem_global_ref.object; | ||
48 | global_ref = &bochs->ttm.bo_global_ref.ref; | 24 | global_ref = &bochs->ttm.bo_global_ref.ref; |
49 | global_ref->global_type = DRM_GLOBAL_TTM_BO; | 25 | global_ref->global_type = DRM_GLOBAL_TTM_BO; |
50 | global_ref->size = sizeof(struct ttm_bo_global); | 26 | global_ref->size = sizeof(struct ttm_bo_global); |
@@ -53,7 +29,6 @@ static int bochs_ttm_global_init(struct bochs_device *bochs) | |||
53 | r = drm_global_item_ref(global_ref); | 29 | r = drm_global_item_ref(global_ref); |
54 | if (r != 0) { | 30 | if (r != 0) { |
55 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); | 31 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); |
56 | drm_global_item_unref(&bochs->ttm.mem_global_ref); | ||
57 | return r; | 32 | return r; |
58 | } | 33 | } |
59 | 34 | ||
@@ -62,12 +37,11 @@ static int bochs_ttm_global_init(struct bochs_device *bochs) | |||
62 | 37 | ||
63 | static void bochs_ttm_global_release(struct bochs_device *bochs) | 38 | static void bochs_ttm_global_release(struct bochs_device *bochs) |
64 | { | 39 | { |
65 | if (bochs->ttm.mem_global_ref.release == NULL) | 40 | if (bochs->ttm.bo_global_ref.ref.release == NULL) |
66 | return; | 41 | return; |
67 | 42 | ||
68 | drm_global_item_unref(&bochs->ttm.bo_global_ref.ref); | 43 | drm_global_item_unref(&bochs->ttm.bo_global_ref.ref); |
69 | drm_global_item_unref(&bochs->ttm.mem_global_ref); | 44 | bochs->ttm.bo_global_ref.ref.release = NULL; |
70 | bochs->ttm.mem_global_ref.release = NULL; | ||
71 | } | 45 | } |
72 | 46 | ||
73 | 47 | ||
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h index a29f87e98d9d..01852fbda9da 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.h +++ b/drivers/gpu/drm/cirrus/cirrus_drv.h | |||
@@ -136,7 +136,6 @@ struct cirrus_device { | |||
136 | int fb_mtrr; | 136 | int fb_mtrr; |
137 | 137 | ||
138 | struct { | 138 | struct { |
139 | struct drm_global_reference mem_global_ref; | ||
140 | struct ttm_bo_global_ref bo_global_ref; | 139 | struct ttm_bo_global_ref bo_global_ref; |
141 | struct ttm_bo_device bdev; | 140 | struct ttm_bo_device bdev; |
142 | } ttm; | 141 | } ttm; |
diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c b/drivers/gpu/drm/cirrus/cirrus_ttm.c index 2e2141f26c5b..7801c56c3c9b 100644 --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c | |||
@@ -36,37 +36,11 @@ cirrus_bdev(struct ttm_bo_device *bd) | |||
36 | return container_of(bd, struct cirrus_device, ttm.bdev); | 36 | return container_of(bd, struct cirrus_device, ttm.bdev); |
37 | } | 37 | } |
38 | 38 | ||
39 | static int | ||
40 | cirrus_ttm_mem_global_init(struct drm_global_reference *ref) | ||
41 | { | ||
42 | return ttm_mem_global_init(ref->object); | ||
43 | } | ||
44 | |||
45 | static void | ||
46 | cirrus_ttm_mem_global_release(struct drm_global_reference *ref) | ||
47 | { | ||
48 | ttm_mem_global_release(ref->object); | ||
49 | } | ||
50 | |||
51 | static int cirrus_ttm_global_init(struct cirrus_device *cirrus) | 39 | static int cirrus_ttm_global_init(struct cirrus_device *cirrus) |
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 = &cirrus->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 = &cirrus_ttm_mem_global_init; | ||
60 | global_ref->release = &cirrus_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 | cirrus->ttm.bo_global_ref.mem_glob = | ||
69 | cirrus->ttm.mem_global_ref.object; | ||
70 | global_ref = &cirrus->ttm.bo_global_ref.ref; | 44 | global_ref = &cirrus->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 cirrus_ttm_global_init(struct cirrus_device *cirrus) | |||
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(&cirrus->ttm.mem_global_ref); | ||
79 | return r; | 52 | return r; |
80 | } | 53 | } |
81 | return 0; | 54 | return 0; |
@@ -84,12 +57,11 @@ static int cirrus_ttm_global_init(struct cirrus_device *cirrus) | |||
84 | static void | 57 | static void |
85 | cirrus_ttm_global_release(struct cirrus_device *cirrus) | 58 | cirrus_ttm_global_release(struct cirrus_device *cirrus) |
86 | { | 59 | { |
87 | if (cirrus->ttm.mem_global_ref.release == NULL) | 60 | if (cirrus->ttm.bo_global_ref.ref.release == NULL) |
88 | return; | 61 | return; |
89 | 62 | ||
90 | drm_global_item_unref(&cirrus->ttm.bo_global_ref.ref); | 63 | drm_global_item_unref(&cirrus->ttm.bo_global_ref.ref); |
91 | drm_global_item_unref(&cirrus->ttm.mem_global_ref); | 64 | cirrus->ttm.bo_global_ref.ref.release = NULL; |
92 | cirrus->ttm.mem_global_ref.release = NULL; | ||
93 | } | 65 | } |
94 | 66 | ||
95 | 67 | ||
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h index 45c25a488f42..60479502e277 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | |||
@@ -49,7 +49,6 @@ struct hibmc_drm_private { | |||
49 | bool mode_config_initialized; | 49 | bool mode_config_initialized; |
50 | 50 | ||
51 | /* ttm */ | 51 | /* ttm */ |
52 | struct drm_global_reference mem_global_ref; | ||
53 | struct ttm_bo_global_ref bo_global_ref; | 52 | struct ttm_bo_global_ref bo_global_ref; |
54 | struct ttm_bo_device bdev; | 53 | struct ttm_bo_device bdev; |
55 | bool initialized; | 54 | bool initialized; |
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c index 0454aa43ffc6..14071c849121 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | |||
@@ -29,34 +29,10 @@ hibmc_bdev(struct ttm_bo_device *bd) | |||
29 | return container_of(bd, struct hibmc_drm_private, bdev); | 29 | return container_of(bd, struct hibmc_drm_private, bdev); |
30 | } | 30 | } |
31 | 31 | ||
32 | static int | ||
33 | hibmc_ttm_mem_global_init(struct drm_global_reference *ref) | ||
34 | { | ||
35 | return ttm_mem_global_init(ref->object); | ||
36 | } | ||
37 | |||
38 | static void | ||
39 | hibmc_ttm_mem_global_release(struct drm_global_reference *ref) | ||
40 | { | ||
41 | ttm_mem_global_release(ref->object); | ||
42 | } | ||
43 | |||
44 | static int hibmc_ttm_global_init(struct hibmc_drm_private *hibmc) | 32 | static int hibmc_ttm_global_init(struct hibmc_drm_private *hibmc) |
45 | { | 33 | { |
46 | int ret; | 34 | int ret; |
47 | 35 | ||
48 | hibmc->mem_global_ref.global_type = DRM_GLOBAL_TTM_MEM; | ||
49 | hibmc->mem_global_ref.size = sizeof(struct ttm_mem_global); | ||
50 | hibmc->mem_global_ref.init = &hibmc_ttm_mem_global_init; | ||
51 | hibmc->mem_global_ref.release = &hibmc_ttm_mem_global_release; | ||
52 | ret = drm_global_item_ref(&hibmc->mem_global_ref); | ||
53 | if (ret) { | ||
54 | DRM_ERROR("could not get ref on ttm global: %d\n", ret); | ||
55 | return ret; | ||
56 | } | ||
57 | |||
58 | hibmc->bo_global_ref.mem_glob = | ||
59 | hibmc->mem_global_ref.object; | ||
60 | hibmc->bo_global_ref.ref.global_type = DRM_GLOBAL_TTM_BO; | 36 | hibmc->bo_global_ref.ref.global_type = DRM_GLOBAL_TTM_BO; |
61 | hibmc->bo_global_ref.ref.size = sizeof(struct ttm_bo_global); | 37 | hibmc->bo_global_ref.ref.size = sizeof(struct ttm_bo_global); |
62 | hibmc->bo_global_ref.ref.init = &ttm_bo_global_ref_init; | 38 | hibmc->bo_global_ref.ref.init = &ttm_bo_global_ref_init; |
@@ -64,7 +40,6 @@ static int hibmc_ttm_global_init(struct hibmc_drm_private *hibmc) | |||
64 | ret = drm_global_item_ref(&hibmc->bo_global_ref.ref); | 40 | ret = drm_global_item_ref(&hibmc->bo_global_ref.ref); |
65 | if (ret) { | 41 | if (ret) { |
66 | DRM_ERROR("failed setting up TTM BO subsystem: %d\n", ret); | 42 | DRM_ERROR("failed setting up TTM BO subsystem: %d\n", ret); |
67 | drm_global_item_unref(&hibmc->mem_global_ref); | ||
68 | return ret; | 43 | return ret; |
69 | } | 44 | } |
70 | return 0; | 45 | return 0; |
@@ -73,9 +48,11 @@ static int hibmc_ttm_global_init(struct hibmc_drm_private *hibmc) | |||
73 | static void | 48 | static void |
74 | hibmc_ttm_global_release(struct hibmc_drm_private *hibmc) | 49 | hibmc_ttm_global_release(struct hibmc_drm_private *hibmc) |
75 | { | 50 | { |
51 | if (hibmc->bo_global_ref.ref.release == NULL) | ||
52 | return; | ||
53 | |||
76 | drm_global_item_unref(&hibmc->bo_global_ref.ref); | 54 | drm_global_item_unref(&hibmc->bo_global_ref.ref); |
77 | drm_global_item_unref(&hibmc->mem_global_ref); | 55 | hibmc->bo_global_ref.ref.release = NULL; |
78 | hibmc->mem_global_ref.release = NULL; | ||
79 | } | 56 | } |
80 | 57 | ||
81 | static void hibmc_bo_ttm_destroy(struct ttm_buffer_object *tbo) | 58 | static void hibmc_bo_ttm_destroy(struct ttm_buffer_object *tbo) |
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 04f1dfba12e5..e5348955a3cc 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h | |||
@@ -212,7 +212,6 @@ struct mga_device { | |||
212 | int fb_mtrr; | 212 | int fb_mtrr; |
213 | 213 | ||
214 | struct { | 214 | struct { |
215 | struct drm_global_reference mem_global_ref; | ||
216 | struct ttm_bo_global_ref bo_global_ref; | 215 | struct ttm_bo_global_ref bo_global_ref; |
217 | struct ttm_bo_device bdev; | 216 | struct ttm_bo_device bdev; |
218 | } ttm; | 217 | } ttm; |
diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c index 3444b539e7f4..11bdc8121a7d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_ttm.c +++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c | |||
@@ -36,37 +36,11 @@ mgag200_bdev(struct ttm_bo_device *bd) | |||
36 | return container_of(bd, struct mga_device, ttm.bdev); | 36 | return container_of(bd, struct mga_device, ttm.bdev); |
37 | } | 37 | } |
38 | 38 | ||
39 | static int | ||
40 | mgag200_ttm_mem_global_init(struct drm_global_reference *ref) | ||
41 | { | ||
42 | return ttm_mem_global_init(ref->object); | ||
43 | } | ||
44 | |||
45 | static void | ||
46 | mgag200_ttm_mem_global_release(struct drm_global_reference *ref) | ||
47 | { | ||
48 | ttm_mem_global_release(ref->object); | ||
49 | } | ||
50 | |||
51 | static int mgag200_ttm_global_init(struct mga_device *ast) | 39 | static int mgag200_ttm_global_init(struct mga_device *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 = &mgag200_ttm_mem_global_init; | ||
60 | global_ref->release = &mgag200_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 mgag200_ttm_global_init(struct mga_device *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 mgag200_ttm_global_init(struct mga_device *ast) | |||
84 | static void | 57 | static void |
85 | mgag200_ttm_global_release(struct mga_device *ast) | 58 | mgag200_ttm_global_release(struct mga_device *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 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index 0b2191fa96f7..0f3bb1a11fc9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
@@ -146,7 +146,6 @@ struct nouveau_drm { | |||
146 | 146 | ||
147 | /* TTM interface support */ | 147 | /* TTM interface support */ |
148 | struct { | 148 | struct { |
149 | struct drm_global_reference mem_global_ref; | ||
150 | struct ttm_bo_global_ref bo_global_ref; | 149 | struct ttm_bo_global_ref bo_global_ref; |
151 | struct ttm_bo_device bdev; | 150 | struct ttm_bo_device bdev; |
152 | atomic_t validate_sequence; | 151 | atomic_t validate_sequence; |
diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c index a293383c8654..69448b02649e 100644 --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c | |||
@@ -174,38 +174,12 @@ nouveau_ttm_mmap(struct file *filp, struct vm_area_struct *vma) | |||
174 | return ttm_bo_mmap(filp, vma, &drm->ttm.bdev); | 174 | return ttm_bo_mmap(filp, vma, &drm->ttm.bdev); |
175 | } | 175 | } |
176 | 176 | ||
177 | static int | ||
178 | nouveau_ttm_mem_global_init(struct drm_global_reference *ref) | ||
179 | { | ||
180 | return ttm_mem_global_init(ref->object); | ||
181 | } | ||
182 | |||
183 | static void | ||
184 | nouveau_ttm_mem_global_release(struct drm_global_reference *ref) | ||
185 | { | ||
186 | ttm_mem_global_release(ref->object); | ||
187 | } | ||
188 | |||
189 | int | 177 | int |
190 | nouveau_ttm_global_init(struct nouveau_drm *drm) | 178 | nouveau_ttm_global_init(struct nouveau_drm *drm) |
191 | { | 179 | { |
192 | struct drm_global_reference *global_ref; | 180 | struct drm_global_reference *global_ref; |
193 | int ret; | 181 | int ret; |
194 | 182 | ||
195 | global_ref = &drm->ttm.mem_global_ref; | ||
196 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | ||
197 | global_ref->size = sizeof(struct ttm_mem_global); | ||
198 | global_ref->init = &nouveau_ttm_mem_global_init; | ||
199 | global_ref->release = &nouveau_ttm_mem_global_release; | ||
200 | |||
201 | ret = drm_global_item_ref(global_ref); | ||
202 | if (unlikely(ret != 0)) { | ||
203 | DRM_ERROR("Failed setting up TTM memory accounting\n"); | ||
204 | drm->ttm.mem_global_ref.release = NULL; | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | drm->ttm.bo_global_ref.mem_glob = global_ref->object; | ||
209 | global_ref = &drm->ttm.bo_global_ref.ref; | 183 | global_ref = &drm->ttm.bo_global_ref.ref; |
210 | global_ref->global_type = DRM_GLOBAL_TTM_BO; | 184 | global_ref->global_type = DRM_GLOBAL_TTM_BO; |
211 | global_ref->size = sizeof(struct ttm_bo_global); | 185 | global_ref->size = sizeof(struct ttm_bo_global); |
@@ -215,8 +189,7 @@ nouveau_ttm_global_init(struct nouveau_drm *drm) | |||
215 | ret = drm_global_item_ref(global_ref); | 189 | ret = drm_global_item_ref(global_ref); |
216 | if (unlikely(ret != 0)) { | 190 | if (unlikely(ret != 0)) { |
217 | DRM_ERROR("Failed setting up TTM BO subsystem\n"); | 191 | DRM_ERROR("Failed setting up TTM BO subsystem\n"); |
218 | drm_global_item_unref(&drm->ttm.mem_global_ref); | 192 | drm->ttm.bo_global_ref.ref.release = NULL; |
219 | drm->ttm.mem_global_ref.release = NULL; | ||
220 | return ret; | 193 | return ret; |
221 | } | 194 | } |
222 | 195 | ||
@@ -226,12 +199,11 @@ nouveau_ttm_global_init(struct nouveau_drm *drm) | |||
226 | void | 199 | void |
227 | nouveau_ttm_global_release(struct nouveau_drm *drm) | 200 | nouveau_ttm_global_release(struct nouveau_drm *drm) |
228 | { | 201 | { |
229 | if (drm->ttm.mem_global_ref.release == NULL) | 202 | if (drm->ttm.bo_global_ref.ref.release == NULL) |
230 | return; | 203 | return; |
231 | 204 | ||
232 | drm_global_item_unref(&drm->ttm.bo_global_ref.ref); | 205 | drm_global_item_unref(&drm->ttm.bo_global_ref.ref); |
233 | drm_global_item_unref(&drm->ttm.mem_global_ref); | 206 | drm->ttm.bo_global_ref.ref.release = NULL; |
234 | drm->ttm.mem_global_ref.release = NULL; | ||
235 | } | 207 | } |
236 | 208 | ||
237 | static int | 209 | static int |
diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h index 8ff70a7281a7..52912e54e990 100644 --- a/drivers/gpu/drm/qxl/qxl_drv.h +++ b/drivers/gpu/drm/qxl/qxl_drv.h | |||
@@ -128,7 +128,6 @@ struct qxl_output { | |||
128 | 128 | ||
129 | struct qxl_mman { | 129 | struct qxl_mman { |
130 | struct ttm_bo_global_ref bo_global_ref; | 130 | struct ttm_bo_global_ref bo_global_ref; |
131 | struct drm_global_reference mem_global_ref; | ||
132 | bool mem_global_referenced; | 131 | bool mem_global_referenced; |
133 | struct ttm_bo_device bdev; | 132 | struct ttm_bo_device bdev; |
134 | }; | 133 | }; |
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c index db2a0036e9c4..bb8cc9b16780 100644 --- a/drivers/gpu/drm/qxl/qxl_ttm.c +++ b/drivers/gpu/drm/qxl/qxl_ttm.c | |||
@@ -46,37 +46,11 @@ static struct qxl_device *qxl_get_qdev(struct ttm_bo_device *bdev) | |||
46 | return qdev; | 46 | return qdev; |
47 | } | 47 | } |
48 | 48 | ||
49 | static int qxl_ttm_mem_global_init(struct drm_global_reference *ref) | ||
50 | { | ||
51 | return ttm_mem_global_init(ref->object); | ||
52 | } | ||
53 | |||
54 | static void qxl_ttm_mem_global_release(struct drm_global_reference *ref) | ||
55 | { | ||
56 | ttm_mem_global_release(ref->object); | ||
57 | } | ||
58 | |||
59 | static int qxl_ttm_global_init(struct qxl_device *qdev) | 49 | static int qxl_ttm_global_init(struct qxl_device *qdev) |
60 | { | 50 | { |
61 | struct drm_global_reference *global_ref; | 51 | struct drm_global_reference *global_ref; |
62 | int r; | 52 | int r; |
63 | 53 | ||
64 | qdev->mman.mem_global_referenced = false; | ||
65 | global_ref = &qdev->mman.mem_global_ref; | ||
66 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | ||
67 | global_ref->size = sizeof(struct ttm_mem_global); | ||
68 | global_ref->init = &qxl_ttm_mem_global_init; | ||
69 | global_ref->release = &qxl_ttm_mem_global_release; | ||
70 | |||
71 | r = drm_global_item_ref(global_ref); | ||
72 | if (r != 0) { | ||
73 | DRM_ERROR("Failed setting up TTM memory accounting " | ||
74 | "subsystem.\n"); | ||
75 | return r; | ||
76 | } | ||
77 | |||
78 | qdev->mman.bo_global_ref.mem_glob = | ||
79 | qdev->mman.mem_global_ref.object; | ||
80 | global_ref = &qdev->mman.bo_global_ref.ref; | 54 | global_ref = &qdev->mman.bo_global_ref.ref; |
81 | global_ref->global_type = DRM_GLOBAL_TTM_BO; | 55 | global_ref->global_type = DRM_GLOBAL_TTM_BO; |
82 | global_ref->size = sizeof(struct ttm_bo_global); | 56 | global_ref->size = sizeof(struct ttm_bo_global); |
@@ -85,7 +59,6 @@ static int qxl_ttm_global_init(struct qxl_device *qdev) | |||
85 | r = drm_global_item_ref(global_ref); | 59 | r = drm_global_item_ref(global_ref); |
86 | if (r != 0) { | 60 | if (r != 0) { |
87 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); | 61 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); |
88 | drm_global_item_unref(&qdev->mman.mem_global_ref); | ||
89 | return r; | 62 | return r; |
90 | } | 63 | } |
91 | 64 | ||
@@ -97,7 +70,6 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev) | |||
97 | { | 70 | { |
98 | if (qdev->mman.mem_global_referenced) { | 71 | if (qdev->mman.mem_global_referenced) { |
99 | drm_global_item_unref(&qdev->mman.bo_global_ref.ref); | 72 | drm_global_item_unref(&qdev->mman.bo_global_ref.ref); |
100 | drm_global_item_unref(&qdev->mman.mem_global_ref); | ||
101 | qdev->mman.mem_global_referenced = false; | 73 | qdev->mman.mem_global_referenced = false; |
102 | } | 74 | } |
103 | } | 75 | } |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 1a6f6edb3515..06fb952b6290 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -449,7 +449,6 @@ struct radeon_surface_reg { | |||
449 | */ | 449 | */ |
450 | struct radeon_mman { | 450 | struct radeon_mman { |
451 | struct ttm_bo_global_ref bo_global_ref; | 451 | struct ttm_bo_global_ref bo_global_ref; |
452 | struct drm_global_reference mem_global_ref; | ||
453 | struct ttm_bo_device bdev; | 452 | struct ttm_bo_device bdev; |
454 | bool mem_global_referenced; | 453 | bool mem_global_referenced; |
455 | bool initialized; | 454 | bool initialized; |
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index dac4ec5a120b..2104429ddbac 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c | |||
@@ -64,36 +64,12 @@ static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev) | |||
64 | /* | 64 | /* |
65 | * Global memory. | 65 | * Global memory. |
66 | */ | 66 | */ |
67 | static int radeon_ttm_mem_global_init(struct drm_global_reference *ref) | ||
68 | { | ||
69 | return ttm_mem_global_init(ref->object); | ||
70 | } | ||
71 | |||
72 | static void radeon_ttm_mem_global_release(struct drm_global_reference *ref) | ||
73 | { | ||
74 | ttm_mem_global_release(ref->object); | ||
75 | } | ||
76 | |||
77 | static int radeon_ttm_global_init(struct radeon_device *rdev) | 67 | static int radeon_ttm_global_init(struct radeon_device *rdev) |
78 | { | 68 | { |
79 | struct drm_global_reference *global_ref; | 69 | struct drm_global_reference *global_ref; |
80 | int r; | 70 | int r; |
81 | 71 | ||
82 | rdev->mman.mem_global_referenced = false; | 72 | rdev->mman.mem_global_referenced = false; |
83 | global_ref = &rdev->mman.mem_global_ref; | ||
84 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | ||
85 | global_ref->size = sizeof(struct ttm_mem_global); | ||
86 | global_ref->init = &radeon_ttm_mem_global_init; | ||
87 | global_ref->release = &radeon_ttm_mem_global_release; | ||
88 | r = drm_global_item_ref(global_ref); | ||
89 | if (r != 0) { | ||
90 | DRM_ERROR("Failed setting up TTM memory accounting " | ||
91 | "subsystem.\n"); | ||
92 | return r; | ||
93 | } | ||
94 | |||
95 | rdev->mman.bo_global_ref.mem_glob = | ||
96 | rdev->mman.mem_global_ref.object; | ||
97 | global_ref = &rdev->mman.bo_global_ref.ref; | 73 | global_ref = &rdev->mman.bo_global_ref.ref; |
98 | global_ref->global_type = DRM_GLOBAL_TTM_BO; | 74 | global_ref->global_type = DRM_GLOBAL_TTM_BO; |
99 | global_ref->size = sizeof(struct ttm_bo_global); | 75 | global_ref->size = sizeof(struct ttm_bo_global); |
@@ -102,7 +78,6 @@ static int radeon_ttm_global_init(struct radeon_device *rdev) | |||
102 | r = drm_global_item_ref(global_ref); | 78 | r = drm_global_item_ref(global_ref); |
103 | if (r != 0) { | 79 | if (r != 0) { |
104 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); | 80 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); |
105 | drm_global_item_unref(&rdev->mman.mem_global_ref); | ||
106 | return r; | 81 | return r; |
107 | } | 82 | } |
108 | 83 | ||
@@ -114,7 +89,6 @@ static void radeon_ttm_global_fini(struct radeon_device *rdev) | |||
114 | { | 89 | { |
115 | if (rdev->mman.mem_global_referenced) { | 90 | if (rdev->mman.mem_global_referenced) { |
116 | drm_global_item_unref(&rdev->mman.bo_global_ref.ref); | 91 | drm_global_item_unref(&rdev->mman.bo_global_ref.ref); |
117 | drm_global_item_unref(&rdev->mman.mem_global_ref); | ||
118 | rdev->mman.mem_global_referenced = false; | 92 | rdev->mman.mem_global_referenced = false; |
119 | } | 93 | } |
120 | } | 94 | } |
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 9edece6510d3..3006050b1720 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -1526,18 +1526,22 @@ void ttm_bo_global_release(struct ttm_bo_global *glob) | |||
1526 | { | 1526 | { |
1527 | kobject_del(&glob->kobj); | 1527 | kobject_del(&glob->kobj); |
1528 | kobject_put(&glob->kobj); | 1528 | kobject_put(&glob->kobj); |
1529 | ttm_mem_global_release(&ttm_mem_glob); | ||
1529 | } | 1530 | } |
1530 | EXPORT_SYMBOL(ttm_bo_global_release); | 1531 | EXPORT_SYMBOL(ttm_bo_global_release); |
1531 | 1532 | ||
1532 | int ttm_bo_global_init(struct ttm_bo_global *glob, | 1533 | int ttm_bo_global_init(struct ttm_bo_global *glob) |
1533 | struct ttm_mem_global *mem_glob) | ||
1534 | { | 1534 | { |
1535 | int ret; | 1535 | int ret; |
1536 | unsigned i; | 1536 | unsigned i; |
1537 | 1537 | ||
1538 | ret = ttm_mem_global_init(&ttm_mem_glob); | ||
1539 | if (ret) | ||
1540 | return ret; | ||
1541 | |||
1538 | mutex_init(&glob->device_list_mutex); | 1542 | mutex_init(&glob->device_list_mutex); |
1539 | spin_lock_init(&glob->lru_lock); | 1543 | spin_lock_init(&glob->lru_lock); |
1540 | glob->mem_glob = mem_glob; | 1544 | glob->mem_glob = &ttm_mem_glob; |
1541 | glob->mem_glob->bo_glob = glob; | 1545 | glob->mem_glob->bo_glob = glob; |
1542 | glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32); | 1546 | glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32); |
1543 | 1547 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c index 450387c92b63..7704e17c402f 100644 --- a/drivers/gpu/drm/ttm/ttm_memory.c +++ b/drivers/gpu/drm/ttm/ttm_memory.c | |||
@@ -41,6 +41,9 @@ | |||
41 | 41 | ||
42 | #define TTM_MEMORY_ALLOC_RETRIES 4 | 42 | #define TTM_MEMORY_ALLOC_RETRIES 4 |
43 | 43 | ||
44 | struct ttm_mem_global ttm_mem_glob; | ||
45 | EXPORT_SYMBOL(ttm_mem_glob); | ||
46 | |||
44 | struct ttm_mem_zone { | 47 | struct ttm_mem_zone { |
45 | struct kobject kobj; | 48 | struct kobject kobj; |
46 | struct ttm_mem_global *glob; | 49 | struct ttm_mem_global *glob; |
@@ -464,7 +467,6 @@ out_no_zone: | |||
464 | ttm_mem_global_release(glob); | 467 | ttm_mem_global_release(glob); |
465 | return ret; | 468 | return ret; |
466 | } | 469 | } |
467 | EXPORT_SYMBOL(ttm_mem_global_init); | ||
468 | 470 | ||
469 | void ttm_mem_global_release(struct ttm_mem_global *glob) | 471 | void ttm_mem_global_release(struct ttm_mem_global *glob) |
470 | { | 472 | { |
@@ -486,7 +488,6 @@ void ttm_mem_global_release(struct ttm_mem_global *glob) | |||
486 | kobject_del(&glob->kobj); | 488 | kobject_del(&glob->kobj); |
487 | kobject_put(&glob->kobj); | 489 | kobject_put(&glob->kobj); |
488 | } | 490 | } |
489 | EXPORT_SYMBOL(ttm_mem_global_release); | ||
490 | 491 | ||
491 | static void ttm_check_swapping(struct ttm_mem_global *glob) | 492 | static void ttm_check_swapping(struct ttm_mem_global *glob) |
492 | { | 493 | { |
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h index d29f0c7c768c..d9756b59e329 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h | |||
@@ -143,7 +143,6 @@ struct virtio_gpu_fbdev { | |||
143 | 143 | ||
144 | struct virtio_gpu_mman { | 144 | struct virtio_gpu_mman { |
145 | struct ttm_bo_global_ref bo_global_ref; | 145 | struct ttm_bo_global_ref bo_global_ref; |
146 | struct drm_global_reference mem_global_ref; | ||
147 | bool mem_global_referenced; | 146 | bool mem_global_referenced; |
148 | struct ttm_bo_device bdev; | 147 | struct ttm_bo_device bdev; |
149 | }; | 148 | }; |
diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c b/drivers/gpu/drm/virtio/virtgpu_ttm.c index 526a5e48dc3b..8510109e09da 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ttm.c +++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c | |||
@@ -50,37 +50,12 @@ virtio_gpu_device *virtio_gpu_get_vgdev(struct ttm_bo_device *bdev) | |||
50 | return vgdev; | 50 | return vgdev; |
51 | } | 51 | } |
52 | 52 | ||
53 | static int virtio_gpu_ttm_mem_global_init(struct drm_global_reference *ref) | ||
54 | { | ||
55 | return ttm_mem_global_init(ref->object); | ||
56 | } | ||
57 | |||
58 | static void virtio_gpu_ttm_mem_global_release(struct drm_global_reference *ref) | ||
59 | { | ||
60 | ttm_mem_global_release(ref->object); | ||
61 | } | ||
62 | |||
63 | static int virtio_gpu_ttm_global_init(struct virtio_gpu_device *vgdev) | 53 | static int virtio_gpu_ttm_global_init(struct virtio_gpu_device *vgdev) |
64 | { | 54 | { |
65 | struct drm_global_reference *global_ref; | 55 | struct drm_global_reference *global_ref; |
66 | int r; | 56 | int r; |
67 | 57 | ||
68 | vgdev->mman.mem_global_referenced = false; | 58 | vgdev->mman.mem_global_referenced = false; |
69 | global_ref = &vgdev->mman.mem_global_ref; | ||
70 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | ||
71 | global_ref->size = sizeof(struct ttm_mem_global); | ||
72 | global_ref->init = &virtio_gpu_ttm_mem_global_init; | ||
73 | global_ref->release = &virtio_gpu_ttm_mem_global_release; | ||
74 | |||
75 | r = drm_global_item_ref(global_ref); | ||
76 | if (r != 0) { | ||
77 | DRM_ERROR("Failed setting up TTM memory accounting " | ||
78 | "subsystem.\n"); | ||
79 | return r; | ||
80 | } | ||
81 | |||
82 | vgdev->mman.bo_global_ref.mem_glob = | ||
83 | vgdev->mman.mem_global_ref.object; | ||
84 | global_ref = &vgdev->mman.bo_global_ref.ref; | 59 | global_ref = &vgdev->mman.bo_global_ref.ref; |
85 | global_ref->global_type = DRM_GLOBAL_TTM_BO; | 60 | global_ref->global_type = DRM_GLOBAL_TTM_BO; |
86 | global_ref->size = sizeof(struct ttm_bo_global); | 61 | global_ref->size = sizeof(struct ttm_bo_global); |
@@ -89,7 +64,6 @@ static int virtio_gpu_ttm_global_init(struct virtio_gpu_device *vgdev) | |||
89 | r = drm_global_item_ref(global_ref); | 64 | r = drm_global_item_ref(global_ref); |
90 | if (r != 0) { | 65 | if (r != 0) { |
91 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); | 66 | DRM_ERROR("Failed setting up TTM BO subsystem.\n"); |
92 | drm_global_item_unref(&vgdev->mman.mem_global_ref); | ||
93 | return r; | 67 | return r; |
94 | } | 68 | } |
95 | 69 | ||
@@ -101,7 +75,6 @@ static void virtio_gpu_ttm_global_fini(struct virtio_gpu_device *vgdev) | |||
101 | { | 75 | { |
102 | if (vgdev->mman.mem_global_referenced) { | 76 | if (vgdev->mman.mem_global_referenced) { |
103 | drm_global_item_unref(&vgdev->mman.bo_global_ref.ref); | 77 | drm_global_item_unref(&vgdev->mman.bo_global_ref.ref); |
104 | drm_global_item_unref(&vgdev->mman.mem_global_ref); | ||
105 | vgdev->mman.mem_global_referenced = false; | 78 | vgdev->mman.mem_global_referenced = false; |
106 | } | 79 | } |
107 | } | 80 | } |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 61a84b958d67..67494148accd 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | |||
@@ -828,8 +828,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) | |||
828 | goto out_err4; | 828 | goto out_err4; |
829 | } | 829 | } |
830 | 830 | ||
831 | dev_priv->tdev = ttm_object_device_init | 831 | dev_priv->tdev = ttm_object_device_init(&ttm_mem_glob, 12, |
832 | (dev_priv->mem_global_ref.object, 12, &vmw_prime_dmabuf_ops); | 832 | &vmw_prime_dmabuf_ops); |
833 | 833 | ||
834 | if (unlikely(dev_priv->tdev == NULL)) { | 834 | if (unlikely(dev_priv->tdev == NULL)) { |
835 | DRM_ERROR("Unable to initialize TTM object management.\n"); | 835 | DRM_ERROR("Unable to initialize TTM object management.\n"); |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 59f614225bcd..252f202ae897 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | |||
@@ -418,7 +418,6 @@ enum { | |||
418 | struct vmw_private { | 418 | struct vmw_private { |
419 | struct ttm_bo_device bdev; | 419 | struct ttm_bo_device bdev; |
420 | struct ttm_bo_global_ref bo_global_ref; | 420 | struct ttm_bo_global_ref bo_global_ref; |
421 | struct drm_global_reference mem_global_ref; | ||
422 | 421 | ||
423 | struct vmw_fifo_state fifo; | 422 | struct vmw_fifo_state fifo; |
424 | 423 | ||
@@ -1363,7 +1362,7 @@ vmw_bo_reference(struct vmw_buffer_object *buf) | |||
1363 | 1362 | ||
1364 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) | 1363 | static inline struct ttm_mem_global *vmw_mem_glob(struct vmw_private *dev_priv) |
1365 | { | 1364 | { |
1366 | return (struct ttm_mem_global *) dev_priv->mem_global_ref.object; | 1365 | return &ttm_mem_glob; |
1367 | } | 1366 | } |
1368 | 1367 | ||
1369 | static inline void vmw_fifo_resource_inc(struct vmw_private *dev_priv) | 1368 | static inline void vmw_fifo_resource_inc(struct vmw_private *dev_priv) |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c index f3ce43c41978..0ac473cd5136 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_glue.c | |||
@@ -43,36 +43,11 @@ int vmw_mmap(struct file *filp, struct vm_area_struct *vma) | |||
43 | return ttm_bo_mmap(filp, vma, &dev_priv->bdev); | 43 | return ttm_bo_mmap(filp, vma, &dev_priv->bdev); |
44 | } | 44 | } |
45 | 45 | ||
46 | static int vmw_ttm_mem_global_init(struct drm_global_reference *ref) | ||
47 | { | ||
48 | DRM_INFO("global init.\n"); | ||
49 | return ttm_mem_global_init(ref->object); | ||
50 | } | ||
51 | |||
52 | static void vmw_ttm_mem_global_release(struct drm_global_reference *ref) | ||
53 | { | ||
54 | ttm_mem_global_release(ref->object); | ||
55 | } | ||
56 | |||
57 | int vmw_ttm_global_init(struct vmw_private *dev_priv) | 46 | int vmw_ttm_global_init(struct vmw_private *dev_priv) |
58 | { | 47 | { |
59 | struct drm_global_reference *global_ref; | 48 | struct drm_global_reference *global_ref; |
60 | int ret; | 49 | int ret; |
61 | 50 | ||
62 | global_ref = &dev_priv->mem_global_ref; | ||
63 | global_ref->global_type = DRM_GLOBAL_TTM_MEM; | ||
64 | global_ref->size = sizeof(struct ttm_mem_global); | ||
65 | global_ref->init = &vmw_ttm_mem_global_init; | ||
66 | global_ref->release = &vmw_ttm_mem_global_release; | ||
67 | |||
68 | ret = drm_global_item_ref(global_ref); | ||
69 | if (unlikely(ret != 0)) { | ||
70 | DRM_ERROR("Failed setting up TTM memory accounting.\n"); | ||
71 | return ret; | ||
72 | } | ||
73 | |||
74 | dev_priv->bo_global_ref.mem_glob = | ||
75 | dev_priv->mem_global_ref.object; | ||
76 | global_ref = &dev_priv->bo_global_ref.ref; | 51 | global_ref = &dev_priv->bo_global_ref.ref; |
77 | global_ref->global_type = DRM_GLOBAL_TTM_BO; | 52 | global_ref->global_type = DRM_GLOBAL_TTM_BO; |
78 | global_ref->size = sizeof(struct ttm_bo_global); | 53 | global_ref->size = sizeof(struct ttm_bo_global); |
@@ -87,12 +62,10 @@ int vmw_ttm_global_init(struct vmw_private *dev_priv) | |||
87 | 62 | ||
88 | return 0; | 63 | return 0; |
89 | out_no_bo: | 64 | out_no_bo: |
90 | drm_global_item_unref(&dev_priv->mem_global_ref); | ||
91 | return ret; | 65 | return ret; |
92 | } | 66 | } |
93 | 67 | ||
94 | void vmw_ttm_global_release(struct vmw_private *dev_priv) | 68 | void vmw_ttm_global_release(struct vmw_private *dev_priv) |
95 | { | 69 | { |
96 | drm_global_item_unref(&dev_priv->bo_global_ref.ref); | 70 | drm_global_item_unref(&dev_priv->bo_global_ref.ref); |
97 | drm_global_item_unref(&dev_priv->mem_global_ref); | ||
98 | } | 71 | } |