]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu/userq: pin mqd and fw object bo to avoid eviction
authorSunil Khatri <sunil.khatri@amd.com>
Fri, 8 May 2026 10:28:09 +0000 (15:58 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 May 2026 16:07:36 +0000 (12:07 -0400)
mqd and fw objects are queue core objects which should remain
valid and never be unmapped and evicted for user queues to work
properly.

During eviction if these buffers are evicted the hw continue to
use the invalid addresses and caused page faults and system hung.

Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit a3bbf32a336939a1d21b9561f8e53333b684b7ef)

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

index 70d74f04d2ddcb41237cdc7d63caf3c12df313cc..8841955927bbf1dd6c2afe58e142c45fd8c7ea46 100644 (file)
@@ -504,16 +504,20 @@ int amdgpu_userq_create_object(struct amdgpu_userq_mgr *uq_mgr,
                goto free_obj;
        }
 
+       r = amdgpu_bo_pin(userq_obj->obj, AMDGPU_GEM_DOMAIN_GTT);
+       if (r)
+               goto unresv;
+
        r = amdgpu_ttm_alloc_gart(&(userq_obj->obj)->tbo);
        if (r) {
                drm_file_err(uq_mgr->file, "Failed to alloc GART for userqueue object (%d)", r);
-               goto unresv;
+               goto unpin_bo;
        }
 
        r = amdgpu_bo_kmap(userq_obj->obj, &userq_obj->cpu_ptr);
        if (r) {
                drm_file_err(uq_mgr->file, "Failed to map BO for userqueue (%d)", r);
-               goto unresv;
+               goto unpin_bo;
        }
 
        userq_obj->gpu_addr = amdgpu_bo_gpu_offset(userq_obj->obj);
@@ -521,11 +525,13 @@ int amdgpu_userq_create_object(struct amdgpu_userq_mgr *uq_mgr,
        memset(userq_obj->cpu_ptr, 0, size);
        return 0;
 
+unpin_bo:
+       amdgpu_bo_unpin(userq_obj->obj);
 unresv:
        amdgpu_bo_unreserve(userq_obj->obj);
-
 free_obj:
        amdgpu_bo_unref(&userq_obj->obj);
+
        return r;
 }
 
@@ -533,6 +539,7 @@ void amdgpu_userq_destroy_object(struct amdgpu_userq_mgr *uq_mgr,
                                 struct amdgpu_userq_obj *userq_obj)
 {
        amdgpu_bo_kunmap(userq_obj->obj);
+       amdgpu_bo_unpin(userq_obj->obj);
        amdgpu_bo_unref(&userq_obj->obj);
 }