[PATCH] drm/xe: Use distinct error code in VM_CREATE for device fault mode checks

Matthew Brost matthew.brost at intel.com
Wed Apr 24 03:20:34 UTC 2024


On Tue, Apr 23, 2024 at 04:47:07PM -0700, Brian Welty wrote:
> vm_create_ioctl doesn't allow creating new VM in fault_mode while existing
> VMs are in non-fault mode, and vice-versa.
> This is not necessarily the user doing anything wrong if others are sharing
> the system. Instead of returning -EINVAL which suggests the user provided a
> bad argument, return distinct error code of -EBUSY for this class of errors
> so the user knows they can retry the vm_create when system is idle.
> 

We (Thomas, myself, UMD teams) have been discussing error codes for VM
bind and exec IOCTLs but haven't considered the error codes in the
create IOCTLs. We likely need to do a complete scrub of these IOCTLs
too.

Looking at xe_vm_create_ioctl, after this change it looks correct to me.
I think if we all agree on this change (and other error codes) we should
also update the kerenl doc with all the possible returns.

It looks like:
-EINVAL: Various bad input
-EBUSY: VM in fault mode or non-fault mode present
-ENOMEM: kmalloc or device memory allocation failed

The only change I could possibly see is for extensions return
-EOPNOTSUPP.

Let's get a few others input here.

Matt

> Signed-off-by: Brian Welty <brian.welty at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_vm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index 85d6f359142d..e8628a982db6 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -1840,16 +1840,16 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
>  			 args->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE))
>  		return -EINVAL;
>  
> +	if (XE_IOCTL_DBG(xe, args->extensions))
> +		return -EINVAL;
> +
>  	if (XE_IOCTL_DBG(xe, args->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE &&
>  			 xe_device_in_non_fault_mode(xe)))
> -		return -EINVAL;
> +		return -EBUSY;
>  
>  	if (XE_IOCTL_DBG(xe, !(args->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE) &&
>  			 xe_device_in_fault_mode(xe)))
> -		return -EINVAL;
> -
> -	if (XE_IOCTL_DBG(xe, args->extensions))
> -		return -EINVAL;
> +		return -EBUSY;
>  
>  	if (args->flags & DRM_XE_VM_CREATE_FLAG_SCRATCH_PAGE)
>  		flags |= XE_VM_FLAG_SCRATCH_PAGE;
> -- 
> 2.43.0
> 


More information about the Intel-xe mailing list