[PATCH i-g-t v2 1/2] lib/xe/xe_query: return errno from xe_supports_faults check
Kamil Konieczny
kamil.konieczny at linux.intel.com
Mon May 13 13:12:38 UTC 2024
Hi Jonathan,
On 2024-05-10 at 11:24:37 -0700, Jonathan Cavitt wrote:
> Return the exact error value from the ioctl used in xe_supports_faults.
> This is done because it is possible that faults are supported on the
> system but are temporarily unavailable due to VM usage. This change
> allows the user to determine if they are willing to wait for fault
> support to become active again.
>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> ---
> lib/xe/xe_query.c | 15 ++++++++-------
> lib/xe/xe_query.h | 2 +-
> 2 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
> index 6df8f42649..145dee8142 100644
> --- a/lib/xe/xe_query.c
> +++ b/lib/xe/xe_query.c
> @@ -300,27 +300,28 @@ void xe_device_put(int fd)
> * xe_supports_faults:
> * @fd: xe device fd
> *
> - * Returns true if xe device @fd allows creating vm in fault mode otherwise
> - * false.
> + * Returns the return value of the ioctl. This can either be 0 if the
> + * xe device @fd allows creating a vm in fault mode, or an error value
> + * if it does not.
> *
> * NOTE: This function temporarily creates a VM in fault mode. Hence, while
> * this function is executing, no non-fault mode VMs can be created.
> */
> -bool xe_supports_faults(int fd)
> +int xe_supports_faults(int fd)
> {
> - bool supports_faults;
> + int ret;
>
> struct drm_xe_vm_create create = {
> .flags = DRM_XE_VM_CREATE_FLAG_LR_MODE |
> DRM_XE_VM_CREATE_FLAG_FAULT_MODE,
> };
>
> - supports_faults = !igt_ioctl(fd, DRM_IOCTL_XE_VM_CREATE, &create);
> + ret = igt_ioctl(fd, DRM_IOCTL_XE_VM_CREATE, &create);
>
> - if (supports_faults)
> + if (!ret)
> xe_vm_destroy(fd, create.vm_id);
>
> - return supports_faults;
> + return ret;
> }
>
> static void xe_device_destroy_cache(void)
> diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
> index f91d16bdf5..54115f8f7c 100644
> --- a/lib/xe/xe_query.h
> +++ b/lib/xe/xe_query.h
> @@ -94,7 +94,7 @@ uint64_t xe_visible_available_vram_size(int fd, int gt);
> uint32_t xe_get_default_alignment(int fd);
> uint32_t xe_va_bits(int fd);
> uint16_t xe_dev_id(int fd);
> -bool xe_supports_faults(int fd);
> +int xe_supports_faults(int fd);
> const char *xe_engine_class_string(uint32_t engine_class);
> bool xe_has_engine_class(int fd, uint16_t engine_class);
> bool xe_has_media_gt(int fd);
> --
> 2.25.1
>
More information about the igt-dev
mailing list