drm/amdgpu: re-validate per VM BOs if required
Subsystems (2)
PATCH 1/2 drm/amdgpu: re-validate per VM BOs if required
From: Christian König <[email protected]>
If a per VM BO ends up in a allowed domain it never moves back into the prefered domain.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +13 -2
@@ -1808,14 +1808,16 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,spin_lock (&vm->status_lock);while (!list_empty (&vm->moved)) { -struct amdgpu_bo_va *bo_va;struct reservation_object *resv; +struct amdgpu_bo_va *bo_va; +struct amdgpu_bo *bo; bo_va =list_first_entry (&vm->moved, struct amdgpu_bo_va, base.vm_status);spin_unlock (&vm->status_lock); - resv = bo_va->base.bo->tbo.resv; + bo = bo_va->base.bo; + resv = bo->tbo.resv;/* Per VM BOs never need to bo cleared in the page tables */ if (resv == vm->root.base.bo->tbo.resv)
@@ -1835,6 +1837,15 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,kcl_reservation_object_unlock (resv);spin_lock (&vm->status_lock); + +/* If the BO prefers to be in VRAM, but currently isn't add it +* back to the evicted list so that it gets validated again on +* the next command submission. +*/ +if (resv == vm->root.base.bo->tbo.resv && + bo->preferred_domains ==AMDGPU_GEM_DOMAIN_VRAM && + bo->tbo.mem.mem_type !=TTM_PL_VRAM ) +list_add_tail (&bo_va->base.vm_status, &vm->evicted); }spin_unlock (&vm->status_lock);
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/2 drm/amdgpu: add per vm bo validation order
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 14 +++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +13 -1
@@ -205,12 +205,22 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,spin_lock (&vm->status_lock);while (!list_empty (&vm->evicted)) { -struct amdgpu_vm_bo_base *bo_base; +struct amdgpu_vm_bo_base *bo_base, *tmp;struct amdgpu_bo *bo; +u64 bo_order; bo_base =list_first_entry (&vm->evicted, struct amdgpu_vm_bo_base, vm_status); + bo_order = bo_base->order; +if (bo_order >0 ) { +list_for_each_entry (tmp, &vm->evicted, vm_status) { +if (tmp->order < bo_order) { + bo_order = tmp->order; + bo_base = tmp; + } + } + }spin_unlock (&vm->status_lock); bo = bo_base->bo;
@@ -1903,6 +1913,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev,* */ spin_lock (&vm->status_lock);list_move_tail (&bo_va->base.vm_status, &vm->evicted); + bo_va->base.order = (u64 )atomic64_inc_return (&vm->bo_order);spin_unlock (&vm->status_lock);return bo_va;
@@ -2424,6 +2435,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,INIT_LIST_HEAD (&vm->relocated);INIT_LIST_HEAD (&vm->moved);INIT_LIST_HEAD (&vm->freed); +atomic64_set (&vm->bo_order,0 );/* create scheduler entity for page table updates */
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +6 -0
@@ -152,6 +152,9 @@ struct amdgpu_vm_bo_base {/* protected by the BO being reserved */ bool moved; + +/* validate order */ +u64 order; };struct amdgpu_vm_pt {
@@ -214,6 +217,9 @@ struct amdgpu_vm {/* Limit non-retry fault storms */ unsigned int fault_credit; + +/* per vm bo order in this vm */ +atomic64_t bo_order; };struct amdgpu_vm_manager {
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 26.03.2018 um 10:47 schrieb Chunming Zhou:
Quoted 38 lines
From: Christian König <[email protected]>
If a per VM BO ends up in a allowed domain it never moves back into the prefered domain.
Change-Id Ifb3e561785d3b464da28c439b271c26825224c5eSigned-off-by Christian König <[email protected]>Reviewed-and-Tested-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-2@@ -1808,14 +1808,16 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,spin_lock (&vm->status_lock);while (!list_empty (&vm->moved)) { -struct amdgpu_bo_va *bo_va;struct reservation_object *resv; +struct amdgpu_bo_va *bo_va; +struct amdgpu_bo *bo; bo_va =list_first_entry (&vm->moved, struct amdgpu_bo_va, base.vm_status);spin_unlock (&vm->status_lock); - resv = bo_va->base.bo->tbo.resv; + bo = bo_va->base.bo; + resv = bo->tbo.resv;/* Per VM BOs never need to bo cleared in the page tables */ if (resv == vm->root.base.bo->tbo.resv)@@ -1835,6 +1837,15 @@ int amdgpu_vm_handle_moved(struct amdgpu_device *adev,kcl_reservation_object_unlock (resv);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_handle_moved(struct amdgpu_device *adev, · line 1848
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +9
-0spin_lock (&vm->status_lock); + +/* If the BO prefers to be in VRAM, but currently isn't add it +* back to the evicted list so that it gets validated again on +* the next command submission. +*/ +if (resv == vm->root.base.bo->tbo.resv && + bo->preferred_domains ==AMDGPU_GEM_DOMAIN_VRAM && + bo->tbo.mem.mem_type !=TTM_PL_VRAM ) +list_add_tail (&bo_va->base.vm_status, &vm->evicted);
Thinking about this more, might be even better to put that into amdgpu_vm_bo_update() instead of the "list_del_init(&bo_va->base.vm_status);".
I'm on easter vacation this week, so checking mails is delayed. But I'm going to look at patch #2 this evening or tomorrow.
Regards,
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_handle_moved(struct amdgpu_device *adev, · line 1851
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0}spin_unlock (&vm->status_lock);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx