Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cavitt <jonathan.cavitt@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: jonathan.cavitt@intel.com, saurabhg.gupta@intel.com,
	brian.welty@intel.com, tomasz.mistat@intel.com,
	himanshu.girotra@intel.com, kamil.konieczny@linux.intel.com
Subject: [PATCH i-g-t v2 1/2] lib/xe/xe_query: return errno from xe_supports_faults check
Date: Fri, 10 May 2024 11:24:37 -0700	[thread overview]
Message-ID: <20240510182438.3178575-2-jonathan.cavitt@intel.com> (raw)
In-Reply-To: <20240510182438.3178575-1-jonathan.cavitt@intel.com>

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@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


  reply	other threads:[~2024-05-10 18:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 18:24 [PATCH i-g-t v2 0/2] lib/xe/xe_query: Wait for xe_supports_faults Jonathan Cavitt
2024-05-10 18:24 ` Jonathan Cavitt [this message]
2024-05-13 13:12   ` [PATCH i-g-t v2 1/2] lib/xe/xe_query: return errno from xe_supports_faults check Kamil Konieczny
2024-05-10 18:24 ` [PATCH i-g-t v2 2/2] tests/intel/xe_exec_fault_mode: account for EBUSY in support check Jonathan Cavitt
2024-05-13 13:19   ` Kamil Konieczny
2024-05-10 20:10 ` ✓ CI.xeBAT: success for lib/xe/xe_query: Wait for xe_supports_faults Patchwork
2024-05-10 20:18 ` ✓ Fi.CI.BAT: " Patchwork
2024-05-10 22:31 ` ✗ CI.xeFULL: failure " Patchwork
2024-05-12  6:58 ` ✗ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240510182438.3178575-2-jonathan.cavitt@intel.com \
    --to=jonathan.cavitt@intel.com \
    --cc=brian.welty@intel.com \
    --cc=himanshu.girotra@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=saurabhg.gupta@intel.com \
    --cc=tomasz.mistat@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox