History

drm/amdgpu: drop amdgpu_gtt_node

We have the BO pointer in the base structure now as well.

Christian König committed 5 years ago

Commit 77ef2711 parent fee2ede2 files · +26 −31Browse files

Unified · Split

2 files
  1. drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +18 −31
  2. include/drm/ttm/ttm_resource.h +8 −0
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c+18−31
@@ -26,23 +26,12 @@ · 25 unmodified lines
2626
2727 #include "amdgpu.h"
2828
29−struct amdgpu_gtt_node {
30− struct ttm_buffer_object *tbo;
31− struct ttm_range_mgr_node base;
32−};
33−
3429 static inline struct amdgpu_gtt_mgr *
3530 to_gtt_mgr(struct ttm_resource_manager *man)
3631 {
3732 return container_of(man, struct amdgpu_gtt_mgr, manager);
3833 }
3934
40−static inline struct amdgpu_gtt_node *
41−to_amdgpu_gtt_node(struct ttm_resource *res)
42−{
43− return container_of(res, struct amdgpu_gtt_node, base.base);
44−}
45−
4635 /**
4736 * DOC: mem_info_gtt_total
4837 *
@@ -106,9 +95,9 @@ const struct attribute_group amdgpu_gtt_mgr_attr_group = { · 57 unmodified lines
10695 */
10796 bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *res)
10897 {
109− struct amdgpu_gtt_node *node = to_amdgpu_gtt_node(res);
98+ struct ttm_range_mgr_node *node = to_ttm_range_mgr_node(res);
11099
111− return drm_mm_node_allocated(&node->base.mm_nodes[0]);
100+ return drm_mm_node_allocated(&node->mm_nodes[0]);
112101 }
113102
114103 /**
@@ -128,15 +117,14 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, · 13 unmodified lines
128117 {
129118 struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
130119 uint32_t num_pages = PFN_UP(tbo->base.size);
131− struct amdgpu_gtt_node *node;
120+ struct ttm_range_mgr_node *node;
132121 int r;
133122
134− node = kzalloc(struct_size(node, base.mm_nodes, 1), GFP_KERNEL);
123+ node = kzalloc(struct_size(node, mm_nodes, 1), GFP_KERNEL);
135124 if (!node)
136125 return -ENOMEM;
137126
138− node->tbo = tbo;
139− ttm_resource_init(tbo, place, &node->base.base);
127+ ttm_resource_init(tbo, place, &node->base);
140128 if (!(place->flags & TTM_PL_FLAG_TEMPORARY) &&
141129 ttm_resource_manager_usage(man) > man->size) {
142130 r = -ENOSPC;
@@ -145,8 +133,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, · 2 unmodified lines
145133
146134 if (place->lpfn) {
147135 spin_lock(&mgr->lock);
148− r = drm_mm_insert_node_in_range(&mgr->mm,
149− &node->base.mm_nodes[0],
136+ r = drm_mm_insert_node_in_range(&mgr->mm, &node->mm_nodes[0],
150137 num_pages, tbo->page_alignment,
151138 0, place->fpfn, place->lpfn,
152139 DRM_MM_INSERT_BEST);
@@ -154,18 +141,18 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man, · 1 unmodified line
154141 if (unlikely(r))
155142 goto err_free;
156143
157− node->base.base.start = node->base.mm_nodes[0].start;
144+ node->base.start = node->mm_nodes[0].start;
158145 } else {
159− node->base.mm_nodes[0].start = 0;
160− node->base.mm_nodes[0].size = node->base.base.num_pages;
161− node->base.base.start = AMDGPU_BO_INVALID_OFFSET;
146+ node->mm_nodes[0].start = 0;
147+ node->mm_nodes[0].size = node->base.num_pages;
148+ node->base.start = AMDGPU_BO_INVALID_OFFSET;
162149 }
163150
164− *res = &node->base.base;
151+ *res = &node->base;
165152 return 0;
166153
167154 err_free:
168− ttm_resource_fini(man, &node->base.base);
155+ ttm_resource_fini(man, &node->base);
169156 kfree(node);
170157 return r;
171158 }
@@ -181,12 +168,12 @@ err_free: · 9 unmodified lines
181168 static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
182169 struct ttm_resource *res)
183170 {
184− struct amdgpu_gtt_node *node = to_amdgpu_gtt_node(res);
171+ struct ttm_range_mgr_node *node = to_ttm_range_mgr_node(res);
185172 struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
186173
187174 spin_lock(&mgr->lock);
188− if (drm_mm_node_allocated(&node->base.mm_nodes[0]))
189− drm_mm_remove_node(&node->base.mm_nodes[0]);
175+ if (drm_mm_node_allocated(&node->mm_nodes[0]))
176+ drm_mm_remove_node(&node->mm_nodes[0]);
190177 spin_unlock(&mgr->lock);
191178
192179 ttm_resource_fini(man, res);
@@ -202,7 +189,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man, · 9 unmodified lines
202189 */
203190 int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr)
204191 {
205− struct amdgpu_gtt_node *node;
192+ struct ttm_range_mgr_node *node;
206193 struct drm_mm_node *mm_node;
207194 struct amdgpu_device *adev;
208195 int r = 0;
@@ -210,8 +197,8 @@ int amdgpu_gtt_mgr_recover(struct amdgpu_gtt_mgr *mgr) · 1 unmodified line
210197 adev = container_of(mgr, typeof(*adev), mman.gtt_mgr);
211198 spin_lock(&mgr->lock);
212199 drm_mm_for_each_node(mm_node, &mgr->mm) {
213− node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
214− r = amdgpu_ttm_recover_gart(node->tbo);
200+ node = container_of(mm_node, typeof(*node), mm_nodes[0]);
201+ r = amdgpu_ttm_recover_gart(node->base.bo);
215202 if (r)
216203 break;
217204 }
include/drm/ttm/ttm_resource.h+8−0
@@ -355,6 +355,14 @@ ttm_resource_manager_next(struct ttm_resource_manager *man, · 354 unmodified lines
355355 struct ttm_resource_cursor *cursor,
356356 struct ttm_resource *res);
357357
358+/**
359+ * ttm_resource_manager_for_each_res - iterate over all resources
360+ * @man: the resource manager
361+ * @cursor: struct ttm_resource_cursor for the current position
362+ * @res: the current resource
363+ *
364+ * Iterate over all the evictable resources in a resource manager.
365+ */
358366 #define ttm_resource_manager_for_each_res(man, cursor, res) \
359367 for (res = ttm_resource_manager_first(man, cursor); res; \
360368 res = ttm_resource_manager_next(man, cursor, res))