Skip to content

Commit aed4053

Browse files
Lin.Caogregkh
authored andcommitted
drm/sched: Remove optimization that causes hang when killing dependent jobs
[ Upstream commit 15f7776 ] When application A submits jobs and application B submits a job with a dependency on A's fence, the normal flow wakes up the scheduler after processing each job. However, the optimization in drm_sched_entity_add_dependency_cb() uses a callback that only clears dependencies without waking up the scheduler. When application A is killed before its jobs can run, the callback gets triggered but only clears the dependency without waking up the scheduler, causing the scheduler to enter sleep state and application B to hang. Remove the optimization by deleting drm_sched_entity_clear_dep() and its usage, ensuring the scheduler is always woken up when dependencies are cleared. Fixes: 777dbd4 ("drm/amdgpu: drop a dummy wakeup scheduler") Cc: stable@vger.kernel.org # v4.6+ Signed-off-by: Lin.Cao <lincao12@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Philipp Stanner <phasta@kernel.org> Link: https://lore.kernel.org/r/20250717084453.921097-1-lincao12@amd.com [ replaced drm_sched_wakeup() calls with drm_sched_wakeup_if_can_queue() ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 79c8d93 commit aed4053

1 file changed

Lines changed: 4 additions & 21 deletions

File tree

drivers/gpu/drm/scheduler/sched_entity.c

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -346,28 +346,18 @@ void drm_sched_entity_destroy(struct drm_sched_entity *entity)
346346
}
347347
EXPORT_SYMBOL(drm_sched_entity_destroy);
348348

349-
/* drm_sched_entity_clear_dep - callback to clear the entities dependency */
350-
static void drm_sched_entity_clear_dep(struct dma_fence *f,
351-
struct dma_fence_cb *cb)
352-
{
353-
struct drm_sched_entity *entity =
354-
container_of(cb, struct drm_sched_entity, cb);
355-
356-
entity->dependency = NULL;
357-
dma_fence_put(f);
358-
}
359-
360349
/*
361-
* drm_sched_entity_clear_dep - callback to clear the entities dependency and
362-
* wake up scheduler
350+
* drm_sched_entity_wakeup - callback to clear the entity's dependency and
351+
* wake up the scheduler
363352
*/
364353
static void drm_sched_entity_wakeup(struct dma_fence *f,
365354
struct dma_fence_cb *cb)
366355
{
367356
struct drm_sched_entity *entity =
368357
container_of(cb, struct drm_sched_entity, cb);
369358

370-
drm_sched_entity_clear_dep(f, cb);
359+
entity->dependency = NULL;
360+
dma_fence_put(f);
371361
drm_sched_wakeup_if_can_queue(entity->rq->sched);
372362
}
373363

@@ -420,13 +410,6 @@ static bool drm_sched_entity_add_dependency_cb(struct drm_sched_entity *entity)
420410
fence = dma_fence_get(&s_fence->scheduled);
421411
dma_fence_put(entity->dependency);
422412
entity->dependency = fence;
423-
if (!dma_fence_add_callback(fence, &entity->cb,
424-
drm_sched_entity_clear_dep))
425-
return true;
426-
427-
/* Ignore it when it is already scheduled */
428-
dma_fence_put(fence);
429-
return false;
430413
}
431414

432415
if (!dma_fence_add_callback(entity->dependency, &entity->cb,

0 commit comments

Comments
 (0)