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: kamil.konieczny@linux.intel.com, matthew.d.roper@intel.com,
	shuicheng.lin@intel.com, brian3.nguyen@intel.com,
	alex.zuo@intel.com, nakshtra.goyal@intel.com,
	dnyaneshwar.bhadane@intel.com, gustavo.sousa@intel.com,
	Xin Wang <x.wang@intel.com>
Subject: [PATCH v2 1/6] lib: Add runtime device info query APIs for xe devices
Date: Tue,  7 Oct 2025 23:26:01 +0000	[thread overview]
Message-ID: <20251007232606.363629-2-x.wang@intel.com> (raw)
In-Reply-To: <20251007232606.363629-1-x.wang@intel.com>

Introduce new APIs to query device information at runtime for xe devices:
- intel_query_gen(int fd): Get graphics generation
- intel_query_graphics_ver(int fd): Get combined graphics version
- intel_query_device_info(int fd): Get device info structure

For xe devices, graphics versions (both major and minor) can be
accurately determined by retrieving GMD_ID via IOCTL, rather than
relying on static intel_device_match table. Different device instances
of the same type may have different graphics_rel (minor version) values.

Implementation details:
- xe_device struct now includes intel_device_info for compatibility
- graphics_rel is populated from GMD_ID's ip_ver_minor at runtime
- For non-GMD_ID platforms (ip_ver_major == 0), hardcoded values are preserved
- New APIs fall back to traditional devid-based lookup for i915 devices

This infrastructure enables accurate device capability detection and
avoids issues when adding new device IDs with varying graphics_rel values.

Signed-off-by: Xin Wang <x.wang@intel.com>
---
 lib/intel_chipset.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
 lib/intel_chipset.h |  3 +++
 lib/xe/xe_query.c   | 19 +++++++++++++++
 lib/xe/xe_query.h   |  3 +++
 4 files changed, 81 insertions(+)

diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c
index 760faede2..4b1cb3b97 100644
--- a/lib/intel_chipset.c
+++ b/lib/intel_chipset.c
@@ -189,3 +189,59 @@ intel_check_pch(void)
 		return;
 	}
 }
+
+/**
+ * intel_query_gen:
+ * @fd: open i915/xe drm file descriptor
+ *
+ * Returns gen IP version for device @fd. For i915 devices,
+ * falls back to i915 graphics version lookup.
+ */
+unsigned intel_query_gen(int fd)
+{
+	struct xe_device *xe_dev;
+
+	if (is_i915_device(fd))
+		return intel_gen(intel_get_drm_devid(fd));
+
+	xe_dev = xe_device_get(fd);
+
+	return xe_dev->info.graphics_ver;
+}
+/**
+ * intel_query_graphics_ver:
+ * @fd: open i915/xe drm file descriptor
+ *
+ * Returns graphics IP version for device @fd. For i915 devices,
+ * falls back to i915 graphics version lookup.
+ */
+unsigned intel_query_graphics_ver(int fd)
+{
+	struct xe_device *xe_dev;
+
+	if (is_i915_device(fd))
+		return intel_graphics_ver(intel_get_drm_devid(fd));
+
+	xe_dev = xe_device_get(fd);
+
+	return IP_VER(xe_dev->info.graphics_ver, xe_dev->info.graphics_rel);
+}
+
+/**
+ * intel_query_device_info:
+ * @fd: open i915/xe drm file descriptor
+ *
+ * Returns device information structure for device @fd. For i915 devices,
+ * falls back to i915 device info lookup.
+ */
+const struct intel_device_info *intel_query_device_info(int fd)
+{
+	struct xe_device *xe_dev;
+
+	if (is_i915_device(fd))
+		return intel_get_device_info(intel_get_drm_devid(fd));
+
+	xe_dev = xe_device_get(fd);
+
+	return &xe_dev->info;
+}
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 2f6bf788a..61bdc1084 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -104,6 +104,9 @@ const struct intel_cmds_info *intel_get_cmds_info(uint16_t devid) __attribute__(
 unsigned intel_gen(uint16_t devid) __attribute__((pure));
 unsigned intel_graphics_ver(uint16_t devid) __attribute__((pure));
 unsigned intel_display_ver(uint16_t devid) __attribute__((pure));
+unsigned intel_query_gen(int fd);
+unsigned intel_query_graphics_ver(int fd);
+const struct intel_device_info *intel_query_device_info(int fd);
 
 extern enum pch_type intel_pch;
 
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index a89e0b980..3caeecf20 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -20,6 +20,7 @@
 
 #include "drmtest.h"
 #include "ioctl_wrappers.h"
+#include "igt_core.h"
 #include "igt_map.h"
 
 #include "xe_query.h"
@@ -375,10 +376,28 @@ struct xe_device *xe_device_get(int fd)
 	xe_dev->dev_id = xe_dev->config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff;
 	xe_dev->gt_list = xe_query_gt_list_new(fd);
 
+	memcpy(&xe_dev->info, intel_get_device_info(xe_dev->dev_id), sizeof(xe_dev->info));
+
 	/* GT 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->gt_mask |= (1ull << xe_dev->gt_list->gt_list[gt].gt_id);
 
+	/*
+	* Set graphics_rel based on the main GT's ip_ver_minor. We should
+	* use the hardcoded value for the none GMD_ID (ip_ver_major == 0)
+	* platforms (e.g. DG2,ADL,ATSM)
+	*/
+	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);
+			igt_assert(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);
diff --git a/lib/xe/xe_query.h b/lib/xe/xe_query.h
index 715b64e2f..eefeb47dc 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) \
-- 
2.43.0


  reply	other threads:[~2025-10-07 23:26 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07  5:05 [PATCH] lib/intel_device_info: get the xe .graphics_rel from GMD_ID Xin Wang
2025-10-07  9:34 ` Kamil Konieczny
2025-10-07 13:12 ` ✗ Xe.CI.BAT: failure for " Patchwork
2025-10-07 13:32 ` ✓ i915.CI.BAT: success " Patchwork
2025-10-07 16:10 ` ✗ Xe.CI.Full: failure " Patchwork
2025-10-07 16:42 ` [PATCH] " Lin, Shuicheng
2025-10-07 23:26 ` [PATCH v2 0/6] lib: Add runtime device info query APIs for xe devices Xin Wang
2025-10-07 23:26   ` Xin Wang [this message]
2025-10-07 23:26   ` [PATCH v2 2/6] lib/xe: Use new APIs for xe device info queries Xin Wang
2025-10-07 23:26   ` [PATCH v2 3/6] lib: " Xin Wang
2025-10-07 23:26   ` [PATCH v2 4/6] tests/intel: " Xin Wang
2025-10-07 23:26   ` [PATCH v2 5/6] tools: " Xin Wang
2025-10-07 23:26   ` [PATCH v2 6/6] lib/intel_device_info: Remove hardcoded .graphics_rel values Xin Wang
2025-10-08  1:19 ` ✓ Xe.CI.BAT: success for lib/intel_device_info: get the xe .graphics_rel from GMD_ID (rev2) Patchwork
2025-10-08  3:07 ` ✗ Xe.CI.Full: failure " Patchwork
2025-10-08  5:04 ` ✓ i915.CI.BAT: success " Patchwork
2025-10-08  6:45 ` ✗ i915.CI.Full: failure for lib/intel_device_info: get the xe .graphics_rel from GMD_ID Patchwork
2025-10-08 12:14 ` ✗ i915.CI.Full: failure for lib/intel_device_info: get the xe .graphics_rel from GMD_ID (rev2) Patchwork
2025-10-08 21:02 ` [PATCH v3 0/6] lib/intel_device_info: get the xe .graphics_rel from GMD_ID Xin Wang
2025-10-08 21:02   ` [PATCH v3 1/6] lib: Add runtime device info query APIs for xe devices Xin Wang
2025-10-08 22:01     ` Matt Roper
2025-10-09 18:00       ` Wang, X
2025-10-09 23:57         ` Matt Roper
2025-10-10 23:25           ` Ville Syrjälä
2025-10-08 22:07     ` Lin, Shuicheng
2025-10-09 22:34       ` Wang, X
2025-10-09 16:42     ` Kamil Konieczny
2025-10-09 22:30       ` Wang, X
2025-10-08 21:02   ` [PATCH v3 2/6] lib/xe: Use new APIs for xe device info queries Xin Wang
2025-10-08 21:02   ` [PATCH v3 3/6] lib: " Xin Wang
2025-10-08 21:02   ` [PATCH v3 4/6] tests/intel: " Xin Wang
2025-10-08 21:02   ` [PATCH v3 5/6] tools: " Xin Wang
2025-10-08 21:02   ` [PATCH v3 6/6] lib/intel_device_info: Remove hardcoded .graphics_rel values Xin Wang
2025-10-08 21:46 ` ✗ Xe.CI.BAT: failure for lib/intel_device_info: get the xe .graphics_rel from GMD_ID (rev3) Patchwork
2025-10-08 22:04 ` ✓ i915.CI.BAT: success " Patchwork
2025-10-09  1:06 ` ✗ Xe.CI.Full: failure " Patchwork
2025-10-09 11:21 ` ✗ i915.CI.Full: " 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=20251007232606.363629-2-x.wang@intel.com \
    --to=x.wang@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=brian3.nguyen@intel.com \
    --cc=dnyaneshwar.bhadane@intel.com \
    --cc=gustavo.sousa@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=nakshtra.goyal@intel.com \
    --cc=shuicheng.lin@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