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

drm/amdgpu: remove amdgpu_cs_try_evict

Trying to evict things from the current working set doesn't work that
well anymore because of per VM BOs.

Rely on reserving VRAM for page tables to avoid contention.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 9d1b3c78
...@@ -478,7 +478,6 @@ struct amdgpu_cs_parser { ...@@ -478,7 +478,6 @@ struct amdgpu_cs_parser {
uint64_t bytes_moved_vis_threshold; uint64_t bytes_moved_vis_threshold;
uint64_t bytes_moved; uint64_t bytes_moved;
uint64_t bytes_moved_vis; uint64_t bytes_moved_vis;
struct amdgpu_bo_list_entry *evictable;
/* user fence */ /* user fence */
struct amdgpu_bo_list_entry uf_entry; struct amdgpu_bo_list_entry uf_entry;
......
...@@ -449,75 +449,12 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p, ...@@ -449,75 +449,12 @@ static int amdgpu_cs_bo_validate(struct amdgpu_cs_parser *p,
return r; return r;
} }
/* Last resort, try to evict something from the current working set */
static bool amdgpu_cs_try_evict(struct amdgpu_cs_parser *p,
struct amdgpu_bo *validated)
{
uint32_t domain = validated->allowed_domains;
struct ttm_operation_ctx ctx = { true, false };
int r;
if (!p->evictable)
return false;
for (;&p->evictable->tv.head != &p->validated;
p->evictable = list_prev_entry(p->evictable, tv.head)) {
struct amdgpu_bo_list_entry *candidate = p->evictable;
struct amdgpu_bo *bo = ttm_to_amdgpu_bo(candidate->tv.bo);
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
bool update_bytes_moved_vis;
uint32_t other;
/* If we reached our current BO we can forget it */
if (bo == validated)
break;
/* We can't move pinned BOs here */
if (bo->pin_count)
continue;
other = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
/* Check if this BO is in one of the domains we need space for */
if (!(other & domain))
continue;
/* Check if we can move this BO somewhere else */
other = bo->allowed_domains & ~domain;
if (!other)
continue;
/* Good we can try to move this BO somewhere else */
update_bytes_moved_vis =
!amdgpu_gmc_vram_full_visible(&adev->gmc) &&
amdgpu_bo_in_cpu_visible_vram(bo);
amdgpu_bo_placement_from_domain(bo, other);
r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
p->bytes_moved += ctx.bytes_moved;
if (update_bytes_moved_vis)
p->bytes_moved_vis += ctx.bytes_moved;
if (unlikely(r))
break;
p->evictable = list_prev_entry(p->evictable, tv.head);
list_move(&candidate->tv.head, &p->validated);
return true;
}
return false;
}
static int amdgpu_cs_validate(void *param, struct amdgpu_bo *bo) static int amdgpu_cs_validate(void *param, struct amdgpu_bo *bo)
{ {
struct amdgpu_cs_parser *p = param; struct amdgpu_cs_parser *p = param;
int r; int r;
do { r = amdgpu_cs_bo_validate(p, bo);
r = amdgpu_cs_bo_validate(p, bo);
} while (r == -ENOMEM && amdgpu_cs_try_evict(p, bo));
if (r) if (r)
return r; return r;
...@@ -556,9 +493,6 @@ static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p, ...@@ -556,9 +493,6 @@ static int amdgpu_cs_list_validate(struct amdgpu_cs_parser *p,
binding_userptr = true; binding_userptr = true;
} }
if (p->evictable == lobj)
p->evictable = NULL;
r = amdgpu_cs_validate(p, bo); r = amdgpu_cs_validate(p, bo);
if (r) if (r)
return r; return r;
...@@ -661,9 +595,6 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, ...@@ -661,9 +595,6 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
&p->bytes_moved_vis_threshold); &p->bytes_moved_vis_threshold);
p->bytes_moved = 0; p->bytes_moved = 0;
p->bytes_moved_vis = 0; p->bytes_moved_vis = 0;
p->evictable = list_last_entry(&p->validated,
struct amdgpu_bo_list_entry,
tv.head);
r = amdgpu_vm_validate_pt_bos(p->adev, &fpriv->vm, r = amdgpu_vm_validate_pt_bos(p->adev, &fpriv->vm,
amdgpu_cs_validate, p); amdgpu_cs_validate, p);
......
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