drm/amdgpu: add ring soft recovery v3
Subsystems (2)
PATCH 1/4 drm/amdgpu: add ring soft recovery v3
Instead of hammering hard on the GPU try a soft recovery first.
v2: reorder code a bit
v3: increase timeout to 10ms, increment GPU reset counter
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 4 ++++ 3 files changed, 35 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6 -0
@@ -33,6 +33,12 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_ring *ring =to_amdgpu_ring (s_job->sched);struct amdgpu_job *job =to_amdgpu_job (s_job); +if (amdgpu_ring_soft_recovery (ring, job->vmid, s_job->s_fence->parent)) { +DRM_ERROR ("ring %s timeout, but soft recovered\n" , + s_job->sched->name); +return ; + } +DRM_ERROR ("ring %s timeout, signaled seq=%u, emitted seq=%u\n" , job->base.sched->name,atomic_read (&ring->fence_drv.last_seq), ring->fence_drv.sync_seq);
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +25 -0
@@ -383,6 +383,31 @@ void amdgpu_ring_emit_reg_write_reg_wait_helper(struct amdgpu_ring *ring,amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +/** +* amdgpu_ring_soft_recovery - try to soft recover a ring lockup +* +* @ring: ring to try the recovery on +* @vmid: VMID we try to get going again +* @fence: timedout fence +* +* Tries to get a ring proceeding again when it is stuck. +*/ +bool amdgpu_ring_soft_recovery (struct amdgpu_ring *ring,unsigned int vmid, +struct dma_fence *fence) +{ +ktime_t deadline =ktime_add_us (ktime_get (),10000 ); + +if (!ring->funcs->soft_recovery) +return false; + +atomic_inc (&adev->gpu_reset_counter); +while (!dma_fence_is_signaled (fence) && +ktime_to_ns (ktime_sub (deadline,ktime_get ())) >0 ) + ring->funcs->soft_recovery (ring, vmid); + +return dma_fence_is_signaled (fence); +} +/* * Debugfs info */
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +4 -0
@@ -168,6 +168,8 @@ struct amdgpu_ring_funcs {/* priority functions */ void (*set_priority) (struct amdgpu_ring *ring,enum drm_sched_priority priority); +/* Try to soft recover the ring to make the fence signal */ +void (*soft_recovery)(struct amdgpu_ring *ring,unsigned vmid); };struct amdgpu_ring {
@@ -260,6 +262,8 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring);void amdgpu_ring_emit_reg_write_reg_wait_helper (struct amdgpu_ring *ring,uint32_t reg0,uint32_t val0,uint32_t reg1,uint32_t val1); +bool amdgpu_ring_soft_recovery (struct amdgpu_ring *ring,unsigned int vmid, +struct dma_fence *fence);static inline void amdgpu_ring_clear_ring (struct amdgpu_ring *ring) {
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20180823112334.10321-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/4 drm/amdgpu: implement soft_recovery for GFX7
Try to kill waves on the SQ.
--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +13 -0
@@ -4212,6 +4212,18 @@ static void gfx_v7_0_ring_emit_gds_switch(struct amdgpu_ring *ring,amdgpu_ring_write (ring, (1 << (oa_size + oa_base)) - (1 << oa_base)); } +static void gfx_v7_0_ring_soft_recovery (struct amdgpu_ring *ring,unsigned vmid) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t value =0 ; + + value =REG_SET_FIELD (value,SQ_CMD ,CMD ,0x03 ); + value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); + value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); + value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +WREG32 (mmSQ_CMD, value); +} +static uint32_t wave_read_ind (struct amdgpu_device *adev,uint32_t simd,uint32_t wave,uint32_t address) { WREG32(mmSQ_IND_INDEX,
@@ -5088,6 +5100,7 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { .pad_ib = amdgpu_ring_generic_pad_ib, .emit_cntxcntl = gfx_v7_ring_emit_cntxcntl, .emit_wreg = gfx_v7_0_ring_emit_wreg, + .soft_recovery = gfx_v7_0_ring_soft_recovery, };static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = {
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: implement soft_recovery for GFX8 v2
In reply to a message not in the archiveTry to kill waves on the SQ.
v2: only for the GFX ring for now.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +13 -0
@@ -6714,6 +6714,18 @@ static void gfx_v8_0_ring_emit_wreg(struct amdgpu_ring *ring, uint32_t reg,amdgpu_ring_write (ring, val); } +static void gfx_v8_0_ring_soft_recovery (struct amdgpu_ring *ring,unsigned vmid) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t value =0 ; + + value =REG_SET_FIELD (value,SQ_CMD ,CMD ,0x03 ); + value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); + value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); + value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +WREG32 (mmSQ_CMD, value); +} +static void gfx_v8_0_set_gfx_eop_interrupt_state (struct amdgpu_device *adev,enum amdgpu_interrupt_state state) {
@@ -7171,6 +7183,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { .init_cond_exec = gfx_v8_0_ring_emit_init_cond_exec, .patch_cond_exec = gfx_v8_0_ring_emit_patch_cond_exec, .emit_wreg = gfx_v8_0_ring_emit_wreg, + .soft_recovery = gfx_v8_0_ring_soft_recovery, };static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = {
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu: implement soft_recovery for GFX9
In reply to a message not in the archiveTry to kill waves on the SQ.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +13 -0
@@ -4421,6 +4421,18 @@ static void gfx_v9_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, ref, mask); } +static void gfx_v9_0_ring_soft_recovery (struct amdgpu_ring *ring,unsigned vmid) +{ +struct amdgpu_device *adev = ring->adev; +uint32_t value =0 ; + + value =REG_SET_FIELD (value,SQ_CMD ,CMD ,0x03 ); + value =REG_SET_FIELD (value,SQ_CMD ,MODE ,0x01 ); + value =REG_SET_FIELD (value,SQ_CMD ,CHECK_VMID ,1 ); + value =REG_SET_FIELD (value,SQ_CMD ,VM_ID , vmid); +WREG32 (mmSQ_CMD, value); +} +static void gfx_v9_0_set_gfx_eop_interrupt_state (struct amdgpu_device *adev,enum amdgpu_interrupt_state state) {
@@ -4743,6 +4755,7 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_gfx = { .emit_wreg = gfx_v9_0_ring_emit_wreg, .emit_reg_wait = gfx_v9_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v9_0_ring_emit_reg_write_reg_wait, + .soft_recovery = gfx_v9_0_ring_soft_recovery, };static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_compute = {
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 6 lines · Christian König
Instead of hammering hard on the GPU try a soft recovery first.
v2: reorder code a bit
v3: increase timeout to 10ms, increment GPU reset counterSigned-off-by Christian König <[email protected]>
Series are Reviewed-by: Huang Rui <[email protected]>
Quoted 88 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 4 ++++ 3 files changed, 35 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6
-0@@ -33,6 +33,12 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_ring *ring =to_amdgpu_ring (s_job->sched);struct amdgpu_job *job =to_amdgpu_job (s_job); +if (amdgpu_ring_soft_recovery (ring, job->vmid, s_job->s_fence->parent)) { +DRM_ERROR ("ring %s timeout, but soft recovered\n" , + s_job->sched->name); +return ; + } +DRM_ERROR ("ring %s timeout, signaled seq=%u, emitted seq=%u\n" , job->base.sched->name,atomic_read (&ring->fence_drv.last_seq), ring->fence_drv.sync_seq);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +25
-0@@ -383,6 +383,31 @@ void amdgpu_ring_emit_reg_write_reg_wait_helper(struct amdgpu_ring *ring,amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +/** +* amdgpu_ring_soft_recovery - try to soft recover a ring lockup +* +* @ring: ring to try the recovery on +* @vmid: VMID we try to get going again +* @fence: timedout fence +* +* Tries to get a ring proceeding again when it is stuck. +*/ +bool amdgpu_ring_soft_recovery (struct amdgpu_ring *ring,unsigned int vmid, +struct dma_fence *fence) +{ +ktime_t deadline =ktime_add_us (ktime_get (),10000 ); + +if (!ring->funcs->soft_recovery) +return false; + +atomic_inc (&adev->gpu_reset_counter); +while (!dma_fence_is_signaled (fence) && +ktime_to_ns (ktime_sub (deadline,ktime_get ())) >0 ) + ring->funcs->soft_recovery (ring, vmid); + +return dma_fence_is_signaled (fence); +} +/* * Debugfs info */ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +4
-0@@ -168,6 +168,8 @@ struct amdgpu_ring_funcs {/* priority functions */ void (*set_priority) (struct amdgpu_ring *ring,enum drm_sched_priority priority); +/* Try to soft recover the ring to make the fence signal */ +void (*soft_recovery)(struct amdgpu_ring *ring,unsigned vmid); };struct amdgpu_ring {@@ -260,6 +262,8 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring);void amdgpu_ring_emit_reg_write_reg_wait_helper (struct amdgpu_ring *ring,uint32_t reg0,uint32_t val0,uint32_t reg1,uint32_t val1); +bool amdgpu_ring_soft_recovery (struct amdgpu_ring *ring,unsigned int vmid, +struct dma_fence *fence);static inline void amdgpu_ring_clear_ring (struct amdgpu_ring *ring) {Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 64 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Thursday, August 23, 2018 7:24 PM
To: [email protected]
Subject: [PATCH 1/4] drm/amdgpu: add ring soft recovery v3Instead of hammering hard on the GPU try a soft recovery first.
v2: reorder code a bit
v3: increase timeout to 10ms, increment GPU reset counterSigned-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 4 ++++ 3 files changed, 35 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6
-0@@ -33,6 +33,12 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_ring *ring =to_amdgpu_ring (s_job->sched);struct amdgpu_job *job =to_amdgpu_job (s_job); +if (amdgpu_ring_soft_recovery (ring, job->vmid, s_job->s_fence- >parent)) { +DRM_ERROR ("ring %s timeout, but soft recovered\n" , + s_job->sched->name); +return ; + } + DRM_ERROR("ring %s timeout, signaled seq=%u, emitted seq=%u\n",
job->base.sched->name, atomic_read(&ring-Quoted 1 line
fence_drv.last_seq),
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0ring->fence_drv.sync_seq);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +11
-0@@ -383,6 +383,31 @@ void amdgpu_ring_emit_reg_write_reg_wait_helper(struct amdgpu_ring *ring,amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +/** +* amdgpu_ring_soft_recovery - try to soft recover a ring lockup +* +* @ring: ring to try the recovery on +* @vmid: VMID we try to get going again +* @fence: timedout fence +* +* Tries to get a ring proceeding again when it is stuck. +*/ +bool amdgpu_ring_soft_recovery (struct amdgpu_ring *ring,unsigned int vmid, +struct dma_fence *fence)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c void · line 407
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +10
-0+{ +ktime_t deadline =ktime_add_us (ktime_get (),10000 ); + +if (!ring->funcs->soft_recovery) +return false; + +atomic_inc (&adev->gpu_reset_counter); +while (!dma_fence_is_signaled (fence) && +ktime_to_ns (ktime_sub (deadline,ktime_get ())) >0 ) + ring->funcs->soft_recovery (ring, vmid);
Hi Christian,
Is it necessary to add a udelay() here?
Regards
Rex
Quoted 33 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-0+return dma_fence_is_signaled (fence); +} +/* * Debugfs info */ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -168,6 +168,8 @@ struct amdgpu_ring_funcs {/* priority functions */ void (*set_priority) (struct amdgpu_ring *ring,enum drm_sched_priority priority); +/* Try to soft recover the ring to make the fence signal */ +void (*soft_recovery)(struct amdgpu_ring *ring,unsigned vmid); };struct amdgpu_ring {@@ -260,6 +262,8 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring);void amdgpu_ring_emit_reg_write_reg_wait_helper(struct
amdgpu_ring*ring,drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-0uint32_t reg0, uint32_t val0, uint32_t reg1, uint32_t val1); +bool amdgpu_ring_soft_recovery(struct amdgpu_ring *ring, unsigned intvmid,
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-1+ struct dma_fence *fence);static inline void amdgpu_ring_clear_ring (struct amdgpu_ring *ring) { --2.14.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BYAPR12MB2775BAADFC74D3301884B5F2FB370-ZGDeBxoHBPmJeBUhB162ZQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Am 23.08.2018 um 17:20 schrieb Zhu, Rex:
Quoted 75 lines
Quoted 63 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Christian König
Sent: Thursday, August 23, 2018 7:24 PM
To: [email protected]
Subject: [PATCH 1/4] drm/amdgpu: add ring soft recovery v3Instead of hammering hard on the GPU try a soft recovery first.
v2: reorder code a bit
v3: increase timeout to 10ms, increment GPU reset counterSigned-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 25 +++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 4 ++++ 3 files changed, 35 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6
-0@@ -33,6 +33,12 @@ static void amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_ring *ring =to_amdgpu_ring (s_job->sched);struct amdgpu_job *job =to_amdgpu_job (s_job); +if (amdgpu_ring_soft_recovery (ring, job->vmid, s_job->s_fence- > parent)) { +DRM_ERROR ("ring %s timeout, but soft recovered\n" , + s_job->sched->name); +return ; + } + DRM_ERROR("ring %s timeout, signaled seq=%u, emitted seq=%u\n",
job->base.sched->name, atomic_read(&ring-Quoted 1 line
fence_drv.last_seq),
ring->fence_drv.sync_seq);drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +11
-0@@ -383,6 +383,31 @@ void amdgpu_ring_emit_reg_write_reg_wait_helper(struct amdgpu_ring *ring,amdgpu_ring_emit_reg_wait (ring, reg1, mask, mask); } +/** +* amdgpu_ring_soft_recovery - try to soft recover a ring lockup +* +* @ring: ring to try the recovery on +* @vmid: VMID we try to get going again +* @fence: timedout fence +* +* Tries to get a ring proceeding again when it is stuck. +*/ +bool amdgpu_ring_soft_recovery (struct amdgpu_ring *ring,unsigned int vmid, +struct dma_fence *fence)drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c void · line 407
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +10
-0+{ +ktime_t deadline =ktime_add_us (ktime_get (),10000 ); + +if (!ring->funcs->soft_recovery) +return false; + +atomic_inc (&adev->gpu_reset_counter); +while (!dma_fence_is_signaled (fence) && +ktime_to_ns (ktime_sub (deadline,ktime_get ())) >0 ) + ring->funcs->soft_recovery (ring, vmid);Hi Christian,
Quoted 1 line
Is it necessary to add a
udelay()here?
No, I don't think so.
Christian.
Quoted 32 lines
Regards
RexQuoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +3
-0+return dma_fence_is_signaled (fence); +} +/* * Debugfs info */ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +2
-0@@ -168,6 +168,8 @@ struct amdgpu_ring_funcs {/* priority functions */ void (*set_priority) (struct amdgpu_ring *ring,enum drm_sched_priority priority); +/* Try to soft recover the ring to make the fence signal */ +void (*soft_recovery)(struct amdgpu_ring *ring,unsigned vmid); };struct amdgpu_ring {@@ -260,6 +262,8 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring);void amdgpu_ring_emit_reg_write_reg_wait_helper(struct
amdgpu_ring*ring,
uint32_treg0,uint32_tval0,uint32_treg1,uint32_tval1);
+bool amdgpu_ring_soft_recovery(structamdgpu_ring*ring, unsigned int vmid,drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1
-0+ struct dma_fence *fence);
Quoted 8 lines
Quoted 8 lines
static inline void
amdgpu_ring_clear_ring(struct amdgpu_ring *ring){
--
2.14.1_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx