[igt-dev] [PATCH i-g-t v8 2/4] lib/igt_sysfs: Handling gt related sysfs uapi changes

Dixit, Ashutosh ashutosh.dixit at intel.com
Sat Jul 8 19:30:16 UTC 2023


On Fri, 07 Jul 2023 04:30:53 -0700, Himal Prasad Ghimiray wrote:
>
> +char *xe_sysfs_gt_path(int xe_device, int gt, char *path, int pathlen)
> +{
> +	struct stat st;
> +
> +	if (xe_device < 0)
> +		return NULL;
> +
> +	if (igt_debug_on(fstat(xe_device, &st)) || igt_debug_on(!S_ISCHR(st.st_mode)))
> +		return NULL;
> +
> +	if (IS_METEORLAKE(xe_device))

This is wrong, it should be:

	if (IS_METEORLAKE(intel_get_drm_devid(xe_device)))

Also why not use the IS_PONTEVECCHIO() check as I suggested? Several
upcoming platforms will have the MTL tile/gt configuration so we'll need to
keep fixing this, if we use PVC we can leave this code alone for a
while. Anyway I am ok as is too.

Also maybe move these 2 functions above igt_sysfs_gt_path() in the file. I
have a reason for that, will explain later.

Apart from this, almost there I think. I can suggest a couple more changes
but will hold off so that we can get this merged first.

But the build seems to have failed so let's fix that and also make sure
xe_guc_pc IGT's are passing in pre-merge CI (just in case we've missed
anything). I'll take a look and then R-b the patches.

Thanks.
--
Ashutosh


> +		snprintf(path, pathlen, "/sys/dev/char/%d:%d/device/tile0/gt%d",
> +			 major(st.st_rdev), minor(st.st_rdev), gt);
> +	else
> +		snprintf(path, pathlen, "/sys/dev/char/%d:%d/device/tile%d/gt%d",
> +			 major(st.st_rdev), minor(st.st_rdev), gt, gt);
> +
> +	if (!access(path, F_OK))
> +		return path;
> +
> +	return NULL;
> +}
> +
> +/**
> + * xe_sysfs_gt_open:
> + * @xe_device: fd of the device
> + * @gt: gt number
> + *
> + * This opens the sysfs gt directory corresponding to device and tile for use
> + *
> + * Returns:
> + * The directory fd, or -1 on failure.
> + */
> +int xe_sysfs_gt_open(int xe_device, int gt)
> +{
> +	char path[96];
> +
> +	if (!xe_sysfs_gt_path(xe_device, gt, path, sizeof(path)))
> +		return -1;
> +
> +	return open(path, O_RDONLY);
> +}
> +
>  /**
>   * xe_sysfs_tile_path:
>   * @xe_device: fd of the device
> diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
> index 5d584b1c7..afcafb07c 100644
> --- a/lib/igt_sysfs.h
> +++ b/lib/igt_sysfs.h
> @@ -157,6 +157,8 @@ void igt_sysfs_rw_attr_verify(igt_sysfs_rw_attr_t *rw);
>  void igt_sysfs_engines(int xe, int engines, const char **property,
>		       void (*test)(int, int, const char **));
>
> +char *xe_sysfs_gt_path(int xe_device, int gt, char *path, int pathlen);
> +int xe_sysfs_gt_open(int xe_device, int gt);
>  char *xe_sysfs_tile_path(int xe_device, int tile, char *path, int pathlen);
>  int xe_sysfs_tile_open(int xe_device, int tile);
>  int xe_sysfs_get_num_tiles(int xe_device);
> --
> 2.25.1
>


More information about the igt-dev mailing list