From: nishit.sharma@intel.com
To: igt-dev@lists.freedesktop.org, nishit.sharma@intel.com,
pravalika.gurram@intel.com
Subject: [PATCH i-g-t v9 02/10] lib/xe: Add synchronous helpers for VM bind/unbind operations
Date: Mon, 1 Dec 2025 09:03:41 +0000 [thread overview]
Message-ID: <20251201090349.326673-3-nishit.sharma@intel.com> (raw)
In-Reply-To: <20251201090349.326673-1-nishit.sharma@intel.com>
From: Nishit Sharma <nishit.sharma@intel.com>
Introduce synchronous wrappers for VM bind/unbind operations that handle
user fence allocation, waiting, and cleanup internally. This simplifies
test code by eliminating repetitive synchronization boilerplate.
Signed-off-by: Nishit Sharma <nishit.sharma@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
lib/xe/xe_ioctl.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index 221fd7c62..369c5887d 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -747,3 +747,42 @@ void xe_vm_madvise(int fd, uint32_t vm, uint64_t addr, uint64_t range,
igt_assert_eq(__xe_vm_madvise(fd, vm, addr, range, ext, type, op_val, policy,
instance), 0);
}
+
+#define BIND_SYNC_VAL 0x686868
+void xe_vm_bind_lr_sync(int fd, uint32_t vm, uint32_t bo, uint64_t offset,
+ uint64_t addr, uint64_t size, uint32_t flags)
+{
+ volatile uint64_t *sync_addr = malloc(sizeof(*sync_addr));
+ struct drm_xe_sync sync = {
+ .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+ .addr = to_user_pointer((uint64_t *)sync_addr),
+ .timeline_value = BIND_SYNC_VAL,
+ };
+
+ igt_assert(!!sync_addr);
+ xe_vm_bind_async_flags(fd, vm, 0, bo, 0, addr, size, &sync, 1, flags);
+ if (*sync_addr != BIND_SYNC_VAL)
+ xe_wait_ufence(fd, (uint64_t *)sync_addr, BIND_SYNC_VAL, 0, NSEC_PER_SEC * 10);
+ /* Only free if the wait succeeds */
+ free((void *)sync_addr);
+}
+
+void xe_vm_unbind_lr_sync(int fd, uint32_t vm, uint64_t offset,
+ uint64_t addr, uint64_t size)
+{
+ volatile uint64_t *sync_addr = malloc(sizeof(*sync_addr));
+ struct drm_xe_sync sync = {
+ .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+ .addr = to_user_pointer((uint64_t *)sync_addr),
+ .timeline_value = BIND_SYNC_VAL,
+ };
+
+ igt_assert(!!sync_addr);
+ *sync_addr = 0;
+ xe_vm_unbind_async(fd, vm, 0, 0, addr, size, &sync, 1);
+ if (*sync_addr != BIND_SYNC_VAL)
+ xe_wait_ufence(fd, (uint64_t *)sync_addr, BIND_SYNC_VAL, 0, NSEC_PER_SEC * 10);
+ free((void *)sync_addr);
+}
--
2.48.1
next prev parent reply other threads:[~2025-12-01 9:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 9:03 [PATCH i-g-t v9 00/10] Madvise feature in SVM for Multi-GPU configs nishit.sharma
2025-12-01 9:03 ` [PATCH i-g-t v9 01/10] lib/xe: Add instance parameter to xe_vm_madvise nishit.sharma
2025-12-01 13:13 ` Gurram, Pravalika
2025-12-01 15:33 ` Kamil Konieczny
2025-12-01 9:03 ` nishit.sharma [this message]
2025-12-01 13:14 ` [PATCH i-g-t v9 02/10] lib/xe: Add synchronous helpers for VM bind/unbind operations Gurram, Pravalika
2025-12-01 9:03 ` [PATCH i-g-t v9 03/10] tests/intel/xe_multi_gpusvm: Add SVM multi-GPU xGPU memory access test nishit.sharma
2025-12-01 13:14 ` Gurram, Pravalika
2025-12-01 16:03 ` Kamil Konieczny
2025-12-01 16:11 ` Sharma, Nishit
2025-12-01 9:03 ` [PATCH i-g-t v9 04/10] tests/intel/xe_multi_gpusvm: Add SVM multi-GPU atomic operations nishit.sharma
2025-12-01 13:15 ` Gurram, Pravalika
2025-12-01 9:03 ` [PATCH i-g-t v9 05/10] tests/intel/xe_multi_gpusvm: Add SVM multi-GPU coherency test nishit.sharma
2025-12-01 13:17 ` Gurram, Pravalika
2025-12-01 9:03 ` [PATCH i-g-t v9 06/10] tests/intel/xe_multi_gpusvm: Add SVM multi-GPU performance test nishit.sharma
2025-12-01 13:17 ` Gurram, Pravalika
2025-12-01 9:03 ` [PATCH i-g-t v9 07/10] tests/intel/xe_multi_gpusvm: Add SVM multi-GPU fault handling test nishit.sharma
2025-12-01 13:18 ` Gurram, Pravalika
2025-12-01 9:03 ` [PATCH i-g-t v9 08/10] tests/intel/xe_multi_gpusvm: Add SVM multi-GPU simultaneous access test nishit.sharma
2025-12-01 13:18 ` Gurram, Pravalika
2025-12-01 9:03 ` [PATCH i-g-t v9 09/10] tests/intel/xe_multi_gpusvm: Add SVM multi-GPU conflicting madvise test nishit.sharma
2025-12-01 13:18 ` Gurram, Pravalika
2025-12-01 9:03 ` [PATCH i-g-t v9 10/10] tests/intel/xe_multi-gpusvm: Add SVM multi-GPU migration test nishit.sharma
2025-12-01 13:19 ` Gurram, Pravalika
2025-12-01 11:46 ` ✗ i915.CI.BAT: failure for Madvise feature in SVM for Multi-GPU configs Patchwork
2025-12-01 12:36 ` ✓ Xe.CI.BAT: success " Patchwork
2025-12-01 14:31 ` ✓ Xe.CI.Full: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2025-11-21 16:25 [PATCH i-g-t v8 00/10] " nishit.sharma
2025-12-01 9:01 ` [PATCH i-g-t v9 " nishit.sharma
2025-12-01 9:01 ` [PATCH i-g-t v9 02/10] lib/xe: Add synchronous helpers for VM bind/unbind operations nishit.sharma
2025-12-02 7:47 ` Hellstrom, Thomas
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=20251201090349.326673-3-nishit.sharma@intel.com \
--to=nishit.sharma@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=pravalika.gurram@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;
as well as URLs for NNTP newsgroup(s).