Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Bernatowicz, Marcin" <marcin.bernatowicz@linux.intel.com>
To: Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	igt-dev@lists.freedesktop.org, riana.tauro@intel.com,
	rodrigo.vivi@intel.com, lukasz.laguna@intel.com,
	jakub1.kolakowski@intel.com
Subject: Re: [PATCH i-g-t 1/3] lib/igt_sysfs: Add xe_sysfs_gt_has_attr to check attribute existence
Date: Thu, 1 Aug 2024 11:10:37 +0200	[thread overview]
Message-ID: <705dabb2-0af8-47c3-9ded-4dbdc88b90e9@linux.intel.com> (raw)
In-Reply-To: <20240731180018.ajp3jvnznvyo7c5g@kamilkon-DESK.igk.intel.com>



On 7/31/2024 8:00 PM, Kamil Konieczny wrote:
> Hi Marcin,
> On 2024-07-30 at 18:42:30 +0200, Marcin Bernatowicz wrote:
>> Introduce xe_sysfs_gt_has_attr to verify if a specified attribute
>> exists within the sysfs gt directory of a device.
>>
>> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
>> ---
>>   lib/igt_sysfs.c | 25 +++++++++++++++++++++++++
>>   lib/igt_sysfs.h |  1 +
>>   2 files changed, 26 insertions(+)
>>
>> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
>> index 550472d81..bcfd9fad1 100644
>> --- a/lib/igt_sysfs.c
>> +++ b/lib/igt_sysfs.c
>> @@ -265,6 +265,31 @@ int xe_sysfs_gt_open(int xe_device, int gt)
>>   	return open(path, O_RDONLY);
>>   }
>>   
>> +/**
>> + * xe_sysfs_gt_has_attr:
>> + * @xe_device: fd of the device
>> + * @gt: gt number
>> + * @attr: attr inside sysfs gt dir that needs to be checked for existence
>> + *
>> + * This checks if specified attr exists in device sysfs gt directory.
>> + *
>> + * Returns:
>> + * true if attr exists in sysfs, false otherwise.
>> + */
>> +bool xe_sysfs_gt_has_attr(int xe_device, int gt, const char *attr)
>> +{
>> +	bool has_attr;
>> +	int gt_fd;
>> +
>> +	gt_fd = xe_sysfs_gt_open(xe_device, gt);
>> +	if (gt_fd < 0)
>> +		return false;
>> +
>> +	has_attr = igt_sysfs_has_attr(gt_fd, attr);
> 
> Did you check that this will not assert on some unexpected
> boundary conditions?

igt_sysfs_has_attr does not assert

> 
>> +	close(gt_fd);
> 
> Add newline before return here, with this:

Ok
> 
> Reviewed-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
> 
>> +	return has_attr;
>> +}
>> +
>>   static const char *xe_engine_class_to_str(__u16 class)
>>   {
>>   	static const char * const str[] = {
>> diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
>> index 5d050c786..b0288fe36 100644
>> --- a/lib/igt_sysfs.h
>> +++ b/lib/igt_sysfs.h
>> @@ -168,6 +168,7 @@ void igt_sysfs_engines(int xe, int engines, const char **property,
>>   
>>   char *xe_sysfs_gt_path(int xe_device, int gt, char *path, int pathlen);
>>   int xe_sysfs_gt_open(int xe_device, int gt);
>> +bool xe_sysfs_gt_has_attr(int xe_device, int gt, const char *attr);
>>   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.31.1
>>

  reply	other threads:[~2024-08-01  9:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30 16:42 [PATCH i-g-t 0/3] Add sysfs attribute checks for gt_freq and pm_residency tests Marcin Bernatowicz
2024-07-30 16:42 ` [PATCH i-g-t 1/3] lib/igt_sysfs: Add xe_sysfs_gt_has_attr to check attribute existence Marcin Bernatowicz
2024-07-30 19:51   ` Cavitt, Jonathan
2024-07-31 18:00   ` Kamil Konieczny
2024-08-01  9:10     ` Bernatowicz, Marcin [this message]
2024-07-30 16:42 ` [PATCH i-g-t 2/3] tests/intel/xe_gt_freq: Skip test if 'freq0' attribute is missing Marcin Bernatowicz
2024-07-30 19:51   ` Cavitt, Jonathan
2024-07-30 16:42 ` [PATCH i-g-t 3/3] tests/intel/xe_pm_residency: Skip test if 'gtidle' " Marcin Bernatowicz
2024-07-30 19:54   ` Cavitt, Jonathan
2024-07-30 17:23 ` ✓ CI.xeBAT: success for Add sysfs attribute checks for gt_freq and pm_residency tests Patchwork
2024-07-30 17:36 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-07-30 18:39 ` ✗ CI.xeFULL: " Patchwork
2024-08-01 10:27 ` [PATCH v2 i-g-t 0/3] Add sysfs node " Marcin Bernatowicz
2024-08-01 10:27   ` [PATCH v2 i-g-t 1/3] lib/igt_sysfs: Add xe_sysfs_gt_has_node to check node existence Marcin Bernatowicz
2024-08-01 10:27   ` [PATCH v2 i-g-t 2/3] tests/intel/xe_gt_freq: Skip test if 'freq0' node is missing Marcin Bernatowicz
2024-08-01 10:27   ` [PATCH v2 i-g-t 3/3] tests/intel/xe_pm_residency: Skip test if 'gtidle' " Marcin Bernatowicz

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=705dabb2-0af8-47c3-9ded-4dbdc88b90e9@linux.intel.com \
    --to=marcin.bernatowicz@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jakub1.kolakowski@intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=lukasz.laguna@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@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