From: Arvind Yadav <arvind.yadav@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: matthew.brost@intel.com, himal.prasad.ghimiray@intel.com,
thomas.hellstrom@linux.intel.com, nishit.sharma@intel.com,
pravalika.gurram@intel.com
Subject: [i-g-t v2] tests/intel/xe_madvise: Add partial-unbind-dontneed subtest
Date: Tue, 12 May 2026 09:28:16 +0530 [thread overview]
Message-ID: <20260512035816.158130-1-arvind.yadav@intel.com> (raw)
A partial unbind on a DONTNEED BO must succeed because remap remnants
inherit the existing DONTNEED VMA state. A fresh bind on the same BO
must fail with -EBUSY so a new mapping cannot promote purgeable memory
back to WILLNEED.
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: Pravalika Gurram <pravalika.gurram@intel.com>
Reviewed-by: Nishit Sharma <nishit.sharma@intel.com>
Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
---
tests/intel/xe_madvise.c | 65 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/tests/intel/xe_madvise.c b/tests/intel/xe_madvise.c
index cdb115d7e..6e4b18e8f 100644
--- a/tests/intel/xe_madvise.c
+++ b/tests/intel/xe_madvise.c
@@ -20,6 +20,7 @@
#include "xe/xe_gt.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
+#include "intel_pat.h"
/* Purgeable test constants */
#define PURGEABLE_ADDR 0x1a0000
@@ -1034,6 +1035,64 @@ static void test_atomic_cpu(int fd, struct drm_xe_engine_class_instance *eci)
xe_vm_destroy(fd, vm);
}
+/**
+ * SUBTEST: partial-unbind-dontneed
+ * Description: Partial unbind on a DONTNEED BO must succeed; a fresh bind
+ * on the same DONTNEED BO must be rejected with -EBUSY.
+ * Test category: functionality test
+ */
+static void test_partial_unbind_dontneed(int fd)
+{
+ uint32_t vm, bo;
+ uint64_t addr = PURGEABLE_ADDR;
+ uint64_t addr2 = PURGEABLE_ADDR2;
+ size_t page_size = PURGEABLE_BO_SIZE;
+ size_t bo_size = 2 * PURGEABLE_BO_SIZE;
+ struct drm_xe_sync sync = {
+ .type = DRM_XE_SYNC_TYPE_USER_FENCE,
+ .flags = DRM_XE_SYNC_FLAG_SIGNAL,
+ .timeline_value = PURGEABLE_FENCE_VAL,
+ };
+ uint64_t sync_val = 0;
+ uint32_t retained;
+ int ret;
+
+ vm = xe_vm_create(fd, 0, 0);
+ bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd, 0),
+ DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
+
+ sync.addr = to_user_pointer(&sync_val);
+ xe_vm_bind_async(fd, vm, 0, bo, 0, addr, bo_size, &sync, 1);
+ xe_wait_ufence(fd, &sync_val, PURGEABLE_FENCE_VAL, 0, NSEC_PER_SEC);
+
+ /* Mark BO as DONTNEED. */
+ retained = xe_vm_madvise_purgeable(fd, vm, addr, bo_size,
+ DRM_XE_VMA_PURGEABLE_STATE_DONTNEED);
+ igt_assert_eq(retained, 1);
+
+ /*
+ * Partial unbind of the first page must succeed. The remap split
+ * inherits the parent VMA's DONTNEED attr and must not be rejected.
+ */
+ sync_val = 0;
+ xe_vm_unbind_async(fd, vm, 0, 0, addr, page_size, &sync, 1);
+ xe_wait_ufence(fd, &sync_val, PURGEABLE_FENCE_VAL, 0, NSEC_PER_SEC);
+
+ /*
+ * A fresh bind on the same DONTNEED BO must be rejected with -EBUSY.
+ * The kernel must not silently promote a DONTNEED BO back to WILLNEED
+ * through a new bind.
+ */
+ sync_val = 0;
+ ret = __xe_vm_bind(fd, vm, 0, bo, 0, addr2, bo_size,
+ DRM_XE_VM_BIND_OP_MAP, 0, &sync, 1, 0,
+ DEFAULT_PAT_INDEX, 0);
+ igt_assert_eq(ret, -EBUSY);
+
+ gem_close(fd, bo);
+ xe_vm_destroy(fd, vm);
+}
+
int igt_main()
{
struct drm_xe_engine_class_instance *hwe;
@@ -1090,6 +1149,12 @@ int igt_main()
test_per_vma_protection(fd, hwe);
break;
}
+
+ igt_subtest("partial-unbind-dontneed")
+ xe_for_each_engine(fd, hwe) {
+ test_partial_unbind_dontneed(fd);
+ break;
+ }
}
igt_subtest_group() {
--
2.43.0
next reply other threads:[~2026-05-12 3:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 3:58 Arvind Yadav [this message]
2026-05-12 11:57 ` ✓ i915.CI.BAT: success for tests/intel/xe_madvise: Add partial-unbind-dontneed subtest (rev2) Patchwork
2026-05-12 12:13 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-12 21:38 ` ✓ Xe.CI.FULL: " Patchwork
2026-05-13 5:03 ` ✓ i915.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=20260512035816.158130-1-arvind.yadav@intel.com \
--to=arvind.yadav@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=nishit.sharma@intel.com \
--cc=pravalika.gurram@intel.com \
--cc=thomas.hellstrom@linux.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