summaryrefslogtreecommitdiff
path: root/tests/i915/gem_ctx_persistence.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-05-08 10:28:20 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-05-08 10:30:18 +0100
commit4f6c17f0dbbdf2c7b4e647bb909e6d31dfce9827 (patch)
tree33854b8fc567d8d8f6b5a5b362af18aaaec62ec7 /tests/i915/gem_ctx_persistence.c
parent5efb4a1c9cc944eff129cae7794951ae617bca17 (diff)
i915/gem_ctx_persistence: Fix ring, don't block
Beware of using gem_ring_measure_inflight() as it takes a ring identifier and not the engine, should you overwrite the defaults. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1848 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'tests/i915/gem_ctx_persistence.c')
-rw-r--r--tests/i915/gem_ctx_persistence.c45
1 files changed, 39 insertions, 6 deletions
diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
index a5450662..594dc722 100644
--- a/tests/i915/gem_ctx_persistence.c
+++ b/tests/i915/gem_ctx_persistence.c
@@ -22,8 +22,10 @@
*/
#include <errno.h>
+#include <fcntl.h>
#include <sched.h>
#include <signal.h>
+#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
@@ -447,9 +449,28 @@ static void test_nonpersistent_file(int i915)
igt_spin_free(-1, spin);
}
+static int __execbuf_wr(int i915, struct drm_i915_gem_execbuffer2 *execbuf)
+{
+ int err;
+
+ err = 0;
+ if (ioctl(i915, DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) {
+ err = -errno;
+ igt_assume(err);
+ }
+
+ errno = 0;
+ return err;
+}
+
+static void alarm_handler(int sig)
+{
+}
+
static void test_nonpersistent_queued(int i915, unsigned int engine)
{
- const int count = gem_measure_ring_inflight(i915, engine, 0);
+ struct sigaction old_sa, sa = { .sa_handler = alarm_handler };
+ struct itimerval itv;
igt_spin_t *spin;
int fence = -1;
uint32_t ctx;
@@ -465,17 +486,29 @@ static void test_nonpersistent_queued(int i915, unsigned int engine)
.engine = engine,
.flags = IGT_SPIN_FENCE_OUT);
- for (int i = 0; i < count - 1; i++) {
- spin->execbuf.rsvd2 = 0;
- if (fence != -1)
- close(fence);
+ sigaction(SIGALRM, &sa, &old_sa);
+ memset(&itv, 0, sizeof(itv));
+ itv.it_value.tv_sec = 1;
+ itv.it_value.tv_usec = 0;
+ setitimer(ITIMER_REAL, &itv, NULL);
+ fcntl(i915, F_SETFL, fcntl(i915, F_GETFL) | O_NONBLOCK);
+ while (1) {
igt_assert(spin->execbuf.flags & I915_EXEC_FENCE_OUT);
- gem_execbuf_wr(i915, &spin->execbuf);
+ if (__execbuf_wr(i915, &spin->execbuf))
+ break;
+
+ if (fence != -1)
+ close(fence);
igt_assert(spin->execbuf.rsvd2);
fence = spin->execbuf.rsvd2 >> 32;
}
+ fcntl(i915, F_SETFL, fcntl(i915, F_GETFL) & ~O_NONBLOCK);
+
+ memset(&itv, 0, sizeof(itv));
+ setitimer(ITIMER_REAL, &itv, NULL);
+ sigaction(SIGALRM, &old_sa, NULL);
gem_context_destroy(i915, ctx);