Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Xin Wang <x.wang@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Xin Wang <x.wang@intel.com>
Subject: [PATCH v7 1/2] lib/xe/xe_query: Get runtime xe device graphics version from GMD_ID
Date: Wed, 15 Oct 2025 06:01:43 +0000	[thread overview]
Message-ID: <20251015060144.6410-2-x.wang@intel.com> (raw)
In-Reply-To: <20251015060144.6410-1-x.wang@intel.com>

Add intel_device_info support to xe_device to store accurate graphics versions
retrieved from the GMD_ID ioctl. This allows IGT to query the exact IP version
for xe platforms.

Key changes:
- Add intel_device_info field to xe_device structure
- set the graphics versions based on the GMD_ID
- Cache device info in global map indexed by devid for efficient lookup
- Implement xe_device_get_info() to retrieve cached info by devid
- Clean up cached device info entry when xe_device is released

Signed-off-by: Xin Wang <x.wang@intel.com>
---
 lib/xe/xe_query.c | 33 ++++++++++++++++++++++++++++++++-
 lib/xe/xe_query.h |  4 ++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index a89e0b980..b7c9a2bec 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -335,6 +335,17 @@ static struct xe_device *find_in_cache(int fd)
 	return xe_dev;
 }
 
+struct intel_device_info *xe_device_get_info(uint32_t devid)
+{
+	struct intel_device_info *xe_dev_info;
+
+	pthread_mutex_lock(&cache.cache_mutex);
+	xe_dev_info = igt_map_search(cache.map, &devid);
+	pthread_mutex_unlock(&cache.cache_mutex);
+
+	return xe_dev_info;
+}
+
 static void xe_device_free(struct xe_device *xe_dev)
 {
 	free(xe_dev->config);
@@ -379,6 +390,21 @@ struct xe_device *xe_device_get(int fd)
 	for (int gt = 0; gt < xe_dev->gt_list->num_gt; gt++)
 		xe_dev->gt_mask |= (1ull << xe_dev->gt_list->gt_list[gt].gt_id);
 
+	/*
+	* Set graphics_ver and graphics_rel based on the main GT's GMD_ID.
+	* We should use the hardcoded value for the none GMD_ID platforms (ip_ver_major == 0)
+	*/
+	for (int gt = 0; gt < xe_dev->gt_list->num_gt; gt++)
+		if (xe_dev->gt_list->gt_list[gt].type == DRM_XE_QUERY_GT_TYPE_MAIN &&
+		    xe_dev->gt_list->gt_list[gt].ip_ver_major) {
+			igt_debug("Setting graphics_ver to %u and graphics_rel to %u\n",
+				  xe_dev->gt_list->gt_list[gt].ip_ver_major,
+				  xe_dev->gt_list->gt_list[gt].ip_ver_minor);
+			xe_dev->info.graphics_ver = xe_dev->gt_list->gt_list[gt].ip_ver_major;
+			xe_dev->info.graphics_rel = xe_dev->gt_list->gt_list[gt].ip_ver_minor;
+			break;
+		}
+
 	/* Tile IDs may be non-consecutive; keep a mask of valid IDs */
 	for (int gt = 0; gt < xe_dev->gt_list->num_gt; gt++)
 		xe_dev->tile_mask |= (1ull << xe_dev->gt_list->gt_list[gt].tile_id);
@@ -413,6 +439,7 @@ struct xe_device *xe_device_get(int fd)
 	prev = find_in_cache_unlocked(fd);
 	if (!prev) {
 		igt_map_insert(cache.map, &xe_dev->fd, xe_dev);
+		igt_map_insert(cache.map, &xe_dev->dev_id, &xe_dev->info);
 	} else {
 		xe_device_free(xe_dev);
 		xe_dev = prev;
@@ -424,7 +451,11 @@ struct xe_device *xe_device_get(int fd)
 
 static void delete_in_cache(struct igt_map_entry *entry)
 {
-	xe_device_free((struct xe_device *)entry->data);
+	struct xe_device *xe_dev = (struct xe_device *)entry->data;
+	struct igt_map_entry *info_entry = igt_map_search(cache.map, &xe_dev->dev_id);
+
+	igt_map_remove_entry(cache.map, info_entry);
+	xe_device_free(xe_dev);
 }
 
 /**
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 715b64e2f..1a261866f 100644
--- a/lib/xe/xe_query.h
+++ b/lib/xe/xe_query.h
@@ -74,6 +74,9 @@ struct xe_device {
 
 	/** @dev_id: Device id of xe device */
 	uint16_t dev_id;
+
+	/** @info: Device information for compatibility with i915 */
+	struct intel_device_info info;
 };
 
 #define xe_for_each_engine(__fd, __hwe) \
@@ -140,6 +143,7 @@ int xe_query_pxp_status(int fd);
 int xe_wait_for_pxp_init(int fd);
 
 struct xe_device *xe_device_get(int fd);
+struct intel_device_info *xe_device_get_info(uint32_t devid);
 void xe_device_put(int fd);
 
 #endif	/* XE_QUERY_H */
-- 
2.43.0


  reply	other threads:[~2025-10-15  6:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15  6:01 [PATCH v7 0/2] lib/intel_device_info: get the xe .graphics_rel from GMD_ID Xin Wang
2025-10-15  6:01 ` Xin Wang [this message]
2025-10-16 22:13   ` [PATCH v7 1/2] lib/xe/xe_query: Get runtime xe device graphics version " Matt Roper
2025-10-17  4:21     ` Wang, X
2025-10-15  6:01 ` [PATCH v7 2/2] lib/intel_device_info: Query runtime xe device graphics versions Xin Wang
2025-10-16 22:21   ` Matt Roper
2025-10-17  4:53     ` Wang, X
2025-10-15  6:55 ` ✓ Xe.CI.BAT: success for lib/intel_device_info: get the xe .graphics_rel from GMD_ID (rev7) Patchwork
2025-10-15  7:22 ` ✓ i915.CI.BAT: " Patchwork
2025-10-15 13:19 ` ✗ i915.CI.Full: failure " Patchwork
2025-10-15 16:26 ` ✓ Xe.CI.Full: success " Patchwork
2025-10-15 23:15 ` [PATCH v7 0/2] lib/intel_device_info: get the xe .graphics_rel from GMD_ID Matt Roper
2025-10-16  5:07   ` Wang, X
2025-10-16 22:05     ` Matt Roper

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=20251015060144.6410-2-x.wang@intel.com \
    --to=x.wang@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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