drm/amdgpu/userq: validate evicted BOs on the individual idle list on restore
Subsystems (2)
PATCH 1/1 drm/amdgpu/userq: validate evicted BOs on the individual idle list on restore
amdgpu_vm_bo_update() moves an individual bo_va to the idle list even when its BO has been evicted to system memory. A GEM_VA operation or a kernel CS that does not use the BO can therefore leave it idle with invalid PTEs.
User queue restore does not validate these idle BOs before updating the page tables. Validation during eviction fence rearming happens afterwards, without another PTE update before the queues resume.
A GTT BO evicted without user queues, mapped at a second VA, then written by a new SDMA user queue:
after the eviction and the second mapping: dword 0 0x00000000, 64 of 64 dwords differ amdgpu 0000:03:00.0: [gfxhub] page fault (src_id:0 ring:8 vmid:8 pasid:289)
amdgpu 0000:03:00.0: Faulty UTCL2 client ID: SDMA0 (0xd)
Subtest userq-evicted-bo-va-map: FAIL
Validate the BOs on the individual idle list that are in system memory without being allowed there. Discarded BOs may have no resource, so validate those as well to allocate new backing storage before updating their PTEs.
With the fix userq-evicted-bo-va-map (3/3 failed before) and userq-discarded-bo-va-map pass 3/3.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +30 -0
@@ -998,6 +998,7 @@ amdgpu_userq_bo_validate(struct amdgpu_device *adev, struct drm_exec *exec,struct amdgpu_bo *bo, *tmp;int ret; +retry:spin_lock (&vm->individual_lock);while (!list_empty (&vm->individual.needs_update)) { bo_va = list_first_entry(&vm->individual.needs_update,
@@ -1025,6 +1026,35 @@ amdgpu_userq_bo_validate(struct amdgpu_device *adev, struct drm_exec *exec,spin_lock (&vm->individual_lock); } + +/* +* A GEM_VA operation or a kernel CS can update the PTEs of an evicted +* BO without validating it, which moves it to the idle list with PTEs +* pointing nowhere. Validate those as well, that moves them back to the +* needs_update list. +*/ +list_for_each_entry (bo_va, &vm->individual.idle, base.vm_status) { + bo = bo_va->base.bo; +if (!bo ||amdgpu_ttm_tt_is_userptr (bo->tbo.ttm) || + (bo->allowed_domains &AMDGPU_GEM_DOMAIN_CPU ) || + (bo->tbo.resource && + bo->tbo.resource->mem_type !=TTM_PL_SYSTEM )) +continue ; + + tmp =amdgpu_bo_ref (bo); +spin_unlock (&vm->individual_lock); + + ret =drm_exec_prepare_obj (exec, &bo->tbo.base, +TTM_NUM_MOVE_FENCES +1 ); +if (likely (!ret)) { +amdgpu_bo_placement_from_domain (bo, bo->allowed_domains); + ret =ttm_bo_validate (&bo->tbo, &bo->placement, &ctx); + } +amdgpu_bo_unref (&tmp); +if (ret) +return ret; + goto retry; + }spin_unlock (&vm->individual_lock);return 0 ;
Signature · 1 line
2.50.1