diff options
author | Christian König <christian.koenig@amd.com> | 2018-08-07 15:52:13 +0300 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-08-27 19:10:06 +0300 |
commit | 573edb241b44162a1478cc74429f94df86e6e71d (patch) | |
tree | 34085a1e35cdea88890aaf8afd70e5cc4c08f8c9 | |
parent | 93f15e1c0796f102a62fdc4931e4c5f847c98a12 (diff) | |
download | linux-573edb241b44162a1478cc74429f94df86e6e71d.tar.xz |
drm/scheduler: fix last_scheduled handling
Make sure we access last_scheduled only after checking that there are no
more jobs on the entity.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Nayan Deshmukh <nayan26deshmukh@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/scheduler/gpu_scheduler.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index 6be554499be9..f40a504e3d68 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -565,19 +565,20 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, struct drm_sched_entity *entity) { struct drm_sched_rq *rq = entity->rq; - bool first, reschedule, idle; + bool first; - idle = entity->last_scheduled == NULL || - dma_fence_is_signaled(entity->last_scheduled); first = spsc_queue_count(&entity->job_queue) == 0; - reschedule = idle && first && (entity->num_rq_list > 1); + if (first && (entity->num_rq_list > 1)) { + struct dma_fence *fence; - if (reschedule) { - rq = drm_sched_entity_get_free_sched(entity); - spin_lock(&entity->rq_lock); - drm_sched_rq_remove_entity(entity->rq, entity); - entity->rq = rq; - spin_unlock(&entity->rq_lock); + fence = READ_ONCE(entity->last_scheduled); + if (fence == NULL || dma_fence_is_signaled(fence)) { + rq = drm_sched_entity_get_free_sched(entity); + spin_lock(&entity->rq_lock); + drm_sched_rq_remove_entity(entity->rq, entity); + entity->rq = rq; + spin_unlock(&entity->rq_lock); + } } sched_job->sched = entity->rq->sched; |