All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: <sai.gowtham.ch@intel.com>
Cc: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t] tests/intel/xe_pm: Test to validate vm bind functionality with suspend and resume.
Date: Fri, 23 Feb 2024 15:43:48 -0500	[thread overview]
Message-ID: <ZdkDhAT9FxalNTEa@intel.com> (raw)
In-Reply-To: <20240223065136.19900-1-sai.gowtham.ch@intel.com>

On Fri, Feb 23, 2024 at 12:21:36PM +0530, sai.gowtham.ch@intel.com wrote:
> From: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
> 
> Test validates vm bind functionality, by suspend and resuming the device
> before and after binding VM to a VA.
> 
> Signed-off-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
> ---
>  tests/intel/xe_pm.c | 92 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 92 insertions(+)
> 
> diff --git a/tests/intel/xe_pm.c b/tests/intel/xe_pm.c
> index a0045da0b..f9d2ce421 100644
> --- a/tests/intel/xe_pm.c
> +++ b/tests/intel/xe_pm.c
> @@ -550,9 +550,96 @@ static void test_mmap(device_t device, uint32_t placement, uint32_t flags)
>  	close(fw_handle);
>  }
>  
> +/**
> + * SUBTEST: vm-bind
> + * Description: Validate vm bind functionality with suspend and resume
> + * Functionality: pm
> + * Run type: FULL
> + */
> +static void vm_bind(device_t device, struct drm_xe_engine_class_instance *eci)
> +{
> +	struct drm_xe_sync sync = {
> +		.type = DRM_XE_SYNC_TYPE_SYNCOBJ,
> +		.flags = DRM_XE_SYNC_FLAG_SIGNAL,
> +	};
> +	struct drm_xe_exec exec = {
> +		.num_batch_buffer = 1,
> +		.num_syncs = 1,
> +		.syncs = to_user_pointer(&sync),
> +	};
> +	struct data {
> +		uint32_t batch[16];
> +		uint32_t data;
> +		uint64_t addr;
> +	} *data;
> +	uint32_t vm;
> +	uint32_t exec_queue;
> +	uint32_t bind_engine;
> +	uint32_t syncobj;
> +	size_t bo_size;
> +	int value = 0x123456;
> +	uint64_t addr = 0x100000;
> +	uint32_t bo = 0;
> +	int b = 0;
> +	uint64_t batch_offset = (char *)&(data->batch) - (char *)data;
> +	uint64_t batch_addr = addr + batch_offset;
> +	uint64_t sdi_offset = (char *)&(data->data) - (char *)data;
> +	uint64_t sdi_addr = addr + sdi_offset;
> +
> +	syncobj = syncobj_create(device.fd_xe, 0);
> +	sync.handle = syncobj;
> +
> +	vm = xe_vm_create(device.fd_xe, 0, 0);
> +	bo_size = sizeof(*data);
> +	bo_size = xe_bb_size(device.fd_xe, bo_size);
> +
> +	bo = xe_bo_create(device.fd_xe, vm, bo_size,
> +			  vram_if_possible(device.fd_xe, eci->gt_id),
> +			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
> +
> +	exec_queue = xe_exec_queue_create(device.fd_xe, vm, eci, 0);
> +	bind_engine = xe_bind_exec_queue_create(device.fd_xe, vm, 0);
> +	xe_vm_bind_async(device.fd_xe, vm, bind_engine, bo, 0, addr, bo_size, &sync, 1);
> +	igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);

this is the only thing new here, a S3 right after the async vm_bind.
for this we can only introduce a new option to test_exec and add this line there,
withouth having to recreate the function.

But I also don't believe that the goal is only to test this,
but a combination of VM_BIND operations and how they survive to the
suspend states.

So, we do need a new function, but to test a combination of the
vm_bind operations against the combination of the suspend states:

*  - %DRM_XE_VM_BIND_OP_MAP                                                               
 *  - %DRM_XE_VM_BIND_OP_UNMAP                                                             
 *  - %DRM_XE_VM_BIND_OP_MAP_USERPTR                                                       
 *  - %DRM_XE_VM_BIND_OP_UNMAP_ALL                                                         
 *  - %DRM_XE_VM_BIND_OP_PREFETCH      

vs the already defined s_states and d_states

> +	data = xe_bo_map(device.fd_xe, bo, bo_size);
> +
> +	b = 0;
> +	data->batch[b++] = MI_STORE_DWORD_IMM_GEN4;
> +	data->batch[b++] = sdi_addr;
> +	data->batch[b++] = sdi_addr >> 32;
> +	data->batch[b++] = value;
> +	data->batch[b++] = MI_BATCH_BUFFER_END;
> +	igt_assert(b <= ARRAY_SIZE(data->batch));
> +
> +	exec.exec_queue_id = exec_queue;
> +	exec.address = batch_addr;
> +	sync.flags &= DRM_XE_SYNC_FLAG_SIGNAL;
> +	xe_exec(device.fd_xe, &exec);
> +
> +	igt_assert(syncobj_wait(device.fd_xe, &syncobj, 1, INT64_MAX, 0, NULL));
> +	igt_assert_eq(data->data, value);
> +	igt_system_suspend_autoresume(SUSPEND_STATE_MEM, SUSPEND_TEST_NONE);
> +
> +	exec.exec_queue_id = exec_queue;
> +	exec.address = batch_addr;
> +	sync.flags &= DRM_XE_SYNC_FLAG_SIGNAL;
> +	xe_exec(device.fd_xe, &exec);
> +
> +	igt_assert(syncobj_wait(device.fd_xe, &syncobj, 1, INT64_MAX, 0, NULL));
> +	igt_assert_eq(data->data, value);
> +
> +	syncobj_destroy(device.fd_xe, syncobj);
> +	munmap(data, bo_size);
> +	gem_close(device.fd_xe, bo);
> +
> +	xe_exec_queue_destroy(device.fd_xe, exec_queue);
> +	xe_vm_destroy(device.fd_xe, vm);
> +}
> +
>  igt_main
>  {
>  	struct drm_xe_engine_class_instance *hwe;
> +	struct drm_xe_engine *engine;
>  	device_t device;
>  	uint32_t d3cold_allowed;
>  	int sysfs_fd;
> @@ -693,6 +780,11 @@ igt_main
>  		}
>  	}
>  
> +	igt_subtest("vm-bind") {
> +		engine = xe_engine(device.fd_xe, 1);
> +		vm_bind(device, &engine->instance);
> +	}
> +
>  	igt_fixture {
>  		close(sysfs_fd);
>  		igt_pm_set_d3cold_allowed(device.pci_slot_name, d3cold_allowed);
> -- 
> 2.39.1
> 

  parent reply	other threads:[~2024-02-23 20:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23  6:51 [PATCH i-g-t] tests/intel/xe_pm: Test to validate vm bind functionality with suspend and resume sai.gowtham.ch
2024-02-23  7:55 ` Dandamudi, Priyanka
2024-02-23  9:28   ` Ch, Sai Gowtham
2024-02-23  8:44 ` ✓ CI.xeBAT: success for " Patchwork
2024-02-23  9:02 ` ✓ Fi.CI.BAT: " Patchwork
2024-02-23 20:43 ` Rodrigo Vivi [this message]
2024-02-26  6:50   ` [PATCH i-g-t] " Ch, Sai Gowtham
2024-02-23 23:29 ` ✓ Fi.CI.IGT: success for " 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=ZdkDhAT9FxalNTEa@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=sai.gowtham.ch@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.