]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: userq_va_mapped should remain true once done
authorSunil Khatri <sunil.khatri@amd.com>
Wed, 13 May 2026 07:59:35 +0000 (13:29 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 May 2026 16:15:49 +0000 (12:15 -0400)
Multiple queues needs these bo_va objects belonging to
the same uq_mgr. So once they are mapped lets not unmap
them as at any point of time any of the queues might be
using it.

Also userq_va_mapped should be a boolean than atomic.

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 5c02889ea22575c3bcfdf212e65fac316cbc6c6a)

drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

index 912c9afaf9e11ed6cafdf1cc58866a1b9cb0c813..4d68732d622357a17674673eeb430050aa7c8dde 100644 (file)
@@ -96,7 +96,8 @@ struct amdgpu_bo_va {
         * if non-zero, cannot unmap from GPU because user queues may still access it
         */
        unsigned int                    queue_refcount;
-       atomic_t                        userq_va_mapped;
+       /* Indicates if this buffer is mapped for any user queue. Once set, never reset. */
+       bool                            userq_va_mapped;
 };
 
 struct amdgpu_bo {
index 6111f6858d2dc6fce60ca496b2e14e55a3361f66..f677a9f2d4add55988bac94ab96ea96b3b8a6914 100644 (file)
@@ -227,7 +227,7 @@ static int amdgpu_userq_buffer_va_list_add(struct amdgpu_usermode_queue *queue,
 
        INIT_LIST_HEAD(&va_cursor->list);
        va_cursor->gpu_addr = addr;
-       atomic_set(&va_map->bo_va->userq_va_mapped, 1);
+       va_map->bo_va->userq_va_mapped = true;
        list_add(&va_cursor->list, &queue->userq_va_list);
 
        return 0;
@@ -274,7 +274,7 @@ static bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)
        dma_resv_assert_held(vm->root.bo->tbo.base.resv);
 
        mapping = amdgpu_vm_bo_lookup_mapping(vm, addr);
-       if (!IS_ERR_OR_NULL(mapping) && atomic_read(&mapping->bo_va->userq_va_mapped))
+       if (!IS_ERR_OR_NULL(mapping) && mapping->bo_va->userq_va_mapped)
                r = true;
        else
                r = false;
@@ -300,15 +300,6 @@ static bool amdgpu_userq_buffer_vas_mapped(struct amdgpu_usermode_queue *queue)
        return false;
 }
 
-static void amdgpu_userq_buffer_va_list_del(struct amdgpu_bo_va_mapping *mapping,
-                                           struct amdgpu_userq_va_cursor *va_cursor)
-{
-       if (mapping)
-               atomic_set(&mapping->bo_va->userq_va_mapped, 0);
-       list_del(&va_cursor->list);
-       kfree(va_cursor);
-}
-
 static void amdgpu_userq_buffer_vas_list_cleanup(struct amdgpu_device *adev,
                                                 struct amdgpu_usermode_queue *queue)
 {
@@ -323,7 +314,8 @@ static void amdgpu_userq_buffer_vas_list_cleanup(struct amdgpu_device *adev,
                if (mapping)
                        dev_dbg(adev->dev, "delete the userq:%p va:%llx\n",
                                queue, va_cursor->gpu_addr);
-               amdgpu_userq_buffer_va_list_del(mapping, va_cursor);
+               list_del(&va_cursor->list);
+               kfree(va_cursor);
        }
 }
 
index 9ba9de16a27a2324334763d16afce1653a16a2f1..fccd758b66994b868bf1cdfb0609691b3ce325ab 100644 (file)
@@ -2002,7 +2002,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,
         * during user requests GEM unmap IOCTL except for forcing the unmap
         * from user space.
         */
-       if (unlikely(atomic_read(&bo_va->userq_va_mapped) > 0))
+       if (unlikely(bo_va->userq_va_mapped))
                amdgpu_userq_gem_va_unmap_validate(adev, mapping, saddr);
 
        list_del(&mapping->list);