[PATCH v2] tests/xe_pm: add coverage for xe_device_sysfs Modify xe_pm subtests to exercise the following xe_device_sysfs.c functions:
[email protected] Wed, 29 Jul 2026 07:40:46 +0000
| Newsgroups | org.freedesktop.lists.igt-dev |
|---|---|
| Message-ID | <[email protected]> |
From: Shivtej Patil <[email protected]> - vram_d3cold_threshold_show() - vram_d3cold_threshold_store() - lb_fan_control_version_show() - lb_voltage_regulator_version_show() - auto_link_downgrade_capable_show() - auto_link_downgrade_status_show() The subtests validate the corresponding sysfs attributes and improve code coverage for xe_device_sysfs.c. Signed-off-by: Shivtej Patil <[email protected]> --- tests/intel-ci/xe.pm.d3cold.testlist | 8 +- tests/intel/xe_pm.c | 154 ++++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 3 deletions(-) diff --git a/tests/intel-ci/xe.pm.d3cold.testlist b/tests/intel-ci/xe.pm.d3cold.testlist index 783859fc7..eb1b23ed8 100644 --- a/tests/intel-ci/xe.pm.d3cold.testlist +++ b/tests/intel-ci/xe.pm.d3cold.testlist @@ -8,4 +8,10 @@ igt@xe_pm@d3cold-multiple-execs igt@xe_pm@d3cold-mmap-system igt@xe_pm@d3cold-mmap-vram igt@xe_pm@d3cold-mocs -igt@xe_pm@vram-d3cold-threshold +igt@xe_pm@vram-d3cold-threshold-show +igt@xe_pm@vram-d3cold-threshold-store +igt@xe_pm@lb-fan-control-version-show +igt@xe_pm@lb-voltage-regulator-version-show +igt@xe_pm@auto-link-downgrade-capable-show +igt@xe_pm@auto-link-downgrade-status-show +vram-d3cold-threshold diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c index 6fbc13e43..cf3f1fd22 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,14 +1159,117 @@ int igt_main() igt_describe("Validate whether card is limited to d3hot," "if vram used > vram threshold"); - igt_subtest("vram-d3cold-threshold") { +igt_subtest("vram-d3cold-threshold") { igt_require_f(has_runtime_pm, "Runtime PM not available\n"); orig_threshold = get_vram_d3cold_threshold(sysfs_fd); igt_install_exit_handler(vram_d3cold_threshold_restore); test_vram_d3cold_threshold(device, sysfs_fd); } - igt_fixture() { +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); + /* + * Ensure the original threshold is restored even if + * an assertion fails later in the test. + */ + igt_install_exit_handler(vram_d3cold_threshold_restore); + 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); + + igt_assert(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_fixture() { close(sysfs_fd); igt_pm_set_d3cold_allowed(device.pci_slot_name, d3cold_allowed); if (has_runtime_pm) -- 2.43.0