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

drm/amdgpu: consistenly use VM moved flag

Instead of sometimes checking if the vm_status is empty use the moved
flag and also reset it when the BO leaves the state machine.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Reviewed-by: default avatarJunwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent a7f91061
...@@ -902,8 +902,8 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_device *adev, ...@@ -902,8 +902,8 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_device *adev,
if (!entry->base.bo) if (!entry->base.bo)
continue; continue;
if (list_empty(&entry->base.vm_status)) if (!entry->base.moved)
list_add(&entry->base.vm_status, &vm->relocated); list_move(&entry->base.vm_status, &vm->relocated);
amdgpu_vm_invalidate_level(adev, vm, entry, level + 1); amdgpu_vm_invalidate_level(adev, vm, entry, level + 1);
} }
} }
...@@ -964,6 +964,7 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev, ...@@ -964,6 +964,7 @@ int amdgpu_vm_update_directories(struct amdgpu_device *adev,
bo_base = list_first_entry(&vm->relocated, bo_base = list_first_entry(&vm->relocated,
struct amdgpu_vm_bo_base, struct amdgpu_vm_bo_base,
vm_status); vm_status);
bo_base->moved = false;
list_del_init(&bo_base->vm_status); list_del_init(&bo_base->vm_status);
bo = bo_base->bo->parent; bo = bo_base->bo->parent;
...@@ -1877,10 +1878,10 @@ static void amdgpu_vm_bo_insert_map(struct amdgpu_device *adev, ...@@ -1877,10 +1878,10 @@ static void amdgpu_vm_bo_insert_map(struct amdgpu_device *adev,
if (mapping->flags & AMDGPU_PTE_PRT) if (mapping->flags & AMDGPU_PTE_PRT)
amdgpu_vm_prt_get(adev); amdgpu_vm_prt_get(adev);
if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv) { if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv &&
!bo_va->base.moved) {
spin_lock(&vm->moved_lock); spin_lock(&vm->moved_lock);
if (list_empty(&bo_va->base.vm_status)) list_move(&bo_va->base.vm_status, &vm->moved);
list_add(&bo_va->base.vm_status, &vm->moved);
spin_unlock(&vm->moved_lock); spin_unlock(&vm->moved_lock);
} }
trace_amdgpu_vm_bo_map(bo_va, mapping); trace_amdgpu_vm_bo_map(bo_va, mapping);
...@@ -2233,6 +2234,7 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, ...@@ -2233,6 +2234,7 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
list_for_each_entry(bo_base, &bo->va, bo_list) { list_for_each_entry(bo_base, &bo->va, bo_list) {
struct amdgpu_vm *vm = bo_base->vm; struct amdgpu_vm *vm = bo_base->vm;
bool was_moved = bo_base->moved;
bo_base->moved = true; bo_base->moved = true;
if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) { if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) {
...@@ -2244,16 +2246,16 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, ...@@ -2244,16 +2246,16 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev,
continue; continue;
} }
if (bo->tbo.type == ttm_bo_type_kernel) { if (was_moved)
if (list_empty(&bo_base->vm_status))
list_add(&bo_base->vm_status, &vm->relocated);
continue; continue;
}
spin_lock(&bo_base->vm->moved_lock); if (bo->tbo.type == ttm_bo_type_kernel) {
if (list_empty(&bo_base->vm_status)) list_move(&bo_base->vm_status, &vm->relocated);
list_add(&bo_base->vm_status, &vm->moved); } else {
spin_unlock(&bo_base->vm->moved_lock); spin_lock(&bo_base->vm->moved_lock);
list_move(&bo_base->vm_status, &vm->moved);
spin_unlock(&bo_base->vm->moved_lock);
}
} }
} }
......
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