diff options
author | Christian König <christian.koenig@amd.com> | 2018-04-19 08:22:56 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-05-24 11:07:54 -0400 |
commit | 862b8c5762e4e2324d18c881ce86062af72b2063 (patch) | |
tree | 0944ba704aff5acc14bcf87d1aea94898fc8dad2 /drivers/gpu/drm/amd/amdgpu | |
parent | a7f91061c60ad9cac2e6a03b642be6a4f88b3662 (diff) |
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: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index a31afac8e8e9..f5dee4c6757c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -902,8 +902,8 @@ static void amdgpu_vm_invalidate_level(struct amdgpu_device *adev, | |||
902 | if (!entry->base.bo) | 902 | if (!entry->base.bo) |
903 | continue; | 903 | continue; |
904 | 904 | ||
905 | if (list_empty(&entry->base.vm_status)) | 905 | if (!entry->base.moved) |
906 | list_add(&entry->base.vm_status, &vm->relocated); | 906 | list_move(&entry->base.vm_status, &vm->relocated); |
907 | amdgpu_vm_invalidate_level(adev, vm, entry, level + 1); | 907 | amdgpu_vm_invalidate_level(adev, vm, entry, level + 1); |
908 | } | 908 | } |
909 | } | 909 | } |
@@ -964,6 +964,7 @@ restart: | |||
964 | bo_base = list_first_entry(&vm->relocated, | 964 | bo_base = list_first_entry(&vm->relocated, |
965 | struct amdgpu_vm_bo_base, | 965 | struct amdgpu_vm_bo_base, |
966 | vm_status); | 966 | vm_status); |
967 | bo_base->moved = false; | ||
967 | list_del_init(&bo_base->vm_status); | 968 | list_del_init(&bo_base->vm_status); |
968 | 969 | ||
969 | bo = bo_base->bo->parent; | 970 | bo = bo_base->bo->parent; |
@@ -1877,10 +1878,10 @@ static void amdgpu_vm_bo_insert_map(struct amdgpu_device *adev, | |||
1877 | if (mapping->flags & AMDGPU_PTE_PRT) | 1878 | if (mapping->flags & AMDGPU_PTE_PRT) |
1878 | amdgpu_vm_prt_get(adev); | 1879 | amdgpu_vm_prt_get(adev); |
1879 | 1880 | ||
1880 | if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv) { | 1881 | if (bo && bo->tbo.resv == vm->root.base.bo->tbo.resv && |
1882 | !bo_va->base.moved) { | ||
1881 | spin_lock(&vm->moved_lock); | 1883 | spin_lock(&vm->moved_lock); |
1882 | if (list_empty(&bo_va->base.vm_status)) | 1884 | list_move(&bo_va->base.vm_status, &vm->moved); |
1883 | list_add(&bo_va->base.vm_status, &vm->moved); | ||
1884 | spin_unlock(&vm->moved_lock); | 1885 | spin_unlock(&vm->moved_lock); |
1885 | } | 1886 | } |
1886 | trace_amdgpu_vm_bo_map(bo_va, mapping); | 1887 | trace_amdgpu_vm_bo_map(bo_va, mapping); |
@@ -2233,6 +2234,7 @@ void amdgpu_vm_bo_invalidate(struct amdgpu_device *adev, | |||
2233 | 2234 | ||
2234 | list_for_each_entry(bo_base, &bo->va, bo_list) { | 2235 | list_for_each_entry(bo_base, &bo->va, bo_list) { |
2235 | struct amdgpu_vm *vm = bo_base->vm; | 2236 | struct amdgpu_vm *vm = bo_base->vm; |
2237 | bool was_moved = bo_base->moved; | ||
2236 | 2238 | ||
2237 | bo_base->moved = true; | 2239 | bo_base->moved = true; |
2238 | if (evicted && bo->tbo.resv == vm->root.base.bo->tbo.resv) { | 2240 | 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 | continue; | 2246 | continue; |
2245 | } | 2247 | } |
2246 | 2248 | ||
2247 | if (bo->tbo.type == ttm_bo_type_kernel) { | 2249 | if (was_moved) |
2248 | if (list_empty(&bo_base->vm_status)) | ||
2249 | list_add(&bo_base->vm_status, &vm->relocated); | ||
2250 | continue; | 2250 | continue; |
2251 | } | ||
2252 | 2251 | ||
2253 | spin_lock(&bo_base->vm->moved_lock); | 2252 | if (bo->tbo.type == ttm_bo_type_kernel) { |
2254 | if (list_empty(&bo_base->vm_status)) | 2253 | list_move(&bo_base->vm_status, &vm->relocated); |
2255 | list_add(&bo_base->vm_status, &vm->moved); | 2254 | } else { |
2256 | spin_unlock(&bo_base->vm->moved_lock); | 2255 | spin_lock(&bo_base->vm->moved_lock); |
2256 | list_move(&bo_base->vm_status, &vm->moved); | ||
2257 | spin_unlock(&bo_base->vm->moved_lock); | ||
2258 | } | ||
2257 | } | 2259 | } |
2258 | } | 2260 | } |
2259 | 2261 | ||