[igt-dev] [PATCH i-g-t 2/3] tests/gem_exec_alignment.c: Update subtest many
Dominik Grzegorzek
dominik.grzegorzek at intel.com
Mon Mar 16 12:03:22 UTC 2020
Updated subtest many, that was unusable due to the long
time of execution. For that purpose global timeout was added.
Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/i915/gem_exec_alignment.c | 73 ++++++++++++++++++++++-----------
1 file changed, 50 insertions(+), 23 deletions(-)
diff --git a/tests/i915/gem_exec_alignment.c b/tests/i915/gem_exec_alignment.c
index b7c11947..44ee137a 100644
--- a/tests/i915/gem_exec_alignment.c
+++ b/tests/i915/gem_exec_alignment.c
@@ -36,9 +36,12 @@
#include <errno.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <sys/ioctl.h>
#include <signal.h>
#include "drm.h"
+#define MANY_TIMEOUT 10
+
IGT_TEST_DESCRIPTION("Exercises the basic execbuffer using object alignments");
static uint32_t find_last_bit(uint64_t x)
@@ -97,13 +100,22 @@ static inline void alignment_reset_timeout(void)
setitimer(ITIMER_REAL, &itv, NULL);
}
+static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
+{
+ int err = 0;
+ if (ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf))
+ err = -errno;
+ return err;
+}
+
static void many(int fd)
{
uint32_t bbe = MI_BATCH_BUFFER_END;
struct drm_i915_gem_exec_object2 *execobj;
struct drm_i915_gem_execbuffer2 execbuf;
- uint64_t gtt_size, ram_size;
- uint64_t alignment, max_alignment, count, i;
+ uint64_t gtt_size, ram_size, flags;
+ uint64_t alignment, max_alignment, count, max_count, curr_count, i;
+ int ret;
gtt_size = gem_aperture_size(fd);
if (!gem_uses_full_ppgtt(fd))
@@ -118,7 +130,9 @@ static void many(int fd)
max_alignment = 4096;
else
max_alignment = 1ull << (max_alignment - 1);
- count = gtt_size / max_alignment / 2;
+ max_count = count = gtt_size / max_alignment / 2;
+
+ flags = (gtt_size-1) >> 32 ? 1<<3 : 0; /* EXEC_OBJECT_SUPPORTS_48B_ADDRESS */
igt_info("gtt_size=%lld MiB, max-alignment=%lld, count=%lld\n",
(long long)gtt_size/1024/1024,
@@ -131,40 +145,53 @@ static void many(int fd)
for (i = 0; i < count; i++) {
execobj[i].handle = gem_create(fd, 4096);
- if ((gtt_size-1) >> 32)
- execobj[i].flags = 1<<3; /* EXEC_OBJECT_SUPPORTS_48B_ADDRESS */
+ execobj[i].flags = flags;
}
execobj[i].handle = gem_create(fd, 4096);
- if ((gtt_size-1) >> 32)
- execobj[i].flags = 1<<3; /* EXEC_OBJECT_SUPPORTS_48B_ADDRESS */
+ execobj[i].flags = flags;
gem_write(fd, execobj[i].handle, 0, &bbe, sizeof(bbe));
+
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = to_user_pointer(execobj);
execbuf.buffer_count = count + 1;
- igt_require(__gem_execbuf(fd, &execbuf) == 0);
+ igt_require(__execbuf(fd, &execbuf) == 0);
- for (alignment = 4096; alignment < gtt_size; alignment <<= 1) {
- for (i = 0; i < count; i++)
- execobj[i].alignment = alignment;
+ alignment_set_timeout(MANY_TIMEOUT, 0);
+
+ for (alignment = 4096; alignment < gtt_size && !timed_out; alignment <<= 1) {
if (alignment > max_alignment) {
uint64_t factor = alignment / max_alignment;
- execbuf.buffer_count = 2*count / factor;
- execbuf.buffers_ptr =
- to_user_pointer(execobj + count - execbuf.buffer_count + 1);
+ max_count = 2 * count / factor;
}
- igt_debug("testing %lld x alignment=%#llx [%db]\n",
- (long long)execbuf.buffer_count - 1,
- (long long)alignment,
- find_last_bit(alignment)-1);
- gem_execbuf(fd, &execbuf);
- for(i = count - execbuf.buffer_count + 1; i < count; i++) {
- igt_assert_eq_u64(execobj[i].alignment, alignment);
- igt_assert_eq_u64(execobj[i].offset % alignment, 0);
+ for (i = 0; i < count; i++)
+ execobj[i].alignment = alignment;
+
+ for (curr_count = 1; curr_count < max_count; curr_count <<= 1) {
+
+ execbuf.buffer_count = curr_count;
+ execbuf.buffers_ptr =
+ to_user_pointer(execobj + count - execbuf.buffer_count + 1);
+
+ igt_debug("testing %lld x alignment=%#llx [%db]\n",
+ (long long)execbuf.buffer_count,
+ (long long)alignment,
+ find_last_bit(alignment)-1);
+ ret = __execbuf(fd, &execbuf);
+
+ if (timed_out)
+ break;
+
+ igt_assert_eq(ret, 0);
+
+ for (i = count - execbuf.buffer_count + 1; i < count; i++) {
+ igt_assert_eq_u64(execobj[i].alignment, alignment);
+ igt_assert_eq_u64(execobj[i].offset % alignment, 0);
+ }
}
}
-
+ alignment_reset_timeout();
for (i = 0; i < count; i++)
gem_close(fd, execobj[i].handle);
gem_close(fd, execobj[i].handle);
--
2.20.1
More information about the igt-dev
mailing list