Skip to contentSkip to conversation

drm/amdgpu: clean wptr on wb when gpu recovery

PATCH In review Yintian Tao 3 participants 3 messages Feb 28, 2020

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

PATCH 1/1 drm/amdgpu: clean wptr on wb when gpu recovery

The TDR will be randomly failed due to compute ring
test failure. If the compute ring wptr & 0x7ff(ring_buf_mask) is 0x100 then after map mqd the compute ring rptr will be synced with 0x100. And the ring test packet size is also 0x100. Then after invocation of amdgpu_ring_commit, the cp will not really handle the packet on the ring buffer because rptr is equal to wptr.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 1 +
 2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -0
index 44f00ecea322..5df1a6d45457 100644
@@ -3508,6 +3508,7 @@ static int gfx_v10_0_kcq_init_queue(struct amdgpu_ring *ring)
 
 		/* reset ring buffer */
 		ring->wptr = 0;
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs], 0);
 		amdgpu_ring_clear_ring(ring);
 	} else {
 		amdgpu_ring_clear_ring(ring);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
index 4135e4126e82..ac22490e8656 100644
@@ -3664,6 +3664,7 @@ static int gfx_v9_0_kcq_init_queue(struct amdgpu_ring *ring)
 
 		/* reset ring buffer */
 		ring->wptr = 0;
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs], 0);
 		amdgpu_ring_clear_ring(ring);
 	} else {
 		amdgpu_ring_clear_ring(ring);
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

Am 28.02.20 um 07:31 schrieb Yintian Tao:

Quoted 8 lines

The TDR will be randomly failed due to compute ring
test failure. If the compute ring wptr & 0x7ff(ring_buf_mask) is 0x100 then after map mqd the compute ring rptr will be synced with 0x100. And the ring test packet size is also 0x100. Then after invocation of amdgpu_ring_commit, the cp will not really handle the packet on the ring buffer because rptr is equal to wptr.

Of hand that looks correct to me, but I can't fully judge if that won't have any negative side effects. Patch is Acked-by: Christian König <[email protected]> for now.

Monk according to git you modified that function as well. Could this have any potential negative effect for SRIOV? I don't think so, but better save than sorry.

Regards,
Christian.

Quoted 22 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 1 +
  2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -0
index 44f00ecea322..5df1a6d45457 100644
@@ -3508,6 +3508,7 @@ static int gfx_v10_0_kcq_init_queue(struct amdgpu_ring *ring)
 
  		/* reset ring buffer */
  		ring->wptr = 0;
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs], 0);
  		amdgpu_ring_clear_ring(ring);
  	} else {
  		amdgpu_ring_clear_ring(ring);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -0
index 4135e4126e82..ac22490e8656 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_kcq_init_queue(struct amdgpu_ring *ring) · line 3670

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
@@ -3664,6 +3664,7 @@ static int gfx_v9_0_kcq_init_queue(struct amdgpu_ring *ring)
 
  		/* reset ring buffer */
  		ring->wptr = 0;
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs], 0);
  		amdgpu_ring_clear_ring(ring);
  	} else {
  		amdgpu_ring_clear_ring(ring);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#2 lore raw

This is a clear fix :

After TDR we have a compute ring HQD restore from its MQD, but the MQD only record "WPTR_ADDR_LO/HI" so once
HQD restored the MEC would immediately read value from "WPTR_ADDR_LO/HI" which is a WB memory, and that value is sometime not "0" (because TDR won't clear WB, its value is what a hang process left there ) So MEC consider there is command in RB (since RPTR != WPTR) thus lead to further hang

_____________________________________
Monk Liu|GPU Virtualization Team |AMD

-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, February 28, 2020 5:20 PM
To: Tao, Yintian <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Liu, Monk <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] drm/amdgpu: clean wptr on wb when gpu recovery

Am 28.02.20 um 07:31 schrieb Yintian Tao:

Quoted 8 lines

The TDR will be randomly failed due to compute ring test failure. If the compute ring wptr & 0x7ff(ring_buf_mask) is 0x100 then after map mqd the compute ring rptr will be synced with 0x100. And the ring test packet size is also 0x100.
Then after invocation of amdgpu_ring_commit, the cp will not really handle the packet on the ring buffer because rptr is equal to wptr.

Of hand that looks correct to me, but I can't fully judge if that won't have any negative side effects. Patch is Acked-by: Christian König <[email protected]> for now.

Monk according to git you modified that function as well. Could this have any potential negative effect for SRIOV? I don't think so, but better save than sorry.

Regards,
Christian.

Quoted 32 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 1 +
  2 files changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -0
index 44f00ecea322..5df1a6d45457 100644
@@ -3508,6 +3508,7 @@ static int gfx_v10_0_kcq_init_queue(struct 
 amdgpu_ring *ring)
 
  		/* reset ring buffer */
  		ring->wptr = 0;
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs], 0);
  		amdgpu_ring_clear_ring(ring);
  	} else {
  		amdgpu_ring_clear_ring(ring);
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
index 4135e4126e82..ac22490e8656 100644
@@ -3664,6 +3664,7 @@ static int gfx_v9_0_kcq_init_queue(struct 
 amdgpu_ring *ring)
 
  		/* reset ring buffer */
  		ring->wptr = 0;
+		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs], 0);
  		amdgpu_ring_clear_ring(ring);
  	} else {
Quoted 1 line
  		amdgpu_ring_clear_ring(ring);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx