From: Xin Wang <x.wang@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Xin Wang" <x.wang@intel.com>,
"Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>,
"Matt Roper" <matthew.d.roper@intel.com>,
"Matthew Auld" <matthew.auld@intel.com>
Subject: [PATCH v11 3/5] tests/xe_pat: add pat-sanity subtest for debugfs vs getters
Date: Wed, 31 Dec 2025 23:21:50 +0000 [thread overview]
Message-ID: <20251231232152.127555-4-x.wang@intel.com> (raw)
In-Reply-To: <20251231232152.127555-1-x.wang@intel.com>
Add a new pat-sanity subtest that reads the Xe PAT software
configuration from debugfs and validates it against the
existing PAT index helper getters.
V2: (Matt Roper)
- Use igt_assert_f() instead of igt_require_f() for PAT debugfs
parsing failures (treat as test failure, not skip).
- Drop PAT entry dumping to reduce test noise.
- Use igt_assert_eq() to improve failure diagnostics.
V3: (Matt Roper)
- code cleanups for consistency
CC: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
CC: Matt Roper <matthew.d.roper@intel.com>
CC: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Xin Wang <x.wang@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
---
tests/intel/xe_pat.c | 79 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/tests/intel/xe_pat.c b/tests/intel/xe_pat.c
index 2fd3635fd..da4234a2c 100644
--- a/tests/intel/xe_pat.c
+++ b/tests/intel/xe_pat.c
@@ -18,6 +18,7 @@
#include "intel_blt.h"
#include "intel_mocs.h"
#include "intel_pat.h"
+#include "linux_scaffold.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
@@ -76,6 +77,81 @@ static void userptr_coh_none(int fd)
munmap(data, size);
xe_vm_destroy(fd, vm);
}
+#define REG_FIELD_GET(__mask, __val) \
+ ((uint32_t)FIELD_GET(__mask, __val))
+
+#define XE2_NO_PROMOTE REG_BIT(10)
+#define XE2_COMP_EN REG_BIT(9)
+#define XE2_L3_CLOS GENMASK(7, 6)
+#define XE2_L3_POLICY GENMASK(5, 4)
+#define XE2_L4_POLICY GENMASK(3, 2)
+#define XE2_COH_MODE GENMASK(1, 0)
+
+#define L3_CLOS1 1
+#define L3_CLOS2 2
+#define L3_CLOS3 3
+
+#define L3_CACHE_POLICY_WB 0
+#define L3_CACHE_POLICY_XD 1
+#define L3_CACHE_POLICY_UC 3
+
+#define L4_CACHE_POLICY_WB 0
+#define L4_CACHE_POLICY_WT 1
+#define L4_CACHE_POLICY_UC 3
+
+#define COH_MODE_NONE 0
+#define COH_MODE_1WAY 2
+#define COH_MODE_2WAY 3
+
+static int xe_fetch_pat_sw_config(int fd, struct intel_pat_cache *pat_sw_config)
+{
+ int32_t parsed = xe_get_pat_sw_config(fd, pat_sw_config);
+
+ igt_assert_f(parsed > 0, "Couldn't get Xe PAT software configuration\n");
+
+ return parsed;
+}
+
+/**
+ * SUBTEST: pat-sanity
+ * Test category: functionality test
+ * Description: Test debugfs PAT config vs getters
+ */
+static void pat_sanity(int fd)
+{
+ uint16_t dev_id = intel_get_drm_devid(fd);
+ struct intel_pat_cache pat_sw_config = {};
+ int32_t parsed;
+ bool has_uc_comp = false, has_wt = false;
+
+ parsed = xe_fetch_pat_sw_config(fd, &pat_sw_config);
+
+ if (intel_graphics_ver(dev_id) >= IP_VER(20, 0)) {
+ for (int i = 0; i < parsed; i++) {
+ uint32_t pat = pat_sw_config.entries[i].pat;
+ if (pat_sw_config.entries[i].rsvd)
+ continue;
+ if (!!(pat & XE2_COMP_EN) &&
+ REG_FIELD_GET(XE2_L3_POLICY, pat) == L3_CACHE_POLICY_UC &&
+ REG_FIELD_GET(XE2_L4_POLICY, pat) == L4_CACHE_POLICY_UC) {
+ has_uc_comp = true;
+ }
+ if (REG_FIELD_GET(XE2_L3_POLICY, pat) == L3_CACHE_POLICY_XD &&
+ REG_FIELD_GET(XE2_L4_POLICY, pat) == L4_CACHE_POLICY_WT) {
+ has_wt = true;
+ }
+ }
+ } else {
+ has_wt = true;
+ }
+ igt_assert_eq(pat_sw_config.max_index, intel_get_max_pat_index(fd));
+ igt_assert_eq(pat_sw_config.uc, intel_get_pat_idx_uc(fd));
+ igt_assert_eq(pat_sw_config.wb, intel_get_pat_idx_wb(fd));
+ if (has_wt)
+ igt_assert_eq(pat_sw_config.wt, intel_get_pat_idx_wt(fd));
+ if (has_uc_comp)
+ igt_assert_eq(pat_sw_config.uc_comp, intel_get_pat_idx_uc_comp(fd));
+}
/**
* SUBTEST: pat-index-all
@@ -1230,6 +1306,9 @@ int igt_main_args("V", NULL, help_str, opt_handler, NULL)
xe_device_get(fd);
}
+ igt_subtest("pat-sanity")
+ pat_sanity(fd);
+
igt_subtest("pat-index-all")
pat_index_all(fd);
--
2.43.0
next prev parent reply other threads:[~2025-12-31 23:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 23:21 [PATCH v11 0/5] tests/intel/xe_pat: add helper funtion to read PAT table Xin Wang
2025-12-31 23:21 ` [PATCH v11 1/5] lib/intel_pat: add pat_sw_config debugfs parser Xin Wang
2025-12-31 23:21 ` [PATCH v11 2/5] include/linux_scaffold: add FIELD_GET() bitfield helper Xin Wang
2025-12-31 23:21 ` Xin Wang [this message]
2025-12-31 23:21 ` [PATCH v11 4/5] tests/xe_pat: use debugfs reserved flags Xin Wang
2025-12-31 23:21 ` [PATCH v11 5/5] intel-ci: add xe_pat pat-sanity Xin Wang
2026-01-01 0:35 ` ✓ Xe.CI.BAT: success for tests/intel/xe_pat: add helper funtion to read PAT table Patchwork
2026-01-01 0:46 ` ✓ i915.CI.BAT: " Patchwork
2026-01-01 1:48 ` ✓ Xe.CI.Full: " Patchwork
2026-01-05 16:58 ` Matt Roper
2026-01-01 2:21 ` ✗ i915.CI.Full: failure " 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=20251231232152.127555-4-x.wang@intel.com \
--to=x.wang@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=matthew.d.roper@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