From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: igt-dev@lists.freedesktop.org, Upadhyay <tejas.upadhyay@intel.com>
Subject: Re: [igt-dev] [PATCH i-g-t v7 1/4] lib/igt_sysfs: Add support to query number of tiles
Date: Thu, 06 Jul 2023 16:46:27 -0700 [thread overview]
Message-ID: <87fs60d2ng.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20230706104500.595707-2-himal.prasad.ghimiray@intel.com>
On Thu, 06 Jul 2023 03:44:57 -0700, Himal Prasad Ghimiray wrote:
>
> With tile and GT seperation in KMD, we need to know
> number of tiles supported by platform.
> We will need to access tile associated properties from IGT.
> Hence adding iterator for all supported tiles.
>
> v2:
> - Calculate number of tiles once within iterator. (Rahul)
> - Use snprintf instead of sprintf.
>
> v3:
> - Remove unrequired for_each_sysfs_tile_dirfd (Ashutosh)
>
> v4:
> - Implement tiles related functions in lib.
>
> Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
> Cc: Aravind Iddamsetty <aravind.iddamsetty@intel.com>
> Cc: Upadhyay <tejas.upadhyay@intel.com>
> Cc: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> ---
> lib/igt_sysfs.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
> lib/igt_sysfs.h | 10 +++++++
> 2 files changed, 87 insertions(+)
>
> diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
> index 0876f4c6b..dcb38cfc9 100644
> --- a/lib/igt_sysfs.c
> +++ b/lib/igt_sysfs.c
> @@ -903,3 +903,80 @@ void igt_sysfs_engines(int xe, int engines, const char **property,
> close(engine_fd);
> }
> }
> +
> +/**
> + * xe_sysfs_tile_path:
> + * @device: fd of the device
xe_device
> + * @tile: tile number
> + * @path: buffer to fill with the sysfs tile path to the device
> + * @pathlen: length of @path buffer
> + *
> + * This finds the sysfs directory corresponding to @device and @tile. If the tile
> + * specific directory is not available and tile is 0, path is filled with sysfs
> + * base directory.
> + *
> + * Returns:
> + * The directory path, or NULL on failure.
> + */
> +char *xe_sysfs_tile_path(int xe_device, int tile, 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;
> +
> + snprintf(path, pathlen, "/sys/dev/char/%d:%d/device/tile%d",
> + major(st.st_rdev), minor(st.st_rdev), tile);
> +
> + if (!access(path, F_OK))
> + return path;
> + if (!tile)
> + return igt_sysfs_path(xe_device, path, pathlen);
This if () is in igt_sysfs_gt_path to take care of the legacy case. There
is no such thing for xe, so let's remove this if ().
Fix the comment above the function too.
> + return NULL;
> +}
> +
> +/**
> + * xe_sysfs_tile_open:
> + * @xe_device: fd of the device
> + * @tile: tile number
> + *
> + * This opens the sysfs tile directory corresponding to device and tile for use
> + *
> + * Returns:
> + * The directory fd, or -1 on failure.
> + */
> +int xe_sysfs_tile_open(int xe_device, int tile)
> +{
> + char path[96];
> +
> + if (!xe_sysfs_tile_path(xe_device, tile, path, sizeof(path)))
> + return -1;
> +
> + return open(path, O_RDONLY);
> +}
> +
> +/**
> + * xe_sysfs_get_num_tiles:
> + * @xe_device: fd of the device
> + *
> + * Reads number of tile sysfs entries.
> + * Asserts for at least one tile entry.
> + * (see xe_sysfs_tile_path).
> + *
> + * Returns: Number of tiles.
> + */
> +int xe_sysfs_get_num_tiles(int xe_device)
> +{
> + int num_tiles = 0;
> + char path[96];
> +
> + while (xe_sysfs_tile_path(xe_device, num_tiles, path, sizeof(path)))
> + ++num_tiles;
> +
> + igt_assert_f(num_tiles > 0, "No GT sysfs entry is found.");
> +
> + return num_tiles;
> +}
> diff --git a/lib/igt_sysfs.h b/lib/igt_sysfs.h
> index 5635fc690..5d584b1c7 100644
> --- a/lib/igt_sysfs.h
> +++ b/lib/igt_sysfs.h
> @@ -38,6 +38,11 @@
> (dirfd__ = igt_sysfs_gt_open(i915__, gt__)) != -1; \
> close(dirfd__), gt__++)
>
> +#define for_each_sysfs_tile_dirfd(xe__, dirfd__, tile__) \
> + for (tile__ = 0; \
> + (dirfd__ = xe_sysfs_tile_open(xe__, tile__)) != -1; \
> + close(dirfd__), tile__++)
> +
> #define i915_for_each_gt for_each_sysfs_gt_dirfd
>
> #define igt_sysfs_rps_write(dir, id, data, len) \
> @@ -73,6 +78,8 @@
> #define igt_sysfs_rps_set_boolean(dir, id, value) \
> igt_sysfs_set_boolean(dir, igt_sysfs_dir_id_to_name(dir, id), value)
>
> +#define xe_for_each_tile for_each_sysfs_tile_dirfd
> +
> enum i915_attr_id {
> RPS_ACT_FREQ_MHZ,
> RPS_CUR_FREQ_MHZ,
> @@ -150,4 +157,7 @@ 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_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);
> #endif /* __IGT_SYSFS_H__ */
> --
> 2.25.1
>
next prev parent reply other threads:[~2023-07-07 0:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 10:44 [igt-dev] [PATCH i-g-t v7 0/4] Handle GT and tile seperation in IGT Himal Prasad Ghimiray
2023-07-06 10:44 ` [igt-dev] [PATCH i-g-t v7 1/4] lib/igt_sysfs: Add support to query number of tiles Himal Prasad Ghimiray
2023-07-06 23:46 ` Dixit, Ashutosh [this message]
2023-07-07 3:57 ` Ghimiray, Himal Prasad
2023-07-06 10:44 ` [igt-dev] [PATCH i-g-t v7 2/4] lib/igt_sysfs: Handling gt related sysfs uapi changes Himal Prasad Ghimiray
2023-07-07 0:56 ` Dixit, Ashutosh
2023-07-07 4:29 ` Ghimiray, Himal Prasad
2023-07-07 5:02 ` Ghimiray, Himal Prasad
2023-07-06 10:44 ` [igt-dev] [PATCH i-g-t v7 3/4] tests/xe/xe_guc_pc: Change the sysfs paths Himal Prasad Ghimiray
2023-07-07 1:01 ` Dixit, Ashutosh
2023-07-07 5:03 ` Ghimiray, Himal Prasad
2023-07-06 10:45 ` [igt-dev] [PATCH i-g-t v7 4/4] tests/xe/xe_sysfs_tile_prop: adds new test to verify per tile vram addr_range Himal Prasad Ghimiray
2023-07-07 1:10 ` Dixit, Ashutosh
2023-07-07 5:04 ` Ghimiray, Himal Prasad
2023-07-06 13:03 ` [igt-dev] ✓ Fi.CI.BAT: success for Handle GT and tile seperation in IGT (rev6) Patchwork
2023-07-06 13:12 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-07-06 17:12 ` [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=87fs60d2ng.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=tejas.upadhyay@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