Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH] tests/xe: Add test waiting for ufence signaling
Date: Wed, 17 Jul 2024 13:52:54 +0000	[thread overview]
Message-ID: <ZpfMtkGAOo9FMOpX@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240717122302.192806-1-maarten.lankhorst@linux.intel.com>

On Wed, Jul 17, 2024 at 02:23:02PM +0200, Maarten Lankhorst wrote:
> Create a single VM_BIND that signals a valid and invalid ufence,
> to see what happens..
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  tests/intel/xe_vm.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
> 
> diff --git a/tests/intel/xe_vm.c b/tests/intel/xe_vm.c
> index a4f6c7a0b..aba2e1b82 100644
> --- a/tests/intel/xe_vm.c
> +++ b/tests/intel/xe_vm.c
> @@ -1839,6 +1839,70 @@ static void bind_flag_invalid(int fd)
>  	xe_vm_destroy(fd, vm);
>  }
>  
> +/**
> + * SUBTEST: ufence-invalid
> + * Description:
> + *	Test what happens when trying to signal completion with read-only
> + * 	ufence address.
> + * Functionality: bind
> + * Test category: functionality test
> + */
> +static void ufence_invalid(int fd)
> +{
> +	uint32_t bo, bo_size = xe_get_default_alignment(fd);
> +	uint64_t addr = 0x1a0000;
> +	uint32_t vm;
> +	uint64_t *ro_ufence = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> +	uint64_t ufence = 0;
> +	struct drm_xe_vm_bind bind;
> +	struct drm_xe_sync sync[] = {
> +		{ .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, },
> +		{ .type = DRM_XE_SYNC_TYPE_USER_FENCE, .flags = DRM_XE_SYNC_FLAG_SIGNAL,
> +			.timeline_value = 0x1234567890abcdef,
> +		}
> +	};
> +
> +	igt_assert(ro_ufence != MAP_FAILED);
> +
> +	vm = xe_vm_create(fd, 0, 0);
> +	bo = xe_bo_create(fd, vm, bo_size, vram_if_possible(fd, 0), 0);
> +	sync[0].handle = syncobj_create(fd, 0);
> +
> +	memset(&bind, 0, sizeof(bind));
> +	bind.vm_id = vm;
> +	bind.num_binds = 1;
> +	bind.bind.obj = bo;
> +	bind.bind.range = bo_size;
> +	bind.bind.addr = addr;
> +	bind.bind.op = DRM_XE_VM_BIND_OP_MAP;
> +	bind.bind.pat_index = intel_get_pat_idx_wb(fd);
> +	bind.num_syncs = ARRAY_SIZE(sync);
> +	bind.syncs = to_user_pointer(sync);

Test looks good, just one question. Any particular reason to open code
the VM bind IOCTLs instead of using the helper?

Matt

> +
> +	/* Using valid with valid ufence should work */
> +	sync[1].addr = (uintptr_t)&ufence;
> +	bind.bind.flags = 0;
> +	igt_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind);
> +	igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
> +	syncobj_reset(fd, &sync[0].handle, 1);
> +	/* Small sleep to allow some time for async kernel worker to run */
> +	usleep(100000);
> +	igt_assert_eq_u64(ufence, sync[1].timeline_value);
> +
> +	/* Also with ro_ufence, but it should remain unsignaled */
> +	sync[1].addr = (uintptr_t)ro_ufence;
> +	bind.bind.flags = DRM_XE_VM_BIND_FLAG_READONLY;
> +	igt_ioctl(fd, DRM_IOCTL_XE_VM_BIND, &bind);
> +	igt_assert(syncobj_wait(fd, &sync[0].handle, 1, INT64_MAX, 0, NULL));
> +	syncobj_reset(fd, &sync[0].handle, 1);
> +	usleep(100000);
> +	igt_assert_eq_u64(*ro_ufence, 0);
> +
> +	syncobj_destroy(fd, sync[0].handle);
> +	xe_vm_destroy(fd, vm);
> +	munmap(ro_ufence, sysconf(_SC_PAGESIZE));
> +}
> +
>  igt_main
>  {
>  	struct drm_xe_engine_class_instance *hwe, *hwe_non_copy = NULL;
> @@ -1973,6 +2037,9 @@ igt_main
>  	igt_subtest("bind-flag-invalid")
>  		bind_flag_invalid(fd);
>  
> +	igt_subtest("ufence-invalid")
> +		ufence_invalid(fd);
> +
>  	igt_subtest("shared-pte-page")
>  		xe_for_each_engine(fd, hwe)
>  			shared_pte_page(fd, hwe, 4,
> -- 
> 2.45.2
> 

  parent reply	other threads:[~2024-07-17 13:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-17 12:23 [PATCH] tests/xe: Add test waiting for ufence signaling Maarten Lankhorst
2024-07-17 13:23 ` ✓ CI.xeBAT: success for " Patchwork
2024-07-17 13:30 ` ✓ Fi.CI.BAT: " Patchwork
2024-07-17 13:52 ` Matthew Brost [this message]
2024-07-17 16:10 ` ✗ CI.xeFULL: failure " Patchwork
2024-07-18  5:19 ` ✗ Fi.CI.IGT: " 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=ZpfMtkGAOo9FMOpX@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=maarten.lankhorst@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