[PATCH] tests/xe_pm: add sysfs coverage subtests

[email protected] Wed, 29 Jul 2026 06:30:11 +0000
Newsgroups org.freedesktop.lists.igt-dev
Message-ID <[email protected]>
From: "Patil, Shivtej Eknath" <[email protected]>

Signed-off-by: Patil, Shivtej Eknath <[email protected]>
---
 tests/intel/xe_pm.c | 156 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 156 insertions(+)

diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c
index 6fbc13e43..51830bffe 100644
--- a/tests/intel/xe_pm.c
+++ b/tests/intel/xe_pm.c
@@ -141,6 +141,11 @@ static void set_vram_d3cold_threshold(int sysfs, uint64_t threshold)
 	igt_assert_lt(0, ret);
 }
 
+static bool sysfs_exists(int sysfs_fd, const char *path)
+{
+    return !faccessat(sysfs_fd, path, R_OK, 0);
+}
+
 static void vram_d3cold_threshold_restore(int sig)
 {
 	int fd, sysfs_fd;
@@ -620,6 +625,48 @@ test_exec(device_t device, int n_exec_queues, int n_execs,
 	active_threads = 0;
 }
 
+/**
+ * SUBTEST: vram-d3cold-threshold-show
+ * Description:
+ *      Validate reading of vram_d3cold_threshold sysfs entry.
+ * Functionality: pm-d3cold
+ */
+
+/**
+ * SUBTEST: vram-d3cold-threshold-store
+ * Description:
+ *      Validate writing and reading back vram_d3cold_threshold sysfs entry.
+ * Functionality: pm-d3cold
+ */
+
+/**
+ * SUBTEST: lb-fan-control-version-show
+ * Description:
+ *      Validate reading lb_fan_control_version sysfs entry.
+ * Functionality: pm-sysfs
+ */
+
+/**
+ * SUBTEST: lb-voltage-regulator-version-show
+ * Description:
+ *      Validate reading lb_voltage_regulator_version sysfs entry.
+ * Functionality: pm-sysfs
+ */
+
+/**
+ * SUBTEST: auto-link-downgrade-capable-show
+ * Description:
+ *      Validate reading auto_link_downgrade_capable sysfs entry.
+ * Functionality: pm-sysfs
+ */
+
+/**
+ * SUBTEST: auto-link-downgrade-status-show
+ * Description:
+ *      Validate reading auto_link_downgrade_status sysfs entry.
+ * Functionality: pm-sysfs
+ */
+
 /**
  * SUBTEST: vram-d3cold-threshold
  * Functionality: pm - d3cold
@@ -1112,6 +1159,115 @@ int igt_main()
 
 	igt_describe("Validate whether card is limited to d3hot,"
 		     "if vram used > vram threshold");
+
+	igt_subtest("vram-d3cold-threshold-show")
+{
+    uint64_t threshold;
+
+    igt_require(sysfs_exists(sysfs_fd,
+                 "device/vram_d3cold_threshold"));
+
+    threshold = get_vram_d3cold_threshold(sysfs_fd);
+
+    igt_info("threshold=%"PRIu64"\n", threshold);
+}
+
+igt_subtest("vram-d3cold-threshold-store")
+{
+    uint64_t old_val;
+    uint64_t new_val;
+
+    igt_require(sysfs_exists(sysfs_fd,
+                 "device/vram_d3cold_threshold"));
+
+    old_val = get_vram_d3cold_threshold(sysfs_fd);
+
+    set_vram_d3cold_threshold(sysfs_fd, old_val + 1);
+
+    new_val = get_vram_d3cold_threshold(sysfs_fd);
+
+    igt_assert_eq(new_val, old_val + 1);
+
+    /* restore */
+    set_vram_d3cold_threshold(sysfs_fd, old_val);
+    igt_info("old=%"PRIu64" new=%"PRIu64"\n",
+         old_val, new_val);
+}
+
+igt_subtest("lb-fan-control-version-show")
+{
+    char version[64];
+    int ret;
+
+    igt_require(sysfs_exists(sysfs_fd,
+                 "device/lb_fan_control_version"));
+
+    ret = igt_sysfs_scanf(sysfs_fd,
+                  "device/lb_fan_control_version",
+                  "%63s",
+                  version);
+
+    igt_assert(ret > 0);
+
+    igt_info("lb-fan-control-version=%s\n", version);
+}
+
+igt_subtest("lb-voltage-regulator-version-show")
+{
+    char version[64] = {};
+    int ret;
+
+    igt_require(sysfs_exists(sysfs_fd,
+                 "device/lb_voltage_regulator_version"));
+
+    ret = igt_sysfs_scanf(sysfs_fd,
+                  "device/lb_voltage_regulator_version",
+                  "%63s",
+                  version);
+	
+    igt_info("ret=%d errno=%d version='%s'\n",
+         ret, errno, version);
+
+    if (ret > 0)
+        igt_info("lb-voltage-regulator-version=%s\n", version);
+}
+
+igt_subtest("auto-link-downgrade-capable-show")
+{
+    int val;
+    int ret;
+
+    igt_require(sysfs_exists(sysfs_fd,
+                 "device/auto_link_downgrade_capable"));
+
+    ret = igt_sysfs_scanf(sysfs_fd,
+                  "device/auto_link_downgrade_capable",
+                  "%d",
+                  &val);
+
+    igt_assert(ret > 0);
+    igt_assert(val == 0 || val == 1);
+    igt_info("auto-link-downgrade-capable=%d\n", val);
+}
+
+igt_subtest("auto-link-downgrade-status-show")
+{
+    int val;
+    int ret;
+
+    igt_require(sysfs_exists(sysfs_fd,
+                 "device/auto_link_downgrade_status"));
+
+    ret = igt_sysfs_scanf(sysfs_fd,
+                  "device/auto_link_downgrade_status",
+                  "%d",
+                  &val);
+
+    igt_assert(ret > 0);
+    igt_assert(val == 0 || val == 1);
+    igt_info("auto-link-downgrade-status=%d\n", val);
+}
+
 	igt_subtest("vram-d3cold-threshold") {
 		igt_require_f(has_runtime_pm, "Runtime PM not available\n");
 		orig_threshold = get_vram_d3cold_threshold(sysfs_fd);
-- 
2.53.0