[PATCH i-g-t 2/2] tests/xe_eudebug: Use library helper to enable ccs_mode

Hajda, Andrzej andrzej.hajda at intel.com
Tue Dec 17 09:34:17 UTC 2024


W dniu 16.12.2024 o 14:11, Dominik Grzegorzek pisze:
> igt_require call within ccs_mode_all_enginesi() when
> condition was not met left fd variable uninitialized, what
> caused xe_eudebug_enable in the cleanup fixure to fail like below:
>
> Test assertion failure function enable_getset, file ../lib/xe/xe_eudebug.c:1795:
> (xe_eudebug:23606) xe/xe_eudebug-CRITICAL: Failed assertion: fstat(fd, &st) == 0
> (xe_eudebug:23606) xe/xe_eudebug-CRITICAL: Last errno: 9, Bad file descriptor
> (xe_eudebug:23606) xe/xe_eudebug-CRITICAL: error: -1 != 0
> Stack trace:
>    #0 ../lib/igt_core.c:2051 __igt_fail_assert()
>    #1 ../lib/xe/xe_eudebug.c:1851 xe_eudebug_enable()
>    #2 ../tests/intel/xe_eudebug.c:2870 __igt_unique____real_main2757()
>    #3 ../tests/intel/xe_eudebug.c:2757 main()
>    #4 ../sysdeps/nptl/libc_start_call_main.h:58 __libc_start_call_main()
>    #5 ../csu/libc-start.c:128 __libc_start_main@@GLIBC_2.34()
>
> Fix that by using xe_sysfs_enable_css_mode library function which opens
> drm fd before calling igt_require. As here, move the check outside the
> fixture to simplify code.
>
> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>

Reviewed-by: Andrzej Hajda <andrzej.hajda at intel.com>

Regards
Andrzej

> ---
>   tests/intel/xe_eudebug.c | 38 ++++----------------------------------
>   1 file changed, 4 insertions(+), 34 deletions(-)
>
> diff --git a/tests/intel/xe_eudebug.c b/tests/intel/xe_eudebug.c
> index 22b0da658..c566d0980 100644
> --- a/tests/intel/xe_eudebug.c
> +++ b/tests/intel/xe_eudebug.c
> @@ -26,6 +26,7 @@
>   #include "xe/xe_eudebug.h"
>   #include "xe/xe_ioctl.h"
>   #include "xe/xe_query.h"
> +#include "xe/xe_util.h"
>   
>   /**
>    * SUBTEST: sysfs-toggle
> @@ -2729,31 +2730,6 @@ static void test_basic_exec_queues_enable(int fd)
>   	xe_vm_destroy(fd, vm_non_lr);
>   }
>   
> -static void ccs_mode_all_engines(int num_gt)
> -{
> -	int fd, gt, gt_fd, num_slices, ccs_mode;
> -	int num_gts_with_ccs_mode = 0;
> -
> -	for (gt = 0; gt < num_gt; gt++) {
> -		fd = drm_open_driver(DRIVER_XE);
> -		gt_fd = xe_sysfs_gt_open(fd, gt);
> -		close(fd);
> -
> -		if (igt_sysfs_scanf(gt_fd, "num_cslices", "%u", &num_slices) <= 0)
> -			continue;
> -
> -		num_gts_with_ccs_mode++;
> -
> -		igt_assert(igt_sysfs_printf(gt_fd, "ccs_mode", "%u", num_slices) > 0);
> -		igt_assert(igt_sysfs_scanf(gt_fd, "ccs_mode", "%u", &ccs_mode) > 0);
> -		igt_assert(num_slices == ccs_mode);
> -		close(gt_fd);
> -	}
> -
> -	errno = 0;
> -	igt_require(num_gts_with_ccs_mode > 0);
> -}
> -
>   igt_main
>   {
>   	bool was_enabled;
> @@ -2856,15 +2832,9 @@ igt_main
>   	igt_subtest("discovery-empty-clients")
>   		test_empty_discovery(fd, DISCOVERY_DESTROY_RESOURCES, 16);
>   
> -	igt_subtest_group {
> -		igt_fixture {
> -			drm_close_driver(fd);
> -			ccs_mode_all_engines(gt_count);
> -			fd = drm_open_driver(DRIVER_XE);
> -		}
> -
> -		igt_subtest("exec-queue-placements")
> -			test_basic_sessions(fd, EXEC_QUEUES_PLACEMENTS, 1, true);
> +	igt_subtest("exec-queue-placements") {
> +		xe_sysfs_enable_ccs_mode(&fd);
> +		test_basic_sessions(fd, EXEC_QUEUES_PLACEMENTS, 1, true);
>   	}
>   
>   	igt_fixture {


More information about the igt-dev mailing list