]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdgpu: simplify return value in amdgpu_userq_get_doorbell_index
authorSunil Khatri <sunil.khatri@amd.com>
Mon, 18 May 2026 12:12:15 +0000 (17:42 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 15:58:10 +0000 (11:58 -0400)
amdgpu_userq_get_doorbell_index returns a uint64 type index
as well as a int type failure values. Simplifying this and
using a int type return value and getting the index in input pointer
of type uint64 type.

Also since it's used at once place making it static would be better.

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 e947ec9d0529d5f93dbdb33cd197347f6a7b2922)

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

index d6390cc5a798ed7504c7b11291b1e13fe716b603..34c0d9ee94f2b8cb7273ea2cba5545f48856739e 100644 (file)
@@ -536,12 +536,13 @@ void amdgpu_userq_destroy_object(struct amdgpu_userq_mgr *uq_mgr,
        amdgpu_bo_unref(&userq_obj->obj);
 }
 
-uint64_t
+static int
 amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
                                struct amdgpu_db_info *db_info,
-                               struct drm_file *filp)
+                               struct drm_file *filp,
+                               u64 *index)
 {
-       uint64_t index;
+       u64 doorbell_index;
        struct drm_gem_object *gobj;
        struct amdgpu_userq_obj *db_obj = db_info->db_obj;
        int r, db_size;
@@ -588,12 +589,13 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
                goto unpin_bo;
        }
 
-       index = amdgpu_doorbell_index_on_bar(uq_mgr->adev, db_obj->obj,
-                                            db_info->doorbell_offset, db_size);
+       doorbell_index = amdgpu_doorbell_index_on_bar(uq_mgr->adev, db_obj->obj,
+                                                     db_info->doorbell_offset, db_size);
        drm_dbg_driver(adev_to_drm(uq_mgr->adev),
-                      "[Usermode queues] doorbell index=%lld\n", index);
+                      "[Usermode queues] doorbell index=%lld\n", doorbell_index);
        amdgpu_bo_unreserve(db_obj->obj);
-       return index;
+       *index = doorbell_index;
+       return 0;
 
 unpin_bo:
        amdgpu_bo_unpin(db_obj->obj);
@@ -776,10 +778,9 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
        db_info.doorbell_handle = queue->doorbell_handle;
        db_info.db_obj = &queue->db_obj;
        db_info.doorbell_offset = args->in.doorbell_offset;
-       index = amdgpu_userq_get_doorbell_index(uq_mgr, &db_info, filp);
-       if (index == (uint64_t)-EINVAL) {
+       r = amdgpu_userq_get_doorbell_index(uq_mgr, &db_info, filp, &index);
+       if (r) {
                drm_file_err(uq_mgr->file, "Failed to get doorbell for queue\n");
-               r = -EINVAL;
                goto clean_mapping;
        }
 
index 49b33e2d6932f87af65fcd1f49d6ec360030c385..033b8a0de6b1489bcbdbb7459912b03f374cbe51 100644 (file)
@@ -163,10 +163,6 @@ void amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr);
 void amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *userq_mgr,
                                  struct amdgpu_eviction_fence_mgr *evf_mgr);
 
-uint64_t amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
-                                        struct amdgpu_db_info *db_info,
-                                            struct drm_file *filp);
-
 u32 amdgpu_userq_get_supported_ip_mask(struct amdgpu_device *adev);
 bool amdgpu_userq_enabled(struct drm_device *dev);