[PATCH 1/3] drm/xe: Clarify LRC size when allocating

Matt Roper matthew.d.roper at intel.com
Fri May 16 17:47:22 UTC 2025


On Fri, May 16, 2025 at 08:44:10AM +0100, Tvrtko Ursulin wrote:
> Clarify in code and kerneldoc that lrc->size is the size of the kernel
> object backing both the ringbuffer and LRC in one block of memory.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at igalia.com>

Reviewed-by: Matt Roper <matthew.d.roper at intel.com>

> ---
>  drivers/gpu/drm/xe/xe_lrc.c       | 17 +++++++----------
>  drivers/gpu/drm/xe/xe_lrc_types.h |  2 +-
>  2 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> index 61a2e87990a9..08835e36a60d 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.c
> +++ b/drivers/gpu/drm/xe/xe_lrc.c
> @@ -982,19 +982,21 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
>  		       u32 init_flags)
>  {
>  	struct xe_gt *gt = hwe->gt;
> +	const u32 lrc_size = xe_gt_lrc_size(gt, hwe->class);
>  	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 lrc_size;
>  	u32 bo_flags;
>  	int err;
>  
>  	kref_init(&lrc->refcount);
>  	lrc->gt = gt;
>  	lrc->flags = 0;
> -	lrc_size = ring_size + xe_gt_lrc_size(gt, hwe->class);
> +	lrc->size = ring_size + lrc_size;
> +	lrc->ring.size = ring_size;
> +	lrc->ring.tail = 0;
>  	if (xe_gt_has_indirect_ring_state(gt))
>  		lrc->flags |= XE_LRC_FLAG_INDIRECT_RING_STATE;
>  
> @@ -1007,7 +1009,7 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
>  	 * FIXME: Perma-pinning LRC as we don't yet support moving GGTT address
>  	 * via VM bind calls.
>  	 */
> -	lrc->bo = xe_bo_create_pin_map(xe, tile, vm, lrc_size,
> +	lrc->bo = xe_bo_create_pin_map(xe, tile, vm, lrc->size,
>  				       ttm_bo_type_kernel,
>  				       bo_flags);
>  	if (IS_ERR(lrc->bo))
> @@ -1021,10 +1023,6 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
>  		goto err_lrc_finish;
>  	}
>  
> -	lrc->size = lrc_size;
> -	lrc->ring.size = ring_size;
> -	lrc->ring.tail = 0;
> -
>  	xe_hw_fence_ctx_init(&lrc->fence_ctx, hwe->gt,
>  			     hwe->fence_irq, hwe->name);
>  
> @@ -1045,10 +1043,9 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
>  		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,
> -				 xe_gt_lrc_size(gt, hwe->class) - LRC_PPHWSP_SIZE);
> +				 lrc_size - LRC_PPHWSP_SIZE);
>  	} else {
> -		xe_map_memcpy_to(xe, &map, 0, init_data,
> -				 xe_gt_lrc_size(gt, hwe->class));
> +		xe_map_memcpy_to(xe, &map, 0, init_data, lrc_size);
>  		kfree(init_data);
>  	}
>  
> diff --git a/drivers/gpu/drm/xe/xe_lrc_types.h b/drivers/gpu/drm/xe/xe_lrc_types.h
> index ae24cf6f8dd9..559c7c831212 100644
> --- a/drivers/gpu/drm/xe/xe_lrc_types.h
> +++ b/drivers/gpu/drm/xe/xe_lrc_types.h
> @@ -22,7 +22,7 @@ struct xe_lrc {
>  	 */
>  	struct xe_bo *bo;
>  
> -	/** @size: size of lrc including any indirect ring state page */
> +	/** @size: size of the ring, lrc and optional indirect ring state */
>  	u32 size;
>  
>  	/** @gt: gt which this LRC belongs to */
> -- 
> 2.48.0
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


More information about the Intel-xe mailing list