[PATCH v3 2/3] drm/amdgpu: Improve the xa field names readability

Arunpravin Paneer Selvam Arunpravin.PaneerSelvam at amd.com
Thu Dec 19 10:38:23 UTC 2024


Make the xa field names used in the userqueue and userfence
structure more understandable and add more clarity.

Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam at amd.com>
---
 .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.c   | 31 ++++++++++---------
 .../gpu/drm/amd/amdgpu/amdgpu_userq_fence.h   |  4 +--
 drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c |  8 ++---
 .../gpu/drm/amd/include/amdgpu_userqueue.h    |  2 +-
 4 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index 4289bed6c1f7..6876f24e5eda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -97,7 +97,7 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device *adev,
 	spin_lock_init(&fence_drv->fence_list_lock);
 
 	fence_drv->adev = adev;
-	fence_drv->fence_drv_xa_ptr = &userq->fence_drv_xa;
+	fence_drv->xa_uq = &userq->xa_uq;
 	fence_drv->context = dma_fence_context_alloc(1);
 	get_task_comm(fence_drv->timeline_name, current);
 
@@ -122,8 +122,8 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device *adev,
 
 void amdgpu_userq_fence_driver_process(struct amdgpu_userq_fence_driver *fence_drv)
 {
-	struct amdgpu_userq_fence_driver *stored_fence_drv;
 	struct amdgpu_userq_fence *userq_fence, *tmp;
+	struct amdgpu_userq_fence_driver *fdrv;
 	struct dma_fence *fence;
 	unsigned long index;
 	u64 rptr;
@@ -142,8 +142,8 @@ void amdgpu_userq_fence_driver_process(struct amdgpu_userq_fence_driver *fence_d
 
 		dma_fence_signal(fence);
 
-		xa_for_each(&userq_fence->fence_drv_xa, index, stored_fence_drv)
-			amdgpu_userq_fence_driver_put(stored_fence_drv);
+		xa_for_each(&userq_fence->xa_uf, index, fdrv)
+			amdgpu_userq_fence_driver_put(fdrv);
 
 		list_del(&userq_fence->link);
 		dma_fence_put(fence);
@@ -222,24 +222,25 @@ int amdgpu_userq_fence_create(struct amdgpu_usermode_queue *userq,
 	dma_fence_init(fence, &amdgpu_userq_fence_ops, &userq_fence->lock,
 		       fence_drv->context, seq);
 
-	xa_init_flags(&userq_fence->fence_drv_xa, XA_FLAGS_ALLOC);
+	xa_init_flags(&userq_fence->xa_uf, XA_FLAGS_ALLOC);
 
 	amdgpu_userq_fence_driver_get(fence_drv);
 	dma_fence_get(fence);
 
-	if (!xa_empty(&userq->fence_drv_xa)) {
-		struct amdgpu_userq_fence_driver *stored_fence_drv;
+	/* Move all fence driver entries from xa_uq to xa_uf */
+	if (!xa_empty(&userq->xa_uq)) {
+		struct amdgpu_userq_fence_driver *fdrv;
 		unsigned long index_uq;
 		u32 index_uf;
 		int err;
 
-		xa_for_each(&userq->fence_drv_xa, index_uq, stored_fence_drv) {
-			err = xa_alloc_irq(&userq_fence->fence_drv_xa, &index_uf,
-					   stored_fence_drv, xa_limit_32b, GFP_KERNEL);
+		xa_for_each(&userq->xa_uq, index_uq, fdrv) {
+			err = xa_alloc_irq(&userq_fence->xa_uf, &index_uf,
+					   fdrv, xa_limit_32b, GFP_KERNEL);
 			if (err)
 				return err;
 		}
-		xa_destroy(&userq->fence_drv_xa);
+		xa_destroy(&userq->xa_uq);
 	}
 
 	/* Check if hardware has already processed the job */
@@ -809,7 +810,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
 		for (i = 0, cnt = 0; i < num_fences; i++) {
 			struct amdgpu_userq_fence_driver *fence_drv;
 			struct amdgpu_userq_fence *userq_fence;
-			u32 index;
+			u32 index_uq;
 
 			userq_fence = to_amdgpu_userq_fence(fences[i]);
 			if (!userq_fence) {
@@ -834,9 +835,9 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
 			 * Otherwise, we would gather those references until we don't
 			 * have any more space left and crash.
 			 */
-			if (fence_drv->fence_drv_xa_ptr) {
-				r = xa_alloc(fence_drv->fence_drv_xa_ptr, &index, fence_drv,
-					     xa_limit_32b, GFP_KERNEL);
+			if (fence_drv->xa_uq) {
+				r = xa_alloc(fence_drv->xa_uq, &index_uq,
+					     fence_drv, xa_limit_32b, GFP_KERNEL);
 				if (r)
 					goto free_fences;
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
index 3283e5573d10..74edabc8e021 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.h
@@ -37,7 +37,7 @@ struct amdgpu_userq_fence {
 	 */
 	spinlock_t lock;
 	struct list_head link;
-	struct xarray fence_drv_xa;
+	struct xarray xa_uf;
 	struct amdgpu_userq_fence_driver *fence_drv;
 };
 
@@ -54,7 +54,7 @@ struct amdgpu_userq_fence_driver {
 	spinlock_t fence_list_lock;
 	struct list_head fences;
 	struct amdgpu_device *adev;
-	struct xarray *fence_drv_xa_ptr;
+	struct xarray *xa_uq;
 	char timeline_name[TASK_COMM_LEN];
 };
 
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index 85baba323ba5..72ff623f8c8b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
@@ -48,8 +48,8 @@ static void amdgpu_userq_walk_and_drop_fence_drv(struct xarray *xa)
 static void
 amdgpu_userq_fence_driver_free(struct amdgpu_usermode_queue *userq)
 {
-	amdgpu_userq_walk_and_drop_fence_drv(&userq->fence_drv_xa);
-	xa_destroy(&userq->fence_drv_xa);
+	amdgpu_userq_walk_and_drop_fence_drv(&userq->xa_uq);
+	xa_destroy(&userq->xa_uq);
 	/* Drop the fence_drv reference held by user queue */
 	amdgpu_userq_fence_driver_put(userq->fence_drv);
 }
@@ -73,7 +73,7 @@ amdgpu_userqueue_cleanup(struct amdgpu_userq_mgr *uq_mgr,
 	}
 
 	uq_funcs->mqd_destroy(uq_mgr, queue);
-	queue->fence_drv->fence_drv_xa_ptr = NULL;
+	queue->fence_drv->xa_uq = NULL;
 	amdgpu_userq_fence_driver_free(queue);
 	idr_remove(&uq_mgr->userq_idr, queue_id);
 	kfree(queue);
@@ -315,7 +315,7 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
 	}
 	queue->doorbell_index = index;
 
-	xa_init_flags(&queue->fence_drv_xa, XA_FLAGS_ALLOC);
+	xa_init_flags(&queue->xa_uq, XA_FLAGS_ALLOC);
 	r = amdgpu_userq_fence_driver_alloc(adev, queue);
 	if (r) {
 		DRM_ERROR("Failed to alloc fence driver\n");
diff --git a/drivers/gpu/drm/amd/include/amdgpu_userqueue.h b/drivers/gpu/drm/amd/include/amdgpu_userqueue.h
index e7e8d79b689d..8048a5fb917a 100644
--- a/drivers/gpu/drm/amd/include/amdgpu_userqueue.h
+++ b/drivers/gpu/drm/amd/include/amdgpu_userqueue.h
@@ -53,7 +53,7 @@ struct amdgpu_usermode_queue {
 	struct amdgpu_userq_obj	db_obj;
 	struct amdgpu_userq_obj fw_obj;
 	struct amdgpu_userq_obj wptr_obj;
-	struct xarray		fence_drv_xa;
+	struct xarray		xa_uq;
 	struct amdgpu_userq_fence_driver *fence_drv;
 	struct dma_fence	*last_fence;
 };
-- 
2.25.1



More information about the amd-gfx mailing list