drm/amdgpu: Force signal hw_fences that are embedded in non-sched jobs
Subsystems (2)
PATCH 1/1 drm/amdgpu: Force signal hw_fences that are embedded in non-sched jobs
[Why]
For engines not supporting soft reset, i.e. VCN, there will be a failed ib test before mode 1 reset during asic reset. The fences in this case are never signaled and next time when we try to free the sa_bo, kernel will hang.
[How]
During pre_asic_reset, driver will clear job fences and afterwards the fences' refcount will be reduced to 1. For drm_sched_jobs it will be released in job_free_cb, and for non-sched jobs like ib_test, it's meant to be released in sa_bo_free but only when the fences are signaled. So we have to force signal the non_sched bad job's fence during pre_asic_reset or the clear is not complete.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4 -0
@@ -673,6 +673,7 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring) {int i;struct dma_fence *old, **ptr; +struct amdgpu_job *job;for (i =0 ; i <= ring->fence_drv.num_fences_mask; i++) { ptr = &ring->fence_drv.fences[i];
@@ -680,6 +681,9 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring)if (old && old->ops == &amdgpu_job_fence_ops) {RCU_INIT_POINTER (*ptr,NULL );dma_fence_put (old); + job = container_of(old, struct amdgpu_job, hw_fence); +if (!job->base.s_fence && !dma_fence_is_signaled (old)) +dma_fence_signal (old); } } }
Signature · 1 line
2.25.1
Christian König
maintainerAm 07.03.23 um 08:02 schrieb YuBiao Wang:
Quoted 6 lines
[Why]
For engines not supporting soft reset, i.e. VCN, there will be a failed ib test before mode 1 reset during asic reset. The fences in this case are never signaled and next time when we try to free thesa_bo, kernel will hang.
Quoted 7 lines
[How]
Duringpre_asic_reset, driver will clear job fences and afterwards the fences' refcount will be reduced to 1. Fordrm_sched_jobsit will be released injob_free_cb, and for non-sched jobs likeib_test, it's meant to be released insa_bo_freebut only when the fences are signaled. So we have to force signal thenon_schedbad job's fence duringpre_asic_resetor the clear is not complete.
Well NAK for now. It looks once more like one of those not very well thought through changes.
Luben can you please take a look at this and double check it.
Thanks,
Christian.
Quoted 28 lines
Signed-off-by YuBiao Wang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4
-0@@ -673,6 +673,7 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring) {int i;struct dma_fence *old, **ptr; +struct amdgpu_job *job;for (i =0 ; i <= ring->fence_drv.num_fences_mask; i++) { ptr = &ring->fence_drv.fences[i];@@ -680,6 +681,9 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring)if (old && old->ops == &amdgpu_job_fence_ops) {RCU_INIT_POINTER (*ptr,NULL );dma_fence_put (old); + job = container_of(old, struct amdgpu_job, hw_fence); +if (!job->base.s_fence && !dma_fence_is_signaled (old)) +dma_fence_signal (old); } } }
Hi,
Thanks for your patch!
Quoted 12 lines · Christian König
Am 07.03.23 um 08:02 schrieb YuBiao Wang:
Quoted 11 lines
[Why]
For engines not supporting soft reset, i.e. VCN, there will be a failed ib test before mode 1 reset during asic reset. The fences in this case are never signaled and next time when we try to free thesa_bo, kernel will hang.[How]
Duringpre_asic_reset, driver will clear job fences and afterwards the fences' refcount will be reduced to 1. Fordrm_sched_jobsit will be released injob_free_cb, and for non-sched jobs likeib_test, it's meant to be released insa_bo_freebut only when the fences are signaled. So
So, you're missing a signal for the non-scheduler job fences?
Quoted 2 lines
Quoted 2 lines
we have to force signal the
non_schedbad job's fence duringpre_asic_resetor the clear is not complete.
Do you want to add a function which does just this (signals non-scheduler job fences) in amdgpu_device_pre_asic_reset(), and resubmit your patch? (There will be code redundancy, but may make the point clearer.)
Are we missing to signal non-scheduler job fences on reset altogether?
Signature · 2 lines
Regards, Luben
Quoted 37 lines
Well NAK for now. It looks once more like one of those not very well thought through changes.
Luben can you please take a look at this and double check it> Thanks,
Christian.Quoted 28 lines
Signed-off-by YuBiao Wang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +4
-0@@ -673,6 +673,7 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring) {int i;struct dma_fence *old, **ptr; +struct amdgpu_job *job;for (i =0 ; i <= ring->fence_drv.num_fences_mask; i++) { ptr = &ring->fence_drv.fences[i];@@ -680,6 +681,9 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring)if (old && old->ops == &amdgpu_job_fence_ops) {RCU_INIT_POINTER (*ptr,NULL );dma_fence_put (old); + job = container_of(old, struct amdgpu_job, hw_fence); +if (!job->base.s_fence && !dma_fence_is_signaled (old)) +dma_fence_signal (old); } } }
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring) · line 686
Quoted 3 lines · Luben Tuikov
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +3
-0+ job = container_of(old, struct amdgpu_job, hw_fence); +if (!job->base.s_fence && !dma_fence_is_signaled (old)) +dma_fence_signal (old);
Thinking about this more, is !job->base.s_fence condition here enough to mean "non-sched jobs like ib_test"?
I feel that it is a bit overloaded here--could we have this condition satisfied,yet we can't willy-nilly signal the fence here?
Signature · 2 lines
Regards, Luben
Hi Luben,
I was comparing the bad jobs of failed ib test and the ones that causes the TDR, and I think the main difference is whether it is submitted via drm_sched or not. In simple test cases it doesn't seem to incorrectly signal the fences that shouldn't be signaled. We indeed may need more heavier tests but so far based on static analyze I think I didn't notice the case you mentioned. There's another case using direct job submission during resete, but it happens in recover_vram which happens after the pre_asic reset so I think it won’t be affected.
I'll move this lines into a new function as you suggested and resent a v2 patch.
Regards,
Yubiao Wang
-----Original Message-----
From: Tuikov, Luben <[email protected]>
Sent: Wednesday, March 8, 2023 7:22 AM
To: Koenig, Christian <[email protected]>; Wang, YuBiao <[email protected]>; [email protected]
Cc: Chen, Horace <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Liu, Monk <[email protected]>; Xu, Feifei <[email protected]>; Wang, Yang(Kevin) <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Force signal hw_fences that are embedded in non-sched jobs
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring) · line 686
Quoted 3 lines · Luben Tuikov
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +3
-0+ job = container_of(old, struct amdgpu_job, hw_fence); +if (!job->base.s_fence && !dma_fence_is_signaled (old)) +dma_fence_signal (old);
Thinking about this more, is !job->base.s_fence condition here enough to mean "non-sched jobs like ib_test"?
I feel that it is a bit overloaded here--could we have this condition satisfied,yet we can't willy-nilly signal the fence here? --
Regards,
Luben
Hi @Tuikov, Luben,
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
Quoted 2 lines
we have to force signal the
non_schedbad job's fence duringpre_asic_resetor the clear is not complete.Do you want to add a function which does just this (signals non-scheduler job fences) in
amdgpu_device_pre_asic_reset(), and resubmit your patch? (There will be code redundancy, but may make the point clearer.)
On second thought, we cannot move this part out of amdgpu_fence_driver_clear_job_fences, because it clears pointer from RCU and after that only NULL and vm flush fence are left in fence drv, which is designed for reason I'm not aware of. This is also why amdgpu_fence_driver_force_completion doesn't handle the ib test bad jobs during pre_asic_reset. So even if I add a new function I cannot move it to pre_asic_reset as a single step. Also it may be confusing since the name and description could be very closed to amdgpu_fence_driver_force_completion. So rather than adding a function, is it ok to just add a comment?
Regards & Thanks,
Yubiao
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Wang, YuBiao
Sent: Wednesday, March 8, 2023 11:09 AM
To: Tuikov, Luben <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Wang, Yang(Kevin) <[email protected]>; Xu, Feifei <[email protected]>; Chen, Horace <[email protected]>; Deucher, Alexander <[email protected]>; Liu, Monk <[email protected]>; Zhang, Hawking <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: Force signal hw_fences that are embedded in non-sched jobs
Hi Luben,
I was comparing the bad jobs of failed ib test and the ones that causes the TDR, and I think the main difference is whether it is submitted via drm_sched or not. In simple test cases it doesn't seem to incorrectly signal the fences that shouldn't be signaled. We indeed may need more heavier tests but so far based on static analyze I think I didn't notice the case you mentioned. There's another case using direct job submission during resete, but it happens in recover_vram which happens after the pre_asic reset so I think it won’t be affected.
I'll move this lines into a new function as you suggested and resent a v2 patch.
Regards,
Yubiao Wang
-----Original Message-----
From: Tuikov, Luben <[email protected]>
Sent: Wednesday, March 8, 2023 7:22 AM
To: Koenig, Christian <[email protected]>; Wang, YuBiao <[email protected]>; [email protected]
Cc: Chen, Horace <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Liu, Monk <[email protected]>; Xu, Feifei <[email protected]>; Wang, Yang(Kevin) <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Force signal hw_fences that are embedded in non-sched jobs
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring) · line 686
Quoted 3 lines · Luben Tuikov
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +3
-0+ job = container_of(old, struct amdgpu_job, hw_fence); +if (!job->base.s_fence && !dma_fence_is_signaled (old)) +dma_fence_signal (old);
Thinking about this more, is !job->base.s_fence condition here enough to mean "non-sched jobs like ib_test"?
I feel that it is a bit overloaded here--could we have this condition satisfied,yet we can't willy-nilly signal the fence here? --
Regards,
Luben