[PATCH] drm/xe/guc_submit: Simplify and fix diff calculation

Matthew Brost matthew.brost at intel.com
Wed May 14 23:54:41 UTC 2025


On Tue, May 13, 2025 at 07:25:49AM -0700, Lucas De Marchi wrote:
> With a u32 type, there's no need to check which one is greater: the
> current is always the latest and if it's less than the previous, it's
> because it wrapped: just do the unsigned calculation that will lead to
> the same result, or better the correct one. It fixes an off-by-one in
> the wrapped calculation, however that doesn't really matter for the
> timeout calculation.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>

Reviewed-by: Matthew Brost <matthew.brost at intel.com>

> ---
>  drivers/gpu/drm/xe/xe_guc_submit.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index fb125f940de8f..80f748baad3f3 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -976,10 +976,7 @@ static bool check_timeout(struct xe_exec_queue *q, struct xe_sched_job *job)
>  	 */
>  	xe_gt_assert(gt, timeout_ms < 100 * MSEC_PER_SEC);
>  
> -	if (ctx_timestamp < ctx_job_timestamp)
> -		diff = ctx_timestamp + U32_MAX - ctx_job_timestamp;
> -	else
> -		diff = ctx_timestamp - ctx_job_timestamp;
> +	diff = ctx_timestamp - ctx_job_timestamp;
>  
>  	/*
>  	 * Ensure timeout is within 5% to account for an GuC scheduling latency
> 
> 
> 


More information about the Intel-xe mailing list