Skip to content

Commit ae45f07

Browse files
author
Andi Shyti
committed
drm/i915/gt/uc: Evaluate GuC priority within locks
The ce->guc_state.lock was made to protect guc_prio, which indicates the GuC priority level. But at the begnning of the function we perform some sanity check of guc_prio outside its protected section. Move them within the locked region. Use this occasion to expand the if statement to make it clearer. Signed-off-by: Andi Shyti <[email protected]> Cc: Matthew Brost <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 45ebbbb commit ae45f07

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4267,20 +4267,25 @@ static void guc_bump_inflight_request_prio(struct i915_request *rq,
42674267
u8 new_guc_prio = map_i915_prio_to_guc_prio(prio);
42684268

42694269
/* Short circuit function */
4270-
if (prio < I915_PRIORITY_NORMAL ||
4271-
rq->guc_prio == GUC_PRIO_FINI ||
4272-
(rq->guc_prio != GUC_PRIO_INIT &&
4273-
!new_guc_prio_higher(rq->guc_prio, new_guc_prio)))
4270+
if (prio < I915_PRIORITY_NORMAL)
42744271
return;
42754272

42764273
spin_lock(&ce->guc_state.lock);
4277-
if (rq->guc_prio != GUC_PRIO_FINI) {
4278-
if (rq->guc_prio != GUC_PRIO_INIT)
4279-
sub_context_inflight_prio(ce, rq->guc_prio);
4280-
rq->guc_prio = new_guc_prio;
4281-
add_context_inflight_prio(ce, rq->guc_prio);
4282-
update_context_prio(ce);
4283-
}
4274+
4275+
if (rq->guc_prio == GUC_PRIO_FINI)
4276+
goto exit;
4277+
4278+
if (!new_guc_prio_higher(rq->guc_prio, new_guc_prio))
4279+
goto exit;
4280+
4281+
if (rq->guc_prio != GUC_PRIO_INIT)
4282+
sub_context_inflight_prio(ce, rq->guc_prio);
4283+
4284+
rq->guc_prio = new_guc_prio;
4285+
add_context_inflight_prio(ce, rq->guc_prio);
4286+
update_context_prio(ce);
4287+
4288+
exit:
42844289
spin_unlock(&ce->guc_state.lock);
42854290
}
42864291

0 commit comments

Comments
 (0)