[PATCH] drm/xe: Have LRC hold VM reference

Maarten Lankhorst maarten at lankhorst.se
Fri May 23 18:37:43 UTC 2025


Hey,

The patch seems like it's missing a fixes tag. Additionally, I would say it's missing a description of the bug being fixed.

Because of this, I'm not entirely clear if this is the correct way to solve the problem.

Looking at the code, I only see that execlists might end up with a reference on LRC, is that when the problem happens?

Could you simply add XE_BO_FLAG_USER on create instead?

Kind regards,
~Maarten Lankhorst

On 2025-05-22 20:09, Niranjana Vishwanathapura wrote:
> LRC's BO uses VM's dma_resv object. Have LRC hold
> VM reference.
>
> Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura at intel.com>
> Reviewed-by: Stuart Summers <stuart.summers at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_lrc.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
> index 61a2e87990a9..efdf4ef35b35 100644
> --- a/drivers/gpu/drm/xe/xe_lrc.c
> +++ b/drivers/gpu/drm/xe/xe_lrc.c
> @@ -908,12 +908,17 @@ static void xe_lrc_set_ppgtt(struct xe_lrc *lrc, struct xe_vm *vm)
>  
>  static void xe_lrc_finish(struct xe_lrc *lrc)
>  {
> +	struct xe_vm *vm = lrc->bo->vm;
> +
>  	xe_hw_fence_ctx_finish(&lrc->fence_ctx);
>  	xe_bo_lock(lrc->bo, false);
>  	xe_bo_unpin(lrc->bo);
>  	xe_bo_unlock(lrc->bo);
>  	xe_bo_put(lrc->bo);
>  	xe_bo_unpin_map_no_vm(lrc->bb_per_ctx_bo);
> +
> +	if (vm)
> +		xe_vm_put(vm);
>  }
>  
>  /*
> @@ -1013,6 +1018,10 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
>  	if (IS_ERR(lrc->bo))
>  		return PTR_ERR(lrc->bo);
>  
> +	/* The lrc->bo uses VM's dma_resv object, take VM reference */
> +	if (vm)
> +		xe_vm_get(vm);
> +
>  	lrc->bb_per_ctx_bo = xe_bo_create_pin_map(xe, tile, NULL, SZ_4K,
>  						  ttm_bo_type_kernel,
>  						  bo_flags);



More information about the Intel-xe mailing list