Skip to contentSkip to conversation

tests/xe: Verify actual frequency on the basis of GT state

PATCH Superseded Badal Nilawar 3 participants 6 messages Jul 19, 2023 – Jul 20, 2023 Library code

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 tests/xe: Verify actual frequency on the basis of GT state

When GT is in RC6 actual frequency reported will be 0. So verify actual on the basic of GT state.

v2:
- Rebased
- Move function xe_is_gt_in_c6, to check rc6 state, to igt_pm library
- Assert if freq reported is not 0 when idle (Ashutosh)
v3:
- Fix review comments (Ashutosh)
v4:
- Move igt_require to igt_main under idle test cases (Ashutosh)
- For idle case wait for C6 instead of usleep (Ashutosh)
v5:
- Remove igt_require from test_freq_range

Fixes acaaca0bf317 ("tests/xe: Add Xe IGT tests")
---
 lib/igt_pm.c               | 20 +++++++++++++++++
 lib/igt_pm.h               |  1 +
 tests/xe/xe_guc_pc.c       | 46 +++++++++++++++++++++++++++++---------
 tests/xe/xe_pm_residency.c | 38 ++++++++++---------------------
 4 files changed, 69 insertions(+), 36 deletions(-)
lib/igt_pm.c +20 -0
index ba591f0f8..ccfa5178b 100644
@@ -1417,3 +1417,23 @@ void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val)
 	igt_require(igt_sysfs_has_attr(gtfd, "slpc_ignore_eff_freq"));
 	igt_sysfs_set_u32(gtfd, "slpc_ignore_eff_freq", val);
 }
+
+/**
+ * xe_is_gt_in_c6:
+ * @fd: pointer to xe drm fd
+ * @gt: gt number
+ *
+ * Check if GT is in C6 state
+ */
+bool xe_is_gt_in_c6(int fd, int gt)
+{
+	char gt_c_state[16];
+	int gt_fd;
+
+	gt_fd = xe_sysfs_gt_open(fd, gt);
+	igt_assert(gt_fd >= 0);
+	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s", gt_c_state) == 1);
+	close(gt_fd);
+
+	return strcmp(gt_c_state, "gt-c6") == 0;
+}
lib/igt_pm.h +1 -0
index 71ec2f239..2fc7b98a1 100644
@@ -89,5 +89,6 @@ bool i915_is_slpc_enabled(int drm_fd);
 int igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev);
 int igt_pm_get_runtime_usage(struct pci_device *pci_dev);
 void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val);
+bool xe_is_gt_in_c6(int fd, int gt);
 
 #endif /* IGT_PM_H */
tests/xe/xe_guc_pc.c +36 -10

105 lines not on this page · raw message

tests/xe/xe_pm_residency.c +12 -26
index a20c4449c..5c4516d03 100644
@@ -28,6 +28,16 @@ const double tolerance = 0.1;
 		     (tol) * 100.0, (tol) * 100.0, \
 		     (double)(ref))
 
+/**
+ * SUBTEST: gt-c6-on-idle
+ * Description: Validate GT C6 state on idle
+ * Run type: BAT
+ *
+ * SUBTEST: idle-residency
+ * Description: basic residency test to validate idle residency
+ *		measured over a time interval is within the tolerance
+ * Run type: FULL
+ */
 IGT_TEST_DESCRIPTION("Tests for gtidle properties");
 
 static unsigned int measured_usleep(unsigned int usec)
@@ -45,24 +55,6 @@ static unsigned int measured_usleep(unsigned int usec)
 	return igt_nsec_elapsed(&ts) / 1000;
 }
 
-/**
- * SUBTEST: gt-c6-on-idle
- * Description: Validate GT C6 state on idle
- * Run type: BAT
- */
-static bool is_gt_in_c6(int fd, int gt)
-{
-	char gt_c_state[16];
-	int gt_fd;
-
-	gt_fd = xe_sysfs_gt_open(fd, gt);
-	igt_assert(gt_fd >= 0);
-	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s", gt_c_state) == 1);
-	close(gt_fd);
-
-	return strcmp(gt_c_state, "gt-c6") == 0;
-}
-
 static unsigned long read_idle_residency(int fd, int gt)
 {
 	unsigned long residency = 0;
@@ -76,17 +68,11 @@ static unsigned long read_idle_residency(int fd, int gt)
 	return residency;
 }
 
