[PATCH v3 2/3] accel/rocket: Collect job dependencies before arming

From: MoGGuU

Date: Fri Aug 28 2026 - 01:09:04 EST


rocket_job_push() arms the scheduler job before collecting its implicit
dependencies. Dependency collection can fail with -ENOMEM, but an armed
job must be pushed and must not be aborted with drm_sched_job_cleanup().

Collect dependencies before taking the scheduler lock and arming the job.
Only operations that cannot fail remain after drm_sched_job_arm().

Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@xxxxxxxxxxxxxxx
Tested-by: Sidong Yang <sidong.yang@xxxxxxxxxx>
Signed-off-by: MoGGuU <Naixumogu@xxxxxxxxxxx>
---
drivers/accel/rocket/rocket_job.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index e6052d1973afa..b55e12aecfe64 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -206,19 +206,21 @@ static int rocket_job_push(struct rocket_job *job)
if (ret)
goto err;

+ ret = rocket_acquire_object_fences(job->in_bos, job->in_bo_count,
+ &job->base, false);
+ if (ret)
+ goto err_unlock;
+
+ ret = rocket_acquire_object_fences(job->out_bos, job->out_bo_count,
+ &job->base, true);
+ if (ret)
+ goto err_unlock;
+
scoped_guard(mutex, &rdev->sched_lock) {
drm_sched_job_arm(&job->base);

job->inference_done_fence = dma_fence_get(&job->base.s_fence->finished);

- ret = rocket_acquire_object_fences(job->in_bos, job->in_bo_count, &job->base, false);
- if (ret)
- goto err_unlock;
-
- ret = rocket_acquire_object_fences(job->out_bos, job->out_bo_count, &job->base, true);
- if (ret)
- goto err_unlock;
-
kref_get(&job->refcount); /* put by scheduler job completion */

drm_sched_entity_push_job(&job->base);
--
2.43.0