[PATCH] drm/xe: Fix coverity issue, truncation warning

Matthew Brost matthew.brost at intel.com
Tue Aug 5 03:35:16 UTC 2025


On Mon, Aug 04, 2025 at 04:14:09PM +0530, Pravalika Gurram wrote:
> Use conditional assignment to avoid cast truncation warning.
> Set instance to 0 when hw_reports_to_instance_zero() returns false.
> 
> Fixes: 95336cfd5b2ce ("drm/xe: Add memirq report page address helpers")

Definitiely no fixes tag required here.

> 
> Signed-off-by: Pravalika Gurram <pravalika.gurram at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_memirq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_memirq.c b/drivers/gpu/drm/xe/xe_memirq.c
> index 49c45ec3e83c..75ddf4eda355 100644
> --- a/drivers/gpu/drm/xe/xe_memirq.c
> +++ b/drivers/gpu/drm/xe/xe_memirq.c
> @@ -257,7 +257,8 @@ static u32 __memirq_source_page(struct xe_memirq *memirq, u16 instance)
>  	memirq_assert(memirq, instance <= XE_HW_ENGINE_MAX_INSTANCE);
>  	memirq_assert(memirq, memirq->bo);
>  
> -	instance = hw_reports_to_instance_zero(memirq) ? instance : 0;
> +	if (!hw_reports_to_instance_zero(memirq))
> +		instance = 0;

I'm failing to see how this fixes any possible static checker. Could you explain?

That said, I do prefer the way you have changed it here.

Matt


>  	return xe_bo_ggtt_addr(memirq->bo) + XE_MEMIRQ_SOURCE_OFFSET(instance);
>  }
>  
> -- 
> 2.34.1
> 


More information about the Intel-xe mailing list