Skip to contentSkip to conversation

drm/amdgpu/userq: use fence_val instead or rptr

PATCH In review Sunil Khatri 4 participants 5 messages Aug 26 – Aug 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 drm/amdgpu/userq: use fence_val instead or rptr

rptr is a confusing variable name as it is a fence value written by the cp in the fence address and no where related to the rptr.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +3 -3
index 09e2079cfdbd..e862b65f5366 100644
@@ -148,13 +148,13 @@ amdgpu_userq_fence_driver_process(struct amdgpu_userq_fence_driver *fence_drv)
 	LIST_HEAD(to_be_signaled);
 	struct dma_fence *fence;
 	unsigned long flags;
-	u64 rptr;
+	u64 fence_val;
 
 	spin_lock_irqsave(&fence_drv->fence_list_lock, flags);
-	rptr = amdgpu_userq_fence_read(fence_drv);
+	fence_val = amdgpu_userq_fence_read(fence_drv);
 
 	list_for_each_entry(userq_fence, &fence_drv->fences, link) {
-		if (rptr < userq_fence->base.seqno)
+		if (fence_val < userq_fence->base.seqno)
 			break;
 	}
 
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/2 drm/amdgpu/userq: use fence_val instead or rptr

rptr is a confusing variabile name as it is a fence value written by the cp in the fence address and no where related to the rptr.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +3 -3
index e862b65f5366..cee5b0241196 100644
@@ -316,12 +316,12 @@ static bool amdgpu_userq_fence_signaled(struct dma_fence *f)
 {
 	struct amdgpu_userq_fence *fence = to_amdgpu_userq_fence(f);
 	struct amdgpu_userq_fence_driver *fence_drv = fence->fence_drv;
-	u64 rptr, wptr;
+	u64 fence_val, wptr;
 
-	rptr = amdgpu_userq_fence_read(fence_drv);
+	fence_val = amdgpu_userq_fence_read(fence_drv);
 	wptr = fence->base.seqno;
 
-	if (rptr >= wptr)
+	if (fence_val >= wptr)
 		return true;
 
 	return false;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v2 1/2
#2 lore raw
In reply to Sunil Khatri

AMD General

Quoted 10 lines

-----Original Message-----
From: Sunil Khatri <[email protected]>
Sent: Wednesday, August 26, 2026 1:59 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Cc: [email protected]; Khatri, Sunil <[email protected]>
Subject: [PATCH v2 1/2] drm/amdgpu/userq: use fence_val instead or rptr

rptr is a confusing variable name as it is a fence value written by the cp in the fence address and no where related to the rptr.

For a little history, the fence value is the actually wptr written by the application when it submits the protected fence packet. The firmware writes the rptr that is aligned to that wptr as the fence value. But in this case, I agree that it is confusing, especially for someone without the history. Patches are:

Quoted 31 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +3 -4
index 09e2079cfdbd..e862b65f5366 100644
@@ -148,13 +148,13 @@ amdgpu_userq_fence_driver_process(struct
 amdgpu_userq_fence_driver *fence_drv)
      LIST_HEAD(to_be_signaled);
      struct dma_fence *fence;
      unsigned long flags;
-     u64 rptr;
+     u64 fence_val;
 
      spin_lock_irqsave(&fence_drv->fence_list_lock, flags);
-     rptr = amdgpu_userq_fence_read(fence_drv);
+     fence_val = amdgpu_userq_fence_read(fence_drv);
 
      list_for_each_entry(userq_fence, &fence_drv->fences, link) {
-             if (rptr < userq_fence->base.seqno)
+             if (fence_val < userq_fence->base.seqno)
                      break;
      }
 
--

2.34.1

#3 lore raw
Quoted 10 lines · Alexander

AMD General

Quoted 8 lines

-----Original Message-----
From: Sunil Khatri <[email protected]>
Sent: Wednesday, August 26, 2026 1:59 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Cc: [email protected]; Khatri, Sunil <[email protected]>
Subject: [PATCH v2 1/2] drm/amdgpu/userq: use fence_val instead or rptr

Quoted 4 lines
Quoted 2 lines

rptr is a confusing variable name as it is a fence value written by the cp in the fence address and no where related to the rptr.

For a little history, the fence value is the actually wptr written by the application when it submits the protected fence packet. The firmware writes the rptr that is aligned to that wptr as the fence value. But in this case, I agree that it is confusing, especially for someone without the history. Patches are:

Totally agree with that. I knew its the wptr value that is written in the fence address but i was confused so many times while debugging the sdma issue. Thanks for the quick review on these.

Regards
Sunil Khatri

Quoted 31 lines
Quoted 31 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +3 -4
index 09e2079cfdbd..e862b65f5366 100644
@@ -148,13 +148,13 @@ amdgpu_userq_fence_driver_process(struct
 amdgpu_userq_fence_driver *fence_drv)
       LIST_HEAD(to_be_signaled);
       struct dma_fence *fence;
       unsigned long flags;
-     u64 rptr;
+     u64 fence_val;
 
       spin_lock_irqsave(&fence_drv->fence_list_lock, flags);
-     rptr = amdgpu_userq_fence_read(fence_drv);
+     fence_val = amdgpu_userq_fence_read(fence_drv);
 
       list_for_each_entry(userq_fence, &fence_drv->fences, link) {
-             if (rptr < userq_fence->base.seqno)
+             if (fence_val < userq_fence->base.seqno)
                       break;
       }
 
--

2.34.1

maintainer Reviewed-by on v2 1/2
#4 lore raw
In reply to Sunil Khatri
Quoted 5 lines · Sunil Khatri

rptr is a confusing variable name as it is a fence value written by the cp in the fence address and no where related to the rptr.

Quoted 25 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +3 -3
index 09e2079cfdbd..e862b65f5366 100644
@@ -148,13 +148,13 @@ amdgpu_userq_fence_driver_process(struct amdgpu_userq_fence_driver *fence_drv)
 	LIST_HEAD(to_be_signaled);
 	struct dma_fence *fence;
 	unsigned long flags;
-	u64 rptr;
+	u64 fence_val;
 
 	spin_lock_irqsave(&fence_drv->fence_list_lock, flags);
-	rptr = amdgpu_userq_fence_read(fence_drv);
+	fence_val = amdgpu_userq_fence_read(fence_drv);
 
 	list_for_each_entry(userq_fence, &fence_drv->fences, link) {
-		if (rptr < userq_fence->base.seqno)
+		if (fence_val < userq_fence->base.seqno)
 			break;
 	}