drm/amdgpu/gfx10: fix wptr reset in KGQ init
Subsystems (2)
Alex Deucher
maintainerPATCH 1/3 drm/amdgpu/gfx10: fix wptr reset in KGQ init
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -1
@@ -6883,7 +6883,7 @@ static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring); }
Signature · 1 line
2.52.0
Alex Deucher
maintainerPATCH 2/3 drm/amdgpu/gfx11: fix wptr reset in KGQ init
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
@@ -4224,7 +4224,7 @@ static int gfx_v11_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring); }
Signature · 1 line
2.52.0
Alex Deucher
maintainerPATCH 3/3 drm/amdgpu/gfx12: fix wptr reset in KGQ init
In reply to Alex Deucherwptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -1
@@ -3096,7 +3096,7 @@ static int gfx_v12_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring); }
Signature · 1 line
2.52.0
RE: [PATCH 3/3] drm/amdgpu/gfx12: fix wptr reset in KGQ init
[AMD Official Use Only - AMD Internal Distribution Only]
Series is :
Quoted 34 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Thursday, January 29, 2026 12:35 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 3/3] drm/amdgpu/gfx12: fix wptr reset in KGQ initwptr is a 64 bit value and we need to update the full value, not just 32 bits. Align with what we already do for KCQs.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-1@@ -3096,7 +3096,7 @@ static int gfx_v12_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring);}--
2.52.0
Quoted 5 lines · Central European Standard Time Alex Deucher
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.Signed-off-by Alex Deucher <[email protected]>
for the series.
I notice that the code base already does this for gfx9, but is rather inconsistent on gfx6-8. If you think that's useful, I could submit some patches to do the same on older GPUs. What do you think?
Quoted 17 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.cindexe9254ec3b6417..ef7d91a4437ec100644drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-0@@ -6883,7 +6883,7 @@ static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset) memcpy_toio(mqd, adev->gfx.me.mqd_backup[mqd_idx],
sizeof(*mqd)); /* reset the ring */drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-1ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring); }
Quoted 7 lines · Timur Kristóf
Quoted 4 lines · Central European Standard Time Alex Deucher
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.
Quoted 8 lines
Quoted 1 line
Signed-off-by Alex Deucher <[email protected]>Reviewed-by Timur Kristóf <[email protected]>for the series.
I notice that the code base already does this for gfx9, but is rather inconsistent on gfx6-8. If you think that's useful, I could submit some patches to do the same on older GPUs. What do you think?
Thanks. Pre-gfx9 only had a 32 bit wptr so they don't use the upper 32 bits.
Alex
Quoted 22 lines
Quoted 18 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.cindexe9254ec3b6417..ef7d91a4437ec100644drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-0@@ -6883,7 +6883,7 @@ static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset) memcpy_toio(mqd, adev->gfx.me.mqd_backup[mqd_idx],
sizeof(*mqd)); /* reset the ring */ring->wptr = 0;drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-1- *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );amdgpu_ring_clear_ring (ring); }
Quoted 14 lines · Alex Deucher
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset) · line 6886
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-1@@ -6883,7 +6883,7 @@ static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );
For my education could I ask if this just about writing the 64-bit value or the atomic part is also important?
Regards,
Tvrtko
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-0amdgpu_ring_clear_ring (ring); }
Quoted 12 lines · Tvrtko Ursulin
Quoted 9 lines · Alex Deucher
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset) · line 6886
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-1@@ -6883,7 +6883,7 @@ static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );For my education could I ask if this just about writing the 64-bit value or the atomic part is also important?
Just the 64 bit value in this case.
Alex
Quoted 9 lines
Regards,
Tvrtko
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-0amdgpu_ring_clear_ring (ring); }
Quoted 27 lines · Alex Deucher
Quoted 12 lines · Tvrtko Ursulin
Quoted 9 lines · Alex Deucher
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset) · line 6886
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-1@@ -6883,7 +6883,7 @@ static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );For my education could I ask if this just about writing the 64-bit value or the atomic part is also important?
Quoted 1 line
Just the 64 bit value in this case.
Thank you, it was a bit confusing for me. Even in the context of what you explained to Timur that pre-gfx9 wptr is 32-bit, becauase when I looked into for example the gfx8 code, I saw it doing a mix of 64- and 32-bit writes.
I guess the layout of the write back info block thingy is fully software/driver defined which is why this is not an issue?
Would it be worth getting rid of the atomics to lessen the confusion and attempt to somehow make this area more self-documenting?
Regards,
Tvrtko
Quoted 32 lines · Tvrtko Ursulin
Quoted 27 lines · Alex Deucher
Quoted 12 lines · Tvrtko Ursulin
Quoted 9 lines · Alex Deucher
wptr is a 64 bit value and we need to update the
full value, not just 32 bits. Align with what we
already do for KCQs.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset) · line 6886
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-1@@ -6883,7 +6883,7 @@ static int gfx_v10_0_kgq_init_queue(struct amdgpu_ring *ring, bool reset)memcpy_toio (mqd, adev->gfx.me.mqd_backup[mqd_idx],sizeof (*mqd));/* reset the ring */ ring->wptr =0 ; - *ring->wptr_cpu_addr =0 ; +atomic64_set ((atomic64_t *)ring->wptr_cpu_addr,0 );For my education could I ask if this just about writing the 64-bit value or the atomic part is also important?
Quoted 1 line
Just the 64 bit value in this case.
Quoted 7 lines
Thank you, it was a bit confusing for me. Even in the context of what you explained to Timur that pre-gfx9 wptr is 32-bit, becauase when I looked into for example the gfx8 code, I saw it doing a mix of 64- and 32-bit writes.
I guess the layout of the write back info block thingy is fully software/driver defined which is why this is not an issue?
The buffer is 64 bits because we support a mix of GPUs, some of which support 64 bit write pointers and some of which support 32 bit write pointers, even on the same GPU (e.g., different IPs may have different sizes).
Quoted 3 lines
Would it be worth getting rid of the atomics to lessen the confusion and attempt to somehow make this area more self-documenting?
Yeah, I suspect the 64 bit updates came back to the older IPs as part of code unification and cleanups from newer chips. Each ring has a ptr_mask in its ring data structure which defines its write pointer size.
Alex
Quoted 4 lines
Regards,
Tvrtko