drm/sched: fix the bug of time out calculation(v4)
Subsystems (3)
PATCH 1/2 drm/sched: fix the bug of time out calculation(v4)
issue:
in cleanup_job the cancle_delayed_work will cancel a TO timer even the its corresponding job is still running.
fix:
do not cancel the timer in cleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job we start_timeout again.
v2:
further cleanup the logic, and do the TDR timer cancelling if the signaled job is the last one in its scheduler.
v3:
change the issue description
remove the cancel_delayed_work in the begining of the cleanup_job recover the implement of drm_sched_job_begin.
v4:
remove the kthread_should_park() checking in cleanup_job routine, we should cleanup the signaled job asap
TODO:
1)introduce pause/resume scheduler in job_timeout to serial the handling of scheduler and job_timeout.
2)drop the bad job's del and insert in scheduler due to above serialization (no race issue anymore with the serialization)
--- drivers/gpu/drm/scheduler/sched_main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +9 -17
@@ -676,15 +676,6 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) {struct drm_sched_job *job, *next; -/* -* Don't destroy jobs while the timeout worker is running OR thread -* is being parked and hence assumed to not touch pending_list -*/ -if ((sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work (&sched->work_tdr)) || -kthread_should_park ()) -return NULL ; -spin_lock (&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list,
@@ -693,17 +684,21 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list); + +/* cancel this job's TO timer */ +cancel_delayed_work (&sched->work_tdr);/* make the scheduled timestamp more accurate */ next =list_first_entry_or_null (&sched->pending_list,typeof (*next), list); -if (next) + +if (next) { next->s_fence->scheduled.timestamp = job->s_fence->finished.timestamp; - +/* start TO timer for next job */ +drm_sched_start_timeout (sched); + } }else { job =NULL ; -/* queue timeout for next job */ -drm_sched_start_timeout (sched); }spin_unlock (&sched->job_list_lock);
@@ -791,11 +786,8 @@ static int drm_sched_main(void *param) (entity = drm_sched_select_entity(sched))) || kthread_should_stop()); -if (cleanup_job) { +if (cleanup_job) sched->ops->free_job (cleanup_job); -/* queue timeout for next job */ -drm_sched_start_timeout (sched); - }if (!entity)continue ;
Signature · 1 line
2.7.4
PATCH 2/2 drm/sched: serialize job_timeout and scheduler
--- drivers/gpu/drm/scheduler/sched_main.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +4 -20
@@ -319,19 +319,17 @@ static void drm_sched_job_timedout(struct work_struct *work) sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);/* Protects against concurrent deletion in drm_sched_get_cleanup_job */ +if (!__kthread_should_park (sched->thread)) +kthread_park (sched->thread); +spin_lock (&sched->job_list_lock); job =list_first_entry_or_null (&sched->pending_list, struct drm_sched_job, list);if (job) { -/* -* Remove the bad job so it cannot be freed by concurrent -* drm_sched_cleanup_jobs. It will be reinserted back after sched->thread -* is parked at which point it's safe. -*/ -list_del_init (&job->list);spin_unlock (&sched->job_list_lock); +/* vendor's timeout_job should call drm_sched_start() */ status = job->sched->ops->timedout_job (job);/*
@@ -393,20 +391,6 @@ void drm_sched_stop(struct drm_gpu_scheduler *sched, struct drm_sched_job *bad)kthread_park (sched->thread);/* -* Reinsert back the bad job here - now it's safe as -* drm_sched_get_cleanup_job cannot race against us and release the -* bad job at this point - we parked (waited for) any in progress -* (earlier) cleanups and drm_sched_get_cleanup_job will not be called -* now until the scheduler thread is unparked. -*/ -if (bad && bad->sched == sched) -/* -* Add at the head of the queue to reflect it was the earliest -* job extracted. -*/ -list_add (&bad->list, &sched->pending_list); - -/* * Iterate the job list from later to earlier one and either deactive * their HW callbacks or remove them from pending list if they already * signaled.
Signature · 1 line
2.7.4
Am 01.09.21 um 02:46 schrieb Monk Liu:
Quoted 22 lines
issue:
incleanup_jobthecancle_delayed_workwill cancel a TO timer even the its corresponding job is still running.fix:
do not cancel the timer incleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job westart_timeoutagain.v2:
further cleanup the logic, and do the TDR timer cancelling if the signaled job is the last one in its scheduler.v3:
change the issue description
remove thecancel_delayed_workin the begining of thecleanup_jobrecover the implement ofdrm_sched_job_begin.v4:
remove thekthread_should_park()checking incleanup_jobroutine, we should cleanup the signaled job asap
Quoted 8 lines
TODO:
1)introduce pause/resume scheduler injob_timeoutto serial the handling of scheduler andjob_timeout.
2)drop the bad job's del and insert in scheduler due to above serialization (no race issue anymore with the serialization)Tested-by jingwen <jingwen.chen@@amd.com>Signed-off-by Monk Liu <[email protected]>
Quoted 63 lines
--- drivers/gpu/drm/scheduler/sched_main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +9
-17@@ -676,15 +676,6 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) {struct drm_sched_job *job, *next; -/* -* Don't destroy jobs while the timeout worker is running OR thread -* is being parked and hence assumed to not touch pending_list -*/ -if ((sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work (&sched->work_tdr)) || -kthread_should_park ()) -return NULL ; -spin_lock (&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list,@@ -693,17 +684,21 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list); + +/* cancel this job's TO timer */ +cancel_delayed_work (&sched->work_tdr);/* make the scheduled timestamp more accurate */ next =list_first_entry_or_null (&sched->pending_list,typeof (*next), list); -if (next) + +if (next) { next->s_fence->scheduled.timestamp = job->s_fence->finished.timestamp; - +/* start TO timer for next job */ +drm_sched_start_timeout (sched); + } }else { job =NULL ; -/* queue timeout for next job */ -drm_sched_start_timeout (sched); }spin_unlock (&sched->job_list_lock);@@ -791,11 +786,8 @@ static int drm_sched_main(void *param) (entity = drm_sched_select_entity(sched))) || kthread_should_stop()); -if (cleanup_job) { +if (cleanup_job) sched->ops->free_job (cleanup_job); -/* queue timeout for next job */ -drm_sched_start_timeout (sched); - }if (!entity)continue ;
Quoted 30 lines · Christian König
Am 01.09.21 um 02:46 schrieb Monk Liu:
Quoted 28 lines
issue:
incleanup_jobthecancle_delayed_workwill cancel a TO timer even the its corresponding job is still running.fix:
do not cancel the timer incleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job westart_timeoutagain.v2:
further cleanup the logic, and do the TDR timer cancelling if the signaled job is the last one in its scheduler.v3:
change the issue description
remove thecancel_delayed_workin the begining of thecleanup_jobrecover the implement ofdrm_sched_job_begin.v4:
remove thekthread_should_park()checking incleanup_jobroutine, we should cleanup the signaled job asapTODO:
1)introduce pause/resume scheduler injob_timeoutto serial the handling of scheduler andjob_timeout.
2)drop the bad job's del and insert in scheduler due to above serialization (no race issue anymore with the serialization)
Quoted 5 lines
Quoted 2 lines
Tested-by jingwen <jingwen.chen@@amd.com>Signed-off-by Monk Liu <[email protected]>Reviewed-by Christian König <[email protected]>
Are you planning to push this to drm-misc?
Alex
Quoted 64 lines
Quoted 63 lines
--- drivers/gpu/drm/scheduler/sched_main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +9
-17@@ -676,15 +676,6 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) {struct drm_sched_job *job, *next; -/* -* Don't destroy jobs while the timeout worker is running OR thread -* is being parked and hence assumed to not touch pending_list -*/ -if ((sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work (&sched->work_tdr)) || -kthread_should_park ()) -return NULL ; -spin_lock (&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list,@@ -693,17 +684,21 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list); + +/* cancel this job's TO timer */ +cancel_delayed_work (&sched->work_tdr);/* make the scheduled timestamp more accurate */ next =list_first_entry_or_null (&sched->pending_list,typeof (*next), list); -if (next) + +if (next) { next->s_fence->scheduled.timestamp = job->s_fence->finished.timestamp; - +/* start TO timer for next job */ +drm_sched_start_timeout (sched); + } }else { job =NULL ; -/* queue timeout for next job */ -drm_sched_start_timeout (sched); }spin_unlock (&sched->job_list_lock);@@ -791,11 +786,8 @@ static int drm_sched_main(void *param) (entity = drm_sched_select_entity(sched))) || kthread_should_stop()); -if (cleanup_job) { +if (cleanup_job) sched->ops->free_job (cleanup_job); -/* queue timeout for next job */ -drm_sched_start_timeout (sched); - }if (!entity)continue ;
Was this fix independent of the other discussions? Should this be applied to drm-misc?
Alex
Quoted 108 lines · Alex Deucher
Quoted 30 lines · Christian König
Am 01.09.21 um 02:46 schrieb Monk Liu:
Quoted 28 lines
issue:
incleanup_jobthecancle_delayed_workwill cancel a TO timer even the its corresponding job is still running.fix:
do not cancel the timer incleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job westart_timeoutagain.v2:
further cleanup the logic, and do the TDR timer cancelling if the signaled job is the last one in its scheduler.v3:
change the issue description
remove thecancel_delayed_workin the begining of thecleanup_jobrecover the implement ofdrm_sched_job_begin.v4:
remove thekthread_should_park()checking incleanup_jobroutine, we should cleanup the signaled job asapTODO:
1)introduce pause/resume scheduler injob_timeoutto serial the handling of scheduler andjob_timeout.
2)drop the bad job's del and insert in scheduler due to above serialization (no race issue anymore with the serialization)Quoted 5 lines
Quoted 2 lines
Tested-by jingwen <jingwen.chen@@amd.com>Signed-off-by Monk Liu <[email protected]>Reviewed-by Christian König <[email protected]>Are you planning to push this to drm-misc?
Alex
Quoted 64 lines
Quoted 63 lines
--- drivers/gpu/drm/scheduler/sched_main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +9
-17@@ -676,15 +676,6 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) {struct drm_sched_job *job, *next; -/* -* Don't destroy jobs while the timeout worker is running OR thread -* is being parked and hence assumed to not touch pending_list -*/ -if ((sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work (&sched->work_tdr)) || -kthread_should_park ()) -return NULL ; -spin_lock (&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list,@@ -693,17 +684,21 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list); + +/* cancel this job's TO timer */ +cancel_delayed_work (&sched->work_tdr);/* make the scheduled timestamp more accurate */ next =list_first_entry_or_null (&sched->pending_list,typeof (*next), list); -if (next) + +if (next) { next->s_fence->scheduled.timestamp = job->s_fence->finished.timestamp; - +/* start TO timer for next job */ +drm_sched_start_timeout (sched); + } }else { job =NULL ; -/* queue timeout for next job */ -drm_sched_start_timeout (sched); }spin_unlock (&sched->job_list_lock);@@ -791,11 +786,8 @@ static int drm_sched_main(void *param) (entity = drm_sched_select_entity(sched))) || kthread_should_stop()); -if (cleanup_job) { +if (cleanup_job) sched->ops->free_job (cleanup_job); -/* queue timeout for next job */ -drm_sched_start_timeout (sched); - }if (!entity)continue ;
AFAIK this one is independent.
Christian, can you confirm ?
Andrey
________________________________
From: amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
Sent: 14 September 2021 15:33
To: Christian König <[email protected]>
Cc: Liu, Monk <[email protected]>; amd-gfx list <[email protected]>; Maling list - DRI developers <[email protected]>
Subject: Re: [PATCH 1/2] drm/sched: fix the bug of time out calculation(v4)
Was this fix independent of the other discussions? Should this be applied to drm-misc?
Alex
Quoted 108 lines · Alex Deucher
Quoted 30 lines · Christian König
Am 01.09.21 um 02:46 schrieb Monk Liu:
Quoted 28 lines
issue:
incleanup_jobthecancle_delayed_workwill cancel a TO timer even the its corresponding job is still running.fix:
do not cancel the timer incleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job westart_timeoutagain.v2:
further cleanup the logic, and do the TDR timer cancelling if the signaled job is the last one in its scheduler.v3:
change the issue description
remove thecancel_delayed_workin the begining of thecleanup_jobrecover the implement ofdrm_sched_job_begin.v4:
remove thekthread_should_park()checking incleanup_jobroutine, we should cleanup the signaled job asapTODO:
1)introduce pause/resume scheduler injob_timeoutto serial the handling of scheduler andjob_timeout.
2)drop the bad job's del and insert in scheduler due to above serialization (no race issue anymore with the serialization)Quoted 5 lines
Quoted 2 lines
Tested-by jingwen <jingwen.chen@@amd.com>Signed-off-by Monk Liu <[email protected]>Reviewed-by Christian König <[email protected]>Are you planning to push this to drm-misc?
Alex
Quoted 64 lines
Quoted 63 lines
--- drivers/gpu/drm/scheduler/sched_main.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +9
-17@@ -676,15 +676,6 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched) {struct drm_sched_job *job, *next; -/* -* Don't destroy jobs while the timeout worker is running OR thread -* is being parked and hence assumed to not touch pending_list -*/ -if ((sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work (&sched->work_tdr)) || -kthread_should_park ()) -return NULL ; -spin_lock (&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list,@@ -693,17 +684,21 @@ drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)if (job &&dma_fence_is_signaled (&job->s_fence->finished)) {/* remove job from pending_list */ list_del_init (&job->list); + +/* cancel this job's TO timer */ +cancel_delayed_work (&sched->work_tdr);/* make the scheduled timestamp more accurate */ next =list_first_entry_or_null (&sched->pending_list,typeof (*next), list); -if (next) + +if (next) { next->s_fence->scheduled.timestamp = job->s_fence->finished.timestamp; - +/* start TO timer for next job */ +drm_sched_start_timeout (sched); + } }else { job =NULL ; -/* queue timeout for next job */ -drm_sched_start_timeout (sched); }spin_unlock (&sched->job_list_lock);@@ -791,11 +786,8 @@ static int drm_sched_main(void *param) (entity = drm_sched_select_entity(sched))) || kthread_should_stop()); -if (cleanup_job) { +if (cleanup_job) sched->ops->free_job (cleanup_job); -/* queue timeout for next job */ -drm_sched_start_timeout (sched); - }if (!entity)continue ;
Christian König
reviewerYes, I think so as well. Andrey can you push this?
Christian.
Am 15.09.21 um 00:59 schrieb Grodzovsky, Andrey:
Quoted 133 lines
AFAIK this one is independent.
Christian, can you confirm ?
Andrey
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
*Sent:* 14 September 2021 15:33
*To:* Christian König <[email protected]>
*Cc:* Liu, Monk <[email protected]>; amd-gfx list <[email protected]>; Maling list - DRI developers <[email protected]> *Subject:* Re: [PATCH 1/2] drm/sched: fix the bug of time out calculation(v4)
Was this fix independent of the other discussions? Should this be
applied to drm-misc?Alex
Quoted 9 lines · Alex Deucher
Quoted 6 lines · Christian König
Am 01.09.21 um 02:46 schrieb Monk Liu:
Quoted 4 lines
issue:
incleanup_jobthecancle_delayed_workwill cancel a TO timer even the its corresponding job is still running.Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
fix:
do not cancel the timer incleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job westart_timeoutagain.v2:
further cleanup the logic, and do the TDR timer cancelling ifthe signaled job
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
is the last one in its scheduler.
v3:
change the issue description
remove thecancel_delayed_workin the begining of thecleanup_jobrecover the implement ofdrm_sched_job_begin.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
v4:
remove thekthread_should_park()checking incleanup_jobroutine, we should cleanup the signaled job asapTODO:
1)introduce pause/resume scheduler injob_timeoutto serial thehandling
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of scheduler and
job_timeout.
2)drop the bad job's del and insert in scheduler due to aboveserialization
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
(no race issue anymore with the serialization)
Tested-by jingwen <jingwen.chen@@amd.com>Signed-off-by Monk Liu <[email protected]>Quoted 10 lines
Quoted 2 lines
Reviewed-by Christian König <[email protected]>Are you planning to push this to drm-misc?
Alex
Quoted 2 lines
Quoted 2 lines
---
drivers/gpu/drm/scheduler/sched_main.c| 26+++++++++-----------------
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
1 file changed, 9 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/scheduler/sched_main.cQuoted 4 lines
Quoted 4 lines
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct
Quoted 4 lines
index a2a9536..3e0bbc7 100644
drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -676,15 +676,6 @@ drm_sched_get_cleanup_job(struct
drm_gpu_scheduler*sched)Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-2{ struct drm_sched_job *job, *next; - /* -* Don't destroy jobs while the timeout worker is running OR thread
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct
Quoted 11 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-7-* is being parked and hence assumed to not touch pending_list -*/ - if ((sched->timeout != MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work (&sched->work_tdr)) || - kthread_should_park()) - return NULL; -spin_lock (&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list,@@ -693,17 +684,21 @@ drm_sched_get_cleanup_job(struct
drm_gpu_scheduler*sched)Quoted 39 lines
Quoted 39 lines
Quoted 38 lines
drivers/gpu/drm/scheduler/sched_main.c +5
-1if (job && dma_fence_is_signaled(&job->s_fence->finished)) { /* remove job from pending_list */list_del_init (&job->list); + + /* cancel this job's TO timer */ +cancel_delayed_work (&sched->work_tdr); /* make the scheduled timestamp more accurate */ next = list_first_entry_or_null(&sched->pending_list,typeof (*next), list); - if (next) + + if (next) {
next->s_fence->scheduled.timestamp=job->s_fence->finished.timestamp;
-
+ /* start TO timer for next job */
+drm_sched_start_timeout(sched);
+ }
} else {
job = NULL;
- /* queue timeout for next job */
-drm_sched_start_timeout(sched);
}
spin_unlock(&sched->job_list_lock);drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -791,11 +786,8 @@ static int drm_sched_main(void *param)(entity =
drm_sched_select_entity(sched))) ||kthread_should_stop());- if (
cleanup_job) {
+ if (cleanup_job)sched->ops->free_job(cleanup_job);
- /* queue timeout for next job */
-drm_sched_start_timeout(sched);
- }if (!entity)
continue;
Pushed
Andrey
Quoted 140 lines · Christian König
Yes, I think so as well. Andrey can you push this?
Christian.
Am 15.09.21 um 00:59 schrieb Grodzovsky, Andrey:
Quoted 134 lines
AFAIK this one is independent.
Christian, can you confirm ?
Andrey
------------------------------------------------------------------------
*From:* amd-gfx <[email protected]> on behalf of Alex Deucher <[email protected]>
*Sent:* 14 September 2021 15:33
*To:* Christian König <[email protected]>
*Cc:* Liu, Monk <[email protected]>; amd-gfx list <[email protected]>; Maling list - DRI developers <[email protected]> *Subject:* Re: [PATCH 1/2] drm/sched: fix the bug of time out calculation(v4)
Was this fix independent of the other discussions? Should this be
applied to drm-misc?Alex
Quoted 9 lines · Alex Deucher
Quoted 6 lines · Christian König
Am 01.09.21 um 02:46 schrieb Monk Liu:
Quoted 4 lines
issue:
incleanup_jobthecancle_delayed_workwill cancel a TO timer even the its corresponding job is still running.Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
fix:
do not cancel the timer incleanup_job, instead do the cancelling only when the heading job is signaled, and if there is a "next" job westart_timeoutagain.v2:
further cleanup the logic, and do the TDR timer cancelling ifthe signaled job
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
is the last one in its scheduler.
v3:
change the issue description
remove thecancel_delayed_workin the begining of thecleanup_jobrecover the implement ofdrm_sched_job_begin.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
v4:
remove thekthread_should_park()checking incleanup_jobroutine, we should cleanup the signaled job asapTODO:
1)introduce pause/resume scheduler injob_timeoutto serial thehandling
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of scheduler and
job_timeout.
2)drop the bad job's del and insert in scheduler due to aboveserialization
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
(no race issue anymore with the serialization)
Tested-by jingwen <jingwen.chen@@amd.com>Signed-off-by Monk Liu <[email protected]>Quoted 10 lines
Quoted 2 lines
Reviewed-by Christian König <[email protected]>Are you planning to push this to drm-misc?
Alex
Quoted 2 lines
Quoted 2 lines
---
drivers/gpu/drm/scheduler/sched_main.c| 26+++++++++-----------------
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
1 file changed, 9 insertions(+), 17 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/scheduler/sched_main.cQuoted 4 lines
Quoted 4 lines
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct
Quoted 4 lines
index a2a9536..3e0bbc7 100644
drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -676,15 +676,6 @@ drm_sched_get_cleanup_job(struct
drm_gpu_scheduler*sched)Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct drm_gpu_scheduler *sched)
Quoted 5 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-2{ struct drm_sched_job *job, *next; - /* -* Don't destroy jobs while the timeout worker is running OR thread
Quoted 1 line
Quoted 1 line
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct · line 681
Quoted 1 line
drivers/gpu/drm/scheduler/sched_main.c +0
-1- * is being parked and hence assumed to not touch
pending_listQuoted 10 lines
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_main.c drm_sched_get_cleanup_job(struct
Quoted 10 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-6-*/ - if ((sched->timeout != MAX_SCHEDULE_TIMEOUT && - !cancel_delayed_work (&sched->work_tdr)) || - kthread_should_park()) - return NULL; -spin_lock (&sched->job_list_lock); job = list_first_entry_or_null(&sched->pending_list,@@ -693,17 +684,21 @@ drm_sched_get_cleanup_job(struct
drm_gpu_scheduler*sched)Quoted 39 lines
Quoted 39 lines
Quoted 38 lines
drivers/gpu/drm/scheduler/sched_main.c +5
-1if (job && dma_fence_is_signaled(&job->s_fence->finished)) { /* remove job from pending_list */list_del_init (&job->list); + + /* cancel this job's TO timer */ +cancel_delayed_work (&sched->work_tdr); /* make the scheduled timestamp more accurate */ next = list_first_entry_or_null(&sched->pending_list,typeof (*next), list); - if (next) + + if (next) {
next->s_fence->scheduled.timestamp=job->s_fence->finished.timestamp;
-
+ /* start TO timer for next job */
+drm_sched_start_timeout(sched);
+ }
} else {
job = NULL;
- /* queue timeout for next job */
-drm_sched_start_timeout(sched);
}
spin_unlock(&sched->job_list_lock);drivers/gpu/drm/scheduler/sched_main.c +0
-0@@ -791,11 +786,8 @@ static int drm_sched_main(void *param)(entity =
drm_sched_select_entity(sched))) ||kthread_should_stop());- if (
cleanup_job) {
+ if (cleanup_job)sched->ops->free_job(cleanup_job);
- /* queue timeout for next job */
-drm_sched_start_timeout(sched);
- }if (!entity)
continue;