]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: move debug_vm handling to amdgpu_cs_parser_fini
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Mon, 22 Jun 2026 08:11:22 +0000 (10:11 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Jul 2026 23:59:29 +0000 (19:59 -0400)
The commit referenced below restarts the CS if the validation is
still in progress. When debug_vm is enabled, all BOs from the CS
are invalidated so we will hit an infinite loop.

To avoid that, defer BO invalidation to amdgpu_cs_parser_fini.

Fixes: 59720bfd8c6d ("drm/amdgpu: restart the CS if some parts of the VM are still invalidated")
Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8c990ee9daa295462df24982ce6878db997a380a)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index e714cee2997aa9754eb3b90c37e7e37b0bfee314..5445f75741b53d12bec625401a5bce37d717e330 100644 (file)
@@ -1177,19 +1177,6 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
                job->vm_pd_addr = amdgpu_gmc_pd_addr(vm->root.bo);
        }
 
-       if (adev->debug_vm) {
-               /* Invalidate all BOs to test for userspace bugs */
-               amdgpu_bo_list_for_each_entry(e, p->bo_list) {
-                       struct amdgpu_bo *bo = e->bo;
-
-                       /* ignore duplicates */
-                       if (!bo)
-                               continue;
-
-                       amdgpu_vm_bo_invalidate(bo, false);
-               }
-       }
-
        return 0;
 }
 
@@ -1378,6 +1365,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 /* Cleanup the parser structure */
 static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser)
 {
+       struct amdgpu_device *adev = parser->adev;
+       struct amdgpu_bo_list_entry *e;
        unsigned int i;
 
        amdgpu_sync_free(&parser->sync);
@@ -1393,8 +1382,21 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser)
 
        if (parser->ctx)
                amdgpu_ctx_put(parser->ctx);
-       if (parser->bo_list)
+       if (parser->bo_list) {
+               if (adev->debug_vm) {
+                       /* Invalidate all BOs to test for userspace bugs */
+                       amdgpu_bo_list_for_each_entry(e, parser->bo_list) {
+                               struct amdgpu_bo *bo = e->bo;
+
+                               /* ignore duplicates */
+                               if (!bo)
+                                       continue;
+
+                               amdgpu_vm_bo_invalidate(bo, false);
+                       }
+               }
                amdgpu_bo_list_put(parser->bo_list);
+       }
 
        for (i = 0; i < parser->nchunks; i++)
                kvfree(parser->chunks[i].kdata);