From: Sobin Thomas <sobin.thomas@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: thomas.hellstrom@intel.com, nishit.sharma@intel.com,
Sobin Thomas <sobin.thomas@intel.com>
Subject: [PATCH i-g-t v8 2/3] lib/xe: Add failable variant of xe_vm_bind_lr_sync()
Date: Fri, 27 Mar 2026 13:24:25 +0000 [thread overview]
Message-ID: <20260327132427.2681193-3-sobin.thomas@intel.com> (raw)
In-Reply-To: <20260327132427.2681193-1-sobin.thomas@intel.com>
Add __xe_vm_bind_lr_sync helper function which returns standard error
codes instead of asserting on failure. This allows calling function
to handle VM bind failures explicitly while preserving the existing
xe_vm_bind_lr_sync() wrapper for tests.
Refactor the implementation to use proper return-code handling and
user-fence synchronization, and add xe_vm_bind_lr_failable() for
callers that expect bind / overcommit failures.
v7: Introduced xe_vm_bind_lr_sync_failable (Thomas)
v8: Modified xe_vm_bind_lr_sync_failable and xe_vm_bind_lr_sync to call
__xe_vm_bind_lr_sync
Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
lib/xe/xe_ioctl.c | 36 ++++++++++++++++++++++++++++++------
lib/xe/xe_ioctl.h | 4 ++++
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index ea3f2fcaa..a8d315dfb 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -822,23 +822,47 @@ void xe_vm_madvise(int fd, uint32_t vm, uint64_t addr, uint64_t range,
}
#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)
+int __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));
+ 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,
};
+ int ret = 0;
- 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)
+ if (!sync_addr)
+ return -ENOMEM;
+
+ WRITE_ONCE(*sync_addr, 0);
+
+ ret = __xe_vm_bind(fd, vm, 0, bo, 0, addr, size, DRM_XE_VM_BIND_OP_MAP, flags,
+ &sync, 1, 0, DEFAULT_PAT_INDEX, 0);
+
+ if (ret)
+ goto out;
+
+ if (READ_ONCE(*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 */
+out:
free((void *)sync_addr);
+ return ret;
+}
+
+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)
+{
+ igt_assert_eq(__xe_vm_bind_lr_sync(fd, vm, bo, offset, addr, size, flags), 0);
+}
+
+int xe_vm_bind_lr_failable(int fd, uint32_t vm, uint32_t bo, uint64_t offset,
+ uint64_t addr, uint64_t size, uint32_t flags)
+{
+ return __xe_vm_bind_lr_sync(fd, vm, bo, offset, addr, size, flags);
}
void xe_vm_unbind_lr_sync(int fd, uint32_t vm, uint64_t offset,
diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h
index b62d259fd..a7e38ea04 100644
--- a/lib/xe/xe_ioctl.h
+++ b/lib/xe/xe_ioctl.h
@@ -117,6 +117,10 @@ struct drm_xe_mem_range_attr
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);
+int __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);
+int xe_vm_bind_lr_failable(int fd, uint32_t vm, uint32_t bo, uint64_t offset,
+ uint64_t addr, uint64_t size, uint32_t flags);
void xe_vm_unbind_lr_sync(int fd, uint32_t vm, uint64_t offset,
uint64_t addr, uint64_t size);
#endif /* XE_IOCTL_H */
--
2.52.0
next prev parent reply other threads:[~2026-03-27 13:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 13:24 [PATCH i-g-t v8 0/3] tests/intel/xe_vm: Add support for overcommit tests Sobin Thomas
2026-03-27 13:24 ` [PATCH i-g-t v8 1/3] drm-uapi/xe: sync with kernel header Sobin Thomas
2026-03-27 13:24 ` Sobin Thomas [this message]
2026-03-27 13:35 ` [PATCH i-g-t v8 2/3] lib/xe: Add failable variant of xe_vm_bind_lr_sync() Hellstrom, Thomas
2026-03-27 13:24 ` [PATCH i-g-t v8 3/3] tests/intel/xe_vm: Add support for overcommit tests Sobin Thomas
2026-03-27 19:38 ` ✓ Xe.CI.BAT: success for tests/intel/xe_vm: Add support for overcommit tests (rev4) Patchwork
2026-03-27 19:53 ` ✓ i915.CI.BAT: " Patchwork
2026-03-28 12:06 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-28 22:46 ` ✓ i915.CI.Full: success " 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=20260327132427.2681193-3-sobin.thomas@intel.com \
--to=sobin.thomas@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=nishit.sharma@intel.com \
--cc=thomas.hellstrom@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