Skip to content

Commit f0d81d8

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 4b606f3 commit f0d81d8

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
@@ -479,6 +479,15 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
479479

480480
if (new_mem->mem_type == TTM_PL_TT ||
481481
new_mem->mem_type == AMDGPU_PL_PREEMPT) {
482+
if (old_mem && (old_mem->mem_type == TTM_PL_TT ||
483+
old_mem->mem_type == AMDGPU_PL_PREEMPT)) {
484+
r = ttm_bo_wait_ctx(bo, ctx);
485+
if (r)
486+
return r;
487+
488+
amdgpu_ttm_backend_unbind(bo->bdev, bo->ttm);
489+
}
490+
482491
r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
483492
if (r)
484493
return r;
@@ -513,6 +522,15 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
513522
ttm_bo_assign_mem(bo, new_mem);
514523
return 0;
515524
}
525+
if ((old_mem->mem_type == TTM_PL_TT ||
526+
old_mem->mem_type == AMDGPU_PL_PREEMPT) &&
527+
(new_mem->mem_type == TTM_PL_TT ||
528+
new_mem->mem_type == AMDGPU_PL_PREEMPT)) {
529+
amdgpu_bo_move_notify(bo, evict, new_mem);
530+
ttm_resource_free(bo, &bo->resource);
531+
ttm_bo_assign_mem(bo, new_mem);
532+
return 0;
533+
}
516534

517535
if (old_mem->mem_type == AMDGPU_PL_GDS ||
518536
old_mem->mem_type == AMDGPU_PL_GWS ||

0 commit comments

Comments
 (0)