diff options
author | Christian König <christian.koenig@amd.com> | 2018-08-06 05:05:30 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 12:11:21 -0400 |
commit | 9a2779528eddacf0123bfd7308b71141b54cc619 (patch) | |
tree | efb7596bcfa08db39c788758c1402d27898598cc /drivers/gpu/drm | |
parent | 8c7655a0fdd32ab39cfef604403dbe1013df213b (diff) |
drm/ttm: revise ttm_bo_move_to_lru_tail to support bulk moves
When move a BO to the end of LRU, it need remember the BO positions.
Make sure all moved bo in between "first" and "last". And they will be bulk
moving together.
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Huang Rui <ray.huang@amd.com>
Tested-by: Mike Lothian <mike@fireburn.co.uk>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Acked-by: Chunming Zhou <david1.zhou@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')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 26 |
2 files changed, 29 insertions, 5 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 7d7d7e532246..d12bffa5f70c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -297,9 +297,9 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
297 | 297 | ||
298 | if (bo->parent) { | 298 | if (bo->parent) { |
299 | spin_lock(&glob->lru_lock); | 299 | spin_lock(&glob->lru_lock); |
300 | ttm_bo_move_to_lru_tail(&bo->tbo); | 300 | ttm_bo_move_to_lru_tail(&bo->tbo, NULL); |
301 | if (bo->shadow) | 301 | if (bo->shadow) |
302 | ttm_bo_move_to_lru_tail(&bo->shadow->tbo); | 302 | ttm_bo_move_to_lru_tail(&bo->shadow->tbo, NULL); |
303 | spin_unlock(&glob->lru_lock); | 303 | spin_unlock(&glob->lru_lock); |
304 | } | 304 | } |
305 | 305 | ||
@@ -319,9 +319,9 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, | |||
319 | if (!bo->parent) | 319 | if (!bo->parent) |
320 | continue; | 320 | continue; |
321 | 321 | ||
322 | ttm_bo_move_to_lru_tail(&bo->tbo); | 322 | ttm_bo_move_to_lru_tail(&bo->tbo, NULL); |
323 | if (bo->shadow) | 323 | if (bo->shadow) |
324 | ttm_bo_move_to_lru_tail(&bo->shadow->tbo); | 324 | ttm_bo_move_to_lru_tail(&bo->shadow->tbo, NULL); |
325 | } | 325 | } |
326 | spin_unlock(&glob->lru_lock); | 326 | spin_unlock(&glob->lru_lock); |
327 | 327 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 7c484729f9b2..7117b6b1e223 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -214,12 +214,36 @@ void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo) | |||
214 | } | 214 | } |
215 | EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); | 215 | EXPORT_SYMBOL(ttm_bo_del_sub_from_lru); |
216 | 216 | ||
217 | void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) | 217 | static void ttm_bo_bulk_move_set_pos(struct ttm_lru_bulk_move_pos *pos, |
218 | struct ttm_buffer_object *bo) | ||
219 | { | ||
220 | if (!pos->first) | ||
221 | pos->first = bo; | ||
222 | pos->last = bo; | ||
223 | } | ||
224 | |||
225 | void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo, | ||
226 | struct ttm_lru_bulk_move *bulk) | ||
218 | { | 227 | { |
219 | reservation_object_assert_held(bo->resv); | 228 | reservation_object_assert_held(bo->resv); |
220 | 229 | ||
221 | ttm_bo_del_from_lru(bo); | 230 | ttm_bo_del_from_lru(bo); |
222 | ttm_bo_add_to_lru(bo); | 231 | ttm_bo_add_to_lru(bo); |
232 | |||
233 | if (bulk && !(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { | ||
234 | switch (bo->mem.mem_type) { | ||
235 | case TTM_PL_TT: | ||
236 | ttm_bo_bulk_move_set_pos(&bulk->tt[bo->priority], bo); | ||
237 | break; | ||
238 | |||
239 | case TTM_PL_VRAM: | ||
240 | ttm_bo_bulk_move_set_pos(&bulk->vram[bo->priority], bo); | ||
241 | break; | ||
242 | } | ||
243 | if (bo->ttm && !(bo->ttm->page_flags & | ||
244 | (TTM_PAGE_FLAG_SG | TTM_PAGE_FLAG_SWAPPED))) | ||
245 | ttm_bo_bulk_move_set_pos(&bulk->swap[bo->priority], bo); | ||
246 | } | ||
223 | } | 247 | } |
224 | EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); | 248 | EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); |
225 | 249 | ||