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 v2 2/4] tests/intel/xe_pat: add prime-external-import-comp subtest
Date: Thu,  8 Jan 2026 06:59:31 +0000	[thread overview]
Message-ID: <20260108065933.409757-3-x.wang@intel.com> (raw)
In-Reply-To: <20260108065933.409757-1-x.wang@intel.com>

Add a xe_pat subtest that imports a vgem dma-buf into Xe and
verifies that binding it with any compression-enabled PAT index
is rejected with -EINVAL.

Also keep a WB sanity bind to ensure imports still work with
non-compressed caching.

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 | 74 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/tests/intel/xe_pat.c b/tests/intel/xe_pat.c
index 5ad4922dd..8af6ad174 100644
--- a/tests/intel/xe_pat.c
+++ b/tests/intel/xe_pat.c
@@ -831,6 +831,77 @@ static void prime_external_import_coh(void)
 	drm_close_driver(fd2);
 }
 
+/**
+ * SUBTEST: prime-external-import-comp
+ * Test category: functionality test
+ * Description: Validate that imported dma-bufs cannot be bound with a PAT index
+ * that enables compression (expected to fail with -EINVAL).
+ */
+static void prime_external_import_comp(void)
+{
+	uint16_t dev_id;
+	struct intel_pat_cache pat_sw_config = {};
+	int32_t parsed;
+	struct vgem_bo vgem_bo = {};
+	int fd_vgem, fd_xe;
+	int dma_buf_fd;
+	uint32_t handle_import;
+	uint32_t vm;
+	int bpp = 32;
+	int size;
+
+	fd_vgem = drm_open_driver(DRIVER_VGEM);
+	fd_xe = drm_open_driver(DRIVER_XE);
+
+	dev_id = intel_get_drm_devid(fd_xe);
+	igt_require(intel_get_device_info(dev_id)->graphics_ver >= 20);
+
+	parsed = xe_fetch_pat_sw_config(fd_xe, &pat_sw_config);
+
+	vgem_bo.width = 1024;
+	vgem_bo.height = 512;
+	vgem_bo.bpp = bpp;
+	vgem_create(fd_vgem, &vgem_bo);
+
+	size = vgem_bo.width * vgem_bo.height * bpp / 8;
+
+	dma_buf_fd = prime_handle_to_fd(fd_vgem, vgem_bo.handle);
+	handle_import = prime_fd_to_handle(fd_xe, dma_buf_fd);
+
+	vm = xe_vm_create(fd_xe, 0, 0);
+
+	for (int i = 0; i < parsed; i++) {
+		uint32_t pat;
+		bool compressed;
+		int ret;
+
+		if (pat_sw_config.entries[i].rsvd)
+			continue;
+		pat = pat_sw_config.entries[i].pat;
+		compressed = !!(pat & XE2_COMP_EN);
+		if (!compressed)
+			continue;
+		ret = __xe_vm_bind(fd_xe, vm, 0, handle_import, 0, 0x40000,
+				   size, DRM_XE_VM_BIND_OP_MAP, 0, NULL, 0, 0,
+				   i, 0);
+		xe_vm_unbind_sync(fd_xe, vm, 0, 0x40000, size);
+		igt_assert_eq(ret, -EINVAL);
+	}
+
+	/* Sanity: non-compressed WB should still be accepted for imports. */
+	igt_assert_eq(__xe_vm_bind(fd_xe, vm, 0, handle_import, 0, 0x40000,
+			   size, DRM_XE_VM_BIND_OP_MAP, 0, NULL, 0, 0,
+			   intel_get_pat_idx_wb(fd_xe), 0),
+		      0);
+	xe_vm_unbind_sync(fd_xe, vm, 0, 0x40000, size);
+
+	xe_vm_destroy(fd_xe, vm);
+	close(dma_buf_fd);
+
+	drm_close_driver(fd_vgem);
+	drm_close_driver(fd_xe);
+}
+
 static bool has_no_compression_hint(int fd)
 {
 	struct drm_xe_query_config *config = xe_config(fd);
@@ -1384,6 +1455,9 @@ int igt_main_args("V", NULL, help_str, opt_handler, NULL)
 	igt_subtest("prime-external-import-coh")
 		prime_external_import_coh();
 
+	igt_subtest("prime-external-import-comp")
+		prime_external_import_comp();
+
 	igt_subtest("bo-comp-disable-bind")
 		bo_comp_disable_bind(fd);
 
-- 
2.43.0


  parent reply	other threads:[~2026-01-08  6:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08  6:59 [PATCH v2 0/4] xe_pat: add compression subtests Xin Wang
2026-01-08  6:59 ` [PATCH v2 1/4] tests/intel/xe_pat: add userptr-comp subtest Xin Wang
2026-01-08  6:59 ` Xin Wang [this message]
2026-01-08  6:59 ` [PATCH v2 3/4] tests/intel/xe_pat: add bo-wb-comp-1way-bind subtest Xin Wang
2026-01-08 10:16   ` Matthew Auld
2026-01-08  6:59 ` [PATCH v2 4/4] intel-ci: add xe_pat compression subtests Xin Wang
2026-01-08  7:46 ` ✗ Xe.CI.BAT: failure for xe_pat: add compression subtests (rev2) Patchwork
2026-01-08  8:21 ` ✓ i915.CI.BAT: success " Patchwork
2026-01-08 10:31 ` ✓ Xe.CI.Full: " Patchwork
2026-01-08 11:07 ` ✗ 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=20260108065933.409757-3-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