]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu: fix task hang from failed job submission during process kill
authorLiu01 Tong <Tong.Liu01@amd.com>
Mon, 11 Aug 2025 06:52:37 +0000 (14:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:34:38 +0000 (16:34 +0200)
commit aa5fc4362fac9351557eb27c745579159a2e4520 upstream.

During process kill, drm_sched_entity_flush() will kill the vm
entities. The following job submissions of this process will fail, and
the resources of these jobs have not been released, nor have the fences
been signalled, causing tasks to hang and timeout.

Fix by check entity status in amdgpu_vm_ready() and avoid submit jobs to
stopped entity.

v2: add amdgpu_vm_ready() check before amdgpu_vm_clear_freed() in
function amdgpu_cs_vm_handling().

Fixes: 1f02f2044bda ("drm/amdgpu: Avoid extra evict-restore process.")
Signed-off-by: Liu01 Tong <Tong.Liu01@amd.com>
Signed-off-by: Lin.Cao <lincao12@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit f101c13a8720c73e67f8f9d511fbbeda95bcedb1)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 9ea0d9b71f48db53119ccccdd5a5b309940c091e..82cb68114ae991c4df779ed83db81b4c6dace948 100644 (file)
@@ -1138,6 +1138,9 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
                }
        }
 
+       if (!amdgpu_vm_ready(vm))
+               return -EINVAL;
+
        r = amdgpu_vm_clear_freed(adev, vm, NULL);
        if (r)
                return r;
index ed37cc2f93ff5c21079e3a81772501c600621ead..9b364502de44f973c0d67977bb4301d150c70883 100644 (file)
@@ -654,11 +654,10 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,
  * Check if all VM PDs/PTs are ready for updates
  *
  * Returns:
- * True if VM is not evicting.
+ * True if VM is not evicting and all VM entities are not stopped
  */
 bool amdgpu_vm_ready(struct amdgpu_vm *vm)
 {
-       bool empty;
        bool ret;
 
        amdgpu_vm_eviction_lock(vm);
@@ -666,10 +665,18 @@ bool amdgpu_vm_ready(struct amdgpu_vm *vm)
        amdgpu_vm_eviction_unlock(vm);
 
        spin_lock(&vm->status_lock);
-       empty = list_empty(&vm->evicted);
+       ret &= list_empty(&vm->evicted);
        spin_unlock(&vm->status_lock);
 
-       return ret && empty;
+       spin_lock(&vm->immediate.lock);
+       ret &= !vm->immediate.stopped;
+       spin_unlock(&vm->immediate.lock);
+
+       spin_lock(&vm->delayed.lock);
+       ret &= !vm->delayed.stopped;
+       spin_unlock(&vm->delayed.lock);
+
+       return ret;
 }
 
 /**