diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-07-31 10:12:05 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-07-31 11:14:53 +0100 |
commit | 2f61bd43993e6d2289f39eb1818d2cd55480e3aa (patch) | |
tree | 23200abb13c081b7f537eefe1a97b5b3aa483f02 /tests | |
parent | d80bd02632e8a91389c58c601b3ebce8e6c924d3 (diff) |
i915/gem_ctx_ringsize: Manually control timeout
Manually setup the signal handler for SIGARLM so that we can dump some
debug information for test failures.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Matthew Auld <matthew.auld@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/i915/gem_ctx_ringsize.c | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/tests/i915/gem_ctx_ringsize.c b/tests/i915/gem_ctx_ringsize.c index c8e661472..60187b7c9 100644 --- a/tests/i915/gem_ctx_ringsize.c +++ b/tests/i915/gem_ctx_ringsize.c @@ -25,6 +25,7 @@ #include <fcntl.h> #include <inttypes.h> #include <math.h> +#include <signal.h> #include <sys/ioctl.h> #include <sys/types.h> #include <unistd.h> @@ -198,51 +199,43 @@ static int __execbuf(int i915, struct drm_i915_gem_execbuffer2 *execbuf) return err; } -static uint32_t __batch_create(int i915, uint32_t offset) -{ - const uint32_t bbe = 0xa << 23; - uint32_t handle; - - handle = gem_create(i915, offset + sizeof(bbe)); - gem_write(i915, handle, offset, &bbe, sizeof(bbe)); - - return handle; -} +#define IDLE (1 << 0) +#define PLUG (1 << 1) -static uint32_t batch_create(int i915) +static void sighandler(int sig) { - return __batch_create(i915, 0); } -static unsigned int measure_inflight(int i915, unsigned int engine, int timeout) +static unsigned int +measure_inflight(int i915, unsigned int engine, int timeout, unsigned int flags) { IGT_CORK_FENCE(cork); - struct drm_i915_gem_exec_object2 obj = { - .handle = batch_create(i915) - }; - struct drm_i915_gem_execbuffer2 execbuf = { - .buffers_ptr = to_user_pointer(&obj), - .buffer_count = 1, - .flags = engine | I915_EXEC_FENCE_IN, - .rsvd2 = igt_cork_plug(&cork, i915), - }; unsigned int count; + igt_spin_t *spin; + int fence; int err; fcntl(i915, F_SETFL, fcntl(i915, F_GETFL) | O_NONBLOCK); - igt_set_timeout(timeout, "execbuf blocked!"); - - gem_execbuf(i915, &execbuf); - for (count = 1; (err = __execbuf(i915, &execbuf)) == 0; count++) + signal(SIGALRM, sighandler); + alarm(timeout); + + fence = igt_cork_plug(&cork, i915); + spin = igt_spin_new(i915, + .engine = engine, + .fence = fence, + .flags = (flags & PLUG) ? IGT_SPIN_FENCE_IN : 0); + for (count = 1; (err = __execbuf(i915, &spin->execbuf)) == 0; count++) ; + igt_debugfs_dump(i915, "i915_engine_info"); igt_assert_eq(err, -EWOULDBLOCK); - close(execbuf.rsvd2); + close(fence); - igt_reset_timeout(); + alarm(0); + signal(SIGALRM, SIG_DFL); fcntl(i915, F_SETFL, fcntl(i915, F_GETFL) & ~O_NONBLOCK); + igt_spin_free(i915, spin); igt_cork_unplug(&cork); - gem_close(i915, obj.handle); return count; } @@ -250,7 +243,6 @@ static unsigned int measure_inflight(int i915, unsigned int engine, int timeout) static void test_resize(int i915, const struct intel_execution_engine2 *e, void *data) -#define IDLE (1 << 0) #define as_pointer(x) (void *)(uintptr_t)(x) { struct drm_i915_gem_context_param p = { @@ -283,7 +275,10 @@ static void test_resize(int i915, gem_context_set_param(i915, &p); igt_nsec_elapsed(&tv); - count = measure_inflight(i915, e->flags, 1 + 4 * ceil(elapsed*1e-9)); + count = measure_inflight(i915, + e->flags, + 1 + 4 * ceil(elapsed*1e-9), + flags); elapsed = igt_nsec_elapsed(&tv); igt_info("%s: %6llx -> %'6d\n", e->name, p.value, count); @@ -340,6 +335,7 @@ igt_main gem_test_each_engine(i915, "idle", test_resize, as_pointer(IDLE)); gem_test_each_engine(i915, "active", test_resize, 0); + gem_test_each_engine(i915, "plugged", test_resize, as_pointer(PLUG)); /* XXX ctx->engines[]? Clone (above) should be enough */ |