public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v3] tests/intel/xe_pm_residency: Fix suspend duration calculation
@ 2026-03-31 10:38 Sk Anirban
  2026-03-31 14:15 ` ✓ Xe.CI.BAT: success for tests/intel/xe_pm_residency: Fix suspend duration calculation (rev3) Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sk Anirban @ 2026-03-31 10:38 UTC (permalink / raw)
  To: igt-dev
  Cc: anshuman.gupta, badal.nilawar, riana.tauro, karthik.poosa,
	raag.jadav, soham.purkait, mallesh.koujalagi, ville.syrjala,
	jani.nikula, Sk Anirban

Calculate actual suspend duration using CLOCK_BOOTTIME instead of
relying on the autoresume delay approximation. This ensures accurate
validation of idle residency measurements during suspend cycles.

v2: Use CLOCK_BOOTTIME (Ville)
    Use Fixes (Jani)
v3: Use igt_time_elapsed (Riana)
    Remove check (Riana)

Fixes: 5c85b336f75b ("tests/xe: Add a test that validates residency during s2idle")
Signed-off-by: Sk Anirban <sk.anirban@intel.com>
---
 tests/intel/xe_pm_residency.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/tests/intel/xe_pm_residency.c b/tests/intel/xe_pm_residency.c
index 61b63ed4f..70dcf432e 100644
--- a/tests/intel/xe_pm_residency.c
+++ b/tests/intel/xe_pm_residency.c
@@ -215,18 +215,18 @@ static unsigned long read_idle_residency(int fd, int gt)
 static void test_idle_residency(int fd, int gt, enum test_type flag)
 {
 	unsigned long elapsed_ms, residency_start, residency_end;
+	struct timespec ts_start, ts_end;
 
 	igt_assert_f(igt_wait(xe_gt_is_in_c6(fd, gt), 1000, 1), "GT %d not in C6\n", gt);
 
 	if (flag == TEST_S2IDLE) {
-		/*
-		 * elapsed time during suspend is approximately equal to autoresume delay
-		 * when a full suspend cycle(SUSPEND_TEST_NONE) is used.
-		 */
-		elapsed_ms = igt_get_autoresume_delay(SUSPEND_STATE_FREEZE);
+		clock_gettime(CLOCK_BOOTTIME, &ts_start);
 		residency_start = read_idle_residency(fd, gt);
 		igt_system_suspend_autoresume(SUSPEND_STATE_FREEZE, SUSPEND_TEST_NONE);
 		residency_end = read_idle_residency(fd, gt);
+		clock_gettime(CLOCK_BOOTTIME, &ts_end);
+
+		elapsed_ms = igt_time_elapsed(&ts_start, &ts_end) * 1000;
 	}
 
 	if (flag == TEST_IDLE) {
@@ -238,14 +238,6 @@ static void test_idle_residency(int fd, int gt, enum test_type flag)
 	igt_info("Measured %lums of idle residency in %lums\n",
 		 residency_end - residency_start, elapsed_ms);
 
-	/*
-	 * When suspended (system or runtime suspend), device needs to be woken up to read
-	 * residency. Idle residency may increase during resume thus being greater than
-	 * elapsed ms.
-	 */
-	if ((residency_end - residency_start) >= elapsed_ms)
-		return;
-
 	assert_within_epsilon(residency_end - residency_start, elapsed_ms, tolerance);
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-02  6:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 10:38 [PATCH v3] tests/intel/xe_pm_residency: Fix suspend duration calculation Sk Anirban
2026-03-31 14:15 ` ✓ Xe.CI.BAT: success for tests/intel/xe_pm_residency: Fix suspend duration calculation (rev3) Patchwork
2026-03-31 14:34 ` ✓ i915.CI.BAT: " Patchwork
2026-03-31 18:15 ` ✓ Xe.CI.FULL: " Patchwork
2026-04-01  4:42 ` ✗ i915.CI.Full: failure " Patchwork
2026-04-02  6:42 ` [PATCH v3] tests/intel/xe_pm_residency: Fix suspend duration calculation Tauro, Riana

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox