Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: nishit.sharma@intel.com
To: igt-dev@lists.freedesktop.org, stuart.summers@intel.com
Subject: [PATCH i-g-t] lib/xe: Retry xe_vm_bind on transient -EBUSY
Date: Tue, 12 May 2026 15:39:19 +0000	[thread overview]
Message-ID: <20260512153919.3676059-1-nishit.sharma@intel.com> (raw)

From: Nishit Sharma <nishit.sharma@intel.com>

__xe_vm_bind_assert() can intermittently fail with -EBUSY when the
kernel rejects the bind because it detects in-flight work that has
not yet completed. This is transient condition the call is expected
to succeed once the competing work settles.

Add a retry loop (up to 5 attempts) that re-issues __xe_vm_bind()
whenever -EBUSY is returned, before asserting success. All other
error codes are treated as fatal and propagate immediately to
igt_assert_eq() as before.

Signed-off-by: Nishit Sharma <nishit.sharma@intel.com>
---
 lib/xe/xe_ioctl.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index e13195e16..3a307f95f 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -242,9 +242,24 @@ void  __xe_vm_bind_assert(int fd, uint32_t vm, uint32_t exec_queue, uint32_t bo,
 			  uint32_t op, uint32_t flags, struct drm_xe_sync *sync,
 			  uint32_t num_syncs, uint32_t prefetch_region, uint64_t ext)
 {
-	igt_assert_eq(__xe_vm_bind(fd, vm, exec_queue, bo, offset, addr, size,
-				   op, flags, sync, num_syncs, prefetch_region,
-				   DEFAULT_PAT_INDEX, ext), 0);
+	int ret, retries = 0;
+
+retry:
+	ret = __xe_vm_bind(fd, vm, exec_queue, bo, offset, addr, size,
+			   op, flags, sync, num_syncs, prefetch_region,
+			   DEFAULT_PAT_INDEX, ext);
+
+	if (ret && retries < 5) {
+		/*
+		 * Retry on transient -EBUSY, which can occur when the
+		 * kernel is contended by in-flight background work
+		 */
+		retries++;
+		goto retry;
+	}
+
+	igt_assert_eq(ret, 0);
+	return;
 }
 
 void xe_vm_prefetch_async(int fd, uint32_t vm, uint32_t exec_queue, uint64_t offset,
-- 
2.43.0


             reply	other threads:[~2026-05-12 15:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 15:39 nishit.sharma [this message]
2026-05-12 22:35 ` ✓ i915.CI.BAT: success for lib/xe: Retry xe_vm_bind on transient -EBUSY Patchwork
2026-05-13  0:47 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-13  8:38 ` [PATCH i-g-t] " Jani Nikula
2026-05-13 17:46 ` ✗ Xe.CI.FULL: failure for " Patchwork
2026-05-13 21:42 ` ✗ i915.CI.Full: " Patchwork
2026-05-14  9:12 ` [PATCH i-g-t] " Zbigniew Kempczyński

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=20260512153919.3676059-1-nishit.sharma@intel.com \
    --to=nishit.sharma@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=stuart.summers@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