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.
Change-Id Ifb3e561785d3b464da28c439b271c26825224c5e
Signed-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 +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
Change-Id I59f1da8a765efae8196c0b1599f47a8b8485c4d3
Signed-off-by Chunming Zhou <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +11 -1
@@ -205,12 +205,20 @@ 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; +list_for_each_entry (tmp, &vm->evicted, vm_status) { +if (tmp->order < bo_order) { + bo_order = bo_base->order; + bo_base = tmp; + } + }spin_unlock (&vm->status_lock); bo = bo_base->bo;
@@ -1903,6 +1911,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 +2433,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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/2] drm/amdgpu: add per vm bo validation order
pls ignore this one, will re-send it.
Quoted 64 lines · Chunming Zhou
Change-Id I59f1da8a765efae8196c0b1599f47a8b8485c4d3Signed-off-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +11
-1@@ -205,12 +205,20 @@ 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; +list_for_each_entry (tmp, &vm->evicted, vm_status) { +if (tmp->order < bo_order) { + bo_order = bo_base->order; + bo_base = tmp; + } + }spin_unlock (&vm->status_lock); bo = bo_base->bo;@@ -1903,6 +1911,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 +2433,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 +3
-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 {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h struct amdgpu_vm { · line 225
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +3
-0@@ -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 {
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx