Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
	igt-dev@lists.freedesktop.org
Cc: Andi Shyti <andi.shyti@intel.com>,
	badal.nilawar@intel.com, arjun.melkaveri@intel.com
Subject: Re: [igt-dev] [PATCH i-g-t 1/7] lib/debugfs: GT directory helpers
Date: Thu, 30 Mar 2023 09:49:36 +0100	[thread overview]
Message-ID: <b0f0c679-214a-e3b8-d700-d2befc4588c0@linux.intel.com> (raw)
In-Reply-To: <20230330003656.1294873-2-umesh.nerlige.ramappa@intel.com>


On 30/03/2023 01:36, Umesh Nerlige Ramappa wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Add two debugfs helpers to be used for opening per-gt debugfs directories.
> 
> Note: This likely needs updating once the final debugfs layout is set.

Andi - final debugfs layout is set now, right? If so probably remove 
this note from the commit message.

Regards,

Tvrtko

> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   lib/igt_debugfs.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++
>   lib/igt_debugfs.h |  4 ++++
>   2 files changed, 64 insertions(+)
> 
> diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
> index 05889bbe..afde2da6 100644
> --- a/lib/igt_debugfs.c
> +++ b/lib/igt_debugfs.c
> @@ -217,6 +217,37 @@ int igt_debugfs_dir(int device)
>   	return open(path, O_RDONLY);
>   }
>   
> +/**
> + * igt_debugfs_gt_dir:
> + * @device: fd of the device
> + * @gt: GT instance number
> + *
> + * This opens the debugfs directory corresponding to device for use
> + * with igt_sysfs_get() and related functions.
> + *
> + * Returns:
> + * The directory fd, or -1 on failure.
> + */
> +int igt_debugfs_gt_dir(int device, unsigned int gt)
> +{
> +	int debugfs_gt_dir_fd;
> +	char path[PATH_MAX];
> +	char gtpath[16];
> +	int ret;
> +
> +	if (!igt_debugfs_path(device, path, sizeof(path)))
> +		return -1;
> +
> +	ret = snprintf(gtpath, sizeof(gtpath), "/gt%u", gt);
> +	igt_assert(ret < sizeof(gtpath));
> +	strncat(path, gtpath, sizeof(path) - 1);
> +
> +	debugfs_gt_dir_fd = open(path, O_RDONLY);
> +	igt_debug_on_f(debugfs_gt_dir_fd < 0, "path: %s\n", path);
> +
> +	return debugfs_gt_dir_fd;
> +}
> +
>   /**
>    * igt_debugfs_connector_dir:
>    * @device: fd of the device
> @@ -313,6 +344,35 @@ bool igt_debugfs_exists(int device, const char *filename, int mode)
>   	return false;
>   }
>   
> +/**
> + * igt_debugfs_gt_open:
> + * @device: open i915 drm fd
> + * @gt: gt instance number
> + * @filename: name of the debugfs node to open
> + * @mode: mode bits as used by open()
> + *
> + * This opens a debugfs file as a Unix file descriptor. The filename should be
> + * relative to the drm device's root, i.e. without "drm/$minor".
> + *
> + * Returns:
> + * The Unix file descriptor for the debugfs file or -1 if that didn't work out.
> + */
> +int
> +igt_debugfs_gt_open(int device, unsigned int gt, const char *filename, int mode)
> +{
> +	int dir, ret;
> +
> +	dir = igt_debugfs_gt_dir(device, gt);
> +	if (dir < 0)
> +		return dir;
> +
> +	ret = openat(dir, filename, mode);
> +
> +	close(dir);
> +
> +	return ret;
> +}
> +
>   /**
>    * igt_debugfs_simple_read:
>    * @dir: fd of the debugfs directory
> diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
> index 4824344a..3e6194ad 100644
> --- a/lib/igt_debugfs.h
> +++ b/lib/igt_debugfs.h
> @@ -45,6 +45,10 @@ void __igt_debugfs_write(int fd, const char *filename, const char *buf, int size
>   int igt_debugfs_simple_read(int dir, const char *filename, char *buf, int size);
>   bool igt_debugfs_search(int fd, const char *filename, const char *substring);
>   
> +int igt_debugfs_gt_dir(int device, unsigned int gt);
> +int igt_debugfs_gt_open(int device, unsigned int gt, const char *filename,
> +			int mode);
> +
>   /**
>    * igt_debugfs_read:
>    * @filename: name of the debugfs file

  reply	other threads:[~2023-03-30  8:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-30  0:36 [igt-dev] [PATCH i-g-t 0/7] Add MTL PMU support for multi-gt Umesh Nerlige Ramappa
2023-03-30  0:36 ` [igt-dev] [PATCH i-g-t 1/7] lib/debugfs: GT directory helpers Umesh Nerlige Ramappa
2023-03-30  8:49   ` Tvrtko Ursulin [this message]
2023-03-30  0:36 ` [igt-dev] [PATCH i-g-t 2/7] tests/i915/perf_pmu: Support multi-tile in rc6 subtest Umesh Nerlige Ramappa
2023-03-30  0:36 ` [igt-dev] [PATCH i-g-t 3/7] tests/i915/perf_pmu: Two new rc6 subtests Umesh Nerlige Ramappa
2023-03-30  0:36 ` [igt-dev] [PATCH i-g-t 4/7] tests/i915/perf_pmu: Support multi-tile in frequency subtest Umesh Nerlige Ramappa
2023-03-30  8:54   ` Tvrtko Ursulin
2023-03-30  0:36 ` [igt-dev] [PATCH i-g-t 5/7] tests/i915/perf_pmu: Quiesce GPU if measuring idle busyness without spinner Umesh Nerlige Ramappa
2023-03-30  9:00   ` Tvrtko Ursulin
2023-03-30 18:35     ` Umesh Nerlige Ramappa
2023-03-30  0:36 ` [igt-dev] [PATCH i-g-t 6/7] tests/i915/perf_pmu: Use correct pmu config for multi-tile Umesh Nerlige Ramappa
2023-03-30  0:36 ` [igt-dev] [PATCH i-g-t 7/7] tools/intel_gpu_top: Add support for gt specific counters Umesh Nerlige Ramappa
2023-03-30  0:45   ` Umesh Nerlige Ramappa
2023-03-30  9:25   ` Tvrtko Ursulin
2023-03-30 18:43     ` Umesh Nerlige Ramappa
2023-04-26 21:13     ` Umesh Nerlige Ramappa
2023-04-27 14:52       ` Tvrtko Ursulin
2023-03-30  1:23 ` [igt-dev] ✓ Fi.CI.BAT: success for Add MTL PMU support for multi-gt Patchwork
2023-03-30 18:58 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

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=b0f0c679-214a-e3b8-d700-d2befc4588c0@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=andi.shyti@intel.com \
    --cc=arjun.melkaveri@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=umesh.nerlige.ramappa@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