Re: [PATCH v4] tests/intel/xe_pm: add coverage for xe_device_sysfs

Kamil Konieczny <[email protected]>
Newsgroups org.freedesktop.lists.igt-dev
Message-ID <[email protected]>
Hi shivtej.eknath.patil,
On 2026-08-11 at 08:08:31 +0000, [email protected] wrote:
> From: Shivtej Patil <[email protected]>
> 
> Modify xe_pm subtests to exercise the following
> xe_device_sysfs.c functions:
> 
> - 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()

Can you add this to xe_sysfs test instead of xe_pm?



Regards,
Kamil

> 
> 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 |   6 ++
>  tests/intel/xe_pm.c                  | 154 ++++++++++++++++++++++++++-
>  2 files changed, 158 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/intel-ci/xe.pm.d3cold.testlist b/tests/intel-ci/xe.pm.d3cold.testlist
> index 783859fc7..e240fe7fb 100644
> --- a/tests/intel-ci/xe.pm.d3cold.testlist
> +++ b/tests/intel-ci/xe.pm.d3cold.testlist
> @@ -9,3 +9,9 @@ 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
> 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
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.