Reset improvements for GC10+
Subsystems (2)
Alex Deucher
maintainerv3 cover Reset improvements for GC10+
This set improves per queue reset support for GC10+. When we reset the queue, the queue is lost so we need to re-emit the unprocessed state from subsequent submissions. To that end, in order to make sure we actually restore unprocessed state, we need to enable legacy enforce isolation so that we can safely re-emit the unprocessed state. If we don't multiple jobs can run in parallel and we may not end up resetting the correct one. This is similar to how windows handles queues. This also gives us correct guilty tracking for GC.
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. As such, I've dropped the KGQ reset code for pre-GC10.
The same approach can be extended to SDMA and VCN in the future. They don't need enforce isolation because those engines are single threaded so they always operate serially.
Alex Deucher (18):
drm/amdgpu/gfx10: enable legacy enforce isolation drm/amdgpu/gfx11: enable legacy enforce isolation drm/amdgpu/gfx12: enable legacy enforce isolation drm/amdgpu/gfx7: drop reset_kgq
drm/amdgpu/gfx8: drop reset_kgq
drm/amdgpu/gfx9: drop reset_kgq
drm/amdgpu: add AMDGPU_QUEUE_RESET_TIMEOUT drm/amdgpu/ring: add helper for padding the ring drm/amdgpu: pad ring in amdgpu_ib_schedule drm/amdgpu: track ring state associated with a job drm/amdgpu/gfx10: re-emit unprocessed state on kgq reset drm/amdgpu/gfx11: re-emit unprocessed state on kgq reset drm/amdgpu/gfx12: re-emit unprocessed state on kgq reset drm/amdgpu/gfx9: re-emit unprocessed state on kcq reset drm/amdgpu/gfx9.4.3: re-emit unprocessed state on kcq reset drm/amdgpu/gfx10: re-emit unprocessed state on kcq reset drm/amdgpu/gfx11: re-emit unprocessed state on kcq reset drm/amdgpu/gfx12: re-emit unprocessed state on kcq reset
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_ib.c | 8 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 32 ++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 52 ++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 6 ++ drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 57 ++++++++++--------- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 48 +++++++++------- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 48 +++++++++------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 71 ------------------------ drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 71 ------------------------ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 59 ++++---------------- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 15 ++++- 13 files changed, 192 insertions(+), 278 deletions(-)
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 1/19 drm/amdgpu/gfx10: enable legacy enforce isolation
Enable 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 v3 2/19 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 v3 3/19 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 v3 4/19 drm/amdgpu/gfx7: drop reset_kgq
In reply to Alex DeucherIt doesn't work reliably and we have soft recover and full adapter reset so drop this.
--- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 71 --------------------------- 1 file changed, 71 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +0 -71
@@ -4884,76 +4884,6 @@ static void gfx_v7_0_emit_mem_sync_compute(struct amdgpu_ring *ring)amdgpu_ring_write (ring,0x0000000A );/* poll interval */ } -static void gfx_v7_0_wait_reg_mem (struct amdgpu_ring *ring,int eng_sel, -int mem_space,int opt,uint32_t addr0, -uint32_t addr1,uint32_t ref,uint32_t mask, -uint32_t inv) -{ -amdgpu_ring_write (ring,PACKET3 (PACKET3_WAIT_REG_MEM ,5 )); -amdgpu_ring_write (ring, -/* memory (1) or register (0) */ - (WAIT_REG_MEM_MEM_SPACE (mem_space) | -WAIT_REG_MEM_OPERATION (opt) |/* wait */ -WAIT_REG_MEM_FUNCTION (3 ) |/* equal */ -WAIT_REG_MEM_ENGINE (eng_sel))); - -if (mem_space) -BUG_ON (addr0 &0x3 );/* Dword align */ -amdgpu_ring_write (ring, addr0); -amdgpu_ring_write (ring, addr1); -amdgpu_ring_write (ring, ref); -amdgpu_ring_write (ring, mask); -amdgpu_ring_write (ring, inv);/* poll interval */ -} - -static void gfx_v7_0_ring_emit_reg_wait (struct amdgpu_ring *ring,uint32_t reg, -uint32_t val,uint32_t mask) -{ -gfx_v7_0_wait_reg_mem (ring,0 ,0 ,0 , reg,0 , val, mask,0x20 ); -} - -static int gfx_v7_0_reset_kgq (struct amdgpu_ring *ring,unsigned int vmid) -{ -struct amdgpu_device *adev = ring->adev; -struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ]; -struct amdgpu_ring *kiq_ring = &kiq->ring; -unsigned long flags; -u32 tmp; -int r; - -if (amdgpu_sriov_vf (adev)) -return -EINVAL ; - -if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) -return -EINVAL ; - -spin_lock_irqsave (&kiq->ring_lock, flags); - -if (amdgpu_ring_alloc (kiq_ring,5 )) { -spin_unlock_irqrestore (&kiq->ring_lock, flags); -return -ENOMEM ; - } - - tmp =REG_SET_FIELD (0 ,CP_VMID_RESET ,RESET_REQUEST ,1 << vmid); -gfx_v7_0_ring_emit_wreg (kiq_ring, mmCP_VMID_RESET, tmp); -amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - - r =amdgpu_ring_test_ring (kiq_ring); -if (r) -return r; - -if (amdgpu_ring_alloc (ring,7 +12 +5 )) -return -ENOMEM ; -gfx_v7_0_ring_emit_fence_gfx (ring, ring->fence_drv.gpu_addr, - ring->fence_drv.sync_seq,AMDGPU_FENCE_FLAG_EXEC ); -gfx_v7_0_ring_emit_reg_wait (ring, mmCP_VMID_RESET,0 ,0xffff ); -gfx_v7_0_ring_emit_wreg (ring, mmCP_VMID_RESET,0 ); - -return amdgpu_ring_test_ring (ring); -} -static const struct amd_ip_funcs gfx_v7_0_ip_funcs = { .name ="gfx_v7_0" , .early_init = gfx_v7_0_early_init,
@@ -5003,7 +4933,6 @@ static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_gfx = { .emit_wreg = gfx_v7_0_ring_emit_wreg, .soft_recovery = gfx_v7_0_ring_soft_recovery, .emit_mem_sync = gfx_v7_0_emit_mem_sync, - .reset = gfx_v7_0_reset_kgq, };static const struct amdgpu_ring_funcs gfx_v7_0_ring_funcs_compute = {
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 5/19 drm/amdgpu/gfx8: drop reset_kgq
In reply to Alex DeucherIt doesn't work reliably and we have soft recover and full adapter reset so drop this.
--- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 71 --------------------------- 1 file changed, 71 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -71
@@ -6339,34 +6339,6 @@ 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_wait_reg_mem (struct amdgpu_ring *ring,int eng_sel, -int mem_space,int opt,uint32_t addr0, -uint32_t addr1,uint32_t ref,uint32_t mask, -uint32_t inv) -{ -amdgpu_ring_write (ring,PACKET3 (PACKET3_WAIT_REG_MEM ,5 )); -amdgpu_ring_write (ring, -/* memory (1) or register (0) */ - (WAIT_REG_MEM_MEM_SPACE (mem_space) | -WAIT_REG_MEM_OPERATION (opt) |/* wait */ -WAIT_REG_MEM_FUNCTION (3 ) |/* equal */ -WAIT_REG_MEM_ENGINE (eng_sel))); - -if (mem_space) -BUG_ON (addr0 &0x3 );/* Dword align */ -amdgpu_ring_write (ring, addr0); -amdgpu_ring_write (ring, addr1); -amdgpu_ring_write (ring, ref); -amdgpu_ring_write (ring, mask); -amdgpu_ring_write (ring, inv);/* poll interval */ -} - -static void gfx_v8_0_ring_emit_reg_wait (struct amdgpu_ring *ring,uint32_t reg, -uint32_t val,uint32_t mask) -{ -gfx_v8_0_wait_reg_mem (ring,0 ,0 ,0 , reg,0 , val, mask,0x20 ); -} -static void gfx_v8_0_ring_soft_recovery (struct amdgpu_ring *ring,unsigned vmid) {struct amdgpu_device *adev = ring->adev;
@@ -6843,48 +6815,6 @@ static void gfx_v8_0_emit_wave_limit(struct amdgpu_ring *ring, bool enable) } -static int gfx_v8_0_reset_kgq (struct amdgpu_ring *ring,unsigned int vmid) -{ -struct amdgpu_device *adev = ring->adev; -struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ]; -struct amdgpu_ring *kiq_ring = &kiq->ring; -unsigned long flags; -u32 tmp; -int r; - -if (amdgpu_sriov_vf (adev)) -return -EINVAL ; - -if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) -return -EINVAL ; - -spin_lock_irqsave (&kiq->ring_lock, flags); - -if (amdgpu_ring_alloc (kiq_ring,5 )) { -spin_unlock_irqrestore (&kiq->ring_lock, flags); -return -ENOMEM ; - } - - tmp =REG_SET_FIELD (0 ,CP_VMID_RESET ,RESET_REQUEST ,1 << vmid); -gfx_v8_0_ring_emit_wreg (kiq_ring, mmCP_VMID_RESET, tmp); -amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - - r =amdgpu_ring_test_ring (kiq_ring); -if (r) -return r; - -if (amdgpu_ring_alloc (ring,7 +12 +5 )) -return -ENOMEM ; -gfx_v8_0_ring_emit_fence_gfx (ring, ring->fence_drv.gpu_addr, - ring->fence_drv.sync_seq,AMDGPU_FENCE_FLAG_EXEC ); -gfx_v8_0_ring_emit_reg_wait (ring, mmCP_VMID_RESET,0 ,0xffff ); -gfx_v8_0_ring_emit_wreg (ring, mmCP_VMID_RESET,0 ); - -return amdgpu_ring_test_ring (ring); -} -static const struct amd_ip_funcs gfx_v8_0_ip_funcs = { .name ="gfx_v8_0" , .early_init = gfx_v8_0_early_init,
@@ -6950,7 +6880,6 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = { .emit_wreg = gfx_v8_0_ring_emit_wreg, .soft_recovery = gfx_v8_0_ring_soft_recovery, .emit_mem_sync = gfx_v8_0_emit_mem_sync, - .reset = gfx_v8_0_reset_kgq, };static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute = {
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 6/19 drm/amdgpu/gfx9: drop reset_kgq
In reply to Alex DeucherIt doesn't work reliably and we have soft recover and full adapter reset so drop this.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 46 --------------------------- 1 file changed, 46 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -46
@@ -7152,51 +7152,6 @@ static void gfx_v9_ring_insert_nop(struct amdgpu_ring *ring, uint32_t num_nop)amdgpu_ring_insert_nop (ring, num_nop -1 ); } -static int gfx_v9_0_reset_kgq (struct amdgpu_ring *ring,unsigned int vmid) -{ -struct amdgpu_device *adev = ring->adev; -struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ]; -struct amdgpu_ring *kiq_ring = &kiq->ring; -unsigned long flags; -u32 tmp; -int r; - -if (amdgpu_sriov_vf (adev)) -return -EINVAL ; - -if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) -return -EINVAL ; - -spin_lock_irqsave (&kiq->ring_lock, flags); - -if (amdgpu_ring_alloc (kiq_ring,5 )) { -spin_unlock_irqrestore (&kiq->ring_lock, flags); -return -ENOMEM ; - } - - tmp =REG_SET_FIELD (0 ,CP_VMID_RESET ,RESET_REQUEST ,1 << vmid); -gfx_v9_0_ring_emit_wreg (kiq_ring, -SOC15_REG_OFFSET (GC ,0 , mmCP_VMID_RESET), tmp); -amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - - r =amdgpu_ring_test_ring (kiq_ring); -if (r) -return r; - -if (amdgpu_ring_alloc (ring,7 +7 +5 )) -return -ENOMEM ; -gfx_v9_0_ring_emit_fence (ring, ring->fence_drv.gpu_addr, - ring->fence_drv.sync_seq,AMDGPU_FENCE_FLAG_EXEC ); -gfx_v9_0_ring_emit_reg_wait (ring, -SOC15_REG_OFFSET (GC ,0 , mmCP_VMID_RESET),0 ,0xffff ); -gfx_v9_0_ring_emit_wreg (ring, -SOC15_REG_OFFSET (GC ,0 , mmCP_VMID_RESET),0 ); - -return amdgpu_ring_test_ring (ring); -} -static int gfx_v9_0_reset_kcq (struct amdgpu_ring *ring,unsigned int vmid) {
@@ -7477,7 +7432,6 @@ static const struct amdgpu_ring_funcs gfx_v9_0_ring_funcs_gfx = { .emit_reg_write_reg_wait = gfx_v9_0_ring_emit_reg_write_reg_wait, .soft_recovery = gfx_v9_0_ring_soft_recovery, .emit_mem_sync = gfx_v9_0_emit_mem_sync, - .reset = gfx_v9_0_reset_kgq, .emit_cleaner_shader = gfx_v9_0_ring_emit_cleaner_shader, .begin_use = amdgpu_gfx_enforce_isolation_ring_begin_use, .end_use = amdgpu_gfx_enforce_isolation_ring_end_use,
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 7/19 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
v3: drop amdgpu_fence_driver_force_completion() for compute ring
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +15 -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,20 @@ 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 ) && + (ring->funcs->type !=AMDGPU_RING_TYPE_COMPUTE )) +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 v3 8/19 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 validating 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 msecs_to_jiffies(1000)#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 v3 9/19 drm/amdgpu/ring: add helper for padding the ring
In reply to Alex DeucherAdd a helper to pad the ring to a multiple of the fetch size.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 29 +++++++++++++++++------- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 2 files changed, 22 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +21 -8
@@ -141,21 +141,17 @@ void amdgpu_ring_generic_pad_ib(struct amdgpu_ring *ring, struct amdgpu_ib *ib) }/** -* amdgpu_ring_commit - tell the GPU to execute the new -* commands on the ring buffer +* amdgpu_ring_pad_to_fetch_size - pad the ring with nops +* to the fetch size. * * @ring: amdgpu_ring structure holding ring information * -* Update the wptr (write pointer) to tell the GPU to -* execute new commands on the ring buffer (all asics). +* Pad the ring with nops to align with the hardware fetch size. */ -void amdgpu_ring_commit (struct amdgpu_ring *ring) +void amdgpu_ring_pad_to_fetch_size (struct amdgpu_ring *ring) {uint32_t count; -if (ring->count_dw <0 ) -DRM_ERROR ("amdgpu: writing more dwords to the ring than expected!\n" ); -/* We pad to match fetch size */ count = ring->funcs->align_mask +1 - (ring->wptr & ring->funcs->align_mask);
@@ -163,6 +159,23 @@ void amdgpu_ring_commit(struct amdgpu_ring *ring)if (count !=0 ) ring->funcs->insert_nop (ring, count); +} + +/** +* amdgpu_ring_commit - tell the GPU to execute the new +* commands on the ring buffer +* +* @ring: amdgpu_ring structure holding ring information +* +* Update the wptr (write pointer) to tell the GPU to +* execute new commands on the ring buffer (all asics). +*/ +void amdgpu_ring_commit (struct amdgpu_ring *ring) +{ +if (ring->count_dw <0 ) +DRM_ERROR ("amdgpu: writing more dwords to the ring than expected!\n" ); + +amdgpu_ring_pad_to_fetch_size (ring);mb ();amdgpu_ring_set_wptr (ring);
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -0
@@ -421,6 +421,7 @@ void amdgpu_ring_ib_on_emit_de(struct amdgpu_ring *ring);void amdgpu_ring_insert_nop (struct amdgpu_ring *ring,uint32_t count);void amdgpu_ring_generic_pad_ib (struct amdgpu_ring *ring,struct amdgpu_ib *ib); +void amdgpu_ring_pad_to_fetch_size (struct amdgpu_ring *ring);void amdgpu_ring_commit (struct amdgpu_ring *ring);void amdgpu_ring_undo (struct amdgpu_ring *ring); int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 10/19 drm/amdgpu: pad ring in amdgpu_ib_schedule
In reply to Alex DeucherWe'll want to include the padding in the wptr count for resets.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2 -0
@@ -304,6 +304,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, ring->hw_prio == AMDGPU_GFX_PIPE_PRIO_HIGH) ring->funcs->emit_wave_limit(ring, false); +amdgpu_ring_pad_to_fetch_size (ring); +amdgpu_ring_ib_end (ring);amdgpu_ring_commit (ring);return 0 ;
Signature · 1 line
2.49.0
Christian König
maintainerRe: [PATCH 10/19] drm/amdgpu: pad ring in amdgpu_ib_schedule
Quoted 13 lines · Alex Deucher
We'll want to include the padding in the wptr count for resets.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, · line 308
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2
-0@@ -304,6 +304,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, ring->hw_prio == AMDGPU_GFX_PIPE_PRIO_HIGH) ring->funcs->emit_wave_limit(ring, false); +amdgpu_ring_pad_to_fetch_size (ring); +
Hui? Why that here? amdgpu_ring_commit will do that anyway.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0amdgpu_ring_ib_end (ring);amdgpu_ring_commit (ring);return 0 ;
Re: [PATCH 10/19] drm/amdgpu: pad ring in amdgpu_ib_schedule
Quoted 18 lines · Christian König
Quoted 16 lines · Alex Deucher
We'll want to include the padding in the wptr count for resets.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -304,6 +304,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, ring->hw_prio == AMDGPU_GFX_PIPE_PRIO_HIGH) ring->funcs->emit_wave_limit (ring, false);
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, · line 308
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2
-0+amdgpu_ring_pad_to_fetch_size (ring); +Hui? Why that here?
amdgpu_ring_commitwill do that anyway.
So that I can know the full size of the submission frame for this job when I grab the follow-on ring contents to re-emit. See the next patch.
Alex
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0amdgpu_ring_ib_end (ring);amdgpu_ring_commit (ring);return 0 ;
Christian König
maintainerRe: [PATCH 10/19] drm/amdgpu: pad ring in amdgpu_ib_schedule
Quoted 20 lines · Alex Deucher
Quoted 18 lines · Christian König
Quoted 16 lines · Alex Deucher
We'll want to include the padding in the wptr count for resets.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0@@ -304,6 +304,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, ring->hw_prio == AMDGPU_GFX_PIPE_PRIO_HIGH) ring->funcs->emit_wave_limit (ring, false);
Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, · line 308
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2
-0+amdgpu_ring_pad_to_fetch_size (ring); +Hui? Why that here?
amdgpu_ring_commitwill do that anyway.So that I can know the full size of the submission frame for this job when I grab the follow-on ring contents to re-emit. See the next patch.
Ah! Ok, why not doing that after the ring_commit? Then we don't need to change anything here.
Christian.
Quoted 9 lines
Alex
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0amdgpu_ring_ib_end (ring);amdgpu_ring_commit (ring);return 0 ;
Re: [PATCH 10/19] drm/amdgpu: pad ring in amdgpu_ib_schedule
Quoted 27 lines · Christian König
Quoted 25 lines · Alex Deucher
Quoted 22 lines · Christian König
Quoted 13 lines · Alex Deucher
We'll want to include the padding in the wptr count for resets.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, · line 308
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +2
-0@@ -304,6 +304,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs, ring->hw_prio == AMDGPU_GFX_PIPE_PRIO_HIGH) ring->funcs->emit_wave_limit (ring, false); +amdgpu_ring_pad_to_fetch_size (ring); +Hui? Why that here?
amdgpu_ring_commitwill do that anyway.
Quoted 5 lines
Quoted 3 lines
So that I can know the full size of the submission frame for this job when I grab the follow-on ring contents to re-emit. See the next patch.
Ah! Ok, why not doing that after the
ring_commit? Then we don't need to change anything here.
Oh, yeah, that should work.
Alex
Quoted 13 lines
Christian.
Quoted 9 lines
Alex
Quoted 6 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +0
-0amdgpu_ring_ib_end (ring);amdgpu_ring_commit (ring);return 0 ;
Alex Deucher
maintainerPATCH v3 11/19 drm/amdgpu: track ring state associated with a job
In reply to Alex DeucherWe need to know the wptr and sequence number associated with a job so that we can re-emit the unprocessed state after a ring reset. Pre-allocate storage space for the ring buffer contents and add a helper to save off the unprocessed state so that it can be re-emitted after the queue is reset.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 23 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 5 +++++ 5 files changed, 40 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +6 -0
@@ -306,6 +306,12 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned int num_ibs,amdgpu_ring_pad_to_fetch_size (ring); +/* This must be last for resets to work properly +* as we need to save the wptr associated with this +* job. +*/ +if (job) + job->ring_wptr = ring->wptr;amdgpu_ring_ib_end (ring);amdgpu_ring_commit (ring);return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -1
@@ -91,6 +91,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_job *job =to_amdgpu_job (s_job);struct amdgpu_task_info *ti;struct amdgpu_device *adev = ring->adev; +struct dma_fence *fence = &job->hw_fence;int idx;int r;
@@ -154,8 +155,10 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)else is_guilty = true; -if (is_guilty) +if (is_guilty) { +amdgpu_ring_backup_unprocessed_jobs (ring, job->ring_wptr, fence->seqno);dma_fence_set_error (&s_job->s_fence->finished, -ETIME ); + } r =amdgpu_ring_reset (ring, job->vmid);if (!r) {
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +2 -0
@@ -79,6 +79,8 @@ struct amdgpu_job {/* enforce isolation */ bool enforce_isolation;bool run_cleaner_shader; +/* wptr for the job for resets */ +uint32_t ring_wptr;uint32_t num_ibs;struct amdgpu_ib ibs[];
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +23 -0
@@ -346,6 +346,12 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,/* Initialize cached_rptr to 0 */ ring->cached_rptr =0 ; +if (!ring->ring_backup) { + ring->ring_backup =kvzalloc (ring->ring_size,GFP_KERNEL ); +if (!ring->ring_backup) +return -ENOMEM ; + } +/* Allocate ring buffer */ if (ring->ring_obj ==NULL ) { r = amdgpu_bo_create_kernel(adev, ring->ring_size + ring->funcs->extra_dw, PAGE_SIZE,
@@ -355,6 +361,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, (void **)&ring->ring);if (r) {dev_err (adev->dev,"(%d) ring create failed\n" , r); +kvfree (ring->ring_backup);return r; }amdgpu_ring_clear_ring (ring);
@@ -398,6 +405,8 @@ void amdgpu_ring_fini(struct amdgpu_ring *ring)amdgpu_bo_free_kernel (&ring->ring_obj, &ring->gpu_addr, (void **)&ring->ring); +kvfree (ring->ring_backup); + ring->ring_backup =NULL ;dma_fence_put (ring->vmid_wait); ring->vmid_wait =NULL ;
@@ -766,3 +775,17 @@ bool amdgpu_ring_sched_ready(struct amdgpu_ring *ring)return true; } + +void amdgpu_ring_backup_unprocessed_jobs (struct amdgpu_ring *ring, +u64 bad_wptr,u32 bad_seq) +{ +unsigned int entries_to_copy = ring->wptr - bad_wptr; +unsigned int idx, i; + +for (i =0 ; i < entries_to_copy; i++) { + idx = (bad_wptr + i) & ring->buf_mask; + ring->ring_backup[i] = ring->ring[idx]; + } + ring->ring_backup_entries_to_copy = entries_to_copy; + ring->ring_backup_seq = bad_seq; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +5 -0
@@ -268,6 +268,9 @@ struct amdgpu_ring {struct amdgpu_bo *ring_obj;uint32_t *ring; +uint32_t *ring_backup; +uint32_t ring_backup_seq; +unsigned int ring_backup_entries_to_copy;unsigned rptr_offs;u64 rptr_gpu_addr;volatile u32 *rptr_cpu_addr;
@@ -535,4 +538,6 @@ int amdgpu_ib_pool_init(struct amdgpu_device *adev);void amdgpu_ib_pool_fini (struct amdgpu_device *adev);int amdgpu_ib_ring_tests (struct amdgpu_device *adev);bool amdgpu_ring_sched_ready (struct amdgpu_ring *ring); +void amdgpu_ring_backup_unprocessed_jobs (struct amdgpu_ring *ring, +u64 bad_wptr,u32 bad_seq);#endif
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 12/19 drm/amdgpu/gfx10: re-emit unprocessed state on kgq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +12 -7
@@ -9537,6 +9537,7 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ];struct amdgpu_ring *kiq_ring = &kiq->ring;unsigned long flags; +unsigned int i;u32 tmp;u64 addr;int r;
@@ -9571,10 +9572,8 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) SOC15_REG_OFFSET(GC, 0, mmCP_VMID_RESET), 0, 0xffffffff); kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;
@@ -9584,7 +9583,15 @@ 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 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +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,
@@ -9612,9 +9619,8 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring, kiq->pmf->kiq_unmap_queues (kiq_ring, ring,RESET_QUEUES ,0 ,0 );amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;
@@ -9891,7 +9897,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v10_0_ring_soft_recovery, .emit_mem_sync = gfx_v10_0_emit_mem_sync, .reset = gfx_v10_0_reset_kgq, .emit_cleaner_shader = gfx_v10_0_ring_emit_cleaner_shader,
Signature · 1 line
2.49.0
Christian König
maintainerRe: [PATCH 12/19] drm/amdgpu/gfx10: re-emit unprocessed state on kgq reset
Quoted 20 lines · Alex Deucher
Re-emit the unprocessed state after resetting the queue.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0@@ -9537,6 +9537,7 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ];struct amdgpu_ring *kiq_ring = &kiq->ring;unsigned long flags; +unsigned int i;u32 tmp;u64 addr;int r;
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9575
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-3@@ -9571,10 +9572,8 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) SOC15_REG_OFFSET(GC, 0, mmCP_VMID_RESET), 0, 0xffffffff); kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring);
I don't think we should do a ring test on the KIQ here That basically doesn't tells as much and might cause additional problems.
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9584,7 +9583,15 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r;
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9592
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +7
-1} -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring);
I'm not sure if the commands are always relocatable. We should probably just instruct the ring to re-start with the original RPTR/WPTR.
That would also avoid the need to save/restore the ring content with the CPU.
Regards,
Christian.
Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3
-3+ +return gfx_v10_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); } static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,@@ -9612,9 +9619,8 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring, kiq->pmf->kiq_unmap_queues (kiq_ring, ring,RESET_QUEUES ,0 ,0 );amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9891,7 +9897,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v10_0_ring_soft_recovery, .emit_mem_sync = gfx_v10_0_emit_mem_sync, .reset = gfx_v10_0_reset_kgq, .emit_cleaner_shader = gfx_v10_0_ring_emit_cleaner_shader,
Re: [PATCH 12/19] drm/amdgpu/gfx10: re-emit unprocessed state on kgq reset
Quoted 23 lines · Christian König
Quoted 21 lines · Alex Deucher
Re-emit the unprocessed state after resetting the queue.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0@@ -9537,6 +9537,7 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ];struct amdgpu_ring *kiq_ring = &kiq->ring;unsigned long flags; +unsigned int i;u32 tmp;u64 addr;int r;@@ -9571,10 +9572,8 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) SOC15_REG_OFFSET(GC, 0, mmCP_VMID_RESET), 0, 0xffffffff);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9575
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-3kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring);I don't think we should do a ring test on the KIQ here That basically doesn't tells as much and might cause additional problems.
We need some way to wait for the KIQ submission to complete. This is a simple way to accomplish that.
Quoted 20 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9584,7 +9583,15 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r;drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9592
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +7
-1} -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring);I'm not sure if the commands are always relocatable. We should probably just instruct the ring to re-start with the original RPTR/WPTR.
Quoted 1 line
That would also avoid the need to save/restore the ring content with the CPU.
I tried that originally, but I couldn't make it work for a few reasons:
1. We need to have enforce isolation enabled otherwise we almost always reset the wrong VMID so then when we execute the rest of the pipeline, we hang again.
2. When enforce isolation is enabled, we need to signal the fence associated with the guilty job first otherwise we get stuck waiting on the pipeline sync when we execute the rest of the pipeline
Alex
Quoted 29 lines
Regards,
Christian.Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3
-3+ +return gfx_v10_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); } static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,@@ -9612,9 +9619,8 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring, kiq->pmf->kiq_unmap_queues (kiq_ring, ring,RESET_QUEUES ,0 ,0 );amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9891,7 +9897,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v10_0_ring_soft_recovery, .emit_mem_sync = gfx_v10_0_emit_mem_sync, .reset = gfx_v10_0_reset_kgq, .emit_cleaner_shader = gfx_v10_0_ring_emit_cleaner_shader,
Christian König
maintainerRe: [PATCH 12/19] drm/amdgpu/gfx10: re-emit unprocessed state on kgq reset
Quoted 34 lines · Alex Deucher
Quoted 23 lines · Christian König
Quoted 21 lines · Alex Deucher
Re-emit the unprocessed state after resetting the queue.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0@@ -9537,6 +9537,7 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ];struct amdgpu_ring *kiq_ring = &kiq->ring;unsigned long flags; +unsigned int i;u32 tmp;u64 addr;int r;@@ -9571,10 +9572,8 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) SOC15_REG_OFFSET(GC, 0, mmCP_VMID_RESET), 0, 0xffffffff);Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9575
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-3kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring);I don't think we should do a ring test on the KIQ here That basically doesn't tells as much and might cause additional problems.
Quoted 2 lines
We need some way to wait for the KIQ submission to complete. This is a simple way to accomplish that.
Ok, that makes sense.
Quoted 23 lines
Quoted 21 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9584,7 +9583,15 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r;drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9592
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +7
-1} -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring);I'm not sure if the commands are always relocatable. We should probably just instruct the ring to re-start with the original RPTR/WPTR.
Quoted 1 line
That would also avoid the need to save/restore the ring content with the CPU.
Quoted 7 lines
I tried that originally, but I couldn't make it work for a few reasons:
1. We need to have enforce isolation enabled otherwise we almost always reset the wrong VMID so then when we execute the rest of the pipeline, we hang again.
2. When enforce isolation is enabled, we need to signal the fence associated with the guilty job first otherwise we get stuck waiting on the pipeline sync when we execute the rest of the pipeline
So we execute the guilty job submission again? What prevents that one from running?
Christian.
Quoted 32 lines
Alex
Quoted 29 lines
Regards,
Christian.Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3
-3+ +return gfx_v10_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); } static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,@@ -9612,9 +9619,8 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring, kiq->pmf->kiq_unmap_queues (kiq_ring, ring,RESET_QUEUES ,0 ,0 );amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9891,7 +9897,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v10_0_ring_soft_recovery, .emit_mem_sync = gfx_v10_0_emit_mem_sync, .reset = gfx_v10_0_reset_kgq, .emit_cleaner_shader = gfx_v10_0_ring_emit_cleaner_shader,
Re: [PATCH 12/19] drm/amdgpu/gfx10: re-emit unprocessed state on kgq reset
Quoted 72 lines · Christian König
Quoted 34 lines · Alex Deucher
Quoted 23 lines · Christian König
Quoted 21 lines · Alex Deucher
Re-emit the unprocessed state after resetting the queue.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0@@ -9537,6 +9537,7 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ];struct amdgpu_ring *kiq_ring = &kiq->ring;unsigned long flags; +unsigned int i;u32 tmp;u64 addr;int r;@@ -9571,10 +9572,8 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) SOC15_REG_OFFSET(GC, 0, mmCP_VMID_RESET), 0, 0xffffffff);Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9575
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-3kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring);I don't think we should do a ring test on the KIQ here That basically doesn't tells as much and might cause additional problems.
Quoted 2 lines
We need some way to wait for the KIQ submission to complete. This is a simple way to accomplish that.
Ok, that makes sense.
Quoted 23 lines
Quoted 21 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9584,7 +9583,15 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r;drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9592
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +7
-1} -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring);I'm not sure if the commands are always relocatable. We should probably just instruct the ring to re-start with the original RPTR/WPTR.
Quoted 1 line
That would also avoid the need to save/restore the ring content with the CPU.
Quoted 7 lines
I tried that originally, but I couldn't make it work for a few reasons:
1. We need to have enforce isolation enabled otherwise we almost always reset the wrong VMID so then when we execute the rest of the pipeline, we hang again.
2. When enforce isolation is enabled, we need to signal the fence associated with the guilty job first otherwise we get stuck waiting on the pipeline sync when we execute the rest of the pipeline
Quoted 1 line
So we execute the guilty job submission again? What prevents that one from running?
Without enforce isolation we usually end up reseting the wrong job. I re-emit everything from the ring after the bad job. What usually happens is that a game is running and then you start an app which hangs the GPU (e.g., an infinite loop in a shader). Most of the time we reset the game rather than the bad app. The scheduler times out on the app first and then we reset the queue and re-emit the following jobs, one of which is the bad app. Queue reset fails and we fall back to a full adapter reset. With enforce isolation, we reset the bad app instead.
Alex
Quoted 36 lines
Christian.
Quoted 32 lines
Alex
Quoted 29 lines
Regards,
Christian.Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3
-3+ +return gfx_v10_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); } static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,@@ -9612,9 +9619,8 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring, kiq->pmf->kiq_unmap_queues (kiq_ring, ring,RESET_QUEUES ,0 ,0 );amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9891,7 +9897,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v10_0_ring_soft_recovery, .emit_mem_sync = gfx_v10_0_emit_mem_sync, .reset = gfx_v10_0_reset_kgq, .emit_cleaner_shader = gfx_v10_0_ring_emit_cleaner_shader,
Re: [PATCH 12/19] drm/amdgpu/gfx10: re-emit unprocessed state on kgq reset
Quoted 77 lines · Alex Deucher
Quoted 72 lines · Christian König
Quoted 34 lines · Alex Deucher
Quoted 23 lines · Christian König
Quoted 21 lines · Alex Deucher
Re-emit the unprocessed state after resetting the queue.
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0@@ -9537,6 +9537,7 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ];struct amdgpu_ring *kiq_ring = &kiq->ring;unsigned long flags; +unsigned int i;u32 tmp;u64 addr;int r;@@ -9571,10 +9572,8 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) SOC15_REG_OFFSET(GC, 0, mmCP_VMID_RESET), 0, 0xffffffff);Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9575
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +0
-3kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); - -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring);I don't think we should do a ring test on the KIQ here That basically doesn't tells as much and might cause additional problems.
Quoted 2 lines
We need some way to wait for the KIQ submission to complete. This is a simple way to accomplish that.
Ok, that makes sense.
Quoted 23 lines
Quoted 21 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1
-0+spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9584,7 +9583,15 @@ static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)return r;drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c static int gfx_v10_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid) · line 9592
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +7
-1} -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring);I'm not sure if the commands are always relocatable. We should probably just instruct the ring to re-start with the original RPTR/WPTR.
Quoted 1 line
That would also avoid the need to save/restore the ring content with the CPU.
Quoted 7 lines
I tried that originally, but I couldn't make it work for a few reasons:
1. We need to have enforce isolation enabled otherwise we almost always reset the wrong VMID so then when we execute the rest of the pipeline, we hang again.
2. When enforce isolation is enabled, we need to signal the fence associated with the guilty job first otherwise we get stuck waiting on the pipeline sync when we execute the rest of the pipelineQuoted 1 line
So we execute the guilty job submission again? What prevents that one from running?
Quoted 9 lines
Without enforce isolation we usually end up reseting the wrong job. I re-emit everything from the ring after the bad job. What usually happens is that a game is running and then you start an app which hangs the GPU (e.g., an infinite loop in a shader). Most of the time we reset the game rather than the bad app. The scheduler times out on the app first and then we reset the queue and re-emit the following jobs, one of which is the bad app. Queue reset fails and we fall back to a full adapter reset. With enforce isolation, we reset the bad app instead.
Thinking about it more, we'll always end up in a full adapter reset if we have back to back bad apps. I think what we need to do is emit the seq number from the bad app, verify that that completes and use that to determine success in the reset function then re-emit the follow on work and exit the function. That way the reset succeeds and then if the follow on job times out, we can repeat the process cleanly.
Alex
Quoted 39 lines
Alex
Quoted 36 lines
Christian.
Quoted 32 lines
Alex
Quoted 29 lines
Regards,
Christian.Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +3
-3+ +return gfx_v10_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); } static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring,@@ -9612,9 +9619,8 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring, kiq->pmf->kiq_unmap_queues (kiq_ring, ring,RESET_QUEUES ,0 ,0 );amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r;@@ -9891,7 +9897,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_gfx = { .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v10_0_ring_soft_recovery, .emit_mem_sync = gfx_v10_0_emit_mem_sync, .reset = gfx_v10_0_reset_kgq, .emit_cleaner_shader = gfx_v10_0_ring_emit_cleaner_shader,
Alex Deucher
maintainerPATCH v3 13/19 drm/amdgpu/gfx11: re-emit unprocessed state on kgq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +9 -2
@@ -6818,6 +6818,7 @@ static int gfx_v11_reset_gfx_pipe(struct amdgpu_ring *ring)static int gfx_v11_0_reset_kgq (struct amdgpu_ring *ring,unsigned int vmid) {struct amdgpu_device *adev = ring->adev; +unsigned int i;int r;if (amdgpu_sriov_vf (adev))
@@ -6843,8 +6844,15 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)dev_err (adev->dev,"failed to remap kgq\n" );return r; } +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring); -return amdgpu_ring_test_ring (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)
@@ -7240,7 +7248,6 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_gfx = { .emit_wreg = gfx_v11_0_ring_emit_wreg, .emit_reg_wait = gfx_v11_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v11_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v11_0_ring_soft_recovery, .emit_mem_sync = gfx_v11_0_emit_mem_sync, .reset = gfx_v11_0_reset_kgq, .emit_cleaner_shader = gfx_v11_0_ring_emit_cleaner_shader,
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 14/19 drm/amdgpu/gfx12: re-emit unprocessed state on kgq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +10 -2
@@ -5319,6 +5319,7 @@ static int gfx_v12_reset_gfx_pipe(struct amdgpu_ring *ring)static int gfx_v12_0_reset_kgq (struct amdgpu_ring *ring,unsigned int vmid) {struct amdgpu_device *adev = ring->adev; +unsigned int i;int r;if (amdgpu_sriov_vf (adev))
@@ -5344,7 +5345,15 @@ 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 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +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)
@@ -5535,7 +5544,6 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_gfx = { .emit_wreg = gfx_v12_0_ring_emit_wreg, .emit_reg_wait = gfx_v12_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v12_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v12_0_ring_soft_recovery, .emit_mem_sync = gfx_v12_0_emit_mem_sync, .reset = gfx_v12_0_reset_kgq, .emit_cleaner_shader = gfx_v12_0_ring_emit_cleaner_shader,
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 15/19 drm/amdgpu/gfx9: re-emit unprocessed state on kcq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +11 -2
@@ -7216,13 +7216,22 @@ static int gfx_v9_0_reset_kcq(struct amdgpu_ring *ring, } kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r) {DRM_ERROR ("fail to remap queue\n" );return r; } -return amdgpu_ring_test_ring (ring); + +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring); + +return gfx_v9_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static void gfx_v9_ip_print (struct amdgpu_ip_block *ip_block,struct drm_printer *p)
Signature · 1 line
2.49.0
Christian König
maintainerRe: [PATCH 15/19] drm/amdgpu/gfx9: re-emit unprocessed state on kcq reset
Quoted 1 line · Alex Deucher
Re-emit the unprocessed state after resetting the queue.
I don't think we want any of this for compute queues.
Regards,
Christian.
Quoted 35 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +11
-2@@ -7216,13 +7216,22 @@ static int gfx_v9_0_reset_kcq(struct amdgpu_ring *ring, } kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r) {DRM_ERROR ("fail to remap queue\n" );return r; } -return amdgpu_ring_test_ring (ring); + +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring); + +return gfx_v9_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static void gfx_v9_ip_print (struct amdgpu_ip_block *ip_block,struct drm_printer *p)
Re: [PATCH 15/19] drm/amdgpu/gfx9: re-emit unprocessed state on kcq reset
Quoted 5 lines · Christian König
Quoted 1 line · Alex Deucher
Re-emit the unprocessed state after resetting the queue.
I don't think we want any of this for compute queues.
Why not? This allows us to do per job resets and can be trivially extended to all engines.
Alex
Quoted 40 lines
Regards,
Christian.Quoted 35 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +11
-2@@ -7216,13 +7216,22 @@ static int gfx_v9_0_reset_kcq(struct amdgpu_ring *ring, } kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r) {DRM_ERROR ("fail to remap queue\n" );return r; } -return amdgpu_ring_test_ring (ring); + +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring); + +return gfx_v9_0_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }static void gfx_v9_ip_print (struct amdgpu_ip_block *ip_block,struct drm_printer *p)
Alex Deucher
maintainerPATCH v3 16/19 drm/amdgpu/gfx9.4.3: re-emit unprocessed state on kcq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +12 -3
@@ -3558,6 +3558,7 @@ static int gfx_v9_4_3_reset_kcq(struct amdgpu_ring *ring,struct amdgpu_kiq *kiq = &adev->gfx.kiq[ring->xcc_id];struct amdgpu_ring *kiq_ring = &kiq->ring;unsigned long flags; +unsigned int i;int r;if (amdgpu_sriov_vf (adev))
@@ -3612,14 +3613,22 @@ static int gfx_v9_4_3_reset_kcq(struct amdgpu_ring *ring, } kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r) {dev_err (adev->dev,"fail to remap queue\n" );return r; } -return amdgpu_ring_test_ring (ring); + +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +amdgpu_ring_commit (ring); + +return gfx_v9_4_3_ring_test_ib (ring,AMDGPU_QUEUE_RESET_TIMEOUT ); }enum amdgpu_gfx_cp_ras_mem_id {
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 17/19 drm/amdgpu/gfx10: re-emit unprocessed state on kcq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 29 +++++++++----------------- 1 file changed, 10 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10 -19
@@ -9055,21 +9055,6 @@ static void gfx_v10_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, ref, mask); } -static void gfx_v10_0_ring_soft_recovery (struct amdgpu_ring *ring, -unsigned int 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); -amdgpu_gfx_rlc_enter_safe_mode (adev,0 ); -WREG32_SOC15 (GC ,0 , mmSQ_CMD, value); -amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); -} - static void gfx_v10_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, uint32_t me, uint32_t pipe,
@@ -9656,13 +9641,20 @@ static int gfx_v10_0_reset_kcq(struct amdgpu_ring *ring, } kiq->pmf->kiq_map_queues (kiq_ring, ring);amdgpu_ring_commit (kiq_ring); -spin_unlock_irqrestore (&kiq->ring_lock, flags); - r =amdgpu_ring_test_ring (kiq_ring); +spin_unlock_irqrestore (&kiq->ring_lock, flags);if (r)return r; -return amdgpu_ring_test_ring (ring); +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +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)
@@ -9937,7 +9929,6 @@ static const struct amdgpu_ring_funcs gfx_v10_0_ring_funcs_compute = { .emit_wreg = gfx_v10_0_ring_emit_wreg, .emit_reg_wait = gfx_v10_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v10_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v10_0_ring_soft_recovery, .emit_mem_sync = gfx_v10_0_emit_mem_sync, .reset = gfx_v10_0_reset_kcq, .emit_cleaner_shader = gfx_v10_0_ring_emit_cleaner_shader,
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 18/19 drm/amdgpu/gfx11: re-emit unprocessed state on kcq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 28 ++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +11 -17
@@ -6287,21 +6287,6 @@ static void gfx_v11_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, ref, mask, 0x20); } -static void gfx_v11_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); -amdgpu_gfx_rlc_enter_safe_mode (adev,0 ); -WREG32_SOC15 (GC ,0 , regSQ_CMD, value); -amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); -} - static void gfx_v11_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, uint32_t me, uint32_t pipe,
@@ -6844,6 +6829,7 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring, unsigned int vmid)dev_err (adev->dev,"failed to remap kgq\n" );return r; } +if (amdgpu_ring_alloc (ring,8 + ring->ring_backup_entries_to_copy))return -ENOMEM ; amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
@@ -6988,6 +6974,7 @@ static int gfx_v11_0_reset_compute_pipe(struct amdgpu_ring *ring)static int gfx_v11_0_reset_kcq (struct amdgpu_ring *ring,unsigned int vmid) {struct amdgpu_device *adev = ring->adev; +unsigned int i;int r =0 ;if (amdgpu_sriov_vf (adev))
@@ -7012,7 +6999,15 @@ 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 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +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)
@@ -7289,7 +7284,6 @@ static const struct amdgpu_ring_funcs gfx_v11_0_ring_funcs_compute = { .emit_wreg = gfx_v11_0_ring_emit_wreg, .emit_reg_wait = gfx_v11_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v11_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v11_0_ring_soft_recovery, .emit_mem_sync = gfx_v11_0_emit_mem_sync, .reset = gfx_v11_0_reset_kcq, .emit_cleaner_shader = gfx_v11_0_ring_emit_cleaner_shader,
Signature · 1 line
2.49.0
Alex Deucher
maintainerPATCH v3 19/19 drm/amdgpu/gfx12: re-emit unprocessed state on kcq reset
In reply to Alex DeucherRe-emit the unprocessed state after resetting the queue.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +10 -17
@@ -4699,21 +4699,6 @@ static void gfx_v12_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring, ref, mask, 0x20); } -static void gfx_v12_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); -amdgpu_gfx_rlc_enter_safe_mode (adev,0 ); -WREG32_SOC15 (GC ,0 , regSQ_CMD, value); -amdgpu_gfx_rlc_exit_safe_mode (adev,0 ); -} - static void gfx_v12_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev, uint32_t me, uint32_t pipe,
@@ -5442,6 +5427,7 @@ static int gfx_v12_0_reset_compute_pipe(struct amdgpu_ring *ring)static int gfx_v12_0_reset_kcq (struct amdgpu_ring *ring,unsigned int vmid) {struct amdgpu_device *adev = ring->adev; +unsigned int i;int r;if (amdgpu_sriov_vf (adev))
@@ -5466,7 +5452,15 @@ 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 + ring->ring_backup_entries_to_copy)) +return -ENOMEM ; +amdgpu_ring_emit_fence (ring, ring->fence_drv.gpu_addr, + ring->ring_backup_seq,0 ); +for (i =0 ; i < ring->ring_backup_entries_to_copy; i++) +amdgpu_ring_write (ring, ring->ring_backup[i]); +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)
@@ -5582,7 +5576,6 @@ static const struct amdgpu_ring_funcs gfx_v12_0_ring_funcs_compute = { .emit_wreg = gfx_v12_0_ring_emit_wreg, .emit_reg_wait = gfx_v12_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = gfx_v12_0_ring_emit_reg_write_reg_wait, - .soft_recovery = gfx_v12_0_ring_soft_recovery, .emit_mem_sync = gfx_v12_0_emit_mem_sync, .reset = gfx_v12_0_reset_kcq, .emit_cleaner_shader = gfx_v12_0_ring_emit_cleaner_shader,
Signature · 1 line
2.49.0