Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maciej Patelczyk <maciej.patelczyk@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Maciej Patelczyk <maciej.patelczyk@intel.com>,
	Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Subject: [PATCH i-g-t] tests/xe_eudebug_online: correct calculate the time diff
Date: Fri, 10 Jan 2025 16:34:55 +0100	[thread overview]
Message-ID: <20250110153455.2791158-1-maciej.patelczyk@intel.com> (raw)

When calculating time difference between two timespec values use
library function which does it right.

Previous way wasn't working well on slower machines. It was only
taking the tv_nsec field from struct timespec.

Fixes: bbf1730baf ("tests/xe_eudebug_online: Debug client which
                    runs workloads on EU")
CC: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
---
 tests/intel/xe_eudebug_online.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/intel/xe_eudebug_online.c b/tests/intel/xe_eudebug_online.c
index 052774a3b..f532387af 100644
--- a/tests/intel/xe_eudebug_online.c
+++ b/tests/intel/xe_eudebug_online.c
@@ -2235,6 +2235,11 @@ static int find_suitable_engines(struct drm_xe_engine_class_instance **hwes,
 	return engine_count;
 }
 
+static uint64_t timespecs_diff_us(struct timespec *ts1, struct timespec *ts2)
+{
+	return (uint64_t)(fabs(igt_time_elapsed(ts1, ts2)) * USEC_PER_SEC);
+}
+
 /**
  * SUBTEST: breakpoint-many-sessions-single-tile
  * Description:
@@ -2255,7 +2260,7 @@ static void test_many_sessions_on_tiles(int fd, bool multi_tile)
 	struct online_debug_data **data;
 	struct drm_xe_engine_class_instance **hwe;
 	struct drm_xe_eudebug_event_eu_attention *eus;
-	uint64_t current_t, next_t, diff;
+	uint64_t diff;
 	int attempt_mask = 0, final_mask, should_break;
 	int i;
 
@@ -2318,10 +2323,8 @@ static void test_many_sessions_on_tiles(int fd, bool multi_tile)
 	igt_assert_eq(attempt_mask, final_mask);
 
 	for (i = 0; i < n - 1; i++) {
-		/* Convert timestamps to microseconds */
-		current_t = data[i]->exception_arrived.tv_nsec * 1000;
-		next_t = data[i + 1]->exception_arrived.tv_nsec * 1000;
-		diff = current_t < next_t ? next_t - current_t : current_t - next_t;
+		diff = timespecs_diff_us(&data[i]->exception_arrived,
+					 &data[i + 1]->exception_arrived);
 
 		if (multi_tile)
 			igt_assert_f(diff < WORKLOAD_DELAY_US,
-- 
2.43.0


             reply	other threads:[~2025-01-10 15:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10 15:34 Maciej Patelczyk [this message]
2025-01-10 18:20 ` ✓ i915.CI.BAT: success for tests/xe_eudebug_online: correct calculate the time diff Patchwork
2025-01-10 18:23 ` ✓ Xe.CI.BAT: " Patchwork
2025-01-13  8:26 ` [PATCH i-g-t] " Hajda, Andrzej
2025-01-13  8:47   ` Maciej Patelczyk
2025-01-14 20:48 ` ✗ i915.CI.Full: failure for " 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=20250110153455.2791158-1-maciej.patelczyk@intel.com \
    --to=maciej.patelczyk@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