Commit b3af8438 authored by Christian König's avatar Christian König

drm/scheduler: fix fence ref counting

We leaked dependency fences when processes were beeing killed.

Additional to that grab a reference to the last scheduled fence.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAndrey Grodzovsky <andrey.grodzovsky@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220929180151.139751-1-christian.koenig@amd.com
parent 5349fad8
...@@ -207,6 +207,7 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f, ...@@ -207,6 +207,7 @@ static void drm_sched_entity_kill_jobs_cb(struct dma_fence *f,
struct drm_sched_job *job = container_of(cb, struct drm_sched_job, struct drm_sched_job *job = container_of(cb, struct drm_sched_job,
finish_cb); finish_cb);
dma_fence_put(f);
INIT_WORK(&job->work, drm_sched_entity_kill_jobs_work); INIT_WORK(&job->work, drm_sched_entity_kill_jobs_work);
schedule_work(&job->work); schedule_work(&job->work);
} }
...@@ -234,8 +235,10 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity) ...@@ -234,8 +235,10 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity)
struct drm_sched_fence *s_fence = job->s_fence; struct drm_sched_fence *s_fence = job->s_fence;
/* Wait for all dependencies to avoid data corruptions */ /* Wait for all dependencies to avoid data corruptions */
while ((f = drm_sched_job_dependency(job, entity))) while ((f = drm_sched_job_dependency(job, entity))) {
dma_fence_wait(f, false); dma_fence_wait(f, false);
dma_fence_put(f);
}
drm_sched_fence_scheduled(s_fence); drm_sched_fence_scheduled(s_fence);
dma_fence_set_error(&s_fence->finished, -ESRCH); dma_fence_set_error(&s_fence->finished, -ESRCH);
...@@ -250,6 +253,7 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity) ...@@ -250,6 +253,7 @@ static void drm_sched_entity_kill_jobs(struct drm_sched_entity *entity)
continue; continue;
} }
dma_fence_get(entity->last_scheduled);
r = dma_fence_add_callback(entity->last_scheduled, r = dma_fence_add_callback(entity->last_scheduled,
&job->finish_cb, &job->finish_cb,
drm_sched_entity_kill_jobs_cb); drm_sched_entity_kill_jobs_cb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment