Commit dfb8fa98 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: forward operation context to ttm_bo_mem_space

This way we can finally use some more stats.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Tested-by: default avatarDieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Acked-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 3f3a7c82
...@@ -466,12 +466,10 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo, ...@@ -466,12 +466,10 @@ static int amdgpu_move_blit(struct ttm_buffer_object *bo,
return r; return r;
} }
static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
bool evict, bool interruptible, struct ttm_operation_ctx *ctx,
bool no_wait_gpu,
struct ttm_mem_reg *new_mem) struct ttm_mem_reg *new_mem)
{ {
struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
struct amdgpu_device *adev; struct amdgpu_device *adev;
struct ttm_mem_reg *old_mem = &bo->mem; struct ttm_mem_reg *old_mem = &bo->mem;
struct ttm_mem_reg tmp_mem; struct ttm_mem_reg tmp_mem;
...@@ -489,7 +487,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, ...@@ -489,7 +487,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo,
placements.fpfn = 0; placements.fpfn = 0;
placements.lpfn = 0; placements.lpfn = 0;
placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
r = ttm_bo_mem_space(bo, &placement, &tmp_mem, &ctx); r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
if (unlikely(r)) { if (unlikely(r)) {
return r; return r;
} }
...@@ -503,22 +501,20 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, ...@@ -503,22 +501,20 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo,
if (unlikely(r)) { if (unlikely(r)) {
goto out_cleanup; goto out_cleanup;
} }
r = amdgpu_move_blit(bo, true, no_wait_gpu, &tmp_mem, old_mem); r = amdgpu_move_blit(bo, true, ctx->no_wait_gpu, &tmp_mem, old_mem);
if (unlikely(r)) { if (unlikely(r)) {
goto out_cleanup; goto out_cleanup;
} }
r = ttm_bo_move_ttm(bo, interruptible, no_wait_gpu, new_mem); r = ttm_bo_move_ttm(bo, ctx->interruptible, ctx->no_wait_gpu, new_mem);
out_cleanup: out_cleanup:
ttm_bo_mem_put(bo, &tmp_mem); ttm_bo_mem_put(bo, &tmp_mem);
return r; return r;
} }
static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
bool evict, bool interruptible, struct ttm_operation_ctx *ctx,
bool no_wait_gpu,
struct ttm_mem_reg *new_mem) struct ttm_mem_reg *new_mem)
{ {
struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
struct amdgpu_device *adev; struct amdgpu_device *adev;
struct ttm_mem_reg *old_mem = &bo->mem; struct ttm_mem_reg *old_mem = &bo->mem;
struct ttm_mem_reg tmp_mem; struct ttm_mem_reg tmp_mem;
...@@ -536,15 +532,15 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, ...@@ -536,15 +532,15 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
placements.fpfn = 0; placements.fpfn = 0;
placements.lpfn = 0; placements.lpfn = 0;
placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT; placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
r = ttm_bo_mem_space(bo, &placement, &tmp_mem, &ctx); r = ttm_bo_mem_space(bo, &placement, &tmp_mem, ctx);
if (unlikely(r)) { if (unlikely(r)) {
return r; return r;
} }
r = ttm_bo_move_ttm(bo, interruptible, no_wait_gpu, &tmp_mem); r = ttm_bo_move_ttm(bo, ctx->interruptible, ctx->no_wait_gpu, &tmp_mem);
if (unlikely(r)) { if (unlikely(r)) {
goto out_cleanup; goto out_cleanup;
} }
r = amdgpu_move_blit(bo, true, no_wait_gpu, new_mem, old_mem); r = amdgpu_move_blit(bo, true, ctx->no_wait_gpu, new_mem, old_mem);
if (unlikely(r)) { if (unlikely(r)) {
goto out_cleanup; goto out_cleanup;
} }
...@@ -590,12 +586,10 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict, ...@@ -590,12 +586,10 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
if (old_mem->mem_type == TTM_PL_VRAM && if (old_mem->mem_type == TTM_PL_VRAM &&
new_mem->mem_type == TTM_PL_SYSTEM) { new_mem->mem_type == TTM_PL_SYSTEM) {
r = amdgpu_move_vram_ram(bo, evict, ctx->interruptible, r = amdgpu_move_vram_ram(bo, evict, ctx, new_mem);
ctx->no_wait_gpu, new_mem);
} else if (old_mem->mem_type == TTM_PL_SYSTEM && } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
new_mem->mem_type == TTM_PL_VRAM) { new_mem->mem_type == TTM_PL_VRAM) {
r = amdgpu_move_ram_vram(bo, evict, ctx->interruptible, r = amdgpu_move_ram_vram(bo, evict, ctx, new_mem);
ctx->no_wait_gpu, new_mem);
} else { } else {
r = amdgpu_move_blit(bo, evict, ctx->no_wait_gpu, r = amdgpu_move_blit(bo, evict, ctx->no_wait_gpu,
new_mem, old_mem); new_mem, old_mem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment