According to the DMA scheduler documentation, once a job is armed, it must be pushed. Drivers should avoid calling the failing code path that attempts to add dependencies after a job has been armed. This change enforces that rule.
Cc: Christian König <[email protected]> Cc: Danilo Krummrich <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Philipp Stanner <[email protected]> Cc: [email protected] Signed-off-by: Matthew Brost <[email protected]> --- drivers/gpu/drm/scheduler/sched_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c index 676484dd3ea3..436cb2844161 100644 --- a/drivers/gpu/drm/scheduler/sched_main.c +++ b/drivers/gpu/drm/scheduler/sched_main.c @@ -873,7 +873,8 @@ EXPORT_SYMBOL(drm_sched_job_arm); * @job: scheduler job to add the dependencies to * @fence: the dma_fence to add to the list of dependencies. * - * Note that @fence is consumed in both the success and error cases. + * Note that @fence is consumed in both the success and error cases. This + * function cannot be called if the job is armed. * * Returns: * 0 on success, or an error on failing to expand the array. @@ -886,6 +887,10 @@ int drm_sched_job_add_dependency(struct drm_sched_job *job, u32 id = 0; int ret; + /* Do not allow additional dependencies when job is armed */ + if (WARN_ON_ONCE(job->sched)) + return -EINVAL; + if (!fence) return 0; -- 2.34.1
