Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 4/4] tests/xe_waitfence: Add abstime subtest for user fence
Date: Fri,  2 Jun 2023 18:20:11 +0200	[thread overview]
Message-ID: <20230602162011.90097-5-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20230602162011.90097-1-zbigniew.kempczynski@intel.com>

Start testing timeout passed as absolute time.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 tests/xe/xe_waitfence.c | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/tests/xe/xe_waitfence.c b/tests/xe/xe_waitfence.c
index 390d9b3221..8979a9c2d0 100644
--- a/tests/xe/xe_waitfence.c
+++ b/tests/xe/xe_waitfence.c
@@ -37,12 +37,23 @@ static void do_bind(int fd, uint32_t vm, uint32_t bo, uint64_t offset,
 	xe_vm_bind(fd, vm, bo, offset, addr, size, sync, 1);
 }
 
+#define MS_TO_NS(ms) (((long)ms) * 1000000)
+enum waittype {
+	RELTIME,
+	ABSTIME,
+};
+
 /**
  * SUBTEST: reltime
- * Description: Check basic waitfences functionality
+ * Description: Check basic waitfences functionality with timeout
+ *              as relative timeout in nanoseconds
+ *
+ * SUBTEST: abstime
+ * Description: Check basic waitfences functionality with timeout
+ *              passed as absolute time in nanoseconds
  */
 static void
-waitfence(int fd)
+waitfence(int fd, enum waittype wt)
 {
 	uint32_t bo_1;
 	uint32_t bo_2;
@@ -51,6 +62,7 @@ waitfence(int fd)
 	uint32_t bo_5;
 	uint32_t bo_6;
 	uint32_t bo_7;
+	long timeout;
 
 	uint32_t vm = xe_vm_create(fd, 0, 0);
 	bo_1 = xe_bo_create_flags(fd, vm, 0x40000, MY_FLAG);
@@ -67,7 +79,23 @@ waitfence(int fd)
 	do_bind(fd, vm, bo_6, 0, 0xc0040000, 0x1c0000, 6);
 	bo_7 = xe_bo_create_flags(fd, vm, 0x10000, MY_FLAG);
 	do_bind(fd, vm, bo_7, 0, 0xeffff0000, 0x10000, 7);
-	xe_wait_ufence(fd, &wait_fence, 7, NULL, 2000);
+
+	if (wt == RELTIME) {
+		timeout = xe_wait_ufence(fd, &wait_fence, 7, NULL, MS_TO_NS(10));
+		igt_debug("wait type: RELTIME - timeout: %ld, timeout left: %ld\n",
+			  MS_TO_NS(10), timeout);
+	} else {
+		struct timespec ts;
+		long current, signalled;
+
+		clock_gettime(CLOCK_MONOTONIC, &ts);
+		current = ts.tv_sec * 1e9 + ts.tv_nsec;
+		timeout = current + MS_TO_NS(10);
+		signalled = xe_wait_ufence_abstime(fd, &wait_fence, 7, NULL, timeout);
+		igt_debug("wait type: ABSTIME - timeout: %ld, signalled: %ld, elapsed: %ld\n",
+			  timeout, signalled, signalled - current);
+	}
+
 	xe_vm_unbind_sync(fd, vm, 0, 0x200000, 0x40000);
 	xe_vm_unbind_sync(fd, vm, 0, 0xc0000000, 0x40000);
 	xe_vm_unbind_sync(fd, vm, 0, 0x180000000, 0x40000);
@@ -94,7 +122,10 @@ igt_main
 	}
 
 	igt_subtest("reltime")
-		waitfence(fd);
+		waitfence(fd, RELTIME);
+
+	igt_subtest("abstime")
+		waitfence(fd, ABSTIME);
 
 	igt_fixture {
 		xe_device_put(fd);
-- 
2.34.1

  parent reply	other threads:[~2023-06-02 16:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 16:20 [igt-dev] [PATCH i-g-t v2 0/4] Add absolute user fence timeout Zbigniew Kempczyński
2023-06-02 16:20 ` [igt-dev] [PATCH i-g-t v2 1/4] lib/xe_ioctl: Add xe_wait_ufence_abstime() helper Zbigniew Kempczyński
2023-06-14  9:30   ` Kamil Konieczny
2023-06-02 16:20 ` [igt-dev] [PATCH i-g-t v2 2/4] lib/xe_ioctl: Return remaining timeout of user fence wait Zbigniew Kempczyński
2023-06-14 10:34   ` Kamil Konieczny
2023-06-19  4:58     ` Zbigniew Kempczyński
2023-06-02 16:20 ` [igt-dev] [PATCH i-g-t v2 3/4] tests/xe_waitfence: Rename vague subtest name "test" to reltime Zbigniew Kempczyński
2023-06-14 10:35   ` Kamil Konieczny
2023-06-02 16:20 ` Zbigniew Kempczyński [this message]
2023-06-14 10:40   ` [igt-dev] [PATCH i-g-t v2 4/4] tests/xe_waitfence: Add abstime subtest for user fence Kamil Konieczny
2023-06-02 19:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Add absolute user fence timeout (rev2) Patchwork
2023-06-05  5:23 ` [igt-dev] ✓ 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=20230602162011.90097-5-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@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