[Intel-xe] [PATCH] drm/xe: Prevent return with locked vm

Matthew Brost matthew.brost at intel.com
Wed Aug 30 01:02:27 UTC 2023


On Tue, Aug 29, 2023 at 11:43:35PM +0530, Pallavi Mishra wrote:
> Reorder vm_id check after the one for VISIBLE_VRAM. This should
> prevent returning with locked vm in error scenario.
> 
> Signed-off-by: Pallavi Mishra <pallavi.mishra at intel.com>

Reviewed-by: Matthew Brost <matthew.brost at intel.com>

> ---
>  drivers/gpu/drm/xe/xe_bo.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 1ab682d61e3c..6a8a41dafe88 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -1785,17 +1785,6 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
>  	if (XE_IOCTL_DBG(xe, args->size & ~PAGE_MASK))
>  		return -EINVAL;
>  
> -	if (args->vm_id) {
> -		vm = xe_vm_lookup(xef, args->vm_id);
> -		if (XE_IOCTL_DBG(xe, !vm))
> -			return -ENOENT;
> -		err = xe_vm_lock(vm, &ww, 0, true);
> -		if (err) {
> -			xe_vm_put(vm);
> -			return err;
> -		}
> -	}
> -
>  	if (args->flags & XE_GEM_CREATE_FLAG_DEFER_BACKING)
>  		bo_flags |= XE_BO_DEFER_BACKING;
>  
> @@ -1811,6 +1800,17 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
>  		bo_flags |= XE_BO_NEEDS_CPU_ACCESS;
>  	}
>  
> +	if (args->vm_id) {
> +		vm = xe_vm_lookup(xef, args->vm_id);
> +		if (XE_IOCTL_DBG(xe, !vm))
> +			return -ENOENT;
> +		err = xe_vm_lock(vm, &ww, 0, true);
> +		if (err) {
> +			xe_vm_put(vm);
> +			return err;
> +		}
> +	}
> +
>  	bo = xe_bo_create(xe, NULL, vm, args->size, ttm_bo_type_device,
>  			  bo_flags);
>  	if (IS_ERR(bo)) {
> -- 
> 2.25.1
> 


More information about the Intel-xe mailing list