Skip to content

Commit 5659b0c

Browse files
ZhenGuo Yinalexdeucher
authored andcommitted
drm/amdgpu: reset vm state machine after gpu reset(vram lost)
[Why] Page table of compute VM in the VRAM will lost after gpu reset. VRAM won't be restored since compute VM has no shadows. [How] Use higher 32-bit of vm->generation to record a vram_lost_counter. Reset the VM state machine when vm->genertaion is not equal to the new generation token. v2: Check vm->generation instead of calling drm_sched_entity_error in amdgpu_vm_validate. v3: Use new generation token instead of vram_lost_counter for check. Signed-off-by: ZhenGuo Yin <[email protected]> Reviewed-by: Christian König <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected] (cherry picked from commit 47c0388)
1 parent fab1ead commit 5659b0c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ uint64_t amdgpu_vm_generation(struct amdgpu_device *adev, struct amdgpu_vm *vm)
434434
if (!vm)
435435
return result;
436436

437-
result += vm->generation;
437+
result += lower_32_bits(vm->generation);
438438
/* Add one if the page tables will be re-generated on next CS */
439439
if (drm_sched_entity_error(&vm->delayed))
440440
++result;
@@ -463,13 +463,14 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,
463463
int (*validate)(void *p, struct amdgpu_bo *bo),
464464
void *param)
465465
{
466+
uint64_t new_vm_generation = amdgpu_vm_generation(adev, vm);
466467
struct amdgpu_vm_bo_base *bo_base;
467468
struct amdgpu_bo *shadow;
468469
struct amdgpu_bo *bo;
469470
int r;
470471

471-
if (drm_sched_entity_error(&vm->delayed)) {
472-
++vm->generation;
472+
if (vm->generation != new_vm_generation) {
473+
vm->generation = new_vm_generation;
473474
amdgpu_vm_bo_reset_state_machine(vm);
474475
amdgpu_vm_fini_entities(vm);
475476
r = amdgpu_vm_init_entities(adev, vm);
@@ -2439,7 +2440,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,
24392440
vm->last_update = dma_fence_get_stub();
24402441
vm->last_unlocked = dma_fence_get_stub();
24412442
vm->last_tlb_flush = dma_fence_get_stub();
2442-
vm->generation = 0;
2443+
vm->generation = amdgpu_vm_generation(adev, NULL);
24432444

24442445
mutex_init(&vm->eviction_lock);
24452446
vm->evicting = false;

0 commit comments

Comments
 (0)