Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Sokolowski <jan.sokolowski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com>,
	Jan Sokolowski <jan.sokolowski@intel.com>
Subject: [PATCH i-g-t v1 1/2] tests/xe_eudebug: Implement faultable variations of some testcases
Date: Fri, 28 Mar 2025 12:45:54 +0000	[thread overview]
Message-ID: <20250328124555.255036-2-jan.sokolowski@intel.com> (raw)
In-Reply-To: <20250328124555.255036-1-jan.sokolowski@intel.com>

From: Dominik Grzegorzek <dominik.grzegorzek@intel.com>

Implement fault variation of tests, which are accessing the memory via
debugfd, by creating a vm in FAULT_MODE.

Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Signed-off-by: Jan Sokolowski <jan.sokolowski@intel.com>
---
 tests/intel/xe_eudebug.c | 84 +++++++++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 19 deletions(-)

diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c
index 76870805c..0b3de23e2 100644
--- a/tests/intel/xe_eudebug.c
+++ b/tests/intel/xe_eudebug.c
@@ -64,6 +64,7 @@ static void test_sysfs_toggle(int fd)
 #define VM_BIND_DELAY_UFENCE_ACK	(1 << 8)
 #define VM_BIND_UFENCE_RECONNECT	(1 << 9)
 #define VM_BIND_UFENCE_SIGINT_CLIENT	(1 << 10)
+#define TEST_FAULTABLE			(1 << 30)
 #define TEST_DISCOVERY			(1 << 31)
 
 #define PAGE_SIZE SZ_4K
@@ -1445,16 +1446,19 @@ static void test_basic_sessions_th(int fd, unsigned int flags, int num_clients,
 static void vm_access_client(struct xe_eudebug_client *c)
 {
 	struct drm_xe_engine_class_instance *hwe = c->ptr;
+	uint32_t vm_flags = DRM_XE_VM_CREATE_FLAG_LR_MODE;
 	uint32_t bo_placement;
 	struct bind_list *bl;
 	uint32_t vm;
 	int fd, i, j;
 
+
 	igt_debug("Using %s\n", xe_engine_class_string(hwe->engine_class));
 
 	fd = xe_eudebug_client_open_driver(c);
 
-	vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
+	vm_flags |= (c->flags & TEST_FAULTABLE) ? DRM_XE_VM_CREATE_FLAG_FAULT_MODE : 0;
+	vm = xe_eudebug_client_vm_create(c, fd, vm_flags, 0);
 
 	if (c->flags & VM_BIND_OP_MAP_USERPTR)
 		bo_placement = 0;
@@ -1567,17 +1571,27 @@ static void vm_trigger(struct xe_eudebug_debugger *d,
  *      vm fd, concerning many different offsets inside the vm,
  *      and many virtual addresses of the vm_bound object.
  *
+ * SUBTEST: basic-vm-access-faultable
+ * Description:
+ *      Fault variation of test basic-vm-access.
+ *
  * SUBTEST: basic-vm-access-userptr
  * Description:
  *      Exercise XE_EUDEBUG_VM_OPEN with pread and pwrite into the
  *      vm fd, concerning many different offsets inside the vm,
  *      and many virtual addresses of the vm_bound object, but backed
  *      by userptr.
+ *
+ * SUBTEST: basic-vm-access-userptr-faultable
+ * Description:
+ *      Fault variation of test basic-vm-access-userptr.
  */
 static void test_vm_access(int fd, unsigned int flags, int num_clients)
 {
 	struct drm_xe_engine_class_instance *hwe;
 
+	igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
+
 	xe_eudebug_for_each_engine(fd, hwe)
 		test_client_with_trigger(fd, flags, num_clients,
 					 vm_access_client,
@@ -1717,15 +1731,25 @@ static void vm_trigger_access_parameters(struct xe_eudebug_debugger *d,
  *      Check negative scenarios of VM_OPEN ioctl and pread/pwrite usage
  *      with bo backing storage.
  *
+ * SUBTEST: basic-vm-access-parameters-faultable
+ * Description:
+ *	Fault variation of test basic-vm-access-parameters.
+ *
  * SUBTEST: basic-vm-access-parameters-userptr
  * Description:
  *      Check negative scenarios of VM_OPEN ioctl and pread/pwrite usage
  *      with userptr backing storage.
+ *
+ * SUBTEST: basic-vm-access-parameters-userptr-faultable
+ * Description:
+ *      Fault variation of test basic-vm-access-parameters-userptr.
  */
 static void test_vm_access_parameters(int fd, unsigned int flags, int num_clients)
 {
 	struct drm_xe_engine_class_instance *hwe;
 
+	igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
+
 	xe_eudebug_for_each_engine(fd, hwe)
 		test_client_with_trigger(fd, flags, num_clients,
 					 vm_access_client,
@@ -2185,7 +2209,8 @@ static void *vm_bind_clear_thread(void *data)
 	struct vm_bind_clear_thread_priv *priv = data;
 	int fd = xe_eudebug_client_open_driver(priv->c);
 	uint32_t gtt_size = 1ull << min_t(uint32_t, xe_va_bits(fd), 48);
-	uint32_t vm = xe_eudebug_client_vm_create(priv->c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
+	uint32_t vm_flags = (priv->c->flags & TEST_FAULTABLE) ? DRM_XE_VM_CREATE_FLAG_FAULT_MODE : 0;
+	uint32_t vm = xe_eudebug_client_vm_create(priv->c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE | vm_flags, 0);
 	size_t bo_size = xe_bb_size(fd, batch_size);
 	unsigned long count = 0;
 	uint64_t *fence_data;
@@ -2397,14 +2422,20 @@ static void vm_bind_clear_ack_trigger(struct xe_eudebug_debugger *d,
  * SUBTEST: vm-bind-clear
  * Description:
  *      Check that fresh buffers we vm_bind into the ppGTT are always clear.
+ *
+ * SUBTEST: vm-bind-clear-faultable
+ * Description:
+ *      Fault variation of test vm-bind-clear.
  */
-static void test_vm_bind_clear(int fd)
+static void test_vm_bind_clear(int fd, uint32_t flags)
 {
 	struct vm_bind_clear_priv *priv;
 	struct xe_eudebug_session *s;
 
+	igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
+
 	priv = vm_bind_clear_priv_create();
-	s = xe_eudebug_session_create(fd, vm_bind_clear_client, 0, priv);
+	s = xe_eudebug_session_create(fd, vm_bind_clear_client, flags, priv);
 
 	xe_eudebug_debugger_add_trigger(s->debugger, DRM_XE_EUDEBUG_EVENT_VM_BIND_OP,
 					vm_bind_clear_test_trigger);
@@ -2433,7 +2464,8 @@ static void vma_ufence_client(struct xe_eudebug_client *c)
 	const unsigned int n = UFENCE_EVENT_COUNT_EXPECTED;
 	int fd = xe_eudebug_client_open_driver(c);
 	struct ufence_bind *binds = create_binds_with_ufence(fd, n);
-	uint32_t vm = xe_eudebug_client_vm_create(c, fd, DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
+	uint32_t vm_flags = (c->flags & TEST_FAULTABLE) ? DRM_XE_VM_CREATE_FLAG_FAULT_MODE : 0;
+	uint32_t vm = xe_eudebug_client_vm_create(c, fd, vm_flags | DRM_XE_VM_CREATE_FLAG_LR_MODE, 0);
 	size_t bo_size = xe_get_default_alignment(fd);
 	uint64_t items = bo_size / sizeof(uint32_t);
 	uint32_t bo[UFENCE_EVENT_COUNT_EXPECTED];
@@ -2613,12 +2645,18 @@ static void vma_ufence_trigger(struct xe_eudebug_debugger *d,
  * Description:
  *      Intercept vm bind after receiving ufence event, then access target vm and write to it.
  *      Then check on client side if the write was successful.
+ *
+ * SUBTEST: vma-ufence-faultable
+ * Description:
+ *      Fault variation of test vma-ufence.
  */
 static void test_vma_ufence(int fd, unsigned int flags)
 {
 	struct xe_eudebug_session *s;
 	struct ufence_priv *priv;
 
+	igt_require(!(flags & TEST_FAULTABLE) || !xe_supports_faults(fd));
+
 	priv = ufence_priv_create();
 	s = xe_eudebug_session_create(fd, vma_ufence_client, flags, priv);
 
@@ -2742,17 +2780,31 @@ igt_main
 	igt_subtest("basic-client-th")
 		test_basic_sessions_th(fd, 0, 1, true);
 
-	igt_subtest("basic-vm-access")
-		test_vm_access(fd, 0, 1);
 
-	igt_subtest("basic-vm-access-userptr")
-		test_vm_access(fd, VM_BIND_OP_MAP_USERPTR, 1);
+	igt_subtest_group {
+		uint32_t flags[] = {0, TEST_FAULTABLE};
+		const char *suffix[] = {"", "-faultable"};
+
+		for (int i = 0; i < ARRAY_SIZE(flags); i++) {
+			igt_subtest_f("basic-vm-access%s", suffix[i])
+				test_vm_access(fd, flags[i], 1);
+
+			igt_subtest_f("basic-vm-access-userptr%s", suffix[i])
+				test_vm_access(fd, VM_BIND_OP_MAP_USERPTR | flags[i], 1);
+
+			igt_subtest_f("basic-vm-access-parameters%s", suffix[i])
+				test_vm_access_parameters(fd, flags[i], 1);
 
-	igt_subtest("basic-vm-access-parameters")
-		test_vm_access_parameters(fd, 0, 1);
+			igt_subtest_f("basic-vm-access-parameters-userptr%s", suffix[i])
+				test_vm_access_parameters(fd, VM_BIND_OP_MAP_USERPTR | flags[i], 1);
 
-	igt_subtest("basic-vm-access-parameters-userptr")
-		test_vm_access_parameters(fd, VM_BIND_OP_MAP_USERPTR, 1);
+			igt_subtest_f("vma-ufence%s", suffix[i])
+				test_vma_ufence(fd, flags[i]);
+
+			igt_subtest_f("vm-bind-clear%s", suffix[i])
+				test_vm_bind_clear(fd, flags[i]);
+		}
+	}
 
 	igt_subtest("multiple-sessions")
 		test_basic_sessions(fd, CREATE_VMS | CREATE_EXEC_QUEUES, 4, true);
@@ -2781,12 +2833,6 @@ igt_main
 	igt_subtest("basic-vm-bind-ufence-sigint-client")
 		test_basic_ufence(fd, VM_BIND_UFENCE_SIGINT_CLIENT);
 
-	igt_subtest("vma-ufence")
-		test_vma_ufence(fd, 0);
-
-	igt_subtest("vm-bind-clear")
-		test_vm_bind_clear(fd);
-
 	igt_subtest("basic-vm-bind-discovery")
 		test_basic_discovery(fd, VM_BIND, true);
 
-- 
2.34.1


  reply	other threads:[~2025-03-28 12:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-28 12:45 [PATCH i-g-t v1 0/2] Fault variations of tests Jan Sokolowski
2025-03-28 12:45 ` Jan Sokolowski [this message]
2025-03-31  9:49   ` [PATCH i-g-t v1 1/2] tests/xe_eudebug: Implement faultable variations of some testcases Piecielska, Katarzyna
2025-03-28 12:45 ` [PATCH i-g-t v1 2/2] tests/xe_eudebug_online: " Jan Sokolowski
2025-03-29  0:51 ` ✓ Xe.CI.BAT: success for Fault variations of tests Patchwork
2025-03-29  1:05 ` ✓ i915.CI.BAT: " Patchwork
2025-03-29  6:20 ` ✓ i915.CI.Full: " Patchwork
2025-03-29 18:59 ` ✗ Xe.CI.Full: failure " Patchwork
2025-04-06 19:35 ` 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=20250328124555.255036-2-jan.sokolowski@intel.com \
    --to=jan.sokolowski@intel.com \
    --cc=dominik.grzegorzek@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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