From: Xin Wang <x.wang@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: alex.zuo@intel.com, shuicheng.lin@intel.com,
stuart.summers@intel.com, kamil.konieczny@intel.com,
matthew.d.roper@intel.com, ravi.kumar.vodapalli@intel.com,
zbigniew.kempczynski@intel.com, Xin Wang <x.wang@intel.com>,
Matthew Auld <matthew.auld@intel.com>
Subject: [PATCH v8 2/2] tests/intel/xe_pat: validate PAT table using debugfs
Date: Fri, 19 Dec 2025 23:46:14 +0000 [thread overview]
Message-ID: <20251219234615.90213-3-x.wang@intel.com> (raw)
In-Reply-To: <20251219234615.90213-1-x.wang@intel.com>
Use xe_get_pat_sw_config() to parse the kernel-exposed PAT layout from
debugfs and validate it against IGT's predefined UC/WT/WB/UC_COMP mapping
returned by intel_get_pat_idx_*().
This helps catch drift as new platforms are added, while keeping the
common library path free of debugfs dependencies.
Also use the debugfs-provided reserved flags to determine which PAT
indices should be rejected by the kernel, instead of hard-coding the
reserved range.
V2:
- Validate the parsed sw config against intel_pat getters
CC: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Xin Wang <x.wang@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
---
tests/intel/xe_pat.c | 48 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
diff --git a/tests/intel/xe_pat.c b/tests/intel/xe_pat.c
index 2fd3635fd..9b8ea165f 100644
--- a/tests/intel/xe_pat.c
+++ b/tests/intel/xe_pat.c
@@ -77,6 +77,18 @@ static void userptr_coh_none(int fd)
xe_vm_destroy(fd, vm);
}
+#define BITS_TO(n) (n >= sizeof(long) * 8 ? ~0 : (1UL << (n)) - 1)
+#define BITMASK(high, low) (uint32_t)(BITS_TO(high+1) & ~BITS_TO(low))
+#define FIELD_GET(val, high, low) (((val) & (BITMASK(high, low))) >> (low))
+#define FIELD_GET_BIT(val, n) FIELD_GET(val, n, n)
+
+#define XE_NO_PROMOTE(val) FIELD_GET_BIT(val, 10)
+#define XE_COMP_EN(val) FIELD_GET_BIT(val, 9)
+#define XE_L3_CLOS(val) FIELD_GET(val, 7, 6)
+#define XE_L3_POLICY(val) FIELD_GET(val, 5, 4)
+#define XE_L4_POLICY(val) FIELD_GET(val, 3, 2)
+#define XE_COH_MODE(val) FIELD_GET(val, 1, 0)
+
/**
* SUBTEST: pat-index-all
* Test category: functionality test
@@ -86,6 +98,7 @@ static void pat_index_all(int fd)
{
uint16_t dev_id = intel_get_drm_devid(fd);
size_t size = xe_get_default_alignment(fd);
+ struct intel_pat_cache pat_sw_config = {};
uint32_t vm, bo;
uint8_t pat_index;
@@ -114,10 +127,41 @@ static void pat_index_all(int fd)
igt_assert(intel_get_max_pat_index(fd));
+ if (intel_graphics_ver(dev_id) >= IP_VER(20, 0)) {
+ /* Get the Xe PAT software configuration from the debugfs.*/
+ int32_t parsed = xe_get_pat_sw_config(fd, &pat_sw_config);
+ igt_require_f(parsed > 0,
+ "Couldn't get Xe PAT software configuration\n");
+ for (int i = 0; i < parsed; i++) {
+ uint32_t pat = pat_sw_config.entries[i].pat;
+ igt_debug("PAT[%2d] = [ %u, %u, %u, %u, %u, %u] (%#8x)%s\n", i,
+ XE_NO_PROMOTE(pat),
+ XE_COMP_EN(pat),
+ XE_L3_CLOS(pat),
+ XE_L3_POLICY(pat),
+ XE_L4_POLICY(pat),
+ XE_COH_MODE(pat),
+ pat,
+ pat_sw_config.entries[i].rsvd ? " *" : "");
+ }
+
+ /* Validate the parsed sw config against intel_pat getters */
+ igt_assert(pat_sw_config.max_index == intel_get_max_pat_index(fd));
+ igt_assert(pat_sw_config.uc == intel_get_pat_idx_uc(fd));
+ igt_assert(pat_sw_config.wb == intel_get_pat_idx_wb(fd));
+ if (intel_graphics_ver(dev_id) != IP_VER(35, 11)) {
+ igt_assert(pat_sw_config.wt == intel_get_pat_idx_wt(fd));
+ igt_assert(pat_sw_config.uc_comp == intel_get_pat_idx_uc_comp(fd));
+ }
+ }
+
for (pat_index = 0; pat_index <= intel_get_max_pat_index(fd);
pat_index++) {
- if (intel_get_device_info(dev_id)->graphics_ver >= 20 &&
- pat_index >= 16 && pat_index <= 19) { /* hw reserved */
+
+ bool hw_reserved = intel_graphics_ver(dev_id) >= IP_VER(20, 0) ?
+ pat_sw_config.entries[pat_index].rsvd : false;
+
+ if (hw_reserved) {
igt_assert_eq(__xe_vm_bind(fd, vm, 0, bo, 0, 0x40000,
size, DRM_XE_VM_BIND_OP_MAP, 0, NULL, 0, 0,
pat_index, 0),
--
2.43.0
next prev parent reply other threads:[~2025-12-19 23:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 23:46 [PATCH v8 0/2] tests/intel/xe_pat: add helper funtion to read PAT table Xin Wang
2025-12-19 23:46 ` [PATCH v8 1/2] lib/intel_pat: add pat_sw_config debugfs parser Xin Wang
2025-12-23 21:00 ` Matt Roper
2025-12-19 23:46 ` Xin Wang [this message]
2025-12-23 21:27 ` [PATCH v8 2/2] tests/intel/xe_pat: validate PAT table using debugfs Matt Roper
2025-12-22 17:19 ` ✗ Xe.CI.BAT: failure for tests/intel/xe_pat: add helper funtion to read PAT table (rev2) Patchwork
2025-12-22 17:29 ` ✗ i915.CI.BAT: " Patchwork
2025-12-22 20:33 ` ✓ Xe.CI.Full: success " Patchwork
2025-12-23 17:59 ` ✓ Xe.CI.BAT: success for tests/intel/xe_pat: add helper funtion to read PAT table (rev3) Patchwork
2025-12-23 18:00 ` ✓ i915.CI.BAT: " Patchwork
2025-12-24 4:06 ` ✓ Xe.CI.Full: " Patchwork
2025-12-24 22:51 ` ✓ 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=20251219234615.90213-3-x.wang@intel.com \
--to=x.wang@intel.com \
--cc=alex.zuo@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=ravi.kumar.vodapalli@intel.com \
--cc=shuicheng.lin@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