Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Sharma, Nishit" <nishit.sharma@intel.com>
To: Arvind Yadav <arvind.yadav@intel.com>, <igt-dev@lists.freedesktop.org>
Cc: <matthew.brost@intel.com>, <himal.prasad.ghimiray@intel.com>,
	<thomas.hellstrom@linux.intel.com>, <pravalika.gurram@intel.com>
Subject: Re: [i-g-t] tests/intel/xe_madvise: Add partial-unbind-dontneed subtest
Date: Mon, 11 May 2026 11:01:42 +0530	[thread overview]
Message-ID: <4336b790-8eac-4308-b430-72b215c3d293@intel.com> (raw)
In-Reply-To: <20260507060335.3397890-1-arvind.yadav@intel.com>


On 5/7/2026 11:33 AM, Arvind Yadav wrote:
> 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: Nishit Sharma <nishit.sharma@intel.com>
> Cc: Pravalika Gurram <pravalika.gurram@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 e9bf55ff5..629c5eb06 100644
> --- a/tests/intel/xe_madvise.c
> +++ b/tests/intel/xe_madvise.c
> @@ -14,6 +14,7 @@
>   #include "igt.h"
>   #include "xe_drm.h"
>   
> +#include "intel_pat.h"
>   #include "xe/xe_ioctl.h"
>   #include "xe/xe_query.h"
>   #include "lib/igt_syncobj.h"
> @@ -768,6 +769,64 @@ out:
>   		igt_skip("Unable to induce purge on this platform/config");
>   }
>   
> +/**
> + * 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;
> @@ -822,6 +881,12 @@ int igt_main()
>   			break;
>   		}
>   
> +	igt_subtest("partial-unbind-dontneed")
> +		xe_for_each_engine(fd, hwe) {
> +			test_partial_unbind_dontneed(fd);
> +			break;
> +		}
> +
>   	igt_fixture() {
>   		xe_device_put(fd);
>   		drm_close_driver(fd);


LGTM:

Reviewed-by: Nishit Sharma <nishit.sharma@intel.com>


      parent reply	other threads:[~2026-05-11  5:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07  6:03 [i-g-t] tests/intel/xe_madvise: Add partial-unbind-dontneed subtest Arvind Yadav
2026-05-07 17:41 ` ✓ i915.CI.BAT: success for " Patchwork
2026-05-07 18:28 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-08  4:31 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-05-08  6:34 ` ✓ i915.CI.Full: success " Patchwork
2026-05-11  5:31 ` Sharma, Nishit [this message]

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=4336b790-8eac-4308-b430-72b215c3d293@intel.com \
    --to=nishit.sharma@intel.com \
    --cc=arvind.yadav@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=matthew.brost@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