diff options
| author | Christian König <christian.koenig@amd.com> | 2023-04-19 15:17:57 +0200 | 
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2023-06-15 11:37:55 -0400 | 
| commit | f88e295e9094deee93066f32a4380307e8cb3dd9 (patch) | |
| tree | 0bf57795436d6a26eacedf3b91f7245b8f53a95f /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |
| parent | 55bf196f60dfc89488c5645d112a9176c6fe4708 (diff) | |
drm/amdgpu: add VM generation token
Instead of using the VRAM lost counter add a 64bit token which indicates
if a context or job is still valid to use.
Should the VRAM be lost or the page tables need re-creation the token will
change indicating that userspace needs to act and re-create the contexts
and re-submit the work.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 | 
1 files changed, 26 insertions, 0 deletions
| diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 1045be4b547c..143d11afe0e5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -406,6 +406,30 @@ static void amdgpu_vm_fini_entities(struct amdgpu_vm *vm)  }  /** + * amdgpu_vm_generation - return the page table re-generation counter + * @adev: the amdgpu_device + * @vm: optional VM to check, might be NULL + * + * Returns a page table re-generation token to allow checking if submissions + * are still valid to use this VM. The VM parameter might be NULL in which case + * just the VRAM lost counter will be used. + */ +uint64_t amdgpu_vm_generation(struct amdgpu_device *adev, struct amdgpu_vm *vm) +{ +	uint64_t result = (u64)atomic_read(&adev->vram_lost_counter) << 32; + +	if (!vm) +		return result; + +	result += vm->generation; +	/* Add one if the page tables will be re-generated on next CS */ +	if (drm_sched_entity_error(&vm->delayed)) +		++result; + +	return result; +} + +/**   * amdgpu_vm_validate_pt_bos - validate the page table BOs   *   * @adev: amdgpu device pointer @@ -428,6 +452,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,  	int r;  	if (drm_sched_entity_error(&vm->delayed)) { +		++vm->generation;  		amdgpu_vm_bo_reset_state_machine(vm);  		amdgpu_vm_fini_entities(vm);  		r = amdgpu_vm_init_entities(adev, vm); @@ -2134,6 +2159,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)  	vm->last_update = dma_fence_get_stub();  	vm->last_unlocked = dma_fence_get_stub();  	vm->last_tlb_flush = dma_fence_get_stub(); +	vm->generation = 0;  	mutex_init(&vm->eviction_lock);  	vm->evicting = false; | 
