drm/sched: add drm_sched_start_timeout helper
Subsystems (3)
Christian König
reviewerPATCH 1/2 drm/sched: add drm_sched_start_timeout helper
Cleanup starting the timeout a bit.
--- drivers/gpu/drm/scheduler/sched_main.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/gpu/drm/scheduler/sched_main.c +17 -12
@@ -182,6 +182,20 @@ bool drm_sched_dependency_optimized(struct dma_fence* fence, }EXPORT_SYMBOL (drm_sched_dependency_optimized); +/** +* drm_sched_start_timeout - start timeout for reset worker +* +* @sched: scheduler instance to start the worker for +* +* Start the timeout for the given scheduler. +*/ +static void drm_sched_start_timeout (struct drm_gpu_scheduler *sched) +{ +if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && + !list_empty (&sched->ring_mirror_list)) +schedule_delayed_work (&sched->work_tdr, sched->timeout); +} +/* job_finish is called after hw fence signaled */ static void drm_sched_job_finish (struct work_struct *work)
@@ -203,9 +217,7 @@ static void drm_sched_job_finish(struct work_struct *work)/* remove job from ring_mirror_list */ list_del (&s_job->node);/* queue TDR for next job */ -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !list_empty (&sched->ring_mirror_list)) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock);dma_fence_put (&s_job->s_fence->finished);
@@ -229,10 +241,7 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)spin_lock (&sched->job_list_lock);list_add_tail (&s_job->node, &sched->ring_mirror_list); -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && -list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node) == s_job) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock); }
@@ -313,11 +322,6 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched)int r;spin_lock (&sched->job_list_lock); - s_job =list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node); -if (s_job && sched->timeout !=MAX_SCHEDULE_TIMEOUT ) -schedule_delayed_work (&sched->work_tdr, sched->timeout); -list_for_each_entry_safe (s_job, tmp, &sched->ring_mirror_list, node) {struct drm_sched_fence *s_fence = s_job->s_fence;struct dma_fence *fence;
@@ -350,6 +354,7 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) }spin_lock (&sched->job_list_lock); } +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock); }EXPORT_SYMBOL (drm_sched_job_recovery);
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
reviewerPATCH 2/2 drm/sched: fix timeout handling
We need to make sure that we don't race between job completion and timeout.
--- drivers/gpu/drm/scheduler/sched_main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/gpu/drm/scheduler/sched_main.c +27 -1
@@ -248,14 +248,40 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)static void drm_sched_job_timedout (struct work_struct *work) {struct drm_gpu_scheduler *sched; +struct drm_sched_fence *fence;struct drm_sched_job *job; +int r; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); + +spin_lock (&sched->job_list_lock); +list_for_each_entry_reverse (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!dma_fence_remove_callback (fence->parent, &fence->cb)) + goto already_signaled; + } + job =list_first_entry_or_null (&sched->ring_mirror_list, struct drm_sched_job, node); +spin_unlock (&sched->job_list_lock);if (job) - job->sched->ops->timedout_job (job); + sched->ops->timedout_job (job); + +spin_lock (&sched->job_list_lock); +list_for_each_entry (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!fence->parent || !list_empty (&fence->cb.node)) +continue ; + + r =dma_fence_add_callback (fence->parent, &fence->cb, + drm_sched_process_job); +if (r) +already_signaled: +drm_sched_process_job (fence->parent, &fence->cb); + + } +spin_unlock (&sched->job_list_lock); }/**
Signature · 6 lines
2.14.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/sched: fix timeout handling
Hi Christian,
I am a bit confused with this patch. It will be better if you can explain what these 3 functions are supposed to do. From my understanding this is what they are supposed to do:
1. drm_sched_job_timedout: This function is called when a job has been executing for more than "timeout" seconds. This function needs to identify the wrong job and call the timedout_job function which will notify the driver of that job and the gpu should be recovered to its original state.
2. drm_sched_hw_job_reset: stop the scheduler if it contains the bad job. ATM this function first removes all the callback and goes through the ring_mirror_list afterward to find the bad job. I think it should do it in the opposite order. Or my understanding of this function is not fully correct.
3. drm_sched_job_recovery: recover jobs after a reset. It resubmits the job to the hardware queue avoiding the guilty job.
Some other questions and suggestions:
1. We can avoid the race condition altogether if we shift the canceling and rescheduling of the timedout work item to the drm_sched_process_job().
2. How does removing and adding the callback help with the race condition? Moreover, the hardware might execute some jobs while we are in this function leading to more races.
3. What is the order in which the above 3 functions should be executed by the hardware? I think the answer to this question might clear a lot of my doubts.
Regards,
Nayan
Quoted 58 lines · Christian König
We need to make sure that we don't race between job completion and timeout.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/sched_main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)drivers/gpu/drm/scheduler/sched_main.c +27
-2@@ -248,14 +248,40 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)static void drm_sched_job_timedout (struct work_struct *work) {struct drm_gpu_scheduler *sched; +struct drm_sched_fence *fence;struct drm_sched_job *job; +int r; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); + +spin_lock (&sched->job_list_lock); +list_for_each_entry_reverse (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!dma_fence_remove_callback (fence->parent, &fence->cb)) + goto already_signaled; + } + job =list_first_entry_or_null (&sched->ring_mirror_list, struct drm_sched_job, node); +spin_unlock (&sched->job_list_lock);if (job) - job->sched->ops->timedout_job (job); + sched->ops->timedout_job (job); + +spin_lock (&sched->job_list_lock); +list_for_each_entry (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!fence->parent || !list_empty (&fence->cb.node)) +continue ; + + r =dma_fence_add_callback (fence->parent, &fence->cb, + drm_sched_process_job); +if (r) +already_signaled: +drm_sched_process_job (fence->parent, &fence->cb); + + } +spin_unlock (&sched->job_list_lock); }/** -- 2.14.1
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
reviewerRe: [PATCH 2/2] drm/sched: fix timeout handling
Am 08.10.2018 um 19:40 schrieb Nayan Deshmukh:
Quoted 12 lines
Hi Christian,
I am a bit confused with this patch. It will be better if you can explain what these 3 functions are supposed to do. From my understanding this is what they are supposed to do:
1.
drm_sched_job_timedout: This function is called when a job has been executing for more than "timeout" seconds. This function needs to identify the wrong job and call thetimedout_jobfunction which will notify the driver of that job and the gpu should be recovered to its original state.
Quoted 5 lines
2.
drm_sched_hw_job_reset: stop the scheduler if it contains the bad job. ATM this function first removes all the callback and goes through thering_mirror_listafterward to find the bad job. I think it should do it in the opposite order. Or my understanding of this function is not fully correct.
That function actually has a couple of bugs itself, but it is irrelevant for the current patch.
Quoted 2 lines
3.
drm_sched_job_recovery: recover jobs after a reset. It resubmits the job to the hardware queue avoiding the guilty job.
That function is completely unrelated and only called after recovering from a hard reset.
Quoted 6 lines
Some other questions and suggestions:
1. We can avoid the race condition altogether if we shift the canceling and rescheduling of the timedout work item to the
drm_sched_process_job().
That won't work. drm_sched_process_job() is called from interrupt context and can't sync with a timeout worker.
Quoted 3 lines
2. How does removing and adding the callback help with the race condition? Moreover, the hardware might execute some jobs while we are in this function leading to more races.
We need to make sure that the underlying hardware fence doesn't signal and triggers new processing while we are about to call the drivers timeout function to reset the hardware.
This is done by removing the callbacks in reverse order (e.g. newest to oldest).
If we find that we can't remove the callback because the hardware has actually continued and the fence has already signaled we add back the callback again in normal order (e.g. oldest to newest) starting from the job which was already signaled.
Quoted 4 lines
3. What is the order in which the above 3 functions should be executed by the hardware? I think the answer to this question might clear a lot of my doubts.
If we can quickly recover from a problem only the drm_sched_job_timedout() should be execute.
The other two are for hard resets where we need to stop multiple scheduler instances and get them running again.
That the karma handling is mixed into that is rather unfortunate and actually quite buggy as well.
I should probably also clean that up.
Regards,
Christian.
Quoted 59 lines
Regards,
NayanQuoted 53 lines · Christian König
We need to make sure that we don't race between job completion and timeout.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/sched_main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)drivers/gpu/drm/scheduler/sched_main.c +27
-1@@ -248,14 +248,40 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)static void drm_sched_job_timedout (struct work_struct *work) {struct drm_gpu_scheduler *sched; +struct drm_sched_fence *fence;struct drm_sched_job *job; +int r; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); + +spin_lock (&sched->job_list_lock); +list_for_each_entry_reverse (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!dma_fence_remove_callback (fence->parent, &fence->cb)) + goto already_signaled; + } + job =list_first_entry_or_null (&sched->ring_mirror_list, struct drm_sched_job, node); +spin_unlock (&sched->job_list_lock);if (job) - job->sched->ops->timedout_job (job); + sched->ops->timedout_job (job); + +spin_lock (&sched->job_list_lock); +list_for_each_entry (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!fence->parent || !list_empty (&fence->cb.node)) +continue ; + + r =dma_fence_add_callback (fence->parent, &fence->cb, + drm_sched_process_job); +if (r) +already_signaled: +drm_sched_process_job (fence->parent, &fence->cb); + + } +spin_unlock (&sched->job_list_lock); }
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-1/** -- 2.14.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/sched: fix timeout handling
Thanks for all the explanations. Looks like this part of scheduler has a lot of bugs.
Quoted 47 lines · Christian König
Am 08.10.2018 um 19:40 schrieb Nayan Deshmukh:
Quoted 12 lines
Hi Christian,
I am a bit confused with this patch. It will be better if you can explain what these 3 functions are supposed to do. From my understanding this is what they are supposed to do:
1.
drm_sched_job_timedout: This function is called when a job has been executing for more than "timeout" seconds. This function needs to identify the wrong job and call thetimedout_jobfunction which will notify the driver of that job and the gpu should be recovered to its original state.Quoted 5 lines
2.
drm_sched_hw_job_reset: stop the scheduler if it contains the bad job. ATM this function first removes all the callback and goes through thering_mirror_listafterward to find the bad job. I think it should do it in the opposite order. Or my understanding of this function is not fully correct.That function actually has a couple of bugs itself, but it is irrelevant for the current patch.
Quoted 2 lines
3.
drm_sched_job_recovery: recover jobs after a reset. It resubmits the job to the hardware queue avoiding the guilty job.That function is completely unrelated and only called after recovering from a hard reset.
Quoted 6 lines
Some other questions and suggestions:
1. We can avoid the race condition altogether if we shift the canceling and rescheduling of the timedout work item to the
drm_sched_process_job().That won't work.
drm_sched_process_job()is called from interrupt context and can't sync with a timeout worker.Quoted 3 lines
2. How does removing and adding the callback help with the race condition? Moreover, the hardware might execute some jobs while we are in this function leading to more races.
We need to make sure that the underlying hardware fence doesn't signal and triggers new processing while we are about to call the drivers timeout function to reset the hardware.
Quoted 7 lines
This is done by removing the callbacks in reverse order (e.g. newest to oldest).
If we find that we can't remove the callback because the hardware has actually continued and the fence has already signaled we add back the callback again in normal order (e.g. oldest to newest) starting from the job which was already signaled.
Why do we need to call drm_sched_process_job() again for the last signaled job?
Regards,
Nayan
Quoted 79 lines
Quoted 5 lines
3. What is the order in which the above 3 functions should be executed by the hardware? I think the answer to this question might clear a lot of my doubts.
If we can quickly recover from a problem only the
drm_sched_job_timedout()should be execute.The other two are for hard resets where we need to stop multiple scheduler instances and get them running again.
That the karma handling is mixed into that is rather unfortunate and actually quite buggy as well.
I should probably also clean that up.
Regards,
Christian.Quoted 59 lines
Regards,
NayanQuoted 53 lines · Christian König
We need to make sure that we don't race between job completion and timeout.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/sched_main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)drivers/gpu/drm/scheduler/sched_main.c +27
-1@@ -248,14 +248,40 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)static void drm_sched_job_timedout (struct work_struct *work) {struct drm_gpu_scheduler *sched; +struct drm_sched_fence *fence;struct drm_sched_job *job; +int r; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); + +spin_lock (&sched->job_list_lock); +list_for_each_entry_reverse (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!dma_fence_remove_callback (fence->parent, &fence->cb)) + goto already_signaled; + } + job =list_first_entry_or_null (&sched->ring_mirror_list, struct drm_sched_job, node); +spin_unlock (&sched->job_list_lock);if (job) - job->sched->ops->timedout_job (job); + sched->ops->timedout_job (job); + +spin_lock (&sched->job_list_lock); +list_for_each_entry (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!fence->parent || !list_empty (&fence->cb.node)) +continue ; + + r =dma_fence_add_callback (fence->parent, &fence->cb, + drm_sched_process_job); +if (r) +already_signaled: +drm_sched_process_job (fence->parent, &fence->cb); + + } +spin_unlock (&sched->job_list_lock); }
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-1/** -- 2.14.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/sched: fix timeout handling
Am 08.10.2018 um 20:01 schrieb Nayan Deshmukh:
Quoted 46 lines
Thanks for all the explanations. Looks like this part of scheduler has a lot of bugs.
Quoted 41 lines · Christian König
Am 08.10.2018 um 19:40 schrieb Nayan Deshmukh:
Quoted 12 lines
Hi Christian,
I am a bit confused with this patch. It will be better if you can explain what these 3 functions are supposed to do. From my understanding this is what they are supposed to do:
1.
drm_sched_job_timedout: This function is called when a job has been executing for more than "timeout" seconds. This function needs to identify the wrong job and call thetimedout_jobfunction which will notify the driver of that job and the gpu should be recovered to its original state.Quoted 5 lines
2.
drm_sched_hw_job_reset: stop the scheduler if it contains the bad job. ATM this function first removes all the callback and goes through thering_mirror_listafterward to find the bad job. I think it should do it in the opposite order. Or my understanding of this function is not fully correct.That function actually has a couple of bugs itself, but it is irrelevant for the current patch.
Quoted 2 lines
3.
drm_sched_job_recovery: recover jobs after a reset. It resubmits the job to the hardware queue avoiding the guilty job.That function is completely unrelated and only called after recovering from a hard reset.
Quoted 5 lines
Some other questions and suggestions:
1. We can avoid the race condition altogether if we shift the canceling and rescheduling of the timedout work item to the
drm_sched_process_job().That won't work.
drm_sched_process_job()is called from interrupt context and can't sync with a timeout worker.Quoted 3 lines
2. How does removing and adding the callback help with the race condition? Moreover, the hardware might execute some jobs while we are in this function leading to more races.
We need to make sure that the underlying hardware fence doesn't signal and triggers new processing while we are about to call the drivers timeout function to reset the hardware.
Quoted 8 lines
Quoted 7 lines
This is done by removing the callbacks in reverse order (e.g. newest to oldest).
If we find that we can't remove the callback because the hardware has actually continued and the fence has already signaled we add back the callback again in normal order (e.g. oldest to newest) starting from the job which was already signaled.
Why do we need to call
drm_sched_process_job()again for the last signaled job?
Oh, good point, that is indeed incorrect.
The label should be after we calling drm_sched_process_job() because we couldn't remove the callback for the current one.
Going to fix that,
Christian,
Quoted 78 lines
Regards,
NayanQuoted 75 lines
Quoted 3 lines
3. What is the order in which the above 3 functions should be executed by the hardware? I think the answer to this question might clear a lot of my doubts.
If we can quickly recover from a problem only the
drm_sched_job_timedout()should be execute.The other two are for hard resets where we need to stop multiple scheduler instances and get them running again.
That the karma handling is mixed into that is rather unfortunate and actually quite buggy as well.
I should probably also clean that up.
Regards,
Christian.Quoted 58 lines
Regards,
NayanQuoted 53 lines · Christian König
We need to make sure that we don't race between job completion and timeout.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/sched_main.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)drivers/gpu/drm/scheduler/sched_main.c +27
-1@@ -248,14 +248,40 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)static void drm_sched_job_timedout (struct work_struct *work) {struct drm_gpu_scheduler *sched; +struct drm_sched_fence *fence;struct drm_sched_job *job; +int r; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work); + +spin_lock (&sched->job_list_lock); +list_for_each_entry_reverse (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!dma_fence_remove_callback (fence->parent, &fence->cb)) + goto already_signaled; + } + job =list_first_entry_or_null (&sched->ring_mirror_list, struct drm_sched_job, node); +spin_unlock (&sched->job_list_lock);if (job) - job->sched->ops->timedout_job (job); + sched->ops->timedout_job (job); + +spin_lock (&sched->job_list_lock); +list_for_each_entry (job, &sched->ring_mirror_list, node) { + fence = job->s_fence; +if (!fence->parent || !list_empty (&fence->cb.node)) +continue ; + + r =dma_fence_add_callback (fence->parent, &fence->cb, + drm_sched_process_job); +if (r) +already_signaled: +drm_sched_process_job (fence->parent, &fence->cb); + + } +spin_unlock (&sched->job_list_lock); }
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-1/** -- 2.14.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 45 lines · Christian König
Cleanup starting the timeout a bit.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/sched_main.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +15
-3@@ -182,6 +182,20 @@ bool drm_sched_dependency_optimized(struct dma_fence* fence, }EXPORT_SYMBOL (drm_sched_dependency_optimized); +/** +* drm_sched_start_timeout - start timeout for reset worker +* +* @sched: scheduler instance to start the worker for +* +* Start the timeout for the given scheduler. +*/ +static void drm_sched_start_timeout (struct drm_gpu_scheduler *sched) +{ +if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && + !list_empty (&sched->ring_mirror_list)) +schedule_delayed_work (&sched->work_tdr, sched->timeout); +} +/* job_finish is called after hw fence signaled */ static void drm_sched_job_finish (struct work_struct *work)@@ -203,9 +217,7 @@ static void drm_sched_job_finish(struct work_struct *work)/* remove job from ring_mirror_list */ list_del (&s_job->node);/* queue TDR for next job */ -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !list_empty (&sched->ring_mirror_list)) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock);dma_fence_put (&s_job->s_fence->finished);
drivers/gpu/drm/scheduler/sched_main.c static void drm_sched_job_begin(struct drm_sched_job *s_job) · line 244
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +1
-4@@ -229,10 +241,7 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)spin_lock (&sched->job_list_lock);list_add_tail (&s_job->node, &sched->ring_mirror_list); -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && -list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node) == s_job) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);
This is not functionally same as before. In this case we only want to schedule a work item if this is the only job in the ring_mirror_list.
Regards,
Nayan
Quoted 26 lines
drivers/gpu/drm/scheduler/sched_main.c +1
-6spin_unlock (&sched->job_list_lock); }@@ -313,11 +322,6 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched)int r;spin_lock (&sched->job_list_lock); - s_job =list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node); -if (s_job && sched->timeout !=MAX_SCHEDULE_TIMEOUT ) -schedule_delayed_work (&sched->work_tdr, sched->timeout); -list_for_each_entry_safe (s_job, tmp, &sched->ring_mirror_list, node) {struct drm_sched_fence *s_fence = s_job->s_fence;struct dma_fence *fence;@@ -350,6 +354,7 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) }spin_lock (&sched->job_list_lock); } +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock); }EXPORT_SYMBOL (drm_sched_job_recovery); --2.14.1
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
reviewerAm 08.10.2018 um 16:40 schrieb Nayan Deshmukh:
Quoted 47 lines
Quoted 45 lines · Christian König
Cleanup starting the timeout a bit.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/sched_main.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +15
-3@@ -182,6 +182,20 @@ bool drm_sched_dependency_optimized(struct dma_fence* fence, }EXPORT_SYMBOL (drm_sched_dependency_optimized); +/** +* drm_sched_start_timeout - start timeout for reset worker +* +* @sched: scheduler instance to start the worker for +* +* Start the timeout for the given scheduler. +*/ +static void drm_sched_start_timeout (struct drm_gpu_scheduler *sched) +{ +if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && + !list_empty (&sched->ring_mirror_list)) +schedule_delayed_work (&sched->work_tdr, sched->timeout); +} +/* job_finish is called after hw fence signaled */ static void drm_sched_job_finish (struct work_struct *work)@@ -203,9 +217,7 @@ static void drm_sched_job_finish(struct work_struct *work)/* remove job from ring_mirror_list */ list_del (&s_job->node);/* queue TDR for next job */ -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !list_empty (&sched->ring_mirror_list)) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock);dma_fence_put (&s_job->s_fence->finished);@@ -229,10 +241,7 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)
Quoted 9 lines
drivers/gpu/drm/scheduler/sched_main.c static void drm_sched_job_begin(struct drm_sched_job *s_job) · line 244
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_main.c +1
-4spin_lock (&sched->job_list_lock);list_add_tail (&s_job->node, &sched->ring_mirror_list); -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && -list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node) == s_job) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);This is not functionally same as before. In this case we only want to schedule a work item if this is the only job in the
ring_mirror_list.
And exactly that is the cleanup :)
Once a work item is scheduled it's timer isn't modified again by schedule_delayed_work().
So it is more common to just schedule a work item again if we potentially need it.
Christian.
Quoted 29 lines
Regards,
NayanQuoted 26 lines
drivers/gpu/drm/scheduler/sched_main.c +1
-6spin_unlock (&sched->job_list_lock); }@@ -313,11 +322,6 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched)int r;spin_lock (&sched->job_list_lock); - s_job =list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node); -if (s_job && sched->timeout !=MAX_SCHEDULE_TIMEOUT ) -schedule_delayed_work (&sched->work_tdr, sched->timeout); -list_for_each_entry_safe (s_job, tmp, &sched->ring_mirror_list, node) {struct drm_sched_fence *s_fence = s_job->s_fence;struct dma_fence *fence;@@ -350,6 +354,7 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) }spin_lock (&sched->job_list_lock); } +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock); }EXPORT_SYMBOL (drm_sched_job_recovery); --2.14.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 59 lines · Christian König
Am 08.10.2018 um 16:40 schrieb Nayan Deshmukh:
Quoted 47 lines
Quoted 45 lines · Christian König
Cleanup starting the timeout a bit.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/scheduler/sched_main.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)drivers/gpu/drm/scheduler/sched_main.c +15
-3@@ -182,6 +182,20 @@ bool drm_sched_dependency_optimized(struct dma_fence* fence, }EXPORT_SYMBOL (drm_sched_dependency_optimized); +/** +* drm_sched_start_timeout - start timeout for reset worker +* +* @sched: scheduler instance to start the worker for +* +* Start the timeout for the given scheduler. +*/ +static void drm_sched_start_timeout (struct drm_gpu_scheduler *sched) +{ +if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && + !list_empty (&sched->ring_mirror_list)) +schedule_delayed_work (&sched->work_tdr, sched->timeout); +} +/* job_finish is called after hw fence signaled */ static void drm_sched_job_finish (struct work_struct *work)@@ -203,9 +217,7 @@ static void drm_sched_job_finish(struct work_struct *work)/* remove job from ring_mirror_list */ list_del (&s_job->node);/* queue TDR for next job */ -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && - !list_empty (&sched->ring_mirror_list)) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock);dma_fence_put (&s_job->s_fence->finished);@@ -229,10 +241,7 @@ static void drm_sched_job_begin(struct drm_sched_job *s_job)Quoted 9 lines
drivers/gpu/drm/scheduler/sched_main.c static void drm_sched_job_begin(struct drm_sched_job *s_job) · line 244
Quoted 7 lines
drivers/gpu/drm/scheduler/sched_main.c +1
-4spin_lock (&sched->job_list_lock);list_add_tail (&s_job->node, &sched->ring_mirror_list); -if (sched->timeout !=MAX_SCHEDULE_TIMEOUT && -list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node) == s_job) -schedule_delayed_work (&sched->work_tdr, sched->timeout); +drm_sched_start_timeout (sched);This is not functionally same as before. In this case we only want to schedule a work item if this is the only job in the
ring_mirror_list.
Quoted 7 lines
And exactly that is the cleanup :)
Once a work item is scheduled it's timer isn't modified again by
schedule_delayed_work().So it is more common to just schedule a work item again if we potentially need it.
I thought that the time included for the timedout seconds should the time spent on the hardware engine and not the time spent in the hardware queue. In this case we will start the counter only when the job before this job finishes executing.
I have more doubts regarding your second patch, a long mail is on its way :)
Regards,
Nayan
Quoted 32 lines
Christian.
Quoted 29 lines
Regards,
NayanQuoted 26 lines
drivers/gpu/drm/scheduler/sched_main.c +1
-6spin_unlock (&sched->job_list_lock); }@@ -313,11 +322,6 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched)int r;spin_lock (&sched->job_list_lock); - s_job =list_first_entry_or_null (&sched->ring_mirror_list, - struct drm_sched_job, node); -if (s_job && sched->timeout !=MAX_SCHEDULE_TIMEOUT ) -schedule_delayed_work (&sched->work_tdr, sched->timeout); -list_for_each_entry_safe (s_job, tmp, &sched->ring_mirror_list, node) {struct drm_sched_fence *s_fence = s_job->s_fence;struct dma_fence *fence;@@ -350,6 +354,7 @@ void drm_sched_job_recovery(struct drm_gpu_scheduler *sched) }spin_lock (&sched->job_list_lock); } +drm_sched_start_timeout (sched);spin_unlock (&sched->job_list_lock); }EXPORT_SYMBOL (drm_sched_job_recovery); --2.14.1
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel