Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Dong, Zhanjun" <zhanjun.dong@intel.com>
To: Peter Senna Tschudin <peter.senna@linux.intel.com>,
	<igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t] lib/xe/xe_legacy: Move test_legacy_mode to lib/
Date: Mon, 28 Apr 2025 17:40:12 -0400	[thread overview]
Message-ID: <0437652e-15ce-4987-8fe7-13459056e56d@intel.com> (raw)
In-Reply-To: <20250424173610.179158-1-peter.senna@linux.intel.com>

Please see my comments inline below.

Regards,
Zhanjun Dong

On 2025-04-24 1:36 p.m., Peter Senna Tschudin wrote:
> There were two similar implementations of test_legacy_mode(), located in
> tests/intel/xe_exec_capture and tests/intel/xe_exec_reset.  This patch
> consolidates them by moving the more complete version from xe_exec_reset
> to lib/xe/xe_legacy, and updates call sites on both tests to use the
> shared function.
> 
> The version from xe_exec_reset.c was chosen because it is more
> feature-complete and flexible, offering the following advantages:
>   - Supports CLOSE_FD
>   - Supports GT reset
>   - Waits for spinner start
>   - Checks batch buffer result
>   - Conditional bind call using xe_vm_bind_async() instead of
>     __xe_vm_bind_assert()
>   - Allows early return
> 
> To cover for a difference between the two function definitions, the
> shared function was extended with the use_capture_mode parameter to
> control whether to use __xe_vm_bind_assert (capture mode) or
> xe_vm_bind_async (legacy mode).
> 
> Cc: zhanjun.dong@intel.com
> Signed-off-by: Peter Senna Tschudin <peter.senna@linux.intel.com>
> ---
>   lib/meson.build               |   1 +
>   lib/xe/xe_legacy.c            | 167 ++++++++++++++++++++++++++++++++++
>   lib/xe/xe_legacy.h            |  15 +++
>   tests/intel/xe_exec_capture.c | 109 +---------------------
>   tests/intel/xe_exec_reset.c   | 153 +++----------------------------
>   5 files changed, 201 insertions(+), 244 deletions(-)
>   create mode 100644 lib/xe/xe_legacy.c
>   create mode 100644 lib/xe/xe_legacy.h
> 
> diff --git a/lib/meson.build b/lib/meson.build
> index 8517cd540..454dcd244 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -114,6 +114,7 @@ lib_sources = [
>   	'igt_hook.c',
>   	'xe/xe_gt.c',
>   	'xe/xe_ioctl.c',
> +	'xe/xe_legacy.c',
>   	'xe/xe_mmio.c',
>   	'xe/xe_query.c',
>   	'xe/xe_spin.c',
> diff --git a/lib/xe/xe_legacy.c b/lib/xe/xe_legacy.c
> new file mode 100644
> index 000000000..81a9f3bd6
> --- /dev/null
> +++ b/lib/xe/xe_legacy.c
> @@ -0,0 +1,167 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2025 Intel Corporation
> + */
> +
> +#include "lib/igt_syncobj.h"
> +#include "linux_scaffold.h"
> +#include "xe/xe_ioctl.h"
> +#include "xe/xe_legacy.h"
> +#include "xe/xe_spin.h"
> +
> +/* Batch buffer element count, in number of dwords(u32) */
> +#define BATCH_DW_COUNT			16
> +#define CAT_ERROR			(0x1 << 5)
> +#define CLOSE_EXEC_QUEUES		(0x1 << 2)
> +#define CLOSE_FD			(0x1 << 1)
> +/* Batch buffer element count, in number of dwords(u32) */
> +#define GT_RESET			(0x1 << 0)
> +#define MAX_N_EXECQUEUES		16
> +
> +/**
> + * xe_legacy_test_mode:
> + * @fd: file descriptor
> + * @eci: engine class instance
> + * @n_exec_queues: number of exec queues
> + * @n_execs: number of execs
> + * @flags: flags for the test
> + * @addr: address for the test
> + * @use_capture_mode: use capture mode or not
> + *
> + * Returns: void
> + */
> +void
> +xe_legacy_test_mode(int fd, struct drm_xe_engine_class_instance *eci,
> +		    int n_exec_queues, int n_execs, unsigned int flags,
> +		    u64 addr, bool use_capture_mode)
> +{
> +	u32 vm;
> +	struct drm_xe_sync sync[2] = {
> +		{ .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, },
> +		{ .type = DRM_XE_SYNC_TYPE_SYNCOBJ, .flags = DRM_XE_SYNC_FLAG_SIGNAL, },
> +	};
> +	struct drm_xe_exec exec = {
> +		.num_batch_buffer = 1,
> +		.num_syncs = 2,
> +		.syncs = to_user_pointer(sync),
> +	};
> +	u32 exec_queues[MAX_N_EXECQUEUES];
> +	u32 syncobjs[MAX_N_EXECQUEUES];
> +	size_t bo_size;
> +	u32 bo = 0;
> +	struct {
> +		struct xe_spin spin;
> +		u32 batch[BATCH_DW_COUNT];
> +		u64 pad;
> +		u32 data;
> +	} *data;
> +	struct xe_spin_opts spin_opts = { .preempt = false };
> +	int i, b;
> +
> +	igt_assert_lte(n_exec_queues, MAX_N_EXECQUEUES);
> +
> +	if (flags & CLOSE_FD)
> +		fd = drm_open_driver(DRIVER_XE);
> +
> +	vm = xe_vm_create(fd, 0, 0);
> +	bo_size = sizeof(*data) * n_execs;
> +	bo_size = xe_bb_size(fd, bo_size);
> +
> +	bo = xe_bo_create(fd, vm, bo_size,
> +			  vram_if_possible(fd, eci->gt_id),
> +			  DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM);
> +	data = xe_bo_map(fd, bo, bo_size);
> +
> +	for (i = 0; i < n_exec_queues; i++) {
> +		exec_queues[i] = xe_exec_queue_create(fd, vm, eci, 0);
> +		syncobjs[i] = syncobj_create(fd, 0);
> +	}
> +
> +	sync[0].handle = syncobj_create(fd, 0);
> +
> +	/* Binding mechanism based on use_capture_mode */
> +	if (use_capture_mode) {
> +		__xe_vm_bind_assert(fd, vm, 0, bo, 0, addr, bo_size,
> +				    DRM_XE_VM_BIND_OP_MAP, flags, sync, 1, 0, 0);
> +	} else {
> +		xe_vm_bind_async(fd, vm, 0, bo, 0, addr, bo_size, sync, 1);
> +	}


> +
> +	for (i = 0; i < n_execs; i++) {
> +		u64 base_addr = (use_capture_mode || !(flags & CAT_ERROR)) ? addr
> +					: addr + bo_size * 128;

Reference form xe_exec_capture.c:
for (i = 0; i < n_execs; i++) {
		u64 base_addr = addr;
		u64 batch_offset = (char *)&data[i].batch - (char *)data;

Reference form xe_exec_reset.c:
	for (i = 0; i < n_execs; i++) {
		uint64_t base_addr = flags & CAT_ERROR && !i ?
			addr + bo_size * 128 : addr;
		uint64_t batch_offset = (char *)&data[i].batch - (char *)data;

Is "&& !i" check lost here?


> +		u64 batch_offset = (char *)&data[i].batch - (char *)data;
> +		u64 batch_addr = base_addr + batch_offset;
> +		u64 spin_offset = (char *)&data[i].spin - (char *)data;
> +		u64 sdi_offset = (char *)&data[i].data - (char *)data;
> +		u64 sdi_addr = base_addr + sdi_offset;
> +		u64 exec_addr;
> +		int e = i % n_exec_queues;

...

  reply	other threads:[~2025-04-28 21:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 19:30 [PATCH RFC i-g-t] lib/xe/xe_legacy: Move test_legacy_mode to lib/ Peter Senna Tschudin
2025-04-17 21:42 ` ✗ i915.CI.BAT: failure for " Patchwork
2025-04-18  9:21   ` Peter Senna Tschudin
2025-04-21 12:21     ` Ravali, JupallyX
2025-04-17 22:00 ` ✗ Xe.CI.BAT: " Patchwork
2025-04-18  9:20   ` Peter Senna Tschudin
2025-04-18 15:43 ` ✗ Xe.CI.Full: " Patchwork
2025-04-21 10:32 ` ✗ i915.CI.BAT: " Patchwork
2025-04-21 11:02 ` ✓ i915.CI.BAT: success " Patchwork
2025-04-21 12:34 ` ✓ i915.CI.Full: " Patchwork
2025-04-24 17:36 ` [PATCH i-g-t] " Peter Senna Tschudin
2025-04-28 21:40   ` Dong, Zhanjun [this message]
2025-04-24 18:57 ` ✗ i915.CI.BAT: failure for lib/xe/xe_legacy: Move test_legacy_mode to lib/ (rev2) Patchwork
2025-04-26  8:06   ` Peter Senna Tschudin
2025-04-24 19:12 ` ✓ Xe.CI.BAT: success " Patchwork
2025-05-08 10:10 ` [PATCH v2 i-g-t] lib/xe/xe_legacy: Move test_legacy_mode to lib/ Peter Senna Tschudin
2025-05-12 23:26   ` Dong, Zhanjun
2025-05-08 19:52 ` ✓ Xe.CI.BAT: success for lib/xe/xe_legacy: Move test_legacy_mode to lib/ (rev3) Patchwork
2025-05-08 20:05 ` ✓ i915.CI.BAT: " Patchwork
2025-05-08 22:54 ` ✗ i915.CI.Full: failure " Patchwork
2025-05-09  7:39   ` Peter Senna Tschudin
2025-05-09 11:32 ` ✗ Xe.CI.Full: " Patchwork
2025-05-09 11:46   ` Peter Senna Tschudin

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=0437652e-15ce-4987-8fe7-13459056e56d@intel.com \
    --to=zhanjun.dong@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=peter.senna@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