[PATCH i-g-t] lib/igt_sysfs: Multi-Tile support in IGT

Matt Roper matthew.d.roper at intel.com
Wed Jan 22 15:56:52 UTC 2025


On Wed, Jan 22, 2025 at 03:00:51PM +0000, nishit.sharma at intel.com wrote:
> From: Nishit Sharma <nishit.sharma at intel.com>
> 
> Added functionality in xe_sysfs_gt_path() function to get Tile ID
> in multi-tile platforms. Added IGT test tests/intel/xe_multi_tile
> to verify Tile IDs and GT IDs
> 
> Signed-off-by: Nishit Sharma <nishit.sharma at intel.com>
> ---
>  lib/igt_sysfs.c             |   3 +-
>  tests/intel/xe_multi_tile.c | 109 ++++++++++++++++++++++++++++++++++++
>  tests/meson.build           |   1 +
>  3 files changed, 112 insertions(+), 1 deletion(-)
>  create mode 100644 tests/intel/xe_multi_tile.c
> 
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 00d5822fd..37f1716e2 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -234,7 +234,8 @@ char *xe_sysfs_gt_path(int xe_device, int gt, char *path, int pathlen)
>  
>  	if (IS_PONTEVECCHIO(intel_get_drm_devid(xe_device)))
>  		snprintf(path, pathlen, "/sys/dev/char/%d:%d/device/tile%d/gt%d",
> -			 major(st.st_rdev), minor(st.st_rdev), gt, gt);
> +			 major(st.st_rdev), minor(st.st_rdev),
> +			 xe_gt_get_tile_id(xe_device, gt), gt);
>  	else
>  		snprintf(path, pathlen, "/sys/dev/char/%d:%d/device/tile0/gt%d",
>  			 major(st.st_rdev), minor(st.st_rdev), gt);
> diff --git a/tests/intel/xe_multi_tile.c b/tests/intel/xe_multi_tile.c
> new file mode 100644
> index 000000000..222da9389
> --- /dev/null
> +++ b/tests/intel/xe_multi_tile.c
> @@ -0,0 +1,109 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2023 Intel Corporation

Typo?  We're in 2025 now, not 2023.

> + *
> + * Authors:
> + *      Nishit Sharma <nishit.sharma at intel.com>
> + */
> +
> +#include <dirent.h>
> +#include <fcntl.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
> +#include "igt.h"
> +#include "igt_sysfs.h"
> +#include "xe_drm.h"
> +#include "xe/xe_query.h"
> +
> +/**
> + * TEST: Test to get tile_id by iterating gt on xe
> + * Category: Core
> + * Mega feature: General Core features
> + * Sub-category: mapping tile/s with slices available

What does "with slices" mean?  Slices are a different hardware concept
inside the GT that we're not doing anything with here.

Actually, it doesn't seem like this IGT test is actually testing
anything multi-tile related.  The first subtest is just printing debug
output and doesn't have any checks (i.e., it can never fail).  The
second test doesn't appear to be related to multi-tile since it's just
iterating over GTs, independent of whatever tiles are present in the
system.

It would be more useful if the IGT test was actually checking the
behavior of the UAPI to make sure it's returning sane values.  E.g.,
E.g., we could check stuff like:

 * all GTs belonging to the same tile must have different types
 * we aren't "missing" any tiles (e.g., if the uapi reports GTs
   associated with tile0 and tile2, where was tile1?)
 * ...etc...*
 

Matt

> + * Functionality: gt operation
> + */
> +
> +/**
> + * SUBTEST: show-tile
> + * SUBTEST: gt-configuration
> + * Description: Test prints the tile_ids and gt_ids available in GPU
> + * Test category: functionality test
> + *
> + */
> +static void engine_test_defaults(int xe, int engine, const char **property,
> +				 uint16_t class, int gt)
> +{
> +	struct dirent *de;
> +	uint64_t property_value;
> +	int defaults;
> +	DIR *dir;
> +
> +	defaults = openat(engine, ".defaults", O_DIRECTORY);
> +	igt_require(defaults != -1);
> +
> +	dir = fdopendir(engine);
> +	while ((de = readdir(dir))) {
> +		if (*de->d_name == '.')
> +			continue;
> +
> +		igt_debug("Checking attr '%s'\n", de->d_name);
> +
> +		igt_assert_f(__igt_sysfs_get_u64(defaults, de->d_name, &property_value),
> +				"Default value %s is not present!\n", de->d_name);
> +
> +		igt_debug("Default property:%s, value:0x%" PRId64 "\n", de->d_name, property_value);
> +
> +		igt_assert_f(!igt_sysfs_set(defaults, de->d_name, "garbage"),
> +				"write into default value of %s succeeded!\n",
> +				de->d_name);
> +	}
> +	closedir(dir);
> +}
> +
> +igt_main
> +{
> +	int fd;
> +	struct xe_engine_list_entry *en;
> +	struct drm_xe_engine_class_instance *hwe;
> +	int gt, tile_id, prev_tile = -1, gt_num;
> +
> +	igt_fixture {
> +		fd = drm_open_driver(DRIVER_XE);
> +		xe_device_get(fd);
> +		gt_num = xe_number_gt(fd);
> +	}
> +
> +	igt_subtest("show-tile") {
> +		xe_for_each_gt(fd, gt) {
> +			tile_id = xe_gt_get_tile_id(fd, gt);
> +			if (prev_tile != tile_id) {
> +				igt_info("Tile id: %d\n", tile_id);
> +				prev_tile = tile_id;
> +			}
> +			igt_info("GT id: %d\n", gt);
> +		}
> +	}
> +
> +	igt_subtest_with_dynamic("gt-configuration") {
> +		for (gt = 0; gt < gt_num; gt++) {
> +			int engines_fd = -1;
> +			int gt_fd = -1;
> +
> +			gt_fd = xe_sysfs_gt_open(fd, gt);
> +			igt_require(gt_fd != -1);
> +			engines_fd = openat(gt_fd, "engines", O_RDONLY);
> +			igt_require(engines_fd != -1);
> +
> +			igt_sysfs_engines(fd, engines_fd, 0, 0, NULL, engine_test_defaults);
> +
> +			close(engines_fd);
> +			close(gt_fd);
> +		}
> +	}
> +
> +	igt_fixture {
> +		drm_close_driver(fd);
> +	}
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 2724c7a9a..2cc01aa0c 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -292,6 +292,7 @@ intel_xe_progs = [
>  	'xe_exec_reset',
>  	'xe_exec_sip',
>  	'xe_exec_store',
> +	'xe_multi_tile',
>  	'xe_exec_threads',
>  	'xe_exercise_blt',
>  	'xe_fault_injection',
> -- 
> 2.34.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


More information about the igt-dev mailing list