-/**
- * SUBTEST: idle-residency
- * Description: basic residency test to validate idle residency
- *		measured over a time interval is within the tolerance
- * Run type: FULL
- */
 static void test_idle_residency(int fd, int gt)
 {
 	unsigned long elapsed_ms, residency_start, residency_end;
 
-	igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
+	igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
 
 	residency_start = read_idle_residency(fd, gt);
 	elapsed_ms = measured_usleep(SLEEP_DURATION * 1000) / 1000;
@@ -110,7 +96,7 @@ igt_main
 	igt_describe("Validate GT C6 on idle");
 	igt_subtest("gt-c6-on-idle")
 		xe_for_each_gt(fd, gt)
-			igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
+			igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
 
 	igt_describe("Validate idle residency measured over a time interval is within the tolerance");
 	igt_subtest("idle-residency")
Signature · 1 line
2.25.1
#1 lore raw

[igt-dev] ○ CI.xeBAT: info for tests/xe: Verify actual frequency on the basis of GT state (rev4)

== Series Details ==

== Series Details ==

Series: tests/xe: Verify actual frequency on the basis of GT state (rev4)
URL : https://patchwork.freedesktop.org/series/120831/
State : info

== Summary ==

Participating hosts:
bat-pvc-2
bat-atsm-2
bat-dg2-oem2
bat-adlp-7
Missing hosts results[0]:
Results: [IGTPW_9433](https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_9433/index.html)

#2 lore raw

[igt-dev] ✗ Fi.CI.BAT: failure for tests/xe: Verify actual frequency on the basis of GT state (rev4)

In reply to Badal Nilawar
== Series Details ==

== Series Details ==

Series: tests/xe: Verify actual frequency on the basis of GT state (rev4)
URL : https://patchwork.freedesktop.org/series/120831/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13396 -> IGTPW_9433
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with IGTPW_9433 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in IGTPW_9433, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/index.html

Participating hosts (42 -> 43)
------------------------------

Additional (2): fi-kbl-soraka bat-rpls-2
Missing (1): fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in IGTPW_9433:

### IGT changes ###

#### Possible regressions ####

* igt@debugfs_test@read_all_entries:
- bat-mtlp-6: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/bat-mtlp-6/igt@debugfs_test@read_all_entries.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-mtlp-6/igt@debugfs_test@read_all_entries.html

Known issues
------------

Here are the changes found in IGTPW_9433 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- bat-rpls-2: NOTRUN -> [SKIP][3] ([i915#7456])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@fbdev@info:
- bat-rpls-2: NOTRUN -> [SKIP][4] ([i915#1849] / [i915#2582])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@fbdev@read:
- bat-rpls-2: NOTRUN -> [SKIP][5] ([i915#2582]) +3 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@gem_huc_copy@huc-copy:
- fi-kbl-soraka: NOTRUN -> [SKIP][6] ([fdo#109271] / [i915#2190])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@basic:
- fi-kbl-soraka: NOTRUN -> [SKIP][7] ([fdo#109271] / [i915#4613]) +3 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-kbl-soraka/igt@[email protected]

* igt@gem_lmem_swapping@verify-random:
- bat-rpls-2: NOTRUN -> [SKIP][8] ([i915#4613]) +3 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@gem_tiled_pread_basic:
- bat-rpls-2: NOTRUN -> [SKIP][9] ([i915#3282])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@gem_tiled_pread_basic.html

* igt@i915_pm_backlight@basic-brightness:
- bat-rpls-2: NOTRUN -> [SKIP][10] ([i915#7561])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@i915_pm_rpm@basic-rte:
- fi-cfl-guc: [PASS][11] -> [FAIL][12] ([i915#7940])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/fi-cfl-guc/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-cfl-guc/igt@[email protected]

* igt@i915_pm_rps@basic-api:
- bat-rpls-2: NOTRUN -> [SKIP][13] ([i915#6621])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@i915_selftest@live@execlists:
- fi-bsw-nick: [PASS][14] -> [ABORT][15] ([i915#7911] / [i915#7913])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/fi-bsw-nick/igt@i915_selftest@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-bsw-nick/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][16] ([i915#5334] / [i915#7872])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html

* igt@i915_selftest@live@gt_pm:
- bat-rpls-2: NOTRUN -> [DMESG-FAIL][17] ([i915#4258] / [i915#7913])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@i915_selftest@live@gt_pm.html
- fi-kbl-soraka: NOTRUN -> [DMESG-FAIL][18] ([i915#1886] / [i915#7913])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-kbl-soraka/igt@i915_selftest@live@gt_pm.html

* igt@i915_selftest@live@requests:
- bat-rpls-2: NOTRUN -> [ABORT][19] ([i915#7913] / [i915#7982])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@i915_selftest@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- fi-kbl-7567u: [PASS][20] -> [INCOMPLETE][21] ([i915#4817])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/fi-kbl-7567u/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-kbl-7567u/igt@[email protected]

* igt@kms_busy@basic:
- bat-rpls-2: NOTRUN -> [SKIP][22] ([i915#1845]) +14 similar issues
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@kms_chamelium_edid@hdmi-edid-read:
- bat-rpls-2: NOTRUN -> [SKIP][23] ([i915#7828]) +7 similar issues
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-kbl-soraka: NOTRUN -> [SKIP][24] ([fdo#109271]) +15 similar issues
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-kbl-soraka/igt@[email protected]

* igt@kms_flip@basic-flip-vs-dpms:
- bat-rpls-2: NOTRUN -> [SKIP][25] ([i915#3637]) +3 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- bat-rpls-2: NOTRUN -> [SKIP][26] ([fdo#109285])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@kms_frontbuffer_tracking@basic:
- bat-rpls-2: NOTRUN -> [SKIP][27] ([i915#1849])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@kms_psr@sprite_plane_onoff:
- bat-rpls-2: NOTRUN -> [SKIP][28] ([i915#1072]) +3 similar issues
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@kms_psr@sprite_plane_onoff.html

* igt@kms_setmode@basic-clone-single-crtc:
- bat-rpls-2: NOTRUN -> [SKIP][29] ([i915#3555])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- bat-rpls-2: NOTRUN -> [SKIP][30] ([fdo#109295] / [i915#1845] / [i915#3708])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

* igt@prime_vgem@basic-write:
- bat-rpls-2: NOTRUN -> [SKIP][31] ([fdo#109295] / [i915#3708]) +2 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-2/igt@[email protected]

#### Possible fixes ####

* igt@core_auth@basic-auth:
- bat-mtlp-6: [DMESG-WARN][32] -> [PASS][33]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/bat-mtlp-6/igt@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-mtlp-6/igt@[email protected]

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-skl-guc: [FAIL][34] ([i915#7940]) -> [PASS][35]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/fi-skl-guc/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-skl-guc/igt@[email protected]

* igt@i915_selftest@live@gt_heartbeat:
- fi-glk-j4005: [DMESG-FAIL][36] ([i915#5334]) -> [PASS][37]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/fi-glk-j4005/igt@i915_selftest@live@gt_heartbeat.html
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-glk-j4005/igt@i915_selftest@live@gt_heartbeat.html

* igt@i915_selftest@live@guc:
- bat-rpls-1: [DMESG-WARN][38] ([i915#7852]) -> [PASS][39]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/bat-rpls-1/igt@i915_selftest@[email protected]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-rpls-1/igt@i915_selftest@[email protected]

#### Warnings ####

* igt@i915_module_load@load:
- bat-adlp-11: [DMESG-WARN][40] ([i915#4423]) -> [ABORT][41] ([i915#4423])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/bat-adlp-11/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/bat-adlp-11/igt@[email protected]

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-cfl-guc: [FAIL][42] ([i915#7691]) -> [FAIL][43] ([i915#7940])
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13396/fi-cfl-guc/igt@[email protected]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/fi-cfl-guc/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#1886]: https://gitlab.freedesktop.org/drm/intel/issues/1886
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4258]: https://gitlab.freedesktop.org/drm/intel/issues/4258
[i915#4423]: https://gitlab.freedesktop.org/drm/intel/issues/4423
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4817]: https://gitlab.freedesktop.org/drm/intel/issues/4817
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7691]: https://gitlab.freedesktop.org/drm/intel/issues/7691
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#7852]: https://gitlab.freedesktop.org/drm/intel/issues/7852
[i915#7872]: https://gitlab.freedesktop.org/drm/intel/issues/7872
[i915#7911]: https://gitlab.freedesktop.org/drm/intel/issues/7911
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#7940]: https://gitlab.freedesktop.org/drm/intel/issues/7940
[i915#7982]: https://gitlab.freedesktop.org/drm/intel/issues/7982

Build changes
-------------

* CI: CI-20190529 -> None
* IGT: IGT_7394 -> IGTPW_9433

CI-20190529: 20190529
CI_DRM_13396: da1bb773ff84001b185e7bec54b32b89dff44f91 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_9433: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/index.html
IGT_7394: 3b0c82d7e9f1b8708d351243de7f227153793ede @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_9433/index.html

#3 lore raw
In reply to Badal Nilawar
Quoted 41 lines

-----Original Message-----
From: Nilawar, Badal <[email protected]>
Sent: Wednesday, July 19, 2023 8:16 PM
To: [email protected]
Cc: Tauro, Riana <[email protected]>; Gupta, Anshuman <[email protected]>; Dixit, Ashutosh <[email protected]>; Belgaumkar, Vinay <[email protected]>
Subject: [PATCH i-g-t v5] tests/xe: Verify actual frequency on the basis of GT state

When GT is in RC6 actual frequency reported will be 0. So verify actual on the basic of GT state.

v2:
- Rebased
- Move function xe_is_gt_in_c6, to check rc6 state, to igt_pm library
- Assert if freq reported is not 0 when idle (Ashutosh)
v3:
- Fix review comments (Ashutosh)
v4:
- Move igt_require to igt_main under idle test cases (Ashutosh)
- For idle case wait for C6 instead of usleep (Ashutosh)
v5:
- Remove igt_require from test_freq_range

Fixes acaaca0bf317 ("tests/xe: Add Xe IGT tests")
---
 lib/igt_pm.c               | 20 +++++++++++++++++
 lib/igt_pm.h               |  1 +
 tests/xe/xe_guc_pc.c       | 46 +++++++++++++++++++++++++++++---------
 tests/xe/xe_pm_residency.c | 38 ++++++++++---------------------
 4 files changed, 69 insertions(+), 36 deletions(-)

lib/igt_pm.c void igt_pm_ignore_slpc_efficient_freq(int i915, · line 1422

Quoted 6 lines
lib/igt_pm.c +3 -0
@@ -1417,3 +1417,23 @@ void igt_pm_ignore_slpc_efficient_freq(int i915,
 int gtfd, bool val)
 	igt_require(igt_sysfs_has_attr(gtfd, "slpc_ignore_eff_freq"));
 	igt_sysfs_set_u32(gtfd, "slpc_ignore_eff_freq", val);  }
+
+/**
+ * xe_is_gt_in_c6:

It should follow the igt_pm naming convention.
Though major concern is around igt_pm library, can we have driver specific functions() ? xe_is_gt_in_c6() is xe specific. @Konieczny, Kamil could you please provide your input.

Thanks,
Anshuman.

Quoted 226 lines
lib/igt_pm.c +13 -0
+ * @fd: pointer to xe drm fd
+ * @gt: gt number
+ *
+ * Check if GT is in C6 state
+ */
+bool xe_is_gt_in_c6(int fd, int gt)
+{
+	char gt_c_state[16];
+	int gt_fd;
+
+	gt_fd = xe_sysfs_gt_open(fd, gt);
+	igt_assert(gt_fd >= 0);
+	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s",

gt_c_state) == 1);

lib/igt_pm.c +3 -0
+	close(gt_fd);
+
+	return strcmp(gt_c_state, "gt-c6") == 0; }
lib/igt_pm.h +0 -0
@@ -89,5 +89,6 @@ bool i915_is_slpc_enabled(int drm_fd);  int

igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev); int igt_pm_get_runtime_usage(struct pci_device *pci_dev); void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val);

lib/igt_pm.h +1 -0
+bool xe_is_gt_in_c6(int fd, int gt);
 
 #endif /* IGT_PM_H */
tests/xe/xe_guc_pc.c index renamed from tests/xe/xe_guc_pc.c +0 -0

c34df8d60..d55790afd 100644

tests/xe/xe_guc_pc.c +1 -1
@@ -218,7 +218,7 @@ static void test_freq_basic_api(int fd, int gt_id)
  * Run type: FULL
  */
 
-static void test_freq_fixed(int fd, int gt_id)
+static void test_freq_fixed(int fd, int gt_id, bool gt_idle)
 {
 	uint32_t rpn = get_freq(fd, gt_id, "rpn");
 	uint32_t rpe = get_freq(fd, gt_id, "rpe"); @@ -235,13 +235,26 @@

static void test_freq_fixed(int fd, int gt_id)

tests/xe/xe_guc_pc.c +3 -1
 	igt_assert(set_freq(fd, gt_id, "max", rpn) > 0);
 	usleep(ACT_FREQ_LATENCY_US);
 	igt_assert(get_freq(fd, gt_id, "cur") == rpn);
-	igt_assert(get_freq(fd, gt_id, "act") == rpn);
+
+	if (gt_idle) {
+		/* Wait for GT to go in C6 as previous get_freq wakes up

GT*/

tests/xe/xe_guc_pc.c +12 -1
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		igt_assert(get_freq(fd, gt_id, "act") == rpn);
+	}
 
 	igt_assert(set_freq(fd, gt_id, "min", rpe) > 0);
 	igt_assert(set_freq(fd, gt_id, "max", rpe) > 0);
 	usleep(ACT_FREQ_LATENCY_US);
 	igt_assert(get_freq(fd, gt_id, "cur") == rpe);
-	igt_assert(get_freq(fd, gt_id, "act") == rpe);
+
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		igt_assert(get_freq(fd, gt_id, "act") == rpe);
+	}
 
 	igt_assert(set_freq(fd, gt_id, "min", rp0) > 0);
 	igt_assert(set_freq(fd, gt_id, "max", rp0) > 0); @@ -253,6 +266,11

@@ static void test_freq_fixed(int fd, int gt_id)

tests/xe/xe_guc_pc.c +6 -1
 	 */
 	igt_assert(get_freq(fd, gt_id, "cur") == rp0);
 
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	}
+
 	igt_debug("Finished testing fixed request\n");  }
@@ -266,7 +284,7 @@ static void test_freq_fixed(int fd, int gt_id)
  * Run type: FULL
  */
 
-static void test_freq_range(int fd, int gt_id)
+static void test_freq_range(int fd, int gt_id, bool gt_idle)
 {
 	uint32_t rpn = get_freq(fd, gt_id, "rpn");
 	uint32_t rpe = get_freq(fd, gt_id, "rpe"); @@ -279,8 +297,14 @@

static void test_freq_range(int fd, int gt_id)

tests/xe/xe_guc_pc.c +8 -2
 	usleep(ACT_FREQ_LATENCY_US);
 	cur = get_freq(fd, gt_id, "cur");
 	igt_assert(rpn <= cur && cur <= rpe);
-	act = get_freq(fd, gt_id, "act");
-	igt_assert(rpn <= act && act <= rpe);
+
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		act = get_freq(fd, gt_id, "act");
+		igt_assert(rpn <= act && act <= rpe);
+	}
 
 	igt_debug("Finished testing range request\n");  } @@ -385,7 +409,8

@@ igt_main

tests/xe/xe_guc_pc.c +1 -1
 	igt_subtest("freq_fixed_idle") {
 		xe_for_each_gt(fd, gt) {
-			test_freq_fixed(fd, gt);
+			igt_require(igt_wait(xe_is_gt_in_c6(fd, gt), 1000,

10));

tests/xe/xe_guc_pc.c +4 -2
+			test_freq_fixed(fd, gt, true);
 		}
 	}
@@ -398,14 +423,15 @@ igt_main
 					igt_debug("Execution Finished\n");
 				}
 			/* While exec in threads above, let's check the freq
 */
-			test_freq_fixed(fd, gt);
+			test_freq_fixed(fd, gt, false);
 			igt_waitchildren();
 		}
 	}
 
 	igt_subtest("freq_range_idle") {
 		xe_for_each_gt(fd, gt) {
-			test_freq_range(fd, gt);
+			igt_require(igt_wait(xe_is_gt_in_c6(fd, gt), 1000,
 10));
+			test_freq_range(fd, gt, true);
 		}
tests/xe/xe_guc_pc.c +1 -1
 	}
@@ -418,7 +444,7 @@ igt_main
 					igt_debug("Execution Finished\n");
 				}
 			/* While exec in threads above, let's check the freq
 */
-			test_freq_range(fd, gt);
+			test_freq_range(fd, gt, false);
 			igt_waitchildren();
 		}
tests/xe/xe_guc_pc.c +0 -0
 	}
tests/xe/xe_pm_residency.c +10 -0
index a20c4449c..5c4516d03 100644
@@ -28,6 +28,16 @@ const double tolerance = 0.1;
 		     (tol) * 100.0, (tol) * 100.0, \
 		     (double)(ref))
 
+/**
+ * SUBTEST: gt-c6-on-idle
+ * Description: Validate GT C6 state on idle
+ * Run type: BAT
+ *
+ * SUBTEST: idle-residency
+ * Description: basic residency test to validate idle residency
+ *		measured over a time interval is within the tolerance
+ * Run type: FULL
+ */
 IGT_TEST_DESCRIPTION("Tests for gtidle properties");
 
 static unsigned int measured_usleep(unsigned int usec) @@ -45,24 +55,6

@@ static unsigned int measured_usleep(unsigned int usec)

tests/xe/xe_pm_residency.c +0 -12
 	return igt_nsec_elapsed(&ts) / 1000;
 }
 
-/**
- * SUBTEST: gt-c6-on-idle
- * Description: Validate GT C6 state on idle
- * Run type: BAT
- */
-static bool is_gt_in_c6(int fd, int gt) -{
-	char gt_c_state[16];
-	int gt_fd;
-
-	gt_fd = xe_sysfs_gt_open(fd, gt);
-	igt_assert(gt_fd >= 0);
-	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s",

gt_c_state) == 1);

tests/xe/xe_pm_residency.c +3 -13
-	close(gt_fd);
-
-	return strcmp(gt_c_state, "gt-c6") == 0;
-}
-
 static unsigned long read_idle_residency(int fd, int gt)  {
 	unsigned long residency = 0;
@@ -76,17 +68,11 @@ static unsigned long read_idle_residency(int fd, int gt)
 	return residency;
 }
 
-/**
- * SUBTEST: idle-residency
- * Description: basic residency test to validate idle residency
- *		measured over a time interval is within the tolerance
- * Run type: FULL
- */
 static void test_idle_residency(int fd, int gt)  {
 	unsigned long elapsed_ms, residency_start, residency_end;
 
-	igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
+	igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1), "GT not in
+C6\n");
 
 	residency_start = read_idle_residency(fd, gt);
 	elapsed_ms = measured_usleep(SLEEP_DURATION * 1000) / 1000;
@@ -110,7 +96,7 @@ igt_main
 	igt_describe("Validate GT C6 on idle");
 	igt_subtest("gt-c6-on-idle")
 		xe_for_each_gt(fd, gt)
-			igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1),
 "GT not in C6\n");
+			igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1),

"GT not in

tests/xe/xe_pm_residency.c +1 -0
+C6\n");
 
 	igt_describe("Validate idle residency measured over a time interval is

within the tolerance");
igt_subtest("idle-residency")
--
2.25.1

#4 lore raw
Quoted 37 lines · Anshuman
Quoted 37 lines

-----Original Message-----
From: Nilawar, Badal <[email protected]>
Sent: Wednesday, July 19, 2023 8:16 PM
To: [email protected]
Cc: Tauro, Riana <[email protected]>; Gupta, Anshuman <[email protected]>; Dixit, Ashutosh <[email protected]>; Belgaumkar, Vinay <[email protected]>
Subject: [PATCH i-g-t v5] tests/xe: Verify actual frequency on the basis of GT state

When GT is in RC6 actual frequency reported will be 0. So verify actual on the basic of GT state.

v2:
- Rebased
- Move function xe_is_gt_in_c6, to check rc6 state, to igt_pm library
- Assert if freq reported is not 0 when idle (Ashutosh)
v3:
- Fix review comments (Ashutosh)
v4:
- Move igt_require to igt_main under idle test cases (Ashutosh)
- For idle case wait for C6 instead of usleep (Ashutosh)
v5:
- Remove igt_require from test_freq_range

Fixes acaaca0bf317 ("tests/xe: Add Xe IGT tests")
---
  lib/igt_pm.c               | 20 +++++++++++++++++
  lib/igt_pm.h               |  1 +
  tests/xe/xe_guc_pc.c       | 46 +++++++++++++++++++++++++++++---------
  tests/xe/xe_pm_residency.c | 38 ++++++++++---------------------
  4 files changed, 69 insertions(+), 36 deletions(-)
Quoted 13 lines

lib/igt_pm.c void igt_pm_ignore_slpc_efficient_freq(int i915, · line 1422

Quoted 10 lines
lib/igt_pm.c +3 -0
@@ -1417,3 +1417,23 @@ void igt_pm_ignore_slpc_efficient_freq(int i915,
 int gtfd, bool val)
  	igt_require(igt_sysfs_has_attr(gtfd, "slpc_ignore_eff_freq"));
  	igt_sysfs_set_u32(gtfd, "slpc_ignore_eff_freq", val);  }
+
+/**
+ * xe_is_gt_in_c6:

It should follow the igt_pm naming convention.
Though major concern is around igt_pm library, can we have driver specific functions() ? xe_is_gt_in_c6() is xe specific. @Konieczny, Kamil could you please provide your input.

I saw some of the i915 functions present in igt_pm lib and there is no saperate lib for i915_pm. With that convetion I added xe pm function to this lib. Otherwise xe_pm lib can be created for above function. Regards,
Badal

Quoted 230 lines

Thanks,
Anshuman.

Quoted 226 lines
lib/igt_pm.c +13 -0
+ * @fd: pointer to xe drm fd
+ * @gt: gt number
+ *
+ * Check if GT is in C6 state
+ */
+bool xe_is_gt_in_c6(int fd, int gt)
+{
+	char gt_c_state[16];
+	int gt_fd;
+
+	gt_fd = xe_sysfs_gt_open(fd, gt);
+	igt_assert(gt_fd >= 0);
+	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s",

gt_c_state) == 1);

lib/igt_pm.c +3 -0
+	close(gt_fd);
+
+	return strcmp(gt_c_state, "gt-c6") == 0; }
lib/igt_pm.h +0 -0
@@ -89,5 +89,6 @@ bool i915_is_slpc_enabled(int drm_fd);  int

igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev); int igt_pm_get_runtime_usage(struct pci_device *pci_dev); void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val);

lib/igt_pm.h +1 -0
+bool xe_is_gt_in_c6(int fd, int gt);
 
  #endif /* IGT_PM_H */
tests/xe/xe_guc_pc.c index renamed from tests/xe/xe_guc_pc.c +0 -0

c34df8d60..d55790afd 100644

tests/xe/xe_guc_pc.c +1 -1
@@ -218,7 +218,7 @@ static void test_freq_basic_api(int fd, int gt_id)
   * Run type: FULL
   */
 
-static void test_freq_fixed(int fd, int gt_id)
+static void test_freq_fixed(int fd, int gt_id, bool gt_idle)
  {
  	uint32_t rpn = get_freq(fd, gt_id, "rpn");
  	uint32_t rpe = get_freq(fd, gt_id, "rpe"); @@ -235,13 +235,26 @@

static void test_freq_fixed(int fd, int gt_id)
igt_assert(set_freq(fd, gt_id, "max", rpn) > 0); usleep(ACT_FREQ_LATENCY_US); igt_assert(get_freq(fd, gt_id, "cur") == rpn);

tests/xe/xe_guc_pc.c +3 -1
-	igt_assert(get_freq(fd, gt_id, "act") == rpn);
+
+	if (gt_idle) {
+		/* Wait for GT to go in C6 as previous get_freq wakes up

GT*/

tests/xe/xe_guc_pc.c +12 -1
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		igt_assert(get_freq(fd, gt_id, "act") == rpn);
+	}
 
  	igt_assert(set_freq(fd, gt_id, "min", rpe) > 0);
  	igt_assert(set_freq(fd, gt_id, "max", rpe) > 0);
  	usleep(ACT_FREQ_LATENCY_US);
  	igt_assert(get_freq(fd, gt_id, "cur") == rpe);
-	igt_assert(get_freq(fd, gt_id, "act") == rpe);
+
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		igt_assert(get_freq(fd, gt_id, "act") == rpe);
+	}
 
  	igt_assert(set_freq(fd, gt_id, "min", rp0) > 0);
  	igt_assert(set_freq(fd, gt_id, "max", rp0) > 0); @@ -253,6 +266,11

@@ static void test_freq_fixed(int fd, int gt_id)
*/
igt_assert(get_freq(fd, gt_id, "cur") == rp0);

tests/xe/xe_guc_pc.c +6 -1
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	}
+
  	igt_debug("Finished testing fixed request\n");  }
@@ -266,7 +284,7 @@ static void test_freq_fixed(int fd, int gt_id)
   * Run type: FULL
   */
 
-static void test_freq_range(int fd, int gt_id)
+static void test_freq_range(int fd, int gt_id, bool gt_idle)
  {
  	uint32_t rpn = get_freq(fd, gt_id, "rpn");
  	uint32_t rpe = get_freq(fd, gt_id, "rpe"); @@ -279,8 +297,14 @@

static void test_freq_range(int fd, int gt_id)
usleep(ACT_FREQ_LATENCY_US);
cur = get_freq(fd, gt_id, "cur");
igt_assert(rpn <= cur && cur <= rpe);

tests/xe/xe_guc_pc.c +8 -2
-	act = get_freq(fd, gt_id, "act");
-	igt_assert(rpn <= act && act <= rpe);
+
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		act = get_freq(fd, gt_id, "act");
+		igt_assert(rpn <= act && act <= rpe);
+	}
 
  	igt_debug("Finished testing range request\n");  } @@ -385,7 +409,8

@@ igt_main

  	igt_subtest("freq_fixed_idle") {
  		xe_for_each_gt(fd, gt) {
tests/xe/xe_guc_pc.c +1 -1
-			test_freq_fixed(fd, gt);
+			igt_require(igt_wait(xe_is_gt_in_c6(fd, gt), 1000,

10));

tests/xe/xe_guc_pc.c +4 -2
+			test_freq_fixed(fd, gt, true);
  		}
  	}
@@ -398,14 +423,15 @@ igt_main
  					igt_debug("Execution Finished\n");
  				}
  			/* While exec in threads above, let's check the freq
 */
-			test_freq_fixed(fd, gt);
+			test_freq_fixed(fd, gt, false);
  			igt_waitchildren();
  		}
  	}
 
  	igt_subtest("freq_range_idle") {
  		xe_for_each_gt(fd, gt) {
-			test_freq_range(fd, gt);
+			igt_require(igt_wait(xe_is_gt_in_c6(fd, gt), 1000,
 10));
+			test_freq_range(fd, gt, true);
  		}
  	}
tests/xe/xe_guc_pc.c +1 -1
@@ -418,7 +444,7 @@ igt_main
  					igt_debug("Execution Finished\n");
  				}
  			/* While exec in threads above, let's check the freq
 */
-			test_freq_range(fd, gt);
+			test_freq_range(fd, gt, false);
  			igt_waitchildren();
  		}
  	}
tests/xe/xe_pm_residency.c +10 -0
index a20c4449c..5c4516d03 100644
@@ -28,6 +28,16 @@ const double tolerance = 0.1;
  		     (tol) * 100.0, (tol) * 100.0, \
  		     (double)(ref))
 
+/**
+ * SUBTEST: gt-c6-on-idle
+ * Description: Validate GT C6 state on idle
+ * Run type: BAT
+ *
+ * SUBTEST: idle-residency
+ * Description: basic residency test to validate idle residency
+ *		measured over a time interval is within the tolerance
+ * Run type: FULL
+ */
  IGT_TEST_DESCRIPTION("Tests for gtidle properties");
 
  static unsigned int measured_usleep(unsigned int usec) @@ -45,24 +55,6

@@ static unsigned int measured_usleep(unsigned int usec)
return igt_nsec_elapsed(&ts) / 1000;
}

tests/xe/xe_pm_residency.c +0 -12
-/**
- * SUBTEST: gt-c6-on-idle
- * Description: Validate GT C6 state on idle
- * Run type: BAT
- */
-static bool is_gt_in_c6(int fd, int gt) -{
-	char gt_c_state[16];
-	int gt_fd;
-
-	gt_fd = xe_sysfs_gt_open(fd, gt);
-	igt_assert(gt_fd >= 0);
-	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s",

gt_c_state) == 1);

tests/xe/xe_pm_residency.c +3 -13
-	close(gt_fd);
-
-	return strcmp(gt_c_state, "gt-c6") == 0;
-}
-
  static unsigned long read_idle_residency(int fd, int gt)  {
  	unsigned long residency = 0;
@@ -76,17 +68,11 @@ static unsigned long read_idle_residency(int fd, int gt)
  	return residency;
  }
 
-/**
- * SUBTEST: idle-residency
- * Description: basic residency test to validate idle residency
- *		measured over a time interval is within the tolerance
- * Run type: FULL
- */
  static void test_idle_residency(int fd, int gt)  {
  	unsigned long elapsed_ms, residency_start, residency_end;
 
-	igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
+	igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1), "GT not in
+C6\n");
 
  	residency_start = read_idle_residency(fd, gt);
  	elapsed_ms = measured_usleep(SLEEP_DURATION * 1000) / 1000;
@@ -110,7 +96,7 @@ igt_main
  	igt_describe("Validate GT C6 on idle");
  	igt_subtest("gt-c6-on-idle")
  		xe_for_each_gt(fd, gt)
-			igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1),
 "GT not in C6\n");
+			igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1),

"GT not in
+C6\n");

igt_describe("Validate idle residency measured over a time interval is
within the tolerance");
igt_subtest("idle-residency")
--
2.25.1

#5 lore raw
Quoted 68 lines

-----Original Message-----
From: Nilawar, Badal <[email protected]>
Sent: Thursday, July 20, 2023 1:37 PM
To: Gupta, Anshuman <[email protected]>; igt- [email protected]; Konieczny, Kamil <[email protected]>
Cc: Tauro, Riana <[email protected]>; Dixit, Ashutosh <[email protected]>; Belgaumkar, Vinay <[email protected]>
Subject: Re: [PATCH i-g-t v5] tests/xe: Verify actual frequency on the basis of GT state

Quoted 28 lines · Anshuman
Quoted 28 lines

-----Original Message-----
From: Nilawar, Badal <[email protected]>
Sent: Wednesday, July 19, 2023 8:16 PM
To: [email protected]
Cc: Tauro, Riana <[email protected]>; Gupta, Anshuman <[email protected]>; Dixit, Ashutosh <[email protected]>; Belgaumkar, Vinay <[email protected]>
Subject: [PATCH i-g-t v5] tests/xe: Verify actual frequency on the basis of GT state

When GT is in RC6 actual frequency reported will be 0. So verify actual on the basic of GT state.

v2:
- Rebased
- Move function xe_is_gt_in_c6, to check rc6 state, to igt_pm library
- Assert if freq reported is not 0 when idle (Ashutosh)
v3:
- Fix review comments (Ashutosh)
v4:
- Move igt_require to igt_main under idle test cases (Ashutosh)
- For idle case wait for C6 instead of usleep (Ashutosh)
v5:
- Remove igt_require from test_freq_range

Quoted 7 lines
Quoted 7 lines
Fixes acaaca0bf317 ("tests/xe: Add Xe IGT tests")
---
  lib/igt_pm.c               | 20 +++++++++++++++++
  lib/igt_pm.h               |  1 +
  tests/xe/xe_guc_pc.c       | 46 +++++++++++++++++++++++++++++------

---

Quoted 16 lines
Quoted 8 lines
  tests/xe/xe_pm_residency.c | 38 ++++++++++---------------------
  4 files changed, 69 insertions(+), 36 deletions(-)
lib/igt_pm.c index ba591f0f8..ccfa5178b renamed from lib/igt_pm.c +0 -0

100644

lib/igt_pm.c void igt_pm_ignore_slpc_efficient_freq(int · line 1422

Quoted 6 lines
lib/igt_pm.c +3 -0
@@ -1417,3 +1417,23 @@ void igt_pm_ignore_slpc_efficient_freq(int
 i915, int gtfd, bool val)
  	igt_require(igt_sysfs_has_attr(gtfd, "slpc_ignore_eff_freq"));
  	igt_sysfs_set_u32(gtfd, "slpc_ignore_eff_freq", val);  }
+
+/**
+ * xe_is_gt_in_c6:

It should follow the igt_pm naming convention.
Though major concern is around igt_pm library, can we have driver specific

Quoted 5 lines

functions() ? xe_is_gt_in_c6() is xe specific.

Quoted 1 line

@Konieczny, Kamil could you please provide your input.

I saw some of the i915 functions present in igt_pm lib and there is no saperate lib for i915_pm. With that convetion I added xe pm function to this lib. Otherwise xe_pm lib can be created for above function.

Move this to lib/xe/xe_util.c ?
Igt_pm.c is a generic pci pm related lib with few exception like slpc and dmc. Thanks,
Anshuman Gupta.

Quoted 235 lines

Regards,
Badal

Quoted 121 lines

Thanks,
Anshuman.

Quoted 118 lines
lib/igt_pm.c +13 -0
+ * @fd: pointer to xe drm fd
+ * @gt: gt number
+ *
+ * Check if GT is in C6 state
+ */
+bool xe_is_gt_in_c6(int fd, int gt)
+{
+	char gt_c_state[16];
+	int gt_fd;
+
+	gt_fd = xe_sysfs_gt_open(fd, gt);
+	igt_assert(gt_fd >= 0);
+	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s",

gt_c_state) == 1);

lib/igt_pm.c +3 -0
+	close(gt_fd);
+
+	return strcmp(gt_c_state, "gt-c6") == 0; }
lib/igt_pm.h index 71ec2f239..2fc7b98a1 renamed from lib/igt_pm.h +0 -0

100644

lib/igt_pm.h +0 -0
@@ -89,5 +89,6 @@ bool i915_is_slpc_enabled(int drm_fd);  int

igt_pm_get_runtime_suspended_time(struct pci_device *pci_dev); int igt_pm_get_runtime_usage(struct pci_device *pci_dev); void igt_pm_ignore_slpc_efficient_freq(int i915, int gtfd, bool val);

lib/igt_pm.h +1 -0
+bool xe_is_gt_in_c6(int fd, int gt);
 
  #endif /* IGT_PM_H */
tests/xe/xe_guc_pc.c index renamed from tests/xe/xe_guc_pc.c +0 -0

c34df8d60..d55790afd 100644

tests/xe/xe_guc_pc.c +1 -1
@@ -218,7 +218,7 @@ static void test_freq_basic_api(int fd, int gt_id)
   * Run type: FULL
   */
 
-static void test_freq_fixed(int fd, int gt_id)
+static void test_freq_fixed(int fd, int gt_id, bool gt_idle)
  {
  	uint32_t rpn = get_freq(fd, gt_id, "rpn");
  	uint32_t rpe = get_freq(fd, gt_id, "rpe"); @@ -235,13 +235,26 @@

static void test_freq_fixed(int fd, int gt_id)
igt_assert(set_freq(fd, gt_id, "max", rpn) > 0); usleep(ACT_FREQ_LATENCY_US); igt_assert(get_freq(fd, gt_id, "cur") == rpn);

tests/xe/xe_guc_pc.c +3 -1
-	igt_assert(get_freq(fd, gt_id, "act") == rpn);
+
+	if (gt_idle) {
+		/* Wait for GT to go in C6 as previous get_freq wakes up

GT*/

tests/xe/xe_guc_pc.c +12 -1
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		igt_assert(get_freq(fd, gt_id, "act") == rpn);
+	}
 
  	igt_assert(set_freq(fd, gt_id, "min", rpe) > 0);
  	igt_assert(set_freq(fd, gt_id, "max", rpe) > 0);
  	usleep(ACT_FREQ_LATENCY_US);
  	igt_assert(get_freq(fd, gt_id, "cur") == rpe);
-	igt_assert(get_freq(fd, gt_id, "act") == rpe);
+
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		igt_assert(get_freq(fd, gt_id, "act") == rpe);
+	}
 
  	igt_assert(set_freq(fd, gt_id, "min", rp0) > 0);
  	igt_assert(set_freq(fd, gt_id, "max", rp0) > 0); @@ -253,6 +266,11

@@ static void test_freq_fixed(int fd, int gt_id)
*/
igt_assert(get_freq(fd, gt_id, "cur") == rp0);

tests/xe/xe_guc_pc.c +6 -1
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	}
+
  	igt_debug("Finished testing fixed request\n");  }
@@ -266,7 +284,7 @@ static void test_freq_fixed(int fd, int gt_id)
   * Run type: FULL
   */
 
-static void test_freq_range(int fd, int gt_id)
+static void test_freq_range(int fd, int gt_id, bool gt_idle)
  {
  	uint32_t rpn = get_freq(fd, gt_id, "rpn");
  	uint32_t rpe = get_freq(fd, gt_id, "rpe"); @@ -279,8 +297,14 @@

static void test_freq_range(int fd, int gt_id)
usleep(ACT_FREQ_LATENCY_US);
cur = get_freq(fd, gt_id, "cur");
igt_assert(rpn <= cur && cur <= rpe);

tests/xe/xe_guc_pc.c +8 -2
-	act = get_freq(fd, gt_id, "act");
-	igt_assert(rpn <= act && act <= rpe);
+
+	if (gt_idle) {
+		igt_assert(igt_wait(xe_is_gt_in_c6(fd, gt_id), 1000, 10));
+		igt_assert(get_freq(fd, gt_id, "act") == 0);
+	} else {
+		act = get_freq(fd, gt_id, "act");
+		igt_assert(rpn <= act && act <= rpe);
+	}
 
  	igt_debug("Finished testing range request\n");  } @@ -385,7 +409,8

@@ igt_main

  	igt_subtest("freq_fixed_idle") {
  		xe_for_each_gt(fd, gt) {
tests/xe/xe_guc_pc.c +1 -1
-			test_freq_fixed(fd, gt);
+			igt_require(igt_wait(xe_is_gt_in_c6(fd, gt), 1000,

10));

tests/xe/xe_guc_pc.c +1 -0
+			test_freq_fixed(fd, gt, true);
  		}
  	}
Quoted 4 lines

tests/xe/xe_guc_pc.c igt_main · line 425

Quoted 4 lines
tests/xe/xe_guc_pc.c +0 -0
@@ -398,14 +423,15 @@ igt_main
  					igt_debug("Execution Finished\n");
  				}
  			/* While exec in threads above, let's check the freq

*/

Quoted 15 lines
Quoted 15 lines
tests/xe/xe_guc_pc.c +3 -2
-			test_freq_fixed(fd, gt);
+			test_freq_fixed(fd, gt, false);
  			igt_waitchildren();
  		}
  	}
 
  	igt_subtest("freq_range_idle") {
  		xe_for_each_gt(fd, gt) {
-			test_freq_range(fd, gt);
+			igt_require(igt_wait(xe_is_gt_in_c6(fd, gt), 1000,
 10));
+			test_freq_range(fd, gt, true);
  		}
  	}
Quoted 4 lines

tests/xe/xe_guc_pc.c igt_main · line 446

Quoted 4 lines
tests/xe/xe_guc_pc.c +0 -0
@@ -418,7 +444,7 @@ igt_main
  					igt_debug("Execution Finished\n");
  				}
  			/* While exec in threads above, let's check the freq

*/

Quoted 43 lines
Quoted 43 lines
tests/xe/xe_guc_pc.c +1 -1
-			test_freq_range(fd, gt);
+			test_freq_range(fd, gt, false);
  			igt_waitchildren();
  		}
  	}
tests/xe/xe_pm_residency.c +11 -12
index a20c4449c..5c4516d03 100644
@@ -28,6 +28,16 @@ const double tolerance = 0.1;
  		     (tol) * 100.0, (tol) * 100.0, \
  		     (double)(ref))
 
+/**
+ * SUBTEST: gt-c6-on-idle
+ * Description: Validate GT C6 state on idle
+ * Run type: BAT
+ *
+ * SUBTEST: idle-residency
+ * Description: basic residency test to validate idle residency
+ *		measured over a time interval is within the tolerance
+ * Run type: FULL
+ */
  IGT_TEST_DESCRIPTION("Tests for gtidle properties");
 
  static unsigned int measured_usleep(unsigned int usec) @@ -45,24
+55,6 @@ static unsigned int measured_usleep(unsigned int usec)
  	return igt_nsec_elapsed(&ts) / 1000;
  }
 
-/**
- * SUBTEST: gt-c6-on-idle
- * Description: Validate GT C6 state on idle
- * Run type: BAT
- */
-static bool is_gt_in_c6(int fd, int gt) -{
-	char gt_c_state[16];
-	int gt_fd;
-
-	gt_fd = xe_sysfs_gt_open(fd, gt);
-	igt_assert(gt_fd >= 0);
-	igt_assert(igt_sysfs_scanf(gt_fd, "gtidle/idle_status", "%s",

gt_c_state) == 1);

Quoted 8 lines

tests/xe/xe_pm_residency.c static unsigned long read_idle_residency(int fd, int

Quoted 8 lines
tests/xe/xe_pm_residency.c +0 -5
-	close(gt_fd);
-
-	return strcmp(gt_c_state, "gt-c6") == 0;
-}
-
  static unsigned long read_idle_residency(int fd, int gt)  {
  	unsigned long residency = 0;
@@ -76,17 +68,11 @@ static unsigned long read_idle_residency(int fd, int

gt)

Quoted 12 lines
Quoted 12 lines
tests/xe/xe_pm_residency.c +0 -6
  	return residency;
  }
 
-/**
- * SUBTEST: idle-residency
- * Description: basic residency test to validate idle residency
- *		measured over a time interval is within the tolerance
- * Run type: FULL
- */
  static void test_idle_residency(int fd, int gt)  {
  	unsigned long elapsed_ms, residency_start, residency_end;
 
Quoted 6 lines

tests/xe/xe_pm_residency.c static unsigned long read_idle_residency(int fd, int gt) · line 78

Quoted 6 lines
tests/xe/xe_pm_residency.c +2 -1
-	igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1), "GT not in C6\n");
+	igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1), "GT not in
+C6\n");
 
  	residency_start = read_idle_residency(fd, gt);
  	elapsed_ms = measured_usleep(SLEEP_DURATION * 1000) / 1000;

@@

Quoted 16 lines
Quoted 15 lines
tests/xe/xe_pm_residency.c +0 -1
-110,7 +96,7 @@ igt_main
  	igt_describe("Validate GT C6 on idle");
  	igt_subtest("gt-c6-on-idle")
  		xe_for_each_gt(fd, gt)
tests/xe/xe_pm_residency.c +0 -1
-			igt_assert_f(igt_wait(is_gt_in_c6(fd, gt), 1000, 1),

"GT not in C6\n");

tests/xe/xe_pm_residency.c +1 -0
+			igt_assert_f(igt_wait(xe_is_gt_in_c6(fd, gt), 1000, 1),

"GT not in
+C6\n");

igt_describe("Validate idle residency measured over a time
interval is within the tolerance");
igt_subtest("idle-residency")
--
2.25.1