drm/sched: Avoid memory leaks with cancel_job() callback
authorPhilipp Stanner <phasta@kernel.org>
Thu, 10 Jul 2025 12:54:06 +0000 (14:54 +0200)
committerPhilipp Stanner <phasta@kernel.org>
Thu, 10 Jul 2025 15:07:08 +0000 (17:07 +0200)
commitbf8bbaefaa6ae0a07971ea57b3208df60e8ad0a4
treed319e831687220e886b0dd5e050ec4d9dc458ba8
parentfe69a391808404977b1f002a6e7447de3de7a88e
drm/sched: Avoid memory leaks with cancel_job() callback

Since its inception, the GPU scheduler can leak memory if the driver
calls drm_sched_fini() while there are still jobs in flight.

The simplest way to solve this in a backwards compatible manner is by
adding a new callback, drm_sched_backend_ops.cancel_job(), which
instructs the driver to signal the hardware fence associated with the
job. Afterwards, the scheduler can safely use the established free_job()
callback for freeing the job.

Implement the new backend_ops callback cancel_job().

Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Link: https://lore.kernel.org/dri-devel/20250418113211.69956-1-tvrtko.ursulin@igalia.com/
Reviewed-by: MaĆ­ra Canal <mcanal@igalia.com>
Acked-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://lore.kernel.org/r/20250710125412.128476-4-phasta@kernel.org
drivers/gpu/drm/scheduler/sched_main.c
include/drm/gpu_scheduler.h