drm/amdgpu: dma_fence finished signaled by unexpected callback
Subsystems (2)
PATCH 1/1 drm/amdgpu: dma_fence finished signaled by unexpected callback
When 2 rings met timeout at same time, triggered job_timedout separately.
Each job_timedout called gpu_recover, but one of gpu_recover locked by another's mutex_lock. Bad jod’s callback should be removed by dma_fence_remove_callback but locked inside mutex_lock. So dma_fence_remove_callback could not be called immediately.
Then callback drm_sched_process_job triggered unexpectedly, and signaled DMA_FENCE_FLAG_SIGNALED_BIT. After another's mutex_unlock, signaled bad job went through job_run inside drm_sched_job_recovery. job_run would have WARN_ON and Call-Trace, when calling kcl_dma_fence_set_error for signaled bad job.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4 -1
@@ -225,8 +225,11 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)trace_amdgpu_sched_run_job (job); -if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) +if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) { +/* flags might be signaled by unexpected callback, clear it */ +test_and_clear_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &finished->flags);dma_fence_set_error (finished, -ECANCELED );/* skip IB as well if VRAM lost */ + }if (finished->error <0 ) {DRM_INFO ("Skip scheduling IBs!\n" );
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1545380754-13715-1-git-send-email-Wentao.Lou-5C7GfCeVMHo@public.gmane.org
I believe this issue would be resolved by my pending in review patch set, specifically 'drm/sched: Refactor ring mirror list handling.' since already on the first TO handler it will go over all the rings including the second timed out ring and will remove all call backs including the bad job cb. In case by this time this bad job will signal for some reason it will be removed from the mirror list already during drm_sched_process_job (take a look at 'drm/sched: Rework HW fence processing.') and hence will not be rerun in drm_sched_job_recovery (drm_sched_resubmit_jobs under the new name).
Andrey
Quoted 21 lines · wentalou
When 2 rings met timeout at same time, triggered
job_timedoutseparately.
Eachjob_timedoutcalledgpu_recover, but one ofgpu_recoverlocked by another'smutex_lock. Bad jod’s callback should be removed bydma_fence_remove_callbackbut locked insidemutex_lock. Sodma_fence_remove_callbackcould not be called immediately.
Then callbackdrm_sched_process_jobtriggered unexpectedly, and signaledDMA_FENCE_FLAG_SIGNALED_BIT. After another'smutex_unlock, signaled bad job went throughjob_runinsidedrm_sched_job_recovery.job_runwould haveWARN_ONand Call-Trace, when callingkcl_dma_fence_set_errorfor signaled bad job.Change-Id I6366add13f020476882b2b8b03330a58d072dd1aSigned-off-by Wentao Lou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -225,8 +225,11 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)trace_amdgpu_sched_run_job (job);
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job) · line 235
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +4
-1-if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) +if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) { +/* flags might be signaled by unexpected callback, clear it */ +test_and_clear_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &finished->flags);dma_fence_set_error (finished, -ECANCELED );/* skip IB as well if VRAM lost */ + }if (finished->error <0 ) {DRM_INFO ("Skip scheduling IBs!\n" );
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): cdaffc60-2261-51ee-91d6-1b265baf7dd0-5C7GfCeVMHo@public.gmane.org
Hi Andrey,
In amd-staging-dkms-4.18's merged list, I can't find 'drm/sched: Refactor ring mirror list handling', neither 'drm/sched: Rework HW fence processing'. Now there was still much Call-Trace in new osdb triggered in dma_fence_set_error. Do you have link for these patches?
Thanks.
BR,
Wentao
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Saturday, December 22, 2018 12:57 AM
To: Lou, Wentao <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: dma_fence finished signaled by unexpected callback
I believe this issue would be resolved by my pending in review patch set, specifically 'drm/sched: Refactor ring mirror list handling.' since already on the first TO handler it will go over all the rings including the second timed out ring and will remove all call backs including the bad job cb. In case by this time this bad job will signal for some reason it will be removed from the mirror list already during drm_sched_process_job (take a look at 'drm/sched: Rework HW fence processing.') and hence will not be rerun in drm_sched_job_recovery (drm_sched_resubmit_jobs under the new name).
Andrey
Quoted 30 lines · wentalou
When 2 rings met timeout at same time, triggered
job_timedoutseparately.
Eachjob_timedoutcalledgpu_recover, but one ofgpu_recoverlocked by another'smutex_lock. Bad jod’s callback should be removed bydma_fence_remove_callbackbut locked insidemutex_lock. Sodma_fence_remove_callbackcould not be called immediately.
Then callbackdrm_sched_process_jobtriggered unexpectedly, and signaledDMA_FENCE_FLAG_SIGNALED_BIT. After another'smutex_unlock, signaled bad job went throughjob_runinsidedrm_sched_job_recovery.job_runwould haveWARN_ONand Call-Trace, when callingkcl_dma_fence_set_errorfor signaled bad job.Change-Id I6366add13f020476882b2b8b03330a58d072dd1aSigned-off-by Wentao Lou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +3
-1@@ -225,8 +225,11 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)trace_amdgpu_sched_run_job (job ); -if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) +if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) { +/* flags might be signaled by unexpected callback, clear it */ +test_and_clear_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &finished->flags);dma_fence_set_error (finished, -ECANCELED );/* skip IB as well if VRAM lost */
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job) · line 235
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-0+ }if (finished->error <0 ) {DRM_INFO ("Skip scheduling IBs!\n" );
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BYAPR12MB27428794B99A9E400880D3A183B50-ZGDeBxoHBPmbrehcvEBedAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
They are still not pushed - I am fixing review comments.
Andrey
Quoted 55 lines · Wentao
Hi Andrey,
In amd-staging-dkms-4.18's merged list, I can't find 'drm/sched: Refactor ring mirror list handling', neither 'drm/sched: Rework HW fence processing'. Now there was still much Call-Trace in new osdb triggered in
dma_fence_set_error. Do you have link for these patches?
Thanks.BR,
Wentao-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Saturday, December 22, 2018 12:57 AM
To: Lou, Wentao <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu:dma_fencefinished signaled by unexpected callbackI believe this issue would be resolved by my pending in review patch set, specifically 'drm/sched: Refactor ring mirror list handling.' since already on the first TO handler it will go over all the rings including the second timed out ring and will remove all call backs including the bad job cb. In case by this time this bad job will signal for some reason it will be removed from the mirror list already during
drm_sched_process_job(take a look at 'drm/sched: Rework HW fence processing.') and hence will not be rerun indrm_sched_job_recovery(drm_sched_resubmit_jobsunder the new name).Andrey
Quoted 32 lines · wentalou
When 2 rings met timeout at same time, triggered
job_timedoutseparately.
Eachjob_timedoutcalledgpu_recover, but one ofgpu_recoverlocked by another'smutex_lock. Bad jod’s callback should be removed bydma_fence_remove_callbackbut locked insidemutex_lock. Sodma_fence_remove_callbackcould not be called immediately.
Then callbackdrm_sched_process_jobtriggered unexpectedly, and signaledDMA_FENCE_FLAG_SIGNALED_BIT. After another'smutex_unlock, signaled bad job went throughjob_runinsidedrm_sched_job_recovery.job_runwould haveWARN_ONand Call-Trace, when callingkcl_dma_fence_set_errorfor signaled bad job.Change-Id I6366add13f020476882b2b8b03330a58d072dd1aSigned-off-by Wentao Lou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +3
-1@@ -225,8 +225,11 @@ static struct dma_fence *amdgpu_job_run(struct drm_sched_job *sched_job)trace_amdgpu_sched_run_job (job ); -if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) +if (job->vram_lost_counter !=atomic_read (&ring->adev->vram_lost_counter)) { +/* flags might be signaled by unexpected callback, clear it */ +test_and_clear_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &finished->flags);dma_fence_set_error (finished, -ECANCELED );/* skip IB as well if VRAM lost */
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1
-0+ }
Quoted 2 lines
Quoted 2 lines
if (finished->error < 0) { DRM_INFO("Skip scheduling IBs!\n");
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx