From: Riana Tauro <riana.tauro@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: badal.nilawar@intel.com
Subject: [igt-dev] [PATCH i-g-t v2 1/4] tests/xe: Add basic idle residency test
Date: Fri, 30 Jun 2023 12:34:36 +0530 [thread overview]
Message-ID: <20230630070439.621177-2-riana.tauro@intel.com> (raw)
In-Reply-To: <20230630070439.621177-1-riana.tauro@intel.com>
The test reads idle residency within a time interval and
checks if its within the tolerance.
Patch for gtidle properties
https://patchwork.freedesktop.org/series/119262/
v2:
- rename file to xe_pm_residency
- add kernel patch in commit message (Kamil)
v3:
- add igt test description (Anshuman)
v4:
- fix cosmetic review comments
- replace assert with igt_assert_f (Anshuman)
Signed-off-by: Riana Tauro <riana.tauro@intel.com>
Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com>
---
tests/meson.build | 1 +
tests/xe/xe_pm_residency.c | 120 +++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+)
create mode 100644 tests/xe/xe_pm_residency.c
diff --git a/tests/meson.build b/tests/meson.build
index 85ea7e74e..cde4447e4 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -265,6 +265,7 @@ xe_progs = [
'xe_module_load',
'xe_noexec_ping_pong',
'xe_pm',
+ 'xe_pm_residency',
'xe_prime_self_import',
'xe_query',
'xe_vm',
diff --git a/tests/xe/xe_pm_residency.c b/tests/xe/xe_pm_residency.c
new file mode 100644
index 000000000..32333dfb0
--- /dev/null
+++ b/tests/xe/xe_pm_residency.c
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+/**
+ * TEST: Test gtidle properties
+ * Category: Software building block
+ * Sub-category: Power Management
+ * Functionality: GT C States
+ * Test category: functionality test
+ */
+
+#include <limits.h>
+
+#include "igt.h"
+#include "igt_sysfs.h"
+
+#include "xe/xe_query.h"
+
+#define SLEEP_DURATION 3000 /* in milliseconds */
+
+const double tolerance = 0.1;
+
+#define assert_within_epsilon(x, ref, tol) \
+ igt_assert_f((double)(x) <= (1.0 + (tol)) * (double)(ref) && \
+ (double)(x) >= (1.0 - (tol)) * (double)(ref), \
+ "'%s' != '%s' (%f not within +%.1f%%/-%.1f%% tolerance of %f)\n",\
+ #x, #ref, (double)(x), \
+ (tol) * 100.0, (tol) * 100.0, \
+ (double)(ref))
+
+IGT_TEST_DESCRIPTION("Tests for gtidle properties");
+
+static unsigned int measured_usleep(unsigned int usec)
+{
+ struct timespec ts = { };
+ unsigned int slept;
+
+ slept = igt_nsec_elapsed(&ts);
+ igt_assert(slept == 0);
+ do {
+ usleep(usec - slept);
+ slept = igt_nsec_elapsed(&ts) / 1000;
+ } while (slept < usec);
+
+ return igt_nsec_elapsed(&ts) / 1000;
+}
+
+static bool in_gt_c6(int sysfs, int gt)
+{
+ char path[PATH_MAX];
+ char gt_c_state[8];
+
+ sprintf(path, "device/gt%d/gtidle/idle_status", gt);
+ if (igt_sysfs_scanf(sysfs, path, "%s", gt_c_state) < 0)
+ return false;
+
+ return strcmp(gt_c_state, "gt-c6") == 0;
+}
+
+static unsigned long read_idle_residency(int sysfs, int gt)
+{
+ unsigned long residency;
+ char path[PATH_MAX];
+
+ residency = 0;
+ sprintf(path, "device/gt%d/gtidle/idle_residency_ms", gt);
+ igt_assert(igt_sysfs_scanf(sysfs, path, "%lu", &residency) == 1);
+ return residency;
+}
+
+/**
+ * SUBTEST: idle-residency
+ * Description: basic residency test to validate idle residency
+ * within a time interval is within tolerance
+ * Run type: FULL
+ */
+static void test_idle_residency(int sysfs, int gt)
+{
+ unsigned long elapsed_ms, residency_start, residency_end;
+
+ igt_assert_f(igt_wait(in_gt_c6(sysfs, gt), 1000, 1), "GT not in C6\n");
+
+ residency_start = read_idle_residency(sysfs, gt);
+ elapsed_ms = measured_usleep(SLEEP_DURATION * 1000) / 1000;
+ residency_end = read_idle_residency(sysfs, gt);
+
+ igt_info("Measured %lums of idle residency in %lums\n",
+ residency_end - residency_start, elapsed_ms);
+
+ assert_within_epsilon(residency_end - residency_start, elapsed_ms, tolerance);
+}
+
+igt_main
+{
+ int fd, gt;
+ static int sysfs = -1;
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_XE);
+
+ xe_device_get(fd);
+ igt_require(!IS_PONTEVECCHIO(xe_dev_id(fd)));
+
+ sysfs = igt_sysfs_open(fd);
+ igt_assert(sysfs != -1);
+ }
+
+ igt_describe("validate idle residency within a time interval is within tolerance");
+ igt_subtest("idle-residency")
+ xe_for_each_gt(fd, gt)
+ test_idle_residency(sysfs, gt);
+
+ igt_fixture {
+ close(sysfs);
+ xe_device_put(fd);
+ close(fd);
+ }
+}
--
2.40.0
next prev parent reply other threads:[~2023-06-30 7:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-30 7:04 [igt-dev] [PATCH i-g-t v2 0/4] Test for gtidle properties Riana Tauro
2023-06-30 7:04 ` Riana Tauro [this message]
2023-07-10 7:30 ` [igt-dev] [PATCH i-g-t v2 1/4] tests/xe: Add basic idle residency test Ghimiray, Himal Prasad
2023-07-10 7:49 ` Riana Tauro
2023-06-30 7:04 ` [igt-dev] [PATCH i-g-t v2 2/4] tests/xe: validate gt is in c6 on idle Riana Tauro
2023-06-30 7:04 ` [igt-dev] [PATCH i-g-t v2 3/4] xe-fast-feedback.testlist: Remove rc6 tests from BAT Riana Tauro
2023-06-30 7:04 ` [igt-dev] [PATCH i-g-t v2 4/4] tests/xe/xe_guc_pc: Remove rc6 tests Riana Tauro
2023-06-30 9:56 ` [igt-dev] ✗ Fi.CI.BAT: failure for Test for gtidle properties (rev2) Patchwork
2023-06-30 12:05 ` [igt-dev] ✓ Fi.CI.BAT: success for Test for gtidle properties (rev3) Patchwork
2023-07-01 0:09 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-07-06 14:45 ` Tauro, Riana
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=20230630070439.621177-2-riana.tauro@intel.com \
--to=riana.tauro@intel.com \
--cc=badal.nilawar@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