[PATCH 1/7] drm/xe/lrc: Reduce scope of empty lrc data

Matthew Brost matthew.brost at intel.com
Tue Jul 8 05:01:13 UTC 2025


On Thu, Jul 03, 2025 at 03:41:10PM -0700, Lucas De Marchi wrote:
> The only case in which new lrc data is created from scratch is when it's
> called prior to recording the default lrc. There's no need to check for
> NULL init_data since in that case the function already failed: just move
> the allocation where it's needed.
> 
> 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_lrc.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> index d2ad8fe737eb3..7cde827ddbec9 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.c
> +++ b/drivers/gpu/drm/xe/xe_lrc.c
> @@ -1044,7 +1044,6 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
>  	struct xe_tile *tile = gt_to_tile(gt);
>  	struct xe_device *xe = gt_to_xe(gt);
>  	struct iosys_map map;
> -	void *init_data = NULL;
>  	u32 arb_enable;
>  	u32 bo_flags;
>  	int err;
> @@ -1076,25 +1075,26 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
>  	xe_hw_fence_ctx_init(&lrc->fence_ctx, hwe->gt,
>  			     hwe->fence_irq, hwe->name);
>  
> -	if (!gt->default_lrc[hwe->class]) {
> -		init_data = empty_lrc_data(hwe);
> -		if (!init_data) {
> -			err = -ENOMEM;
> -			goto err_lrc_finish;
> -		}
> -	}
> -
>  	/*
>  	 * Init Per-Process of HW status Page, LRC / context state to known
> -	 * values
> +	 * values. If there's already a primed default_lrc, just copy it, otherwise
> +	 * it's the early submission to record the lrc: build a new empty one from
> +	 * scratch.
>  	 */
>  	map = __xe_lrc_pphwsp_map(lrc);
> -	if (!init_data) {
> +	if (gt->default_lrc[hwe->class]) {
>  		xe_map_memset(xe, &map, 0, 0, LRC_PPHWSP_SIZE);	/* PPHWSP */
>  		xe_map_memcpy_to(xe, &map, LRC_PPHWSP_SIZE,
>  				 gt->default_lrc[hwe->class] + LRC_PPHWSP_SIZE,
>  				 lrc_size - LRC_PPHWSP_SIZE);
>  	} else {
> +		void *init_data = empty_lrc_data(hwe);
> +
> +		if (!init_data) {
> +			err = -ENOMEM;
> +			goto err_lrc_finish;
> +		}
> +
>  		xe_map_memcpy_to(xe, &map, 0, init_data, lrc_size);
>  		kfree(init_data);
>  	}
> 
> -- 
> 2.49.0
> 


More information about the Intel-xe mailing list