From: nishit.sharma@intel.com
To: igt-dev@lists.freedesktop.org, priyanka.dandamudi@intel.com
Subject: [PATCH i-g-t 1/2] tests/intel/xe_exec_store: Validate PCIe6 relax ordering
Date: Tue, 24 Feb 2026 05:33:23 +0000 [thread overview]
Message-ID: <20260224053324.2354159-2-nishit.sharma@intel.com> (raw)
In-Reply-To: <20260224053324.2354159-1-nishit.sharma@intel.com>
From: Nishit Sharma <nishit.sharma@intel.com>
To improve GPU BW, certain copy engine write instructions
to system memory is using relaxed pcie transaction which
can lead to out of order write to system memory.
The recommendation is to use MI_MEM_FENCE for such instructions
like MEM_COPY and MEM_SET to serialize the memory writes.
In this test the copy limit for MEM_COPY instruction is enforced to max
data for linear mode.
Signed-off-by: Nishit Sharma <nishit.sharma@intel.com>
---
tests/intel/xe_exec_store.c | 140 ++++++++++++++++++++++++++++++++++++
1 file changed, 140 insertions(+)
diff --git a/tests/intel/xe_exec_store.c b/tests/intel/xe_exec_store.c
index 6935fa8aa..1acaa5aaa 100644
--- a/tests/intel/xe_exec_store.c
+++ b/tests/intel/xe_exec_store.c
@@ -28,6 +28,7 @@
#define STORE 0
#define COND_BATCH 1
+#define MAX_DATA_WRITE ((size_t)(262143)) //Maximum data MEM_COPY operate for linear mode
struct data {
uint32_t batch[16];
@@ -412,6 +413,126 @@ static void long_shader(int fd, struct drm_xe_engine_class_instance *hwe,
free(buf);
}
+/**
+ * SUBTEST: mem-write-ordering-check
+ * Description: Verify that copy engines writes to sys mem is ordered
+ * Test category: functionality test
+ *
+ */
+static void mem_transaction_ordering(int fd, size_t bo_size, bool fence)
+{
+ struct drm_xe_engine_class_instance inst = {
+ .engine_class = DRM_XE_ENGINE_CLASS_COPY,
+ };
+ struct drm_xe_sync sync[2] = {
+ { .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, },
+ { .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, }
+ };
+
+ struct drm_xe_exec exec = {
+ .num_batch_buffer = 1,
+ .num_syncs = 2,
+ .syncs = to_user_pointer(&sync),
+ };
+
+ int count = 3; // src, dest, batch
+ int i, b = 0;
+ uint64_t offset[count];
+ uint64_t dst_offset;
+ uint64_t src_offset;
+ uint32_t exec_queues, vm, syncobjs;
+ uint32_t bo[count], *bo_map[count];
+ uint64_t ahnd;
+ uint32_t *batch_map;
+ int src_idx = 0, dst_idx = 1;
+ size_t bytes_written, size;
+
+ bo_size = ALIGN(bo_size, xe_get_default_alignment(fd));
+ bytes_written = bo_size;
+ vm = xe_vm_create(fd, 0, 0);
+ ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE);
+ exec_queues = xe_exec_queue_create(fd, vm, &inst, 0);
+ syncobjs = syncobj_create(fd, 0);
+ sync[0].handle = syncobj_create(fd, 0);
+
+ for (i = 0; i < count; i++) {
+ bo[i] = xe_bo_create_caching(fd, vm, bo_size, system_memory(fd), 0,
+ DRM_XE_GEM_CPU_CACHING_WC);
+ bo_map[i] = xe_bo_map(fd, bo[i], bo_size);
+ offset[i] = intel_allocator_alloc_with_strategy(ahnd, bo[i],
+ bo_size, 0,
+ ALLOC_STRATEGY_NONE);
+ xe_vm_bind_async(fd, vm, 0, bo[i], 0, offset[i], bo_size, sync, 1);
+ }
+
+ batch_map = xe_bo_map(fd, bo[i - 1], bo_size);
+ exec.address = offset[i - 1];
+
+ // Fill source buffer with a pattern
+ for (i = 0; i < bo_size; i++)
+ ((uint8_t *)bo_map[src_idx])[i] = i % bo_size;
+
+ dst_offset = offset[dst_idx];
+ src_offset = offset[src_idx];
+ while (bo_size) {
+ size = min(MAX_DATA_WRITE, bo_size);
+ batch_map[b++] = MEM_COPY_CMD;
+ batch_map[b++] = size - 1;// src # of bytes
+ batch_map[b++] = 0; //src height
+ batch_map[b++] = -1; // src pitch
+ batch_map[b++] = -1; // dist pitch
+ batch_map[b++] = src_offset;
+ batch_map[b++] = src_offset >> 32;
+ batch_map[b++] = dst_offset;
+ batch_map[b++] = dst_offset >> 32;
+ batch_map[b++] = intel_get_uc_mocs_index(fd) << 25 | intel_get_uc_mocs_index(fd);
+
+ src_offset += size;
+ dst_offset += size;
+ bo_size -= size;
+ }
+ if (fence)
+ batch_map[b++] = MI_MEM_FENCE | MI_WRITE_FENCE;
+
+ batch_map[b++] = MI_BATCH_BUFFER_END;
+ sync[0].flags &= ~DRM_XE_SYNC_FLAG_SIGNAL;
+ sync[1].flags |= DRM_XE_SYNC_FLAG_SIGNAL;
+ sync[1].handle = syncobjs;
+ exec.exec_queue_id = exec_queues;
+ xe_exec(fd, &exec);
+ igt_assert(syncobj_wait(fd, &syncobjs, 1, INT64_MAX, 0, NULL));
+
+ if (fence) {
+ igt_assert(memcmp(bo_map[src_idx], bo_map[dst_idx], bytes_written) == 0);
+ } else {
+ bool detected_out_of_order = false;
+
+ for (i = bo_size - 1; i >= 0; i--) {
+ if (((uint8_t *)bo_map[src_idx])[i] != ((uint8_t *)bo_map[dst_idx])[i]) {
+ detected_out_of_order = true;
+ break;
+ }
+ }
+
+ if (detected_out_of_order)
+ igt_info("Test detected out of order write at idx %d\n", i);
+ else
+ igt_info("Test didn't detect out of order writes\n");
+ }
+
+ for (i = 0; i < count; i++) {
+ munmap(bo_map[i], bo_size);
+ gem_close(fd, bo[i]);
+ }
+
+ munmap(batch_map, bo_size);
+ put_ahnd(ahnd);
+ syncobj_destroy(fd, sync[0].handle);
+ syncobj_destroy(fd, syncobjs);
+ xe_exec_queue_destroy(fd, exec_queues);
+ xe_vm_destroy(fd, vm);
+}
+
int igt_main()
{
struct drm_xe_engine_class_instance *hwe;
@@ -483,6 +604,25 @@ int igt_main()
igt_collection_destroy(set);
}
+ igt_describe("Verify memory relax ordering using copy/write operations");
+ igt_subtest_with_dynamic("mem-write-ordering-check") {
+ struct {
+ size_t size;
+ const char *label;
+ } sizes[] = {
+ { SZ_1M, "1M" },
+ { SZ_2M, "2M" },
+ { SZ_8M, "8M" },
+ };
+
+ for (size_t i = 0; i < ARRAY_SIZE(sizes); i++) {
+ igt_dynamic_f("size-%s", sizes[i].label) {
+ mem_transaction_ordering(fd, sizes[i].size, true);
+ mem_transaction_ordering(fd, sizes[i].size, false);
+ }
+ }
+ }
+
igt_fixture() {
xe_device_put(fd);
close(fd);
--
2.34.1
next prev parent reply other threads:[~2026-02-24 5:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 5:33 [PATCH i-g-t 0/2] Add memory write ordering verification nishit.sharma
2026-02-24 5:33 ` nishit.sharma [this message]
2026-02-24 8:55 ` [PATCH i-g-t 1/2] tests/intel/xe_exec_store: Validate PCIe6 relax ordering Dandamudi, Priyanka
2026-02-24 5:33 ` [PATCH i-g-t 2/2] tests/intel/xe_exec_store: Extend test coverage to all memory regions nishit.sharma
2026-02-24 8:55 ` Dandamudi, Priyanka
2026-02-24 6:20 ` ✓ Xe.CI.BAT: success for Add memory write ordering verification (rev2) Patchwork
2026-02-24 6:32 ` ✓ i915.CI.BAT: " Patchwork
2026-02-24 9:23 ` ✗ i915.CI.Full: failure " Patchwork
2026-02-24 17:29 ` ✗ Xe.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=20260224053324.2354159-2-nishit.sharma@intel.com \
--to=nishit.sharma@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=priyanka.dandamudi@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