From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: piotr.piorkowski@intel.com, lukasz.laguna@intel.com,
jakub1.kolakowski@intel.com,
Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Subject: [PATCH i-g-t 3/6] lib/xe/xe_query: Add tile helpers and iteration macro
Date: Thu, 6 Nov 2025 16:28:07 +0100 [thread overview]
Message-ID: <20251106152811.1997614-4-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20251106152811.1997614-1-marcin.bernatowicz@linux.intel.com>
From: Piotr Piórkowski <piotr.piorkowski@intel.com>
Add helpers for tile-level access:
- xe_tiles_count(): return number of tiles
- xe_tile_get_main_gt_id(): get MAIN GT ID for a tile
- xe_for_each_tile(): iterate over tiles via tile_mask
v2: Add missing colon in function doc (Lukasz)
Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Reviewed-by: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
---
lib/xe/xe_query.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
lib/xe/xe_query.h | 6 ++++++
2 files changed, 51 insertions(+)
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index a89e0b980..8e3e05fd3 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -515,6 +515,22 @@ unsigned int xe_dev_max_gt(int fd)
return igt_fls(xe_dev->gt_mask) - 1;
}
+/**
+ * xe_tiles_count:
+ * @fd: xe device fd
+ *
+ * Return number of tiles for xe device fd.
+ */
+uint8_t xe_tiles_count(int fd)
+{
+ struct xe_device *xe_dev;
+
+ xe_dev = find_in_cache(fd);
+ igt_assert(xe_dev);
+
+ return igt_hweight(xe_dev->tile_mask);
+}
+
/**
* all_memory_regions:
* @fd: xe device fd
@@ -995,6 +1011,35 @@ uint16_t xe_gt_get_tile_id(int fd, int gt)
return xe_dev->gt_list->gt_list[gt].tile_id;
}
+/**
+ * xe_tile_get_main_gt_id:
+ * @fd: xe device fd
+ * @tile: tile id
+ *
+ * Returns main GT ID for given @tile.
+ */
+uint16_t xe_tile_get_main_gt_id(int fd, uint8_t tile)
+{
+ struct xe_device *xe_dev;
+ int gt_id = -1;
+
+ xe_dev = find_in_cache(fd);
+ igt_assert(xe_dev);
+
+ for (int i = 0; i < xe_dev->gt_list->num_gt; i++) {
+ const struct drm_xe_gt *gt_data = &xe_dev->gt_list->gt_list[i];
+
+ if (gt_data->tile_id == tile && gt_data->type == DRM_XE_QUERY_GT_TYPE_MAIN) {
+ gt_id = gt_data->gt_id;
+ break;
+ }
+ }
+
+ igt_assert_f(gt_id >= 0, "No main GT found for tile %d\n", tile);
+
+ return gt_id;
+}
+
/**
* xe_hwconfig_lookup_value:
* @fd: xe device fd
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 715b64e2f..bcdfb54b0 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -86,6 +86,10 @@ struct xe_device {
for (uint64_t igt_unique(__mask) = xe_device_get(__fd)->gt_mask; \
__gt = ffsll(igt_unique(__mask)) - 1, igt_unique(__mask) != 0; \
igt_unique(__mask) &= ~(1ull << __gt))
+#define xe_for_each_tile(__fd, __tile) \
+ for (uint64_t igt_unique(__mask) = xe_device_get(__fd)->tile_mask; \
+ __tile = ffsll(igt_unique(__mask)) - 1, igt_unique(__mask) != 0; \
+ igt_unique(__mask) &= ~(1ull << __tile))
#define xe_for_each_mem_region(__fd, __memreg, __r) \
for (uint64_t igt_unique(__i) = 0; igt_unique(__i) < igt_fls(__memreg); igt_unique(__i)++) \
for_if(__r = (__memreg & (1ull << igt_unique(__i))))
@@ -101,6 +105,7 @@ struct xe_device {
unsigned int xe_number_gt(int fd);
unsigned int xe_dev_max_gt(int fd);
+uint8_t xe_tiles_count(int fd);
uint64_t all_memory_regions(int fd);
uint64_t system_memory(int fd);
const struct drm_xe_gt *drm_xe_get_gt(struct xe_device *xe_dev, int gt_id);
@@ -135,6 +140,7 @@ uint16_t xe_gt_type(int fd, int gt);
bool xe_is_media_gt(int fd, int gt);
bool xe_is_main_gt(int fd, int gt);
uint16_t xe_gt_get_tile_id(int fd, int gt);
+uint16_t xe_tile_get_main_gt_id(int fd, uint8_t tile);
uint32_t *xe_hwconfig_lookup_value(int fd, enum intel_hwconfig attribute, uint32_t *len);
int xe_query_pxp_status(int fd);
int xe_wait_for_pxp_init(int fd);
--
2.43.0
next prev parent reply other threads:[~2025-11-06 15:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-06 15:28 [PATCH i-g-t 0/6] Multi-tile support for xe_sriov_flr and related MMIO improvements Marcin Bernatowicz
2025-11-06 15:28 ` [PATCH i-g-t 1/6] lib/xe_mmio: Introduce tile-level XE MMIO access helpers Marcin Bernatowicz
2025-11-07 8:53 ` Laguna, Lukasz
2025-11-06 15:28 ` [PATCH i-g-t 2/6] lib/xe_mmio: Add init flag and helper to check initialization Marcin Bernatowicz
2025-11-06 15:28 ` Marcin Bernatowicz [this message]
2025-11-06 15:28 ` [PATCH i-g-t 4/6] tests/intel/xe_sriov_flr: Make subchecks Tile aware Marcin Bernatowicz
2025-11-07 9:17 ` Piotr Piórkowski
2025-11-06 15:28 ` [PATCH i-g-t 5/6] tests/intel/xe_sriov_flr: Use global MMIO context initialized in verify_flr Marcin Bernatowicz
2025-11-06 15:28 ` [PATCH i-g-t 6/6] tests/intel/xe_sriov_flr: Do not ignore failed prerequisites Marcin Bernatowicz
2025-11-06 22:49 ` ✓ Xe.CI.BAT: success for Multi-tile support for xe_sriov_flr and related MMIO improvements (rev2) Patchwork
2025-11-06 23:13 ` ✓ i915.CI.BAT: " Patchwork
2025-11-07 17:02 ` ✗ i915.CI.Full: failure " Patchwork
2025-11-07 21:47 ` ✗ Xe.CI.Full: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-10-31 12:56 [PATCH i-g-t 0/6] Multi-tile support for xe_sriov_flr and related MMIO improvements Marcin Bernatowicz
2025-10-31 12:56 ` [PATCH i-g-t 3/6] lib/xe/xe_query: Add tile helpers and iteration macro Marcin Bernatowicz
2025-11-06 11:32 ` Laguna, Lukasz
2025-11-06 12:42 ` Bernatowicz, Marcin
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=20251106152811.1997614-4-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=lukasz.laguna@intel.com \
--cc=piotr.piorkowski@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.