From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v5 3/4] tests/xe_spin_batch: spin-fixed-duration
Date: Fri, 8 Sep 2023 17:12:59 +0000 [thread overview]
Message-ID: <20230908171300.2749840-4-marcin.bernatowicz@linux.intel.com> (raw)
In-Reply-To: <20230908171300.2749840-1-marcin.bernatowicz@linux.intel.com>
Basic test for xe_spin with fixed duration.
v2: Added assert for expected spinner duration. (Zbyszek)
A median of 5x100ms spins duration is computed, which should
satisfy CI runs, although better accuracy is achieved with
disabled logging (echo 0 > /sys/module/drm/parameters/debug).
v3: Sorted variable declaration/definitions by length
for better readability (Zbyszek)
v4: fixed too long line warning
Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
---
tests/intel/xe_spin_batch.c | 73 +++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/tests/intel/xe_spin_batch.c b/tests/intel/xe_spin_batch.c
index 9bd3dc349..c720511b8 100644
--- a/tests/intel/xe_spin_batch.c
+++ b/tests/intel/xe_spin_batch.c
@@ -1,8 +1,10 @@
#include "igt.h"
+#include "igt_syncobj.h"
#include "lib/intel_reg.h"
#include "xe_drm.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
+#include "xe/xe_spin.h"
/**
* TEST: Tests for spin batch submissons.
@@ -138,6 +140,74 @@ static void spin_all(int fd, int gt, int class)
xe_vm_destroy(fd, vm);
}
+/**
+ * SUBTEST: spin-fixed-duration
+ * Description: Basic test which validates the functionality of xe_spin with fixed duration.
+ * Run type: FULL
+ */
+static void xe_spin_fixed_duration(int fd)
+{
+ struct drm_xe_sync sync = {
+ .handle = syncobj_create(fd, 0),
+ .flags = DRM_XE_SYNC_SYNCOBJ | DRM_XE_SYNC_SIGNAL,
+ };
+ struct drm_xe_exec exec = {
+ .num_batch_buffer = 1,
+ .num_syncs = 1,
+ .syncs = to_user_pointer(&sync),
+ };
+ const uint64_t duration_ns = NSEC_PER_SEC / 10; /* 100ms */
+ uint64_t spin_addr;
+ uint64_t ahnd;
+ uint32_t exec_queue;
+ uint32_t vm;
+ uint32_t bo;
+ size_t bo_size;
+ struct xe_spin *spin;
+ struct timespec tv;
+ double elapsed_ms;
+ igt_stats_t stats;
+ int i;
+
+ vm = xe_vm_create(fd, 0, 0);
+ exec_queue = xe_exec_queue_create_class(fd, vm, DRM_XE_ENGINE_CLASS_COPY);
+ ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_RELOC);
+ bo_size = ALIGN(sizeof(*spin) + xe_cs_prefetch_size(fd), xe_get_default_alignment(fd));
+ bo = xe_bo_create(fd, 0, vm, bo_size);
+ spin = xe_bo_map(fd, bo, bo_size);
+ spin_addr = intel_allocator_alloc_with_strategy(ahnd, bo, bo_size, 0,
+ ALLOC_STRATEGY_LOW_TO_HIGH);
+ xe_vm_bind_sync(fd, vm, bo, 0, spin_addr, bo_size);
+ xe_spin_init_opts(spin, .addr = spin_addr,
+ .preempt = true,
+ .ctx_ticks = duration_to_ctx_ticks(fd, 0, duration_ns));
+ exec.address = spin_addr;
+ exec.exec_queue_id = exec_queue;
+
+#define NSAMPLES 5
+ igt_stats_init_with_size(&stats, NSAMPLES);
+ for (i = 0; i < NSAMPLES; ++i) {
+ igt_gettime(&tv);
+ xe_exec(fd, &exec);
+ xe_spin_wait_started(spin);
+ igt_assert(syncobj_wait(fd, &sync.handle, 1, INT64_MAX, 0, NULL));
+ igt_stats_push_float(&stats, igt_nsec_elapsed(&tv) * 1e-6);
+ syncobj_reset(fd, &sync.handle, 1);
+ igt_debug("i=%d %.2fms\n", i, stats.values_f[i]);
+ }
+ elapsed_ms = igt_stats_get_median(&stats);
+ igt_info("%.0fms spin took %.2fms (median)\n", duration_ns * 1e-6, elapsed_ms);
+ igt_assert(elapsed_ms < duration_ns * 1.5e-6 && elapsed_ms > duration_ns * 0.5e-6);
+
+ xe_vm_unbind_sync(fd, vm, 0, spin_addr, bo_size);
+ syncobj_destroy(fd, sync.handle);
+ gem_munmap(spin, bo_size);
+ gem_close(fd, bo);
+ xe_exec_queue_destroy(fd, exec_queue);
+ xe_vm_destroy(fd, vm);
+ put_ahnd(ahnd);
+}
+
igt_main
{
struct drm_xe_engine_class_instance *hwe;
@@ -163,6 +233,9 @@ igt_main
spin_all(fd, gt, class);
}
+ igt_subtest("spin-fixed-duration")
+ xe_spin_fixed_duration(fd);
+
igt_fixture
drm_close_driver(fd);
}
--
2.30.2
next prev parent reply other threads:[~2023-09-08 17:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 17:12 [igt-dev] [PATCH i-g-t v5 0/4] lib/xe_spin: introduced fixed duration xe_spin Marcin Bernatowicz
2023-09-08 17:12 ` [igt-dev] [PATCH i-g-t v5 1/4] lib/xe_spin: xe_spin_opts for xe_spin initialization Marcin Bernatowicz
2023-09-08 17:12 ` [igt-dev] [PATCH i-g-t v5 2/4] lib/xe_spin: fixed duration xe_spin capability Marcin Bernatowicz
2023-09-08 17:12 ` Marcin Bernatowicz [this message]
2023-09-08 17:13 ` [igt-dev] [PATCH i-g-t v5 4/4] lib/xe_spin.c: fixed code style Marcin Bernatowicz
2023-09-08 19:09 ` [igt-dev] ✓ CI.xeBAT: success for lib/xe_spin: introduced fixed duration xe_spin (rev4) Patchwork
2023-09-08 19:18 ` [igt-dev] ✗ Fi.CI.BAT: failure " Patchwork
2023-09-11 7:50 ` Bernatowicz, Marcin
2023-09-13 9:39 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-09-13 11:32 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-09-13 12:28 ` Bernatowicz, Marcin
2023-09-13 12:50 ` Bernatowicz, Marcin
2023-09-13 13:20 ` Yedireswarapu, SaiX Nandan
2023-09-13 13:02 ` 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=20230908171300.2749840-4-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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.