From: Xin Wang <x.wang@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Xin Wang <x.wang@intel.com>,
matthew.d.roper@intel.com, zbigniew.kempczynski@intel.com,
kamil.konieczny@linux.intel.com, ravi.kumar.vodapalli@intel.com,
stuart.summers@intel.com
Subject: [PATCH i-g-t v13 3/4] lib/intel_device_info: allow xe_query to override graphics version
Date: Wed, 23 Sep 2026 20:55:39 -0700 [thread overview]
Message-ID: <20260924035545.710985-4-x.wang@intel.com> (raw)
In-Reply-To: <20260924035545.710985-1-x.wang@intel.com>
Platforms with GMD_ID report the graphics IP major/minor version in
hardware, and xe exposes it via ip_ver_{major,minor} of the MAIN GT in
the GT list query. The static PCI-ID table cannot describe this
reliably, since devices sharing a PCI device ID may report different
IP versions.
Teach xe_device_get() to pick up the IP version from the MAIN GT and
update the cached intel_device_info via a new
xe_dev_update_graphics_ver() helper.
The cache is keyed by PCI device ID, so a system with multiple GPUs
sharing a device ID but reporting different IP versions is not
supported; the last probed device wins. This is considered unlikely in
practice.
v2:
- make xe_dev_update_graphics_ver() return error and guard NULL cache.
- assert in xe query path to avoid silently ignoring update failures.
v3:
- return -ENOENT instead of -1 and fix coding style.
- document the devid keying and the lockless readers.
Signed-off-by: Xin Wang <x.wang@intel.com>
---
lib/intel_chipset.h | 1 +
lib/intel_device_info.c | 43 +++++++++++++++++++++++++++++++++++++++++
lib/xe/xe_query.c | 17 ++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 1f02932e4a..d71eeb4370 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -110,6 +110,7 @@ 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));
+int xe_dev_update_graphics_ver(uint16_t devid, unsigned int major, unsigned int minor);
extern enum pch_type intel_pch;
diff --git a/lib/intel_device_info.c b/lib/intel_device_info.c
index a7ba40ed2b..096cf6eb7a 100644
--- a/lib/intel_device_info.c
+++ b/lib/intel_device_info.c
@@ -5,6 +5,7 @@
#include "igt_map.h"
#include <ctype.h>
+#include <errno.h>
#include <pthread.h>
#include <strings.h> /* ffs() */
@@ -772,6 +773,48 @@ static const struct intel_device_info *devinfo_table_lookup(uint16_t devid)
return (const struct intel_device_info *)intel_device_match[i].match_data;
}
+/**
+ * xe_dev_update_graphics_ver:
+ * @devid: pci device id
+ * @major: new major graphics version
+ * @minor: new minor graphics version
+ *
+ * Updates the cached graphics version of the device with the specified @devid.
+ * On Xe platforms with GMD_ID, the graphics major and minor versions are read
+ * from the hardware and override the values from the static PCI-ID table.
+ *
+ * The cache is keyed by @devid, so all devices sharing a PCI device ID share
+ * one entry; with several such devices reporting different IP versions, the
+ * last update wins.
+ *
+ * Readers of intel_get_device_info() do not take the cache lock. This is fine
+ * because the entry is only written when a device is first probed by
+ * xe_device_get(), and only if the version actually changes.
+ *
+ * Returns:
+ * 0 on success, -ENOENT if there is no cache entry for @devid.
+ */
+int xe_dev_update_graphics_ver(uint16_t devid, unsigned int major, unsigned int minor)
+{
+ struct intel_device_info *info;
+ int ret = 0;
+
+ if (intel_graphics_ver(devid) == IP_VER(major, minor))
+ return 0;
+
+ pthread_mutex_lock(&devinfo_cache.mutex);
+ info = devinfo_cache_search(devid);
+ if (info) {
+ info->graphics_ver = major;
+ info->graphics_rel = minor;
+ } else {
+ ret = -ENOENT;
+ }
+ pthread_mutex_unlock(&devinfo_cache.mutex);
+
+ return ret;
+}
+
/**
* intel_get_device_info:
* @devid: pci device id
diff --git a/lib/xe/xe_query.c b/lib/xe/xe_query.c
index 91ffc36e64..a15099cb3b 100644
--- a/lib/xe/xe_query.c
+++ b/lib/xe/xe_query.c
@@ -412,6 +412,23 @@ 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);
+ /* On GMD_ID platforms, the MAIN GT reports the graphics IP version */
+ for (int gt = 0; gt < xe_dev->gt_list->num_gt; gt++) {
+ const struct drm_xe_gt *gt_info = &xe_dev->gt_list->gt_list[gt];
+
+ if (gt_info->type != DRM_XE_QUERY_GT_TYPE_MAIN || !gt_info->ip_ver_major)
+ continue;
+
+ igt_debug("GMD_ID graphics IP version %u.%02u for dev_id 0x%x\n",
+ gt_info->ip_ver_major, gt_info->ip_ver_minor, xe_dev->dev_id);
+ igt_assert_f(!xe_dev_update_graphics_ver(xe_dev->dev_id,
+ gt_info->ip_ver_major,
+ gt_info->ip_ver_minor),
+ "Failed to update graphics version for dev_id 0x%x\n",
+ xe_dev->dev_id);
+ 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);
--
2.43.0
next prev parent reply other threads:[~2026-09-24 3:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 3:55 [PATCH i-g-t v13 0/4] lib/intel_device_info: get the xe .graphics_rel from GMD_ID Xin Wang
2026-09-24 3:55 ` [PATCH i-g-t v13 1/4] lib/igt_core: add igt_destructor helper macro Xin Wang
2026-09-24 3:55 ` [PATCH i-g-t v13 2/4] lib/intel_device_info: make device info cache process-wide Xin Wang
2026-09-25 6:22 ` Zbigniew Kempczyński
2026-09-25 23:43 ` Wang, X
2026-09-24 3:55 ` Xin Wang [this message]
2026-09-24 3:55 ` [PATCH i-g-t v13 4/4] lib/intel_device_info: remove the graphics_rel from xe2+ devices Xin Wang
2026-09-24 5:34 ` ✓ Xe.CI.BAT: success for lib/intel_device_info: get the xe .graphics_rel from GMD_ID Patchwork
2026-09-24 5:43 ` ✓ i915.CI.BAT: " Patchwork
2026-09-24 18:22 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-25 5:28 ` ✗ 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=20260924035545.710985-4-x.wang@intel.com \
--to=x.wang@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=matthew.d.roper@intel.com \
--cc=ravi.kumar.vodapalli@intel.com \
--cc=stuart.summers@intel.com \
--cc=zbigniew.kempczynski@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