public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Xin Wang <x.wang@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Xin Wang <x.wang@intel.com>, Matthew Auld <matthew.auld@intel.com>
Subject: [PATCH 1/4] tests/xe_pat: add userptr-comp PAT test
Date: Wed,  7 Jan 2026 05:24:03 +0000	[thread overview]
Message-ID: <20260107052406.21678-2-x.wang@intel.com> (raw)
In-Reply-To: <20260107052406.21678-1-x.wang@intel.com>

Add a new xe_pat subtest that iterates the debugfs PAT table and
validates that userptr bindings are rejected for PAT entries
enabling compression and for COH_MODE_NONE entries.

Expected failures return -EINVAL.

Cc: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Xin Wang <x.wang@intel.com>
---
 tests/intel/xe_pat.c | 61 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/tests/intel/xe_pat.c b/tests/intel/xe_pat.c
index a7f8ab088..5ad4922dd 100644
--- a/tests/intel/xe_pat.c
+++ b/tests/intel/xe_pat.c
@@ -887,6 +887,64 @@ static void bo_comp_disable_bind(int fd)
 	xe_vm_destroy(fd, vm);
 }
 
+/**
+ * SUBTEST: userptr-comp
+ * Test category: functionality test
+ * Description: Validate that userptr mappings cannot be bound with a PAT index
+ * that enables compression (expected to fail with -EINVAL).
+ */
+static void userptr_comp(int fd)
+{
+	size_t size = xe_get_default_alignment(fd);
+	uint16_t dev_id = intel_get_drm_devid(fd);
+	struct intel_pat_cache pat_sw_config = {};
+	int32_t parsed;
+	uint32_t vm;
+	void *data;
+
+	igt_require(intel_get_device_info(dev_id)->graphics_ver >= 20);
+
+	parsed = xe_fetch_pat_sw_config(fd, &pat_sw_config);
+
+	data = mmap(0, size, PROT_READ | PROT_WRITE,
+		    MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+	igt_assert(data != MAP_FAILED);
+
+	vm = xe_vm_create(fd, 0, 0);
+
+	for (int i = 0; i < parsed; i++) {
+		uint32_t pat;
+		uint32_t coh_mode;
+		bool compressed;
+		uint64_t va;
+		int expected;
+		int ret;
+
+		if (pat_sw_config.entries[i].rsvd)
+			continue;
+		pat = pat_sw_config.entries[i].pat;
+		compressed = !!(pat & XE2_COMP_EN);
+		coh_mode = REG_FIELD_GET(XE2_COH_MODE, pat);
+
+		/* Spread VAs to keep each attempt independent. */
+		va = 0x40000ull + (uint64_t)i * 0x200000ull;
+
+		if (compressed || coh_mode == COH_MODE_NONE)
+			expected = -EINVAL;
+		else
+			expected = 0;
+		ret = __xe_vm_bind(fd, vm, 0, 0, to_user_pointer(data), va,
+				   size, DRM_XE_VM_BIND_OP_MAP_USERPTR, 0, NULL, 0, 0,
+				   i, 0);
+		igt_assert_eq(ret, expected);
+		if (!ret)
+			xe_vm_unbind_sync(fd, vm, 0, va, size);
+	}
+
+	munmap(data, size);
+	xe_vm_destroy(fd, vm);
+}
+
 /**
  * SUBTEST: display-vs-wb-transient
  * Test category: functionality test
@@ -1317,6 +1375,9 @@ int igt_main_args("V", NULL, help_str, opt_handler, NULL)
 	igt_subtest("userptr-coh-none")
 		userptr_coh_none(fd);
 
+	igt_subtest("userptr-comp")
+		userptr_comp(fd);
+
 	igt_subtest("prime-self-import-coh")
 		prime_self_import_coh();
 
-- 
2.43.0


  reply	other threads:[~2026-01-07  5:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07  5:24 [PATCH 0/4] xe_pat: add compression subtests Xin Wang
2026-01-07  5:24 ` Xin Wang [this message]
2026-01-07  9:57   ` [PATCH 1/4] tests/xe_pat: add userptr-comp PAT test Matthew Auld
2026-01-07  5:24 ` [PATCH 2/4] tests/xe_pat: add prime-external-import-comp " Xin Wang
2026-01-07 10:01   ` Matthew Auld
2026-01-07  5:24 ` [PATCH 3/4] tests/xe_pat: add bo-wb-comp-1way-bind " Xin Wang
2026-01-07 10:17   ` Matthew Auld
2026-01-08  6:57     ` Wang, X
2026-01-07  5:24 ` [PATCH 4/4] intel-ci: add xe_pat compression subtests Xin Wang
2026-01-07  6:48 ` ✓ Xe.CI.BAT: success for xe_pat: add " Patchwork
2026-01-07  7:08 ` ✓ i915.CI.BAT: " Patchwork
2026-01-07  8:33 ` ✗ Xe.CI.Full: failure " Patchwork
2026-01-07  9:59 ` ✗ 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=20260107052406.21678-2-x.wang@intel.com \
    --to=x.wang@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.auld@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