drm/amdgpu: reset vm state machine after gpu reset(vram lost)
authorjsg <jsg@openbsd.org>
Mon, 5 Aug 2024 02:47:58 +0000 (02:47 +0000)
committerjsg <jsg@openbsd.org>
Mon, 5 Aug 2024 02:47:58 +0000 (02:47 +0000)
From ZhenGuo Yin
323790535237927e1b6a7bc35ddf662c6e7c25cc in linux-6.6.y/6.6.44
5659b0c93a1ea02c662a030b322093203f299185 in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_vm.c

index f409651..4a36a04 100644 (file)
@@ -478,7 +478,7 @@ uint64_t amdgpu_vm_generation(struct amdgpu_device *adev, struct amdgpu_vm *vm)
        if (!vm)
                return result;
 
-       result += vm->generation;
+       result += lower_32_bits(vm->generation);
        /* Add one if the page tables will be re-generated on next CS */
        if (drm_sched_entity_error(&vm->delayed))
                ++result;
@@ -503,13 +503,14 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,
                              int (*validate)(void *p, struct amdgpu_bo *bo),
                              void *param)
 {
+       uint64_t new_vm_generation = amdgpu_vm_generation(adev, vm);
        struct amdgpu_vm_bo_base *bo_base;
        struct amdgpu_bo *shadow;
        struct amdgpu_bo *bo;
        int r;
 
-       if (drm_sched_entity_error(&vm->delayed)) {
-               ++vm->generation;
+       if (vm->generation != new_vm_generation) {
+               vm->generation = new_vm_generation;
                amdgpu_vm_bo_reset_state_machine(vm);
                amdgpu_vm_fini_entities(vm);
                r = amdgpu_vm_init_entities(adev, vm);
@@ -2265,7 +2266,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;
+       vm->generation = amdgpu_vm_generation(adev, NULL);
 
        rw_init(&vm->eviction_lock, "avmev");
        vm->evicting = false;