From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>,
Adam Miszczak <adam.miszczak@linux.intel.com>,
Jakub Kolakowski <jakub1.kolakowski@intel.com>,
Lukasz Laguna <lukasz.laguna@intel.com>,
Michal Wajdeczko <michal.wajdeczko@intel.com>,
Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
Subject: [PATCH i-g-t 1/2] lib/xe/xe_query: Add xe_gt_type() and xe_is_main_gt() helpers
Date: Fri, 29 Aug 2025 12:40:36 +0200 [thread overview]
Message-ID: <20250829104037.649426-2-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20250829104037.649426-1-marcin.bernatowicz@linux.intel.com>
Introduce xe_gt_type() to return the GT type from query data. This
replaces open-coded access in xe_is_media_gt() and makes it easy to
add new GT-specific helpers. Add xe_is_main_gt() for MAIN GT checks.
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
Cc: Adam Miszczak <adam.miszczak@linux.intel.com>
Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
Cc: Lukasz Laguna <lukasz.laguna@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
---
lib/xe/xe_query.c | 40 +++++++++++++++++++++++++++++++---------
lib/xe/xe_query.h | 2 ++
2 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 3b8a682f8..9b88cce8d 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -917,24 +917,46 @@ bool xe_has_media_gt(int fd)
}
/**
- * xe_is_media_gt:
+ * xe_gt_type:
* @fd: xe device fd
* @gt: gt id
*
- * Returns true if @gt for device @fd is media GT, otherwise false.
+ * Returns the type of @gt for device @fd (e.g.,
+ * DRM_XE_QUERY_GT_TYPE_MAIN, DRM_XE_QUERY_GT_TYPE_MEDIA).
*/
-bool xe_is_media_gt(int fd, int gt)
+uint16_t xe_gt_type(int fd, int gt)
{
- struct xe_device *xe_dev;
+ struct xe_device *xe_dev = find_in_cache(fd);
- xe_dev = find_in_cache(fd);
igt_assert(xe_dev);
- igt_assert(gt < xe_number_gt(fd));
+ igt_assert_f(gt >= 0 && gt < xe_number_gt(fd),
+ "gt %d out of range [0..%d)\n", gt, xe_number_gt(fd));
- if (xe_dev->gt_list->gt_list[gt].type == DRM_XE_QUERY_GT_TYPE_MEDIA)
- return true;
+ return xe_dev->gt_list->gt_list[gt].type;
+}
- return false;
+/**
+ * xe_is_media_gt:
+ * @fd: xe device fd
+ * @gt: gt id
+ *
+ * Returns true if @gt for device @fd is MEDIA GT, otherwise false.
+ */
+bool xe_is_media_gt(int fd, int gt)
+{
+ return xe_gt_type(fd, gt) == DRM_XE_QUERY_GT_TYPE_MEDIA;
+}
+
+/**
+ * xe_is_main_gt:
+ * @fd: xe device fd
+ * @gt: gt id
+ *
+ * Returns true if @gt for device @fd is MAIN GT, otherwise false.
+ */
+bool xe_is_main_gt(int fd, int gt)
+{
+ return xe_gt_type(fd, gt) == DRM_XE_QUERY_GT_TYPE_MAIN;
}
/**
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index cc54ec956..4b8a6ee77 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -127,7 +127,9 @@ const char *xe_engine_class_short_string(uint32_t engine_class);
bool xe_has_engine_class(int fd, uint16_t engine_class);
struct drm_xe_engine *xe_find_engine_by_class(int fd, uint16_t engine_class);
bool xe_has_media_gt(int fd);
+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);
uint32_t *xe_hwconfig_lookup_value(int fd, enum intel_hwconfig attribute, uint32_t *len);
--
2.31.1
next prev parent reply other threads:[~2025-08-29 10:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-29 10:40 [PATCH i-g-t 0/2] xe_sriov_flr: Skip non-MAIN GTs when reading provisioning data Marcin Bernatowicz
2025-08-29 10:40 ` Marcin Bernatowicz [this message]
2025-09-01 11:12 ` [PATCH i-g-t 1/2] lib/xe/xe_query: Add xe_gt_type() and xe_is_main_gt() helpers Kamil Konieczny
2025-08-29 10:40 ` [PATCH i-g-t 2/2] tests/intel/xe_sriov_flr: Skip non-MAIN GTs when reading provisioning data Marcin Bernatowicz
2025-09-01 11:14 ` Kamil Konieczny
2025-08-29 11:51 ` ✓ Xe.CI.BAT: success for xe_sriov_flr: " Patchwork
2025-08-29 12:14 ` ✓ i915.CI.BAT: " Patchwork
2025-08-29 19:48 ` ✗ i915.CI.Full: failure " Patchwork
2025-09-01 10:23 ` Bernatowicz, Marcin
2025-08-29 20:36 ` ✗ Xe.CI.Full: " Patchwork
2025-09-01 10:22 ` 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=20250829104037.649426-2-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=adam.miszczak@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=jakub1.kolakowski@intel.com \
--cc=lukasz.laguna@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=satyanarayana.k.v.p@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.