Reset improvements for GC10+
Subsystems (2)
Alex Deucher
maintainercover Reset improvements for GC10+
This set improves per queue reset support for GC10+. This enables the legacy enforce isolation behavior to serialize access to GC for kernel queues so that only one process uses the queue at a time. When we reset the queue, only that process is effected which improves the user experience when a queue is reset. This mirrors how windows handles per queue resets. Tested on GC 10 and 11 chips with a game running and then running hang tests. The game pauses when the hang happens, then continues after the queue reset.
I tried this same approach and GC8 and 9, but it was not as reliable as soft recovery. I also compared this to Christian's reset patches, but I was not able to make them work as reliably as this series.
Alex Deucher (9):
Revert "drm/amd/amdgpu: add pipe1 hardware support" drm/amdgpu: adjust ring reset behavior drm/amdgpu: add AMDGPU_QUEUE_RESET_TIMEOUT drm/amdgpu/gfx11: enable legacy enforce isolation drm/amdgpu/gfx11: adjust ring reset sequences drm/amdgpu/gfx12: enable legacy enforce isolation drm/amdgpu/gfx12: adjust ring reset sequences drm/amdgpu/gfx10: enable legacy enforce isolation drm/amdgpu/gfx10: adjust ring reset sequences
Christian König (1):
drm/amdgpu: rework queue reset scheduler interaction
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 27 +++++++++++---------- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 31 +++++++++++++++++++++---- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 29 ++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 29 ++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/nvd.h | 1 + 6 files changed, 96 insertions(+), 22 deletions(-)
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 1/10 Revert "drm/amd/amdgpu: add pipe1 hardware support"
This reverts commit b7a1a0ef12b81957584fef7b61e2d5ec049c7209.
A user reported stuttering under heavy gfx load with this commit. I suspect it's due to the fact that the gfx contexts are shared between the pipes so if there is alot of load on one pipe, we could end up stalling waiting for a context.
On top of that, disabling the second pipe may fix the reliability of vmid resets.
--- 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
@@ -4781,7 +4781,7 @@ static int gfx_v10_0_sw_init(struct amdgpu_ip_block *ip_block)case IP_VERSION (10 ,3 ,3 ):case IP_VERSION (10 ,3 ,7 ): adev->gfx.me.num_me =1 ; - adev->gfx.me.num_pipe_per_me =2 ; + adev->gfx.me.num_pipe_per_me =1 ; adev->gfx.me.num_queue_per_pipe =2 ; adev->gfx.mec.num_mec =2 ; adev->gfx.mec.num_pipe_per_mec =4 ;
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 2/10 drm/amdgpu: rework queue reset scheduler interaction
In reply to Alex DeucherFrom: Christian König <[email protected]>
Stopping the scheduler for queue reset is generally a good idea because it prevents any worker from touching the ring buffer.
But using amdgpu_fence_driver_force_completion() before restarting it was a really bad idea because it marked fences as failed while the work was potentially still running.
Stop doing that and cleanup the comment a bit.
v2: keep amdgpu_fence_driver_force_completion() for non-gfx rings
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +14 -12
@@ -136,10 +136,12 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) }else if (amdgpu_gpu_recovery && ring->funcs->reset) {bool is_guilty; -dev_err (adev->dev,"Starting %s ring reset\n" , s_job->sched->name); -/* stop the scheduler, but don't mess with the -* bad job yet because if ring reset fails -* we'll fall back to full GPU reset. +dev_err (adev->dev,"Starting %s ring reset\n" , + s_job->sched->name); + +/* +* Stop the scheduler to prevent anybody else from touching the +* ring buffer. */ drm_sched_wqueue_stop (&ring->sched);
@@ -157,19 +159,19 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) r =amdgpu_ring_reset (ring, job->vmid);if (!r) { -if (amdgpu_ring_sched_ready (ring)) -drm_sched_stop (&ring->sched, s_job);if (is_guilty) {atomic_inc (&ring->adev->gpu_reset_counter); -amdgpu_fence_driver_force_completion (ring); +if (ring->funcs->type !=AMDGPU_RING_TYPE_GFX ) +amdgpu_fence_driver_force_completion (ring); } -if (amdgpu_ring_sched_ready (ring)) -drm_sched_start (&ring->sched,0 ); -dev_err (adev->dev,"Ring %s reset succeeded\n" , ring->sched.name); -drm_dev_wedged_event (adev_to_drm (adev),DRM_WEDGE_RECOVERY_NONE ); +drm_sched_wqueue_start (&ring->sched); +dev_err (adev->dev,"Ring %s reset succeeded\n" , + ring->sched.name); +drm_dev_wedged_event (adev_to_drm (adev), +DRM_WEDGE_RECOVERY_NONE ); goto exit; } -dev_err (adev->dev,"Ring %s reset failure\n" , ring->sched.name); +dev_err (adev->dev,"Ring %s reset failed\n" , ring->sched.name); }dma_fence_set_error (&s_job->s_fence->finished, -ETIME );
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 3/10 drm/amdgpu: adjust ring reset behavior
In reply to Alex DeucherThe idea here is to enable enforce isolation legacy behavior for gfx 10+ and as such, we can adjust the behavior to better suite that. This aligns with how windows handles resets and seems to work reliably in my testing on GFX 10+. For older chips, or if enforce isolation is disabled, the soft recovery (wave kill) tends to work better. Additionally, only force completion if enforce isolation is not enabled.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -1
@@ -112,6 +112,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)amdgpu_job_core_dump (adev, job);if (amdgpu_gpu_recovery && + !job->enforce_isolation &&amdgpu_ring_soft_recovery (ring, job->vmid, s_job->s_fence->parent)) {dev_err (adev->dev,"ring %s timeout, but soft recovered\n" , s_job->sched->name);
@@ -161,7 +162,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)if (!r) {if (is_guilty) {atomic_inc (&ring->adev->gpu_reset_counter); -if (ring->funcs->type !=AMDGPU_RING_TYPE_GFX ) +if (!job->enforce_isolation)amdgpu_fence_driver_force_completion (ring); }drm_sched_wqueue_start (&ring->sched);
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 4/10 drm/amdgpu: add AMDGPU_QUEUE_RESET_TIMEOUT
In reply to Alex DeucherAdd a new define for queue reset timeout. This will be used for the IB tests used when validatating ring resets.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -278,6 +278,7 @@ extern int amdgpu_user_queue;#define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000#define AMDGPU_MAX_USEC_TIMEOUT 100000/* 100 ms */ #define AMDGPU_FENCE_JIFFIES_TIMEOUT (HZ / 2) +#define AMDGPU_QUEUE_RESET_TIMEOUT (HZ / 10)#define AMDGPU_DEBUGFS_MAX_COMPONENTS 32#define AMDGPUFB_CONN_LIMIT 4#define AMDGPU_BIOS_NUM_SCRATCH 16
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 5/10 drm/amdgpu/gfx11: enable legacy enforce isolation
In reply to Alex DeucherEnable legacy enforce isolation (just serialize kernel GC submissions). This way we can reset a ring and only affect the the process currently using that ring. This mirrors what windows does.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +9 -0
@@ -5189,6 +5189,15 @@ static void gfx_v11_0_ring_emit_gds_switch(struct amdgpu_ring *ring,static int gfx_v11_0_early_init (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; +int i; + +if (amdgpu_enforce_isolation ==-1 ) { +for (i =0 ; i <MAX_XCP ; i++) { +/* enable legacy mode by default */ + adev->enforce_isolation[i] = +AMDGPU_ENFORCE_ISOLATION_ENABLE_LEGACY ; + } + }switch (amdgpu_user_queue) {case -1 :
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 6/10 drm/amdgpu/gfx11: adjust ring reset sequences
In reply to Alex DeucherWrite the fence after we reset the ring and use an IB test to validate the reset. This is safe since we have enforce isolation legacy enabled by default.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 20 +++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/nvd.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +17 -3
@@ -5912,6 +5912,7 @@ static void gfx_v11_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, {bool write64bit = flags &AMDGPU_FENCE_FLAG_64BIT ;bool int_sel = flags &AMDGPU_FENCE_FLAG_INT ; +bool exec = flags &AMDGPU_FENCE_FLAG_EXEC ;/* RELEASE_MEM - flush caches, send int */ amdgpu_ring_write (ring,PACKET3 (PACKET3_RELEASE_MEM ,6 ));
@@ -5921,7 +5922,8 @@ static void gfx_v11_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,PACKET3_RELEASE_MEM_GCR_GLM_WB |PACKET3_RELEASE_MEM_CACHE_POLICY (3 ) |PACKET3_RELEASE_MEM_EVENT_TYPE (CACHE_FLUSH_AND_INV_TS_EVENT ) | - PACKET3_RELEASE_MEM_EVENT_INDEX(5))); +PACKET3_RELEASE_MEM_EVENT_INDEX (5 ) | + (exec ? PACKET3_RELEASE_MEM_EXECUTE_GFX11 : 0)));amdgpu_ring_write (ring, (PACKET3_RELEASE_MEM_DATA_SEL (write64bit ?2 :1 ) |PACKET3_RELEASE_MEM_INT_SEL (int_sel ?2 :0 )));
@@ -6844,7 +6846,13 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r; } -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 )) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->fence_drv.sync_seq,0 ); +amdgpu_ring_commit (ring); + +return gfx_v11_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static int gfx_v11_0_reset_compute_pipe (struct amdgpu_ring *ring)
@@ -7004,7 +7012,13 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)return r; } -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 )) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->fence_drv.sync_seq,0 ); +amdgpu_ring_commit (ring); + +return gfx_v11_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static void gfx_v11_ip_print (struct amdgpu_ip_block *ip_block,struct drm_printer *p)
drivers/gpu/drm/amd/amdgpu/nvd.h +1 -0
@@ -371,6 +371,7 @@* 3 - cache_policy__me_release_mem__bypass */ #define PACKET3_RELEASE_MEM_EXECUTE (1 << 28) +#define PACKET3_RELEASE_MEM_EXECUTE_GFX11 (3 << 28)#define PACKET3_RELEASE_MEM_DATA_SEL (x) ((x) << 29)/* 0 - discard
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 7/10 drm/amdgpu/gfx12: enable legacy enforce isolation
In reply to Alex DeucherEnable legacy enforce isolation (just serialize kernel GC submissions). This way we can reset a ring and only affect the the process currently using that ring. This mirrors what windows does.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +9 -0
@@ -3823,6 +3823,15 @@ static uint64_t gfx_v12_0_get_gpu_clock_counter(struct amdgpu_device *adev)static int gfx_v12_0_early_init (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; +int i; + +if (amdgpu_enforce_isolation ==-1 ) { +for (i =0 ; i <MAX_XCP ; i++) { +/* enable legacy mode by default */ + adev->enforce_isolation[i] = +AMDGPU_ENFORCE_ISOLATION_ENABLE_LEGACY ; + } + }switch (amdgpu_user_queue) {case -1 :
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 8/10 drm/amdgpu/gfx12: adjust ring reset sequences
In reply to Alex DeucherWrite the fence after we reset the ring and use an IB test to validate the reset. This is safe since we have enforce isolation legacy enabled by default.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +17 -3
@@ -4457,6 +4457,7 @@ static void gfx_v12_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, {bool write64bit = flags &AMDGPU_FENCE_FLAG_64BIT ;bool int_sel = flags &AMDGPU_FENCE_FLAG_INT ; +bool exec = flags &AMDGPU_FENCE_FLAG_EXEC ;/* RELEASE_MEM - flush caches, send int */ amdgpu_ring_write (ring,PACKET3 (PACKET3_RELEASE_MEM ,6 ));
@@ -4464,7 +4465,8 @@ static void gfx_v12_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,PACKET3_RELEASE_MEM_GCR_GL2_WB |PACKET3_RELEASE_MEM_CACHE_POLICY (3 ) |PACKET3_RELEASE_MEM_EVENT_TYPE (CACHE_FLUSH_AND_INV_TS_EVENT ) | - PACKET3_RELEASE_MEM_EVENT_INDEX(5))); +PACKET3_RELEASE_MEM_EVENT_INDEX (5 ) | + (exec ? PACKET3_RELEASE_MEM_EXECUTE_GFX11 : 0)));amdgpu_ring_write (ring, (PACKET3_RELEASE_MEM_DATA_SEL (write64bit ?2 :1 ) |PACKET3_RELEASE_MEM_INT_SEL (int_sel ?2 :0 )));
@@ -5344,7 +5346,13 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r; } -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 )) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->fence_drv.sync_seq,0 ); +amdgpu_ring_commit (ring); + +return gfx_v12_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static int gfx_v12_0_reset_compute_pipe (struct amdgpu_ring *ring)
@@ -5457,7 +5465,13 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, unsigned int vmid)return r; } -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 )) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->fence_drv.sync_seq,0 ); +amdgpu_ring_commit (ring); + +return gfx_v12_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static void gfx_v12_0_ring_begin_use (struct amdgpu_ring *ring)
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 9/10 drm/amdgpu/gfx10: enable legacy enforce isolation
In reply to Alex DeucherEnable legacy enforce isolation (just serialize kernel GC submissions). This way we can reset a ring and only affect the the process currently using that ring. This mirrors what windows does.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +9 -0
@@ -7788,6 +7788,15 @@ static void gfx_v10_0_ring_emit_gds_switch(struct amdgpu_ring *ring,static int gfx_v10_0_early_init (struct amdgpu_ip_block *ip_block) {struct amdgpu_device *adev = ip_block->adev; +int i; + +if (amdgpu_enforce_isolation ==-1 ) { +for (i =0 ; i <MAX_XCP ; i++) { +/* enable legacy mode by default */ + adev->enforce_isolation[i] = +AMDGPU_ENFORCE_ISOLATION_ENABLE_LEGACY ; + } + } adev->gfx.funcs = &gfx_v10_0_gfx_funcs;
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH 10/10 drm/amdgpu/gfx10: adjust ring reset sequences
In reply to Alex DeucherWrite the fence after we reset the ring and use an IB test to validate the reset. This is safe since we have enforce isolation legacy enabled by default.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +17 -3
@@ -8722,6 +8722,7 @@ static void gfx_v10_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, {bool write64bit = flags &AMDGPU_FENCE_FLAG_64BIT ;bool int_sel = flags &AMDGPU_FENCE_FLAG_INT ; +bool exec = flags &AMDGPU_FENCE_FLAG_EXEC ;/* RELEASE_MEM - flush caches, send int */ amdgpu_ring_write (ring,PACKET3 (PACKET3_RELEASE_MEM ,6 ));
@@ -8731,7 +8732,8 @@ static void gfx_v10_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr,PACKET3_RELEASE_MEM_GCR_GLM_WB |PACKET3_RELEASE_MEM_CACHE_POLICY (3 ) |PACKET3_RELEASE_MEM_EVENT_TYPE (CACHE_FLUSH_AND_INV_TS_EVENT ) | - PACKET3_RELEASE_MEM_EVENT_INDEX(5))); +PACKET3_RELEASE_MEM_EVENT_INDEX (5 ) | + (exec ? PACKET3_RELEASE_MEM_EXECUTE : 0)));amdgpu_ring_write (ring, (PACKET3_RELEASE_MEM_DATA_SEL (write64bit ?2 :1 ) |PACKET3_RELEASE_MEM_INT_SEL (int_sel ?2 :0 )));
@@ -9584,7 +9586,13 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r; } -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 )) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->fence_drv.sync_seq,0 ); +amdgpu_ring_commit (ring); + +return gfx_v10_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); } static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,
@@ -9656,7 +9664,13 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,if (r)return r; -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 )) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->fence_drv.sync_seq,0 ); +amdgpu_ring_commit (ring); + +return gfx_v10_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static void gfx_v10_ip_print (struct amdgpu_ip_block *ip_block,struct drm_printer *p)
Signature · 1 line
2.49.0