Skip to content

Commit 2b70014

Browse files
Timur Kristófgregkh
authored andcommitted
drm/amdgpu: Fix amdgpu_bo_move() when old_mem and new_mem are both GTT
commit ee94a65 upstream. The UVD code relies on GTT to GTT moves in order to ensure that its BOs don't cross 256M segments. Fixes: bfe5e58 ("drm/ttm: move last binding into the drivers.") Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 21fd45e) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b1f07bf commit 2b70014

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,15 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
501501

502502
if (new_mem->mem_type == TTM_PL_TT ||
503503
new_mem->mem_type == AMDGPU_PL_PREEMPT) {
504+
if (old_mem && (old_mem->mem_type == TTM_PL_TT ||
505+
old_mem->mem_type == AMDGPU_PL_PREEMPT)) {
506+
r = ttm_bo_wait_ctx(bo, ctx);
507+
if (r)
508+
return r;
509+
510+
amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
511+
}
512+
504513
r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
505514
if (r)
506515
return r;
@@ -535,6 +544,15 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
535544
ttm_bo_assign_mem(bo, new_mem);
536545
return 0;
537546
}
547+
if ((old_mem->mem_type == TTM_PL_TT ||
548+
old_mem->mem_type == AMDGPU_PL_PREEMPT) &&
549+
(new_mem->mem_type == TTM_PL_TT ||
550+
new_mem->mem_type == AMDGPU_PL_PREEMPT)) {
551+
amdgpu_bo_move_notify(bo, evict, new_mem);
552+
ttm_resource_free(bo, &bo->resource);
553+
ttm_bo_assign_mem(bo, new_mem);
554+
return 0;
555+
}
538556

539557
if (old_mem->mem_type == AMDGPU_PL_GDS ||
540558
old_mem->mem_type == AMDGPU_PL_GWS ||

0 commit comments

Comments
 (0)