public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sobin Thomas <sobin.thomas@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Sobin Thomas <sobin.thomas@intel.com>
Subject: [PATCH v7 i-g-t 2/3] lib/xe: Add failable variant of xe_vm_bind_lr_sync
Date: Wed, 25 Mar 2026 06:00:46 +0000	[thread overview]
Message-ID: <20260325060051.2498340-3-sobin.thomas@intel.com> (raw)
In-Reply-To: <20260325060051.2498340-1-sobin.thomas@intel.com>

Introduce a new failable variant that returns error codes instead of
asserting, allowing callers to handle errors explicitly.

Signed-off-by: Sobin Thomas <sobin.thomas@intel.com>
---
 lib/xe/xe_ioctl.c | 36 ++++++++++++++++++++++++++++++++++++
 lib/xe/xe_ioctl.h |  2 ++
 2 files changed, 38 insertions(+)

diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index 16aae05c9..30c8a15f6 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -795,6 +795,42 @@ void xe_vm_bind_lr_sync(int fd, uint32_t vm, uint32_t bo, uint64_t offset,
 	free((void *)sync_addr);
 }
 
+int xe_vm_bind_lr_failable(int fd, uint32_t vm, uint32_t exec_queue, 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 = {0};
+	int ret = 0;
+	int64_t timeout = NSEC_PER_SEC * 10;
+
+	if (!sync_addr)
+		return -ENOMEM;
+
+	*sync_addr = 0;
+
+	sync.flags = DRM_XE_SYNC_FLAG_SIGNAL;
+	sync.type = DRM_XE_SYNC_TYPE_USER_FENCE;
+	sync.addr = to_user_pointer((uint64_t *)sync_addr);
+	sync.timeline_value = BIND_SYNC_VAL;
+
+	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 (*sync_addr != BIND_SYNC_VAL) {
+		ret = __xe_wait_ufence(fd, (uint64_t *)sync_addr, BIND_SYNC_VAL,
+				       0, &timeout);
+	if (ret)
+		goto out;
+	}
+
+out:
+	free((void *)sync_addr);
+	return ret;
+}
+
 void xe_vm_unbind_lr_sync(int fd, uint32_t vm, uint64_t offset,
 			  uint64_t addr, uint64_t size)
 {
diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h
index 3ea651063..eba10bd34 100644
--- a/lib/xe/xe_ioctl.h
+++ b/lib/xe/xe_ioctl.h
@@ -116,6 +116,8 @@ 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_failable(int fd, uint32_t vm, uint32_t exec_queue, 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.43.0


  parent reply	other threads:[~2026-03-25  6:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25  6:00 [PATCH v7 i-g-t 0/3] tests/intel/xe_vm: Add support for overcommit tests Sobin Thomas
2026-03-25  6:00 ` [PATCH v7 i-g-t 1/3] drm-uapi/xe: sync with kernel header Sobin Thomas
2026-03-25  6:00 ` Sobin Thomas [this message]
2026-03-25  6:00 ` [PATCH v7 i-g-t 3/3] tests/intel/xe_vm: Add support for overcommit tests Sobin Thomas
  -- strict thread matches above, loose matches on Subject: below --
2026-03-25  6:03 [PATCH v7 i-g-t 0/3] " Sobin Thomas
2026-03-25  6:03 ` [PATCH v7 i-g-t 2/3] lib/xe: Add failable variant of xe_vm_bind_lr_sync Sobin Thomas
2026-03-25 10:27   ` Sharma, Nishit
2026-03-25 12:43   ` Hellstrom, Thomas
2026-03-26 12:24     ` Thomas, Sobin
2026-03-20 10:05 [PATCH v6 i-g-t 0/2] tests/intel/xe_vm: Add support for overcommit tests Sobin Thomas
2026-03-25  5:55 ` [PATCH v7 i-g-t 0/3] " Sobin Thomas
2026-03-25  5:55   ` [PATCH v7 i-g-t 2/3] lib/xe: Add failable variant of xe_vm_bind_lr_sync Sobin 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=20260325060051.2498340-3-sobin.thomas@intel.com \
    --to=sobin.thomas@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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