Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Welty <brian.welty@intel.com>
To: igt-dev@lists.freedesktop.org, Pallavi Mishra <pallavi.mishra@intel.com>
Subject: [igt-dev] [PATCH i-g-t v2 1/2] lib/xe_ioctl: Add __xe_wait_ufence()
Date: Mon,  4 Dec 2023 11:43:05 -0800	[thread overview]
Message-ID: <20231204194306.12950-2-brian.welty@intel.com> (raw)
In-Reply-To: <20231204194306.12950-1-brian.welty@intel.com>

xe_wait_ufence is expected to fail if GPU hangs or is reset. We need
a version of calling XE_WAIT_USER_FENCE without the assertion that it
won't expire (timeout), for use with IGTs that intentionally cause
hangs or reset.

Signed-off-by: Brian Welty <brian.welty@intel.com>
---
 lib/xe/xe_ioctl.c | 24 ++++++++++++++++++------
 lib/xe/xe_ioctl.h |  3 +++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index a5fe7dd792..36c3bd2f39 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -446,9 +446,9 @@ void xe_exec_wait(int fd, uint32_t exec_queue, uint64_t addr)
 	syncobj_destroy(fd, sync.handle);
 }
 
-int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
-		       struct drm_xe_engine_class_instance *eci,
-		       int64_t timeout)
+int __xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
+		     struct drm_xe_engine_class_instance *eci,
+		     int64_t *timeout)
 {
 	struct drm_xe_wait_user_fence wait = {
 		.addr = to_user_pointer(addr),
@@ -456,14 +456,26 @@ int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
 		.flags = !eci ? DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP : 0,
 		.value = value,
 		.mask = DRM_XE_UFENCE_WAIT_MASK_U64,
-		.timeout = timeout,
 		.num_engines = eci ? 1 :0,
 		.instances = eci ? to_user_pointer(eci) : 0,
 	};
 
-	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_WAIT_USER_FENCE, &wait), 0);
+	igt_assert(timeout);
+	wait.timeout = *timeout;
+
+	if (igt_ioctl(fd, DRM_IOCTL_XE_WAIT_USER_FENCE, &wait))
+		return -errno;
 
-	return wait.timeout;
+	*timeout = wait.timeout;
+	return 0;
+}
+
+int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
+		       struct drm_xe_engine_class_instance *eci,
+		       int64_t timeout)
+{
+	igt_assert_eq(__xe_wait_ufence(fd, addr, value, eci, &timeout), 0);
+	return timeout;
 }
 
 /**
diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h
index 6d91d3e8e6..0ecc04baf4 100644
--- a/lib/xe/xe_ioctl.h
+++ b/lib/xe/xe_ioctl.h
@@ -88,6 +88,9 @@ void xe_exec(int fd, struct drm_xe_exec *exec);
 void xe_exec_sync(int fd, uint32_t exec_queue, uint64_t addr,
 		  struct drm_xe_sync *sync, uint32_t num_syncs);
 void xe_exec_wait(int fd, uint32_t exec_queue, uint64_t addr);
+int __xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
+		     struct drm_xe_engine_class_instance *eci,
+		     int64_t *timeout);
 int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
 		       struct drm_xe_engine_class_instance *eci,
 		       int64_t timeout);
-- 
2.38.0

  reply	other threads:[~2023-12-04 19:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04 19:43 [igt-dev] [PATCH i-g-t v2 0/2] Fix xe_exec_reset@cm-gt-reset Brian Welty
2023-12-04 19:43 ` Brian Welty [this message]
2023-12-04 20:38   ` [igt-dev] [PATCH i-g-t v2 1/2] lib/xe_ioctl: Add __xe_wait_ufence() Kamil Konieczny
2023-12-05 19:21     ` Welty, Brian
2023-12-06 18:02       ` Kamil Konieczny
2023-12-04 19:43 ` [igt-dev] [PATCH i-g-t v2 2/2] tests/intel/xe_exec_reset: Fix cm-gt-reset Brian Welty
2023-12-04 20:38   ` Mishra, Pallavi
2023-12-04 20:40   ` Kamil Konieczny
2023-12-04 21:12 ` [igt-dev] ✓ CI.xeBAT: success for Fix xe_exec_reset@cm-gt-reset (rev2) Patchwork
2023-12-04 21:19 ` [igt-dev] ✓ Fi.CI.BAT: " Patchwork
2023-12-05  3:08 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-12-05 19:51 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Fix xe_exec_reset@cm-gt-reset (rev3) 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=20231204194306.12950-2-brian.welty@intel.com \
    --to=brian.welty@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=pallavi.mishra@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