[PATCH v3 01/30] drm/xe: Retry BO allocation

Gwan-gyeong Mun gwan-gyeong.mun at intel.com
Tue Jan 7 12:28:12 UTC 2025



On 12/18/24 1:33 AM, Matthew Brost wrote:
> TTM doesn't support fair eviction via WW locking, this mitigated in by
> using retry loops in exec and preempt rebind worker. Extend this retry
> loop to BO allocation. Once TTM supports fair eviction this patch can be
> reverted.
> 
> Signed-off-by: Matthew Brost <matthew.brost at intel.com>
> ---
>   drivers/gpu/drm/xe/xe_bo.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index e6c896ad5602..a670a0444e03 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -2142,6 +2142,7 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
>   	struct xe_file *xef = to_xe_file(file);
>   	struct drm_xe_gem_create *args = data;
>   	struct xe_vm *vm = NULL;
> +	ktime_t end = 0;
>   	struct xe_bo *bo;
>   	unsigned int bo_flags;
>   	u32 handle;
> @@ -2214,11 +2215,14 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
>   		vm = xe_vm_lookup(xef, args->vm_id);
>   		if (XE_IOCTL_DBG(xe, !vm))
>   			return -ENOENT;
> +	}
> +
> +retry:
> +	if (vm) {
>   		err = xe_vm_lock(vm, true);
>   		if (err)
>   			goto out_vm;
>   	}
> -
>   	bo = xe_bo_create_user(xe, NULL, vm, args->size, args->cpu_caching,
>   			       bo_flags);
>   
> @@ -2227,6 +2231,8 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
>   
>   	if (IS_ERR(bo)) {
>   		err = PTR_ERR(bo);
> +		if (xe_vm_validate_should_retry(NULL, err, &end))
> +			goto retry;
>   		goto out_vm;
>   	}
>   
looks good to me.

Reviewed-by: Gwan-gyeong Mun <gwan-gyeong.mun at intel.com>


More information about the dri-devel mailing list