Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <andrzej.hajda@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: igt-dev@lists.freedesktop.org,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Dominik Grzegorzek <dominik.grzegorzek@intel.com>,
	Christoph Manszewski <christoph.manszewski@intel.com>,
	Gwan-gyeong Mun <gwan-gyeong.mun@intel.com>
Subject: Re: [PATCH v7 4/5] lib/igt_sysfs: add helpers to access engine sysfs directory
Date: Thu, 27 Jun 2024 09:39:20 +0200	[thread overview]
Message-ID: <d475b754-cab5-4999-9bc2-4db56532e64d@intel.com> (raw)
In-Reply-To: <20240617140454.yr5oio6wdru4zrsb@zkempczy-mobl2>



On 17.06.2024 16:04, Zbigniew Kempczyński wrote:
> On Wed, Jun 12, 2024 at 11:39:02AM +0200, Andrzej Hajda wrote:
>> Helpers follow convention of xe_sysfs_gt_(path|open).
>>
>> v7:
>>    - staticize local const array
>>
>> Signed-off-by: Andrzej Hajda <andrzej.hajda@intel.com>
>> ---
>>   lib/igt_sysfs.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   lib/igt_sysfs.h |  3 +++
>>   2 files changed, 74 insertions(+)
>>
>> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
>> index 0c5817eb1580..90b923a99a26 100644
>> --- a/lib/igt_sysfs.c
>> +++ b/lib/igt_sysfs.c
>> @@ -40,7 +40,9 @@
>>   #include <dirent.h>
>>   #include <unistd.h>
>>   #include <fcntl.h>
>> +#include <xe_drm.h>
>>   
>> +#include "drmtest.h"
>>   #include "igt_core.h"
>>   #include "igt_sysfs.h"
>>   #include "igt_device.h"
>> @@ -263,6 +265,75 @@ int xe_sysfs_gt_open(int xe_device, int gt)
>>   	return open(path, O_RDONLY);
>>   }
>>   
>> +static const char *engine_class_to_str(__u16 class)
>> +{
>> +	static const char * const str[] = {
>> +		[DRM_XE_ENGINE_CLASS_RENDER] = "rcs",
>> +		[DRM_XE_ENGINE_CLASS_COPY] = "bcs",
>> +		[DRM_XE_ENGINE_CLASS_VIDEO_DECODE] = "vcs",
>> +		[DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE] = "vecs",
>> +		[DRM_XE_ENGINE_CLASS_COMPUTE] = "ccs",
>> +	};
>> +
>> +	if (class < ARRAY_SIZE(str))
>> +		return str[class];
>> +
>> +	return "unk";
>> +}
>> +
>> +/**
>> + * xe_sysfs_engine_path:
>> + * @xe_device: fd of the device
>> + * @gt: gt number
>> + * @class: engine class
>> + * @path: buffer to fill with the sysfs gt path to the device
>> + * @pathlen: length of @path buffer
>> + *
>> + * Returns:
>> + * The directory path, or NULL on failure.
>> + */
>> +char *
>> +xe_sysfs_engine_path(int xe_device, int gt, int class, char *path, int pathlen)
>> +{
>> +	struct stat st;
>> +	int tile = IS_PONTEVECCHIO(intel_get_drm_devid(xe_device)) ? gt : 0;
> Why tile is hardcoded here? I think it should be passed as an argument
> if you're providing gt and class as arguments.

Apparently I forgot to address the comment, forgive me :)
Back to the subject, I have just copied/simplified/pasted current 
practice in igt, see xe_sysfs_gt_path.
I have just assumed that with currently supported cards it is enough to 
deduce tile from gt and platform,
no need to complicate things, till it become necessary.

Regards
Andrzej

>
> --
> Zbigniew
>
>> +
>> +	if (xe_device < 0)
>> +		return NULL;
>> +
>> +	if (igt_debug_on(fstat(xe_device, &st)) || igt_debug_on(!S_ISCHR(st.st_mode)))
>> +		return NULL;
>> +
>> +	snprintf(path, pathlen, "/sys/dev/char/%d:%d/device/tile%d/gt%d/engines/%s",
>> +		 major(st.st_rdev), minor(st.st_rdev), tile, gt, engine_class_to_str(class));
>> +
>> +	if (!access(path, F_OK))
>> +		return path;
>> +
>> +	return NULL;
>> +}
>> +
>> +/**
>> + * xe_sysfs_engine_open:
>> + * @xe_device: fd of the device
>> + * @gt: gt number
>> + * @class: engine class
>> + *
>> + * This opens the sysfs gt directory corresponding to device and tile for use
>> + *
>> + * Returns:
>> + * The directory fd, or -1 on failure.
>> + */
>> +int xe_sysfs_engine_open(int xe_device, int gt, int class)
>> +{
>> +	char path[96];
>> +
>> +	if (!xe_sysfs_engine_path(xe_device, gt, class, path, sizeof(path)))
>> +		return -1;
>> +
>> +	return open(path, O_RDONLY);
>> +}
>> +
>>   /**
>>    * igt_sysfs_gt_path:
>>    * @device: fd of the device
>> diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
>> index f37d80ec130e..6c604d939013 100644
>> --- a/lib/igt_sysfs.h
>> +++ b/lib/igt_sysfs.h
>> @@ -166,4 +166,7 @@ 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);
>> +char *xe_sysfs_engine_path(int xe_device, int gt, int class, char *path, int pathlen);
>> +int xe_sysfs_engine_open(int xe_device, int gt, int class);
>> +
>>   #endif /* __IGT_SYSFS_H__ */
>>
>> -- 
>> 2.34.1
>>


  reply	other threads:[~2024-06-27  7:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  9:38 [PATCH v7 0/5] lib/gpgpu: add shader support Andrzej Hajda
2024-06-12  9:38 ` [PATCH v7 1/5] lib/gpu_cmds: add Xe_LP version of emit_vfe_state Andrzej Hajda
2024-06-17 10:51   ` Zbigniew Kempczyński
2024-06-12  9:39 ` [PATCH v7 2/5] lib/gpgpu_shader: tooling for preparing and running gpgpu shaders Andrzej Hajda
2024-06-17 11:41   ` Zbigniew Kempczyński
2024-06-12  9:39 ` [PATCH v7 3/5] lib/gpgpu_shader: add inline support for iga64 assembly Andrzej Hajda
2024-06-19  6:40   ` Zbigniew Kempczyński
2024-06-19  9:08     ` Andrzej Hajda
2024-06-12  9:39 ` [PATCH v7 4/5] lib/igt_sysfs: add helpers to access engine sysfs directory Andrzej Hajda
2024-06-12 12:59   ` Kamil Konieczny
2024-06-17 14:04   ` Zbigniew Kempczyński
2024-06-27  7:39     ` Andrzej Hajda [this message]
2024-06-12  9:39 ` [PATCH v7 5/5] intel/xe_exec_sip: add shader sanity test Andrzej Hajda
2024-06-12 10:18 ` ✗ CI.xeBAT: failure for lib/gpgpu: add shader support (rev7) Patchwork
2024-06-14 13:27   ` Kamil Konieczny
2024-06-18  9:55     ` Modem, Bhanuprakash
2024-06-12 10:33 ` ✓ Fi.CI.BAT: success " Patchwork
2024-06-12 11:21 ` ✓ CI.xeFULL: " Patchwork
2024-06-13  8:20 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-06-14 13:22   ` Kamil Konieczny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d475b754-cab5-4999-9bc2-4db56532e64d@intel.com \
    --to=andrzej.hajda@intel.com \
    --cc=christoph.manszewski@intel.com \
    --cc=dominik.grzegorzek@intel.com \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox