Re: [PATCH] drm/i915/gt/uc: Evaluate GuC priority within locks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 06, 2024 at 02:17:02AM +0200, Andi Shyti wrote:
> 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.
> 
> Fixes: ee242ca704d3 ("drm/i915/guc: Implement GuC priority management")
> Signed-off-by: Andi Shyti <andi.shyti@xxxxxxxxxxxxxxx>
> Cc: Matthew Brost <matthew.brost@xxxxxxxxx>

Reviewed-by: Matthew Brost <matthew.brost@xxxxxxxxx>

> Cc: <stable@xxxxxxxxxxxxxxx> # v5.15+
> ---
>  drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index 0eaa1064242c..1181043bc5e9 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -4267,13 +4267,18 @@ static void guc_bump_inflight_request_prio(struct i915_request *rq,
>  	u8 new_guc_prio = map_i915_prio_to_guc_prio(prio);
>  
>  	/* Short circuit function */
> -	if (prio < I915_PRIORITY_NORMAL ||
> -	    rq->guc_prio == GUC_PRIO_FINI ||
> -	    (rq->guc_prio != GUC_PRIO_INIT &&
> -	     !new_guc_prio_higher(rq->guc_prio, new_guc_prio)))
> +	if (prio < I915_PRIORITY_NORMAL)
>  		return;
>  
>  	spin_lock(&ce->guc_state.lock);
> +
> +	if (rq->guc_prio == GUC_PRIO_FINI)
> +		goto exit;
> +
> +	if (rq->guc_prio != GUC_PRIO_INIT &&
> +	    !new_guc_prio_higher(rq->guc_prio, new_guc_prio))
> +		goto exit;
> +
>  	if (rq->guc_prio != GUC_PRIO_FINI) {
>  		if (rq->guc_prio != GUC_PRIO_INIT)
>  			sub_context_inflight_prio(ce, rq->guc_prio);
> @@ -4281,6 +4286,8 @@ static void guc_bump_inflight_request_prio(struct i915_request *rq,
>  		add_context_inflight_prio(ce, rq->guc_prio);
>  		update_context_prio(ce);
>  	}
> +
> +exit:
>  	spin_unlock(&ce->guc_state.lock);
>  }
>  
> -- 
> 2.45.1
> 




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux