From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD21FC982FD for ; Thu, 24 Sep 2026 03:59:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62AFF88A27; Thu, 24 Sep 2026 03:59:16 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="N2aVg2Ib"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1382910E02D for ; Thu, 24 Sep 2026 03:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1790222148; x=1821758148; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nOZKeXvAz293ZMOJOQZlRy/oFohGrQ3Ynx94aw4Xyj4=; b=N2aVg2Ibei0aGMQ3A0MJtXicnUy+jBsHuohW7+AYWtOCr5Jr1gP+QIiv 6NNV8EEYTL5HyEBfkekc9I5viyooOqPTzGjBUVid9V4Azb6ITigKhK2/3 OxhcH8f92wAgOLBfA/DwYvU/bvxtreCviNGDpNI7JkWbblE8uD9ecpDsv 8vOzyH57qFyZtFUE8Ch5otQmq829nysEmIZSjn7DrzRNEhs4dIyJiRD9I +5x2aBq+a/mzzLygLX7M4tltSUrE5/ADYR/CELJPgedMbDb4y8hoOnaMY XRQZ6sUBGNUFTDbjeSQHBg5I7Wr9MU+xzw0r9YAyIagAZcoWNvmEhfRqi A==; X-CSE-ConnectionGUID: wptYB9xETOqGn7093zzQ9g== X-CSE-MsgGUID: Fa9robA9TL6adChg5vyYJw== X-IronPort-AV: E=McAfee;i="6800,10657,11914"; a="101639489" X-IronPort-AV: E=Sophos;i="6.27,119,1787036400"; d="scan'208";a="101639489" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2026 20:55:47 -0700 X-CSE-ConnectionGUID: zz8zBF8xS22+c/ku2jAPLQ== X-CSE-MsgGUID: IE+peVh5QS645i45E1/eAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,119,1787036400"; d="scan'208";a="270399275" Received: from xwang-desk.fm.intel.com ([10.121.64.134]) by fmviesa009.fm.intel.com with ESMTP; 23 Sep 2026 20:55:48 -0700 From: Xin Wang To: igt-dev@lists.freedesktop.org Cc: Xin Wang , 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 Message-ID: <20260924035545.710985-4-x.wang@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260924035545.710985-1-x.wang@intel.com> References: <20260924035545.710985-1-x.wang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" 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 --- 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 +#include #include #include /* 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