Skip to contentSkip to conversation

lib/debugfs: Make is_mountpoint() non-fatal

PATCH In review Chris Wilson 5 participants 36 messages Aug 14, 2017 – Aug 21, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/24 lib/debugfs: Make is_mountpoint() non-fatal

is_mountpoint() asserts rather than report the error. Normally this isn't a problem, except for atypical selftests.

---
 lib/igt_debugfs.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
lib/igt_debugfs.c +20 -13
index ee1f0f54..98b032a3 100644
@@ -87,18 +87,26 @@
 static bool is_mountpoint(const char *path)
 {
 	char buf[strlen(path) + 4];
-	dev_t dot_dev, dotdot_dev;
 	struct stat st;
+	dev_t dev;
 
 	igt_assert_lt(snprintf(buf, sizeof(buf), "%s/.", path), sizeof(buf));
-	igt_assert_eq(stat(buf, &st), 0);
-	dot_dev = st.st_dev;
+	if (stat(buf, &st))
+		return false;
+
+	if (!S_ISDIR(st.st_mode))
+		return false;
+
+	dev = st.st_dev;
 
 	igt_assert_lt(snprintf(buf, sizeof(buf), "%s/..", path), sizeof(buf));
-	igt_assert_eq(stat(buf, &st), 0);
-	dotdot_dev = st.st_dev;
+	if (stat(buf, &st))
+		return false;
+
+	if (!S_ISDIR(st.st_mode))
+		return false;
 
-	return dot_dev != dotdot_dev;
+	return dev != st.st_dev;
 }
 
 /**
@@ -112,16 +120,14 @@ static bool is_mountpoint(const char *path)
  */
 const char *igt_debugfs_mount(void)
 {
-	struct stat st;
+	if (is_mountpoint("/sys/kernel/debug"))
+		return "/sys/kernel/debug";
 
-	if (stat("/debug/dri", &st) == 0)
+	if (is_mountpoint("/debug"))
 		return "/debug";
 
-	if (stat("/sys/kernel/debug/dri", &st) == 0)
-		return "/sys/kernel/debug";
-
-	igt_assert(is_mountpoint("/sys/kernel/debug") ||
-		   mount("debug", "/sys/kernel/debug", "debugfs", 0, 0) == 0);
+	if (mount("debug", "/sys/kernel/debug", "debugfs", 0, 0))
+		return NULL;
 
 	return "/sys/kernel/debug";
 }
@@ -154,6 +160,7 @@ int igt_debugfs_dir(int device)
 	}
 
 	debugfs_root = igt_debugfs_mount();
+	igt_assert(debugfs_root);
 
 	idx = minor(st.st_rdev);
 	snprintf(path, sizeof(path), "%s/dri/%d/name", debugfs_root, idx);
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/24 lib: Add hooks for enabling ftrace

If the kernel has tracing support builtin, we can enable around troublesome tests to obtain greater detail from the kernel that may prove invaluable in debugging the problem.

---
 lib/Makefile.sources |   2 +
 lib/igt_core.c       |   5 ++
 lib/igt_ftrace.c     | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_ftrace.h     |  46 +++++++++++++
 4 files changed, 234 insertions(+)
 create mode 100644 lib/igt_ftrace.c
 create mode 100644 lib/igt_ftrace.h
lib/Makefile.sources +2 -0
index 53fdb54c..90ff6468 100644
@@ -12,6 +12,8 @@ lib_source_list =	 	\
 	igt_aux.c		\
 	igt_aux.h		\
 	igt_edid_template.h	\
+	igt_ftrace.c		\
+	igt_ftrace.h		\
 	igt_gt.c		\
 	igt_gt.h		\
 	igt_gvt.c		\
lib/igt_core.c +5 -0
index 9eb99eda..ce8482a1 100644
@@ -63,6 +63,7 @@
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
+#include "igt_ftrace.h"
 #include "version.h"
 #include "config.h"
 
@@ -563,6 +564,8 @@ static void low_mem_killer_disable(bool disable)
 bool igt_exit_called;
 static void common_exit_handler(int sig)
 {
+	igt_ftrace_close();
+
 	if (!igt_only_list_subtests()) {
 		low_mem_killer_disable(false);
 		kick_fbcon(true);
@@ -856,6 +859,8 @@ out:
 
 		oom_adjust_for_doom();
 		low_mem_killer_disable(true);
+
+		igt_ftrace_open();
 	}
 
 	/* install exit handler, to ensure we clean up */
lib/igt_ftrace.c new file +181 -0

181 lines not on this page · raw message

lib/igt_ftrace.h new file +46 -0

46 lines not on this page · raw message

Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH 3/24 lib: Enable automatic ftrace dumping for suspend failures

In reply to Chris Wilson

Supplement dmesg with the function call graph to try and help identify why the suspend failed. On the other hand, it may be very noisy and perturb the system due to its overhead...

---
 lib/igt_aux.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
lib/igt_aux.c +11 -4
index f428f159..8fa34411 100644
@@ -56,6 +56,7 @@
 #include "intel_chipset.h"
 #include "igt_aux.h"
 #include "igt_debugfs.h"
+#include "igt_ftrace.h"
 #include "igt_gt.h"
 #include "igt_rand.h"
 #include "igt_sysfs.h"
@@ -762,13 +763,19 @@ static void suspend_via_rtcwake(enum igt_suspend_state state)
 		     "the rtcwake tool or how your distro is set up.\n",
 		      ret);
 
+	igt_ftrace_enable();
+
 	snprintf(cmd, sizeof(cmd), "rtcwake -s %d -m %s ",
 		 delay, suspend_state_name[state]);
 	ret = system(cmd);
-	igt_assert_f(ret == 0,
-		     "rtcwake failed with %i\n"
-		     "Check dmesg for further details.\n",
-		     ret);
+
+	igt_ftrace_disable();
+	if (ret) {
+		igt_warn("rtcwake failed with %i\n", ret);
+		igt_ftrace_dump(__func__);
+		igt_assert_f(ret == 0,
+			     "Check dmesg for further details.\n");
+	}
 }
 
 static void suspend_via_sysfs(int power_dir, enum igt_suspend_state state)
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [PATCH igt 03/24] lib: Enable automatic ftrace dumping for suspend failures

Quoting Chris Wilson (2017-08-14 21:18:27)

Quoted 3 lines

Supplement dmesg with the function call graph to try and help identify why the suspend failed. On the other hand, it may be very noisy and perturb the system due to its overhead...

And it appears ftrace is not stable enough to use across CI. Interesting.
-Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH igt 03/24] lib: Enable automatic ftrace dumping for suspend failures

Quoted 7 lines · Chris Wilson

Quoting Chris Wilson (2017-08-14 21:18:27)

Quoted 3 lines

Supplement dmesg with the function call graph to try and help identify why the suspend failed. On the other hand, it may be very noisy and perturb the system due to its overhead...

And it appears ftrace is not stable enough to use across CI. Interesting.

Hm, should we instead have an --enable-ftrace flag for igt tests? Means we need to do a manual run to capture the failures, but might be the better balance ...
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

Re: [PATCH igt 03/24] lib: Enable automatic ftrace dumping for suspend failures

Quoting Daniel Vetter (2017-08-15 09:45:48)

Quoted 6 lines · Chris Wilson
Quoted 5 lines

Quoting Chris Wilson (2017-08-14 21:18:27)

Quoted 3 lines

Supplement dmesg with the function call graph to try and help identify why the suspend failed. On the other hand, it may be very noisy and perturb the system due to its overhead...

Quoted 6 lines
Quoted 2 lines

And it appears ftrace is not stable enough to use across CI. Interesting.

Hm, should we instead have an --enable-ftrace flag for igt tests? Means we need to do a manual run to capture the failures, but might be the better balance ...

The infrastructure is fine by itself, so I was just considering sending it to the farm as required. Improving ftrace would also be sensible, but likely not an easy task.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

PATCH 4/24 igt/gem_exec_schedule: Do not overcommit batches to the ring

In reply to Chris Wilson

Measure the ring_size so we don't overfill it and block until the GPU hangs.

---
 tests/gem_exec_schedule.c | 99 +++++++++++++++++++++++++++++++++++++----------
 1 file changed, 78 insertions(+), 21 deletions(-)
tests/gem_exec_schedule.c +78 -21
index 545dcc2e..22a5b704 100644
@@ -22,6 +22,7 @@
  */
 
 #include <sys/poll.h>
+#include <sys/ioctl.h>
 
 #include "igt.h"
 #include "igt_vgem.h"
@@ -437,46 +438,104 @@ static void deep(int fd, unsigned ring)
 #undef XS
 }
 
+static void alarm_handler(int sig)
+{
+}
+
+static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
+{
+	return ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf);
+}
+
+static unsigned int measure_ring_size(int fd, unsigned int ring)
+{
+	struct sigaction sa = { .sa_handler = alarm_handler };
+	struct drm_i915_gem_exec_object2 obj[2];
+	struct drm_i915_gem_execbuffer2 execbuf;
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	unsigned int count, last;
+	struct itimerval itv;
+	struct cork c;
+
+	memset(obj, 0, sizeof(obj));
+	obj[1].handle = gem_create(fd, 4096);
+	gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(obj + 1);
+	execbuf.buffer_count = 1;
+	execbuf.flags = ring;
+	gem_execbuf(fd, &execbuf);
+	gem_sync(fd, obj[1].handle);
+
+	plug(fd, &c);
+	obj[0].handle = c.handle;
+
+	execbuf.buffers_ptr = to_user_pointer(obj);
+	execbuf.buffer_count = 2;
+
+	sigaction(SIGALRM, &sa, NULL);
+	itv.it_interval.tv_sec = 0;
+	itv.it_interval.tv_usec = 100;
+	itv.it_value.tv_sec = 0;
+	itv.it_value.tv_usec = 1000;
+	setitimer(ITIMER_REAL, &itv, NULL);
+
+	last = -1;
+	count = 0;
+	do {
+		if (__execbuf(fd, &execbuf) == 0) {
+			count++;
+			continue;
+		}
+
+		if (last == count)
+			break;
+
+		last = count;
+	} while (1);
+
+	memset(&itv, 0, sizeof(itv));
+	setitimer(ITIMER_REAL, &itv, NULL);
+
+	unplug(&c);
+	gem_close(fd, obj[1].handle);
+
+	return count;
+}
+
 static void wide(int fd, unsigned ring)
 {
-#define XS 128
 #define NCTX 4096
-	const uint32_t bbe = MI_BATCH_BUFFER_END;
-	struct drm_i915_gem_exec_object2 obj;
-	struct drm_i915_gem_execbuffer2 execbuf;
+	struct timespec tv = {};
+	unsigned int ring_size = measure_ring_size(fd, ring);
 
 	struct cork cork;
 	uint32_t result;
 	uint32_t *busy;
 	uint32_t *ptr;
 	uint32_t *ctx;
+	unsigned int count;
 
 	ctx = malloc(sizeof(*ctx)*NCTX);
 	for (int n = 0; n < NCTX; n++)
 		ctx[n] = gem_context_create(fd);
 
-	memset(&obj, 0, sizeof(obj));
-	obj.handle = gem_create(fd, 4096);
-	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
-
-	memset(&execbuf, 0, sizeof(execbuf));
-	execbuf.buffers_ptr = to_user_pointer(&obj);
-	execbuf.buffer_count = 1;
-
 	result = gem_create(fd, 4*NCTX);
 
 	busy = make_busy(fd, result, ring);
 	plug(fd, &cork);
 
 	/* Lots of in-order requests, plugged and submitted simultaneously */
-	for (int n = 0; n < NCTX; n++) {
-		store_dword(fd, ctx[n], ring, result, 4*n, ctx[n], cork.handle, I915_GEM_DOMAIN_INSTRUCTION);
-
-		execbuf.rsvd1 = ctx[n];
-		execbuf.flags = ring;
-		for (int m = 0; m < XS; m++)
-			gem_execbuf(fd, &execbuf);
+	for (count = 0;
+	     igt_seconds_elapsed(&tv) < 5 && count < ring_size;
+	     count++) {
+		for (int n = 0; n < NCTX; n++) {
+			store_dword(fd, ctx[n], ring, result, 4*n, ctx[n], cork.handle, I915_GEM_DOMAIN_INSTRUCTION);
+		}
 	}
+	igt_info("Submitted %d requests over %d contexts in %.1fms\n",
+		 count, NCTX, igt_nsec_elapsed(&tv) * 1e-6);
 
 	igt_assert(gem_bo_busy(fd, result));
 	unplug(&cork); /* only now submit our batches */
@@ -493,11 +552,9 @@ static void wide(int fd, unsigned ring)
 		igt_assert_eq_u32(ptr[n], ctx[n]);
 	munmap(ptr, 4096);
 
-	gem_close(fd, obj.handle);
 	gem_close(fd, result);
 	free(ctx);
 #undef CTX
-#undef XS
 }
 
 static bool has_scheduler(int fd)
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

PATCH 5/24 igt/gem_exec_schedule: Exercise reordering with many priority levels

In reply to Chris Wilson

Apply a little more stress to the scheduler.

---
 lib/igt_rand.h            |   6 +++
 tests/gem_exec_schedule.c | 108 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 113 insertions(+), 1 deletion(-)
lib/igt_rand.h +6 -0
index f664af41..c9cb3243 100644
@@ -38,4 +38,10 @@ static inline void hars_petruska_f54_1_random_perturb(uint32_t xor)
 	hars_petruska_f54_1_random_seed(hars_petruska_f54_1_random_unsafe());
 }
 
+/* Returns: pseudo-random number in interval [0, ep_ro) */
+static inline uint32_t hars_petruska_f54_1_random_unsafe_max(uint32_t ep_ro)
+{
+	return ((uint64_t)hars_petruska_f54_1_random_unsafe() * ep_ro) >> 32;
+}
+
 #endif /* IGT_RAND_H */
tests/gem_exec_schedule.c +107 -1

132 lines not on this page · raw message

Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH 6/24 igt/gem_exec_schedule: Basic tests for preemption

In reply to Chris Wilson

We queue N low priority hanging batches across the engines and check that out high priority write over takes them.

---
 lib/igt_dummyload.c       |  20 ++++--
 lib/igt_dummyload.h       |  10 ++-
 tests/gem_busy.c          |   4 +-
 tests/gem_exec_fence.c    |   2 +-
 tests/gem_exec_reloc.c    |   6 +-
 tests/gem_exec_schedule.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/gem_shrink.c        |   4 +-
 tests/gem_spin_batch.c    |   4 +-
 tests/gem_wait.c          |   2 +-
 tests/kms_busy.c          |   8 ++-
 tests/kms_flip.c          |   4 +-
 tests/pm_rps.c            |   2 +-
 12 files changed, 197 insertions(+), 25 deletions(-)
lib/igt_dummyload.c +14 -6
index 00c6a030..5ad386a5 100644
@@ -46,6 +46,8 @@
 
 #define ENGINE_MASK  (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
 
+#define MI_ARB_CHK (0x5 << 23)
+
 static const int BATCH_SIZE = 4096;
 static IGT_LIST(spin_list);
 
@@ -61,7 +63,8 @@ fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
 }
 
 static void emit_recursive_batch(igt_spin_t *spin,
-				 int fd, int engine, unsigned int dep)
+				 int fd, uint32_t ctx, unsigned engine,
+				 uint32_t dep)
 {
 #define SCRATCH 0
 #define BATCH 1
@@ -112,9 +115,13 @@ static void emit_recursive_batch(igt_spin_t *spin,
 	spin->batch = batch;
 	spin->handle = obj[BATCH].handle;
 
+	/* Allow ourselves to be preempted */
+	*batch++ = MI_ARB_CHK;
+
 	/* recurse */
 	fill_reloc(&relocs[obj[BATCH].relocation_count],
-		   obj[BATCH].handle, 1, I915_GEM_DOMAIN_COMMAND, 0);
+		   obj[BATCH].handle, (batch - spin->batch) + 1,
+		   I915_GEM_DOMAIN_COMMAND, 0);
 	if (gen >= 8) {
 		*batch++ = MI_BATCH_BUFFER_START | 1 << 8 | 1;
 		*batch++ = 0;
@@ -135,6 +142,7 @@ static void emit_recursive_batch(igt_spin_t *spin,
 	obj[BATCH].relocs_ptr = to_user_pointer(relocs);
 
 	execbuf.buffers_ptr = to_user_pointer(obj + (2 - execbuf.buffer_count));
+	execbuf.rsvd1 = ctx;
 
 	for (i = 0; i < nengine; i++) {
 		execbuf.flags &= ~ENGINE_MASK;
@@ -144,14 +152,14 @@ static void emit_recursive_batch(igt_spin_t *spin,
 }
 
 igt_spin_t *
-__igt_spin_batch_new(int fd, int engine, unsigned int dep)
+__igt_spin_batch_new(int fd, uint32_t ctx, unsigned engine, uint32_t dep)
 {
 	igt_spin_t *spin;
 
 	spin = calloc(1, sizeof(struct igt_spin));
 	igt_assert(spin);
 
-	emit_recursive_batch(spin, fd, engine, dep);
+	emit_recursive_batch(spin, fd, ctx, engine, dep);
 	igt_assert(gem_bo_busy(fd, spin->handle));
 
 	igt_list_add(&spin->link, &spin_list);
@@ -175,11 +183,11 @@ __igt_spin_batch_new(int fd, int engine, unsigned int dep)
  * Structure with helper internal state for igt_spin_batch_free().
  */
 igt_spin_t *
-igt_spin_batch_new(int fd, int engine, unsigned int dep)
+igt_spin_batch_new(int fd, uint32_t ctx, unsigned engine, uint32_t dep)
 {
 	igt_require_gem(fd);
 
-	return __igt_spin_batch_new(fd, engine, dep);
+	return __igt_spin_batch_new(fd, ctx, engine, dep);
 }
 
 static void notify(union sigval arg)
lib/igt_dummyload.h +8 -2
index 340cada0..215425f7 100644
@@ -37,8 +37,14 @@ typedef struct igt_spin {
 	uint32_t *batch;
 } igt_spin_t;
 
-igt_spin_t *__igt_spin_batch_new(int fd, int engine, unsigned int dep);
-igt_spin_t *igt_spin_batch_new(int fd, int engine, unsigned int dep);
+igt_spin_t *__igt_spin_batch_new(int fd,
+				 uint32_t ctx,
+				 unsigned engine,
+				 uint32_t  dep);
+igt_spin_t *igt_spin_batch_new(int fd,
+			       uint32_t ctx,
+			       unsigned engine,
+			       uint32_t  dep);
 void igt_spin_batch_set_timeout(igt_spin_t *spin, int64_t ns);
 void igt_spin_batch_end(igt_spin_t *spin);
 void igt_spin_batch_free(int fd, igt_spin_t *spin);
tests/gem_busy.c +2 -2
index 8702dd7e..58aa5ee5 100644
@@ -460,7 +460,7 @@ static bool has_semaphores(int fd)
 
 static bool has_extended_busy_ioctl(int fd)
 {
-	igt_spin_t *spin = igt_spin_batch_new(fd, I915_EXEC_RENDER, 0);
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, I915_EXEC_RENDER, 0);
 	uint32_t read, write;
 
 	__gem_busy(fd, spin->handle, &read, &write);
@@ -471,7 +471,7 @@ static bool has_extended_busy_ioctl(int fd)
 
 static void basic(int fd, unsigned ring, unsigned flags)
 {
-	igt_spin_t *spin = igt_spin_batch_new(fd, ring, 0);
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, ring, 0);
 	struct timespec tv;
 	int timeout;
 	bool busy;
tests/gem_exec_fence.c +1 -1
index 76d9a7ea..7a86c379 100644
@@ -438,7 +438,7 @@ static void test_parallel(int fd, unsigned int master)
 	/* Fill the queue with many requests so that the next one has to
 	 * wait before it can be executed by the hardware.
 	 */
-	spin = igt_spin_batch_new(fd, master, c.handle);
+	spin = igt_spin_batch_new(fd, 0, master, c.handle);
 	resubmit(fd, spin->handle, master, 16);
 
 	/* Now queue the master request and its secondaries */
tests/gem_exec_reloc.c +3 -3
index edbc0f13..432a42a9 100644
@@ -388,7 +388,7 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags)
 		}
 
 		if (flags & ACTIVE) {
-			spin = igt_spin_batch_new(fd, I915_EXEC_DEFAULT, obj.handle);
+			spin = igt_spin_batch_new(fd, 0, I915_EXEC_DEFAULT, obj.handle);
 			if (!(flags & HANG))
 				igt_spin_batch_set_timeout(spin, NSEC_PER_SEC/100);
 			igt_assert(gem_bo_busy(fd, obj.handle));
@@ -454,7 +454,7 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags)
 		}
 
 		if (flags & ACTIVE) {
-			spin = igt_spin_batch_new(fd, I915_EXEC_DEFAULT, obj.handle);
+			spin = igt_spin_batch_new(fd, 0, I915_EXEC_DEFAULT, obj.handle);
 			if (!(flags & HANG))
 				igt_spin_batch_set_timeout(spin, NSEC_PER_SEC/100);
 			igt_assert(gem_bo_busy(fd, obj.handle));
@@ -581,7 +581,7 @@ static void basic_range(int fd, unsigned flags)
 	execbuf.buffer_count = n + 1;
 
 	if (flags & ACTIVE) {
-		spin = igt_spin_batch_new(fd, 0, obj[n].handle);
+		spin = igt_spin_batch_new(fd, 0, 0, obj[n].handle);
 		if (!(flags & HANG))
 			igt_spin_batch_set_timeout(spin, NSEC_PER_SEC/100);
 		igt_assert(gem_bo_busy(fd, obj[n].handle));
tests/gem_exec_schedule.c +156 -0

168 lines not on this page · raw message

tests/gem_shrink.c +2 -2
index 8b09fc80..06f7a301 100644
@@ -311,9 +311,9 @@ static void reclaim(unsigned engine, int timeout)
 		} while (!*shared);
 	}
 
-	spin = igt_spin_batch_new(fd, engine, 0);
+	spin = igt_spin_batch_new(fd, 0, engine, 0);
 	igt_until_timeout(timeout) {
-		igt_spin_t *next = __igt_spin_batch_new(fd, engine, 0);
+		igt_spin_t *next = __igt_spin_batch_new(fd, 0, engine, 0);
 
 		igt_spin_batch_set_timeout(spin, timeout_100ms);
 		gem_sync(fd, spin->handle);
tests/gem_spin_batch.c +2 -2
index 941aa139..24c5d9b7 100644
@@ -41,9 +41,9 @@ static void spin(int fd, unsigned int engine, unsigned int timeout_sec)
 	struct timespec itv = { };
 	uint64_t elapsed;
 
-	spin = igt_spin_batch_new(fd, engine, 0);
+	spin = igt_spin_batch_new(fd, 0, engine, 0);
 	while ((elapsed = igt_nsec_elapsed(&tv)) >> 30 < timeout_sec) {
-		igt_spin_t *next = __igt_spin_batch_new(fd, engine, 0);
+		igt_spin_t *next = __igt_spin_batch_new(fd, 0, engine, 0);
 
 		igt_spin_batch_set_timeout(spin,
 					   timeout_100ms - igt_nsec_elapsed(&itv));
tests/gem_wait.c +1 -1
index 591690ad..cf8c8154 100644
@@ -110,7 +110,7 @@ static void unplug(struct cork *c)
 static void basic(int fd, unsigned engine, unsigned flags)
 {
 	struct cork cork = plug(fd, flags);
-	igt_spin_t *spin = igt_spin_batch_new(fd, engine, cork.handle);
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, engine, cork.handle);
 	struct drm_i915_gem_wait wait = {
 	       	flags & WRITE ? cork.handle : spin->handle
        	};
tests/kms_busy.c +5 -3
index ecf0b2eb..7e31c2c8 100644
@@ -91,7 +91,8 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
 	struct timespec tv = { 1, 0 };
 	struct drm_event_vblank ev;
 
-	igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd, ring, fb->gem_handle);
+	igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd,
+					   0, ring, fb->gem_handle);
 
 	if (modeset) {
 		/*
@@ -203,7 +204,8 @@ static void test_flip(igt_display_t *dpy, unsigned ring, int pipe, bool modeset)
 static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary,
 				    struct igt_fb *busy_fb, unsigned ring)
 {
-	igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd, ring, busy_fb->gem_handle);
+	igt_spin_t *t = igt_spin_batch_new(dpy->drm_fd,
+					   0, ring, busy_fb->gem_handle);
 	struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
 	unsigned flags = 0;
 	struct drm_event_vblank ev;
@@ -290,7 +292,7 @@ static void test_pageflip_modeset_hang(igt_display_t *dpy,
 
 	igt_display_commit2(dpy, dpy->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
 
-	t = igt_spin_batch_new(dpy->drm_fd, ring, fb.gem_handle);
+	t = igt_spin_batch_new(dpy->drm_fd, 0, ring, fb.gem_handle);
 
 	do_or_die(drmModePageFlip(dpy->drm_fd, dpy->pipes[pipe].crtc_id, fb.fb_id, DRM_MODE_PAGE_FLIP_EVENT, &fb));
 
tests/kms_flip.c +2 -2
index ea860e19..d701886e 100644
@@ -694,11 +694,11 @@ static unsigned int run_test_step(struct test_output *o)
 		o->current_fb_id = !o->current_fb_id;
 
 	if (o->flags & TEST_WITH_DUMMY_BCS)
-		spin_bcs = igt_spin_batch_new(drm_fd, I915_EXEC_BLT,
+		spin_bcs = igt_spin_batch_new(drm_fd, 0, I915_EXEC_BLT,
 					      o->fb_info[o->current_fb_id].gem_handle);
 
 	if (o->flags & TEST_WITH_DUMMY_RCS)
-		spin_rcs = igt_spin_batch_new(drm_fd, I915_EXEC_RENDER,
+		spin_rcs = igt_spin_batch_new(drm_fd, 0, I915_EXEC_RENDER,
 					      o->fb_info[o->current_fb_id].gem_handle);
 
 	if (o->flags & TEST_FB_RECREATE)
tests/pm_rps.c +1 -1
index f0455e78..ce01c466 100644
@@ -566,7 +566,7 @@ static void boost_freq(int fd, int *boost_freqs)
 	int ring = -1;
 	igt_spin_t *load;
 
-	load = igt_spin_batch_new(fd, ring, 0);
+	load = igt_spin_batch_new(fd, 0, ring, 0);
 
 	/* Waiting will grant us a boost to maximum */
 	gem_wait(fd, load->handle, &timeout);
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH 7/24 igt/gem_exec_fence: Exercise syncobj API (The forgotten tests)

In reply to Chris Wilson

Due to premature patch pushing, lots of tests remain outstanding.

---
 tests/gem_exec_fence.c | 331 +++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 308 insertions(+), 23 deletions(-)
tests/gem_exec_fence.c +308 -23
index 7a86c379..63eb7955 100644
@@ -34,7 +34,7 @@ IGT_TEST_DESCRIPTION("Check that execbuf waits for explicit fences");
 
 #define LOCAL_EXEC_FENCE_IN (1 << 16)
 #define LOCAL_EXEC_FENCE_OUT (1 << 17)
-#define LOCAL_EXEC_FENCE_SUBMIT (1 << 19)
+#define LOCAL_EXEC_FENCE_SUBMIT (1 << 20)
 
 #define LOCAL_EXEC_FENCE_ARRAY (1 << 19)
 struct local_gem_exec_fence {
@@ -732,7 +732,7 @@ static bool has_submit_fence(int fd)
 	int value = 0;
 
 	memset(&gp, 0, sizeof(gp));
-	gp.param = 49; /* I915_PARAM_HAS_EXEC_SUBMIT_FENCE */
+	gp.param = 50; /* I915_PARAM_HAS_EXEC_SUBMIT_FENCE */
 	gp.value = &value;
 
 	ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
@@ -769,6 +769,7 @@ static void test_invalid_fence_array(int fd)
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 obj;
 	struct local_gem_exec_fence fence;
+	void *ptr;
 
 	/* create an otherwise valid execbuf */
 	memset(&obj, 0, sizeof(obj));
@@ -779,10 +780,10 @@ static void test_invalid_fence_array(int fd)
 	execbuf.buffer_count = 1;
 	gem_execbuf(fd, &execbuf);
 
-	/* Now add a few invalid fence-array pointers */
 	execbuf.flags |= LOCAL_EXEC_FENCE_ARRAY;
-	//igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL);
+	gem_execbuf(fd, &execbuf);
 
+	/* Now add a few invalid fence-array pointers */
 	if (sizeof(execbuf.num_cliprects) == sizeof(size_t)) {
 		execbuf.num_cliprects = -1;
 		igt_assert_eq(__gem_execbuf(fd, &execbuf), -EINVAL);
@@ -795,6 +796,19 @@ static void test_invalid_fence_array(int fd)
 	memset(&fence, 0, sizeof(fence));
 	execbuf.cliprects_ptr = to_user_pointer(&fence);
 	igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT);
+
+	ptr = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	igt_assert(ptr != MAP_FAILED);
+	execbuf.cliprects_ptr = to_user_pointer(ptr);
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT);
+
+	do_or_die(mprotect(ptr, 4096, PROT_READ));
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -ENOENT);
+
+	do_or_die(mprotect(ptr, 4096, PROT_NONE));
+	igt_assert_eq(__gem_execbuf(fd, &execbuf), -EFAULT);
+
+	munmap(ptr, 4096);
 }
 
 static uint32_t __syncobj_create(int fd)
@@ -870,6 +884,33 @@ static int syncobj_to_sync_file(int fd, uint32_t handle)
 	return ret;
 }
 
+static int __syncobj_from_sync_file(int fd, uint32_t handle, int sf)
+{
+	struct local_syncobj_handle {
+		uint32_t handle;
+		uint32_t flags;
+		int32_t fd;
+		uint32_t pad;
+	} arg;
+#define LOCAL_IOCTL_SYNCOBJ_FD_TO_HANDLE  DRM_IOWR(0xC2, struct local_syncobj_handle)
+	int err = 0;
+
+	memset(&arg, 0, sizeof(arg));
+	arg.handle = handle;
+	arg.fd = sf;
+	arg.flags = 1 << 0; /* IMPORT_SYNC_FILE */
+	if (ioctl(fd, LOCAL_IOCTL_SYNCOBJ_FD_TO_HANDLE, &arg))
+		err = -errno;
+
+	errno = 0;
+	return err;
+}
+
+static void syncobj_from_sync_file(int fd, uint32_t handle, int sf)
+{
+	igt_assert_eq(__syncobj_from_sync_file(fd, handle, sf), 0);
+}
+
 static int __syncobj_export(int fd, uint32_t handle, int *syncobj)
 {
 	struct local_syncobj_handle {
@@ -954,7 +995,7 @@ static void test_syncobj_unused_fence(int fd)
 	struct local_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
-	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0);
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0, 0);
 
 	/* sanity check our syncobj_to_sync_file interface */
 	igt_assert_eq(__syncobj_to_sync_file(fd, 0), -ENOENT);
@@ -1018,7 +1059,9 @@ static void test_syncobj_signal(int fd)
 	struct local_gem_exec_fence fence = {
 		.handle = syncobj_create(fd),
 	};
-	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0);
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0, 0);
+
+	/* Check that the syncobj is signaled only when our request/fence is */
 
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
@@ -1060,9 +1103,13 @@ static void test_syncobj_wait(int fd)
 	unsigned handle[16];
 	int n;
 
+	/* Check that we can use the syncobj to asynchronous wait prior to
+	 * execution.
+	 */
+
 	gem_quiescent_gpu(fd);
 
-	spin = igt_spin_batch_new(fd, 0, 0);
+	spin = igt_spin_batch_new(fd, 0, 0, 0);
 
 	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(&obj);
@@ -1123,7 +1170,7 @@ static void test_syncobj_wait(int fd)
 	}
 }
 
-static void test_syncobj_import(int fd)
+static void test_syncobj_export(int fd)
 {
 	const uint32_t bbe = MI_BATCH_BUFFER_END;
 	struct drm_i915_gem_exec_object2 obj;
@@ -1132,8 +1179,13 @@ static void test_syncobj_import(int fd)
 		.handle = syncobj_create(fd),
 	};
 	int export[2];
-	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0);
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0, 0);
 
+	/* Check that if we export the syncobj prior to use it picks up
+	 * the later fence. This allows a syncobj to establish a channel
+	 * between clients that may be updated to a later fence by either
+	 * end.
+	 */
 	for (int n = 0; n < ARRAY_SIZE(export); n++)
 		export[n] = syncobj_export(fd, fence.handle);
 
@@ -1166,15 +1218,241 @@ static void test_syncobj_import(int fd)
 	igt_assert(!gem_bo_busy(fd, obj.handle));
 	igt_assert(!syncobj_busy(fd, fence.handle));
 
+	gem_close(fd, obj.handle);
+	syncobj_destroy(fd, fence.handle);
+
 	for (int n = 0; n < ARRAY_SIZE(export); n++) {
 		uint32_t import = syncobj_import(fd, export[n]);
 		igt_assert(!syncobj_busy(fd, import));
-		close(export[n]);
 		syncobj_destroy(fd, import);
+		close(export[n]);
 	}
+}
 
+static void test_syncobj_repeat(int fd)
+{
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	const unsigned nfences = 4096;
+	struct drm_i915_gem_exec_object2 obj;
+	struct drm_i915_gem_execbuffer2 execbuf;
+	struct local_gem_exec_fence *fence;
+	int export;
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0, 0);
+
+	/* Check that we can wait on the same fence multiple times */
+	fence = calloc(nfences, sizeof(*fence));
+	fence->handle = syncobj_create(fd);
+	export = syncobj_export(fd, fence->handle);
+	for (int i = 1; i < nfences; i++)
+		fence[i].handle = syncobj_import(fd, export);
+	close(export);
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&obj);
+	execbuf.buffer_count = 1;
+	execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+	execbuf.cliprects_ptr = to_user_pointer(fence);
+	execbuf.num_cliprects = nfences;
+
+	memset(&obj, 0, sizeof(obj));
+	obj.handle = gem_create(fd, 4096);
+	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
+
+	for (int i = 0; i < nfences; i++)
+		fence[i].flags = LOCAL_EXEC_FENCE_SIGNAL;
+
+	gem_execbuf(fd, &execbuf);
+
+	for (int i = 0; i < nfences; i++) {
+		igt_assert(syncobj_busy(fd, fence[i].handle));
+		fence[i].flags |= LOCAL_EXEC_FENCE_WAIT;
+	}
+	igt_assert(gem_bo_busy(fd, obj.handle));
+
+	gem_execbuf(fd, &execbuf);
+
+	for (int i = 0; i < nfences; i++)
+		igt_assert(syncobj_busy(fd, fence[i].handle));
+	igt_assert(gem_bo_busy(fd, obj.handle));
+
+	igt_spin_batch_free(fd, spin);
+
+	gem_sync(fd, obj.handle);
 	gem_close(fd, obj.handle);
-	syncobj_destroy(fd, fence.handle);
+
+	for (int i = 0; i < nfences; i++) {
+		igt_assert(!syncobj_busy(fd, fence[i].handle));
+		syncobj_destroy(fd, fence[i].handle);
+	}
+	free(fence);
+}
+
+static void test_syncobj_import(int fd)
+{
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	struct drm_i915_gem_exec_object2 obj;
+	struct drm_i915_gem_execbuffer2 execbuf;
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0, 0);
+	uint32_t sync = syncobj_create(fd);
+	int fence;
+
+	/* Check that we can create a syncobj from an explicit fence (which
+	 * uses sync_file) and that it acts just like a regular fence.
+	 */
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&obj);
+	execbuf.buffer_count = 1;
+	execbuf.flags = LOCAL_EXEC_FENCE_OUT;
+	execbuf.rsvd2 = -1;
+
+	memset(&obj, 0, sizeof(obj));
+	obj.handle = gem_create(fd, 4096);
+	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
+
+	gem_execbuf_wr(fd, &execbuf);
+
+	fence = execbuf.rsvd2 >> 32;
+	igt_assert(fence_busy(fence));
+	syncobj_from_sync_file(fd, sync, fence);
+	close(fence);
+
+	igt_assert(gem_bo_busy(fd, obj.handle));
+	igt_assert(syncobj_busy(fd, sync));
+
+	igt_spin_batch_free(fd, spin);
+
+	gem_sync(fd, obj.handle);
+	igt_assert(!gem_bo_busy(fd, obj.handle));
+	igt_assert(!syncobj_busy(fd, sync));
+
+	gem_close(fd, obj.handle);
+	syncobj_destroy(fd, sync);
+}
+
+static void test_syncobj_channel(int fd)
+{
+	const uint32_t bbe = MI_BATCH_BUFFER_END;
+	struct drm_i915_gem_exec_object2 obj;
+	struct drm_i915_gem_execbuffer2 execbuf;
+	unsigned int *control;
+	int syncobj[3];
+
+	/* Create a pair of channels (like a pipe) between two clients
+	 * and try to create races on the syncobj.
+	 */
+
+	control = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
+	igt_assert(control != MAP_FAILED);
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&obj);
+	execbuf.buffer_count = 1;
+	execbuf.flags = LOCAL_EXEC_FENCE_OUT;
+	execbuf.rsvd2 = -1;
+
+	memset(&obj, 0, sizeof(obj));
+	obj.handle = gem_create(fd, 4096);
+	gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
+
+	for (int i = 0; i < ARRAY_SIZE(syncobj); i++) {
+		struct local_gem_exec_fence fence;
+
+		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.cliprects_ptr = to_user_pointer(&fence);
+		execbuf.num_cliprects = 1;
+
+		/* Create a primed fence */
+		fence.handle = syncobj_create(fd);
+		fence.flags = LOCAL_EXEC_FENCE_SIGNAL;
+
+		gem_execbuf(fd, &execbuf);
+
+		syncobj[i] = fence.handle;
+	}
+
+	/* Two processes in ping-pong unison (pipe), one out of sync */
+	igt_fork(child, 1) {
+		struct local_gem_exec_fence fence[3];
+		unsigned long count;
+
+		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.cliprects_ptr = to_user_pointer(fence);
+		execbuf.num_cliprects = 3;
+
+		fence[0].handle = syncobj[0];
+		fence[0].flags = LOCAL_EXEC_FENCE_SIGNAL;
+
+		fence[1].handle = syncobj[1];
+		fence[1].flags = LOCAL_EXEC_FENCE_WAIT;
+
+		fence[2].handle = syncobj[2];
+		fence[2].flags = LOCAL_EXEC_FENCE_WAIT;
+
+		count = 0;
+		while (!*(volatile unsigned *)control) {
+			gem_execbuf(fd, &execbuf);
+			count++;
+		}
+
+		control[1] = count;
+	}
+	igt_fork(child, 1) {
+		struct local_gem_exec_fence fence[3];
+		unsigned long count;
+
+		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.cliprects_ptr = to_user_pointer(fence);
+		execbuf.num_cliprects = 3;
+
+		fence[0].handle = syncobj[0];
+		fence[0].flags = LOCAL_EXEC_FENCE_WAIT;
+
+		fence[1].handle = syncobj[1];
+		fence[1].flags = LOCAL_EXEC_FENCE_SIGNAL;
+
+		fence[2].handle = syncobj[2];
+		fence[2].flags = LOCAL_EXEC_FENCE_WAIT;
+
+		count = 0;
+		while (!*(volatile unsigned *)control) {
+			gem_execbuf(fd, &execbuf);
+			count++;
+		}
+		control[2] = count;
+	}
+	igt_fork(child, 1) {
+		struct local_gem_exec_fence fence;
+		unsigned long count;
+
+		execbuf.flags = LOCAL_EXEC_FENCE_ARRAY;
+		execbuf.cliprects_ptr = to_user_pointer(&fence);
+		execbuf.num_cliprects = 1;
+
+		fence.handle = syncobj[2];
+		fence.flags = LOCAL_EXEC_FENCE_SIGNAL;
+
+		count = 0;
+		while (!*(volatile unsigned *)control) {
+			gem_execbuf(fd, &execbuf);
+			count++;
+		}
+		control[3] = count;
+	}
+
+	sleep(1);
+	*control = 1;
+	igt_waitchildren();
+
+	igt_info("Pipe=[%u, %u], gooseberry=%u\n",
+		 control[1], control[2], control[3]);
+	munmap(control, 4096);
+
+	gem_sync(fd, obj.handle);
+	gem_close(fd, obj.handle);
+
+	for (int i = 0; i < ARRAY_SIZE(syncobj); i++)
+		syncobj_destroy(fd, syncobj[i]);
 }
 
 igt_main
@@ -1282,33 +1560,40 @@ igt_main
 
 	igt_subtest_group { /* syncobj */
 		igt_fixture {
-			igt_require(has_syncobj(i915));
 			igt_require(exec_has_fence_array(i915));
+			igt_assert(has_syncobj(i915));
 			igt_fork_hang_detector(i915);
 		}
 
-		igt_subtest("invalid-fence-array") {
+		igt_subtest("invalid-fence-array")
 			test_invalid_fence_array(i915);
-		}
 
-		igt_subtest("syncobj-unused-fence") {
+		igt_subtest("syncobj-unused-fence")
 			test_syncobj_unused_fence(i915);
-		}
 
-		igt_subtest("syncobj-invalid-wait") {
+		igt_subtest("syncobj-invalid-wait")
 			test_syncobj_invalid_wait(i915);
-		}
 
-		igt_subtest("syncobj-signal") {
+		igt_subtest("syncobj-signal")
 			test_syncobj_signal(i915);
-		}
 
-		igt_subtest("syncobj-wait") {
+		igt_subtest("syncobj-wait")
 			test_syncobj_wait(i915);
-		}
 
-		igt_subtest("syncobj-import") {
+		igt_subtest("syncobj-export")
+			test_syncobj_export(i915);
+
+		igt_subtest("syncobj-repeat")
+			test_syncobj_repeat(i915);
+
+		igt_subtest("syncobj-import")
 			test_syncobj_import(i915);
+
+		igt_subtest("syncobj-channel")
+			test_syncobj_channel(i915);
+
+		igt_fixture {
+			igt_stop_hang_detector();
 		}
 	}
 
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH 8/24 tests/prime_rw: Add basic tests for reading/writing to a dmabuf

In reply to Chris Wilson

The idea is to implement read(dmabuf) and write(dambuf) so provide some tests.

---
 tests/Makefile.sources |   1 +
 tests/prime_rw.c       | 179 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 180 insertions(+)
 create mode 100644 tests/prime_rw.c
tests/Makefile.sources +1 -0
index bb013c78..7a99cafc 100644
@@ -225,6 +225,7 @@ TESTS_progs = \
 	prime_mmap \
 	prime_mmap_coherency \
 	prime_mmap_kms \
+	prime_rw \
 	prime_self_import \
 	prime_udl \
 	prime_vgem \
tests/prime_rw.c new file +179 -0

179 lines not on this page · raw message

Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw

PATCH 9/24 igt/gem_mmap_gtt: Simulate gdb inspecting a GTT mmap using ptrace()

In reply to Chris Wilson

gdb uses ptrace() to peek and poke bytes of the target's address space. The kernel must implement an vm_ops->access() handler or else gdb will be unable to inspect the pointer and report it as out-of-bounds. Worse than useless as it causes immediate suspicion of the valid GTT pointer.

---
 tests/gem_mmap_gtt.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)
tests/gem_mmap_gtt.c +79 -0
index 4ff5e7f1..61c08406 100644
@@ -36,6 +36,8 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#include <sys/ptrace.h>
+#include <sys/wait.h>
 #include "drm.h"
 
 #include "igt.h"
@@ -310,6 +312,81 @@ test_write_gtt(int fd)
 	munmap(src, OBJECT_SIZE);
 }
 
+static void *memchr_inv(const void *s, int c, size_t n)
+{
+	const uint8_t *us = s;
+	const uint8_t uc = c;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+	while (n--) {
+		if (*us != uc)
+			return (void *) us;
+		us++;
+	}
+#pragma GCC diagnostic pop
+
+	return NULL;
+}
+
+static void
+test_ptrace(int fd)
+{
+	long AA, CC;
+	long *gtt, *copy;
+	uint32_t bo;
+	pid_t pid;
+
+	memset(&AA, 0xaa, sizeof(AA));
+	memset(&CC, 0x55, sizeof(CC));
+
+	copy = malloc(OBJECT_SIZE);
+	memset(copy, AA, OBJECT_SIZE);
+
+	bo = gem_create(fd, OBJECT_SIZE);
+	gtt = mmap_bo(fd, bo);
+	memset(gtt, CC, OBJECT_SIZE);
+	gem_close(fd, bo);
+
+	igt_assert(!memchr_inv(gtt, CC, OBJECT_SIZE));
+	igt_assert(!memchr_inv(copy, AA, OBJECT_SIZE));
+
+	switch ((pid = fork())) {
+		case -1:
+			igt_assert(pid != -1);
+			break;
+
+		case 0:
+			ptrace(PTRACE_TRACEME, 0, NULL, NULL);
+			raise(SIGSTOP);
+			raise(SIGKILL);
+			exit(0);
+			break;
+
+		default:
+			/* Wait for the child to ready themselves */
+			wait(NULL);
+
+			ptrace(PTRACE_ATTACH, pid, NULL, NULL);
+			for (int i = 0; i < OBJECT_SIZE/sizeof(long); i++) {
+				copy[i] = ptrace(PTRACE_PEEKDATA, pid, gtt+i, NULL);
+				ptrace(PTRACE_POKEDATA, pid, gtt + i, AA);
+			}
+			ptrace(PTRACE_DETACH, pid, NULL, NULL);
+
+			/* Wakeup the child for it to exit */
+			kill(SIGCONT, pid);
+			break;
+	}
+
+	/* The contents of the two buffers should now be swapped */
+	igt_assert(!memchr_inv(gtt, AA, OBJECT_SIZE));
+	igt_assert(!memchr_inv(copy, CC, OBJECT_SIZE));
+
+	munmap(gtt, OBJECT_SIZE);
+	free(copy);
+}
+
 static void
 test_coherency(int fd)
 {
@@ -809,6 +886,8 @@ igt_main
 		test_write(fd);
 	igt_subtest("basic-write-gtt")
 		test_write_gtt(fd);
+	igt_subtest("ptrace")
+		test_ptrace(fd);
 	igt_subtest("coherency")
 		test_coherency(fd);
 	igt_subtest("clflush")
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw

PATCH 10/24 igt/gem_ctx_switch: Exercise all engines at once

In reply to Chris Wilson

Just a small variant to apply a continuous context-switch load to all engines.

---
 tests/gem_ctx_switch.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
tests/gem_ctx_switch.c +80 -0
index b6ea71cf..df22efec 100644
@@ -140,6 +140,81 @@ static void single(int fd, uint32_t handle,
 		gem_context_destroy(fd, contexts[n]);
 }
 
+static void all(int fd, uint32_t handle, unsigned flags, int timeout)
+{
+	struct drm_i915_gem_execbuffer2 execbuf;
+	struct drm_i915_gem_exec_object2 obj[2];
+	unsigned int engine[16], e;
+	const char *name[16];
+	uint32_t contexts[64];
+	unsigned int nengine;
+	int n;
+
+	nengine = 0;
+	for_each_engine(fd, e) {
+		if (e == 0 || e == I915_EXEC_BSD)
+			continue;
+
+		engine[nengine] = e;
+		name[nengine] = e__->name;
+		nengine++;
+	}
+	igt_require(nengine);
+
+	igt_require(__gem_context_create(fd, &contexts[0]) == 0);
+	for (n = 1; n < 64; n++)
+		contexts[n] = gem_context_create(fd);
+
+	memset(obj, 0, sizeof(obj));
+	obj[1].handle = handle;
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(obj + 1);
+	execbuf.buffer_count = 1;
+	execbuf.rsvd1 = contexts[0];
+	execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
+	execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
+	igt_require(__gem_execbuf(fd, &execbuf) == 0);
+	if (__gem_execbuf(fd, &execbuf)) {
+		execbuf.flags = 0;
+		gem_execbuf(fd, &execbuf);
+	}
+	gem_sync(fd, handle);
+	execbuf.buffers_ptr = to_user_pointer(obj);
+	execbuf.buffer_count = 2;
+
+	igt_fork(child, nengine) {
+		struct timespec start, now;
+		unsigned int count = 0;
+
+		obj[0].handle = gem_create(fd, 4096);
+		execbuf.flags |= engine[child];
+		gem_execbuf(fd, &execbuf);
+		gem_sync(fd, obj[0].handle);
+
+		clock_gettime(CLOCK_MONOTONIC, &start);
+		do {
+			for (int loop = 0; loop < 64; loop++) {
+				execbuf.rsvd1 = contexts[loop % 64];
+				gem_execbuf(fd, &execbuf);
+			}
+			count += 64;
+			clock_gettime(CLOCK_MONOTONIC, &now);
+		} while (elapsed(&start, &now) < timeout);
+		gem_sync(fd, obj[0].handle);
+		clock_gettime(CLOCK_MONOTONIC, &now);
+		gem_close(fd, obj[0].handle);
+
+		igt_info("[%d] %s: %'u cycles: %.3fus%s\n",
+			 child, name[child], count, elapsed(&start, &now)*1e6 / count,
+			 flags & INTERRUPTIBLE ? " (interruptible)" : "");
+	}
+	igt_waitchildren();
+
+	for (n = 0; n < 64; n++)
+		gem_context_destroy(fd, contexts[n]);
+}
+
 igt_main
 {
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
@@ -177,6 +252,11 @@ igt_main
 			single(fd, light, e, INTERRUPTIBLE, ncpus, 150);
 	}
 
+	igt_subtest("basic-all")
+		all(fd, light, 0, 20);
+	igt_subtest("basic-all-heavy")
+		all(fd, heavy, 0, 20);
+
 	igt_fixture {
 		igt_stop_hang_detector();
 		gem_close(fd, heavy);
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#13 lore raw

PATCH 11/24 igt/drv_hangman: Skip if resets are disallowed

In reply to Chris Wilson

If we tell the machine to reset but they are disallowed, we will leave the system in a wedged state, preventing the majority of subsequent tests.

---
 tests/drv_hangman.c | 3 +++
 1 file changed, 3 insertions(+)
tests/drv_hangman.c +3 -0
index 0551ec16..de57e128 100644
@@ -30,6 +30,7 @@
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 
 #include "igt_sysfs.h"
@@ -239,7 +240,9 @@ igt_main
 		int idx;
 
 		device = drm_open_driver(DRIVER_INTEL);
+		igt_allow_hang(device, 0, 0);
 		igt_require_gem(device);
+
 		sysfs = igt_sysfs_open(device, &idx);
 		igt_assert(sysfs != -1);
 	}
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

Re: [PATCH igt 11/24] igt/drv_hangman: Skip if resets are disallowed

Quoted 20 lines · Chris Wilson

If we tell the machine to reset but they are disallowed, we will leave the system in a wedged state, preventing the majority of subsequent tests.

---
 tests/drv_hangman.c | 3 +++
 1 file changed, 3 insertions(+)
tests/drv_hangman.c +1 -0
index 0551ec16..de57e128 100644
@@ -30,6 +30,7 @@
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 
 #include "igt_sysfs.h"

tests/drv_hangman.c igt_main · line 243

Quoted 4 lines
tests/drv_hangman.c +1 -0
@@ -239,7 +240,9 @@ igt_main
 		int idx;
 
 		device = drm_open_driver(DRIVER_INTEL);
+		igt_allow_hang(device, 0, 0);

I think an igt_require_hang_ring here would be better self-documenting. Also, igt_allow/disallow_hang are lacking gtkdocs.

What I'm also wondering is where our unexpected hang detection has gone to. In the past we've reported any gpu hang at error level, except when igt indicated it's expected. We seem to have lost that safety net, at least all the unexpected gpu hangs I've recently fixed in igt did not result in dmesg spam. This seems to have happened as part of the big reset rework we've done earlier this year, but I'm not entirely sure. -Daniel

Quoted 12 lines
tests/drv_hangman.c +1 -0
 		igt_require_gem(device);
+
 		sysfs = igt_sysfs_open(device, &idx);
 		igt_assert(sysfs != -1);
 	}
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

Re: [PATCH igt 11/24] igt/drv_hangman: Skip if resets are disallowed

Quoting Daniel Vetter (2017-08-15 09:52:21)

Quoted 23 lines · Chris Wilson
Quoted 22 lines

If we tell the machine to reset but they are disallowed, we will leave the system in a wedged state, preventing the majority of subsequent tests.

---
 tests/drv_hangman.c | 3 +++
 1 file changed, 3 insertions(+)
tests/drv_hangman.c +1 -0
index 0551ec16..de57e128 100644
@@ -30,6 +30,7 @@
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 
 #include "igt_sysfs.h"
@@ -239,7 +240,9 @@ igt_main
              int idx;
 
Quoted 5 lines

tests/drv_hangman.c igt_main · line 243

Quoted 2 lines
tests/drv_hangman.c +1 -0
              device = drm_open_driver(DRIVER_INTEL);
+             igt_allow_hang(device, 0, 0);

I think an igt_require_hang_ring here would be better self-documenting. Also, igt_allow/disallow_hang are lacking gtkdocs.

Not the same unfortunately.

Quoted 2 lines

What I'm also wondering is where our unexpected hang detection has gone to.

It's "a significant but normal condition" since we recover, so it's a KERN_NOTE. If we fail to reset, then we add a KERN_ERR. It's still there, the logs are flooded with them.

For igt, we have unexpected hang detection which has to enabled when we don't expect hangs and disabled when we do, because we also don't want the side-effects for simulated hangs
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#16 lore raw

PATCH 12/24 igt/gem_ringfill: Prime execbuf before measuring ring size

In reply to Chris Wilson

Make sure that our buffers are ready and loaded to reduce the initial stall.

---
 tests/gem_ringfill.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tests/gem_ringfill.c +8 -2
index b52996a4..01cbd0a9 100644
@@ -288,10 +288,15 @@ static unsigned int measure_ring_size(int fd)
 	obj[1].handle = gem_create(fd, 4096);
 	gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
 
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(obj + 1);
+	execbuf.buffer_count = 1;
+	gem_execbuf(fd, &execbuf);
+	gem_sync(fd, obj[1].handle);
+
 	plug(fd, &c);
 	obj[0].handle = c.handle;
 
-	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
 
@@ -302,7 +307,8 @@ static unsigned int measure_ring_size(int fd)
 	itv.it_value.tv_usec = 1000;
 	setitimer(ITIMER_REAL, &itv, NULL);
 
-	last = count = 0;
+	last = -1;
+	count = 0;
 	do {
 		if (__execbuf(fd, &execbuf) == 0) {
 			count++;
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 12/24
#17 lore raw

Re: [PATCH igt 12/24] igt/gem_ringfill: Prime execbuf before measuring ring size

Quoted 2 lines · Chris Wilson

Make sure that our buffers are ready and loaded to reduce the initial stall.

Already looked at this one before:
https://lists.freedesktop.org/archives/intel-gfx/2017-July/134344.html
(as well as couple of other patches in this series)

-Michał

Quoted 42 lines
---
 tests/gem_ringfill.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tests/gem_ringfill.c +8 -2
index b52996a4..01cbd0a9 100644
@@ -288,10 +288,15 @@ static unsigned int measure_ring_size(int fd)
 	obj[1].handle = gem_create(fd, 4096);
 	gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
 
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(obj + 1);
+	execbuf.buffer_count = 1;
+	gem_execbuf(fd, &execbuf);
+	gem_sync(fd, obj[1].handle);
+
 	plug(fd, &c);
 	obj[0].handle = c.handle;
 
-	memset(&execbuf, 0, sizeof(execbuf));
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
 
@@ -302,7 +307,8 @@ static unsigned int measure_ring_size(int fd)
 	itv.it_value.tv_usec = 1000;
 	setitimer(ITIMER_REAL, &itv, NULL);
 
-	last = count = 0;
+	last = -1;
+	count = 0;
 	do {
 		if (__execbuf(fd, &execbuf) == 0) {
 			count++;
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

PATCH 13/24 igt/gem_exec_suspend: Try to suspend with a pending GPU hang

In reply to Chris Wilson

Ensure that we can suspend the GPU even if it is currently busy in an indefinite loop, requiring us to declare the task hung.

---
 tests/gem_exec_suspend.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
tests/gem_exec_suspend.c +19 -0
index 763cb108..bcb0e089 100644
@@ -29,6 +29,7 @@
 
 #include "igt.h"
 #include "igt_gt.h"
+#include "igt_dummyload.h"
 
 #define NOSLEEP 0
 #define SUSPEND_DEVICES 1
@@ -44,6 +45,7 @@
 
 #define UNCACHED (0<<8)
 #define CACHED (1<<8)
+#define HANG (2<<8)
 
 static void run_test(int fd, unsigned ring, unsigned flags);
 
@@ -105,6 +107,7 @@ static void run_test(int fd, unsigned engine, unsigned flags)
 	struct drm_i915_gem_execbuffer2 execbuf;
 	unsigned engines[16];
 	unsigned nengine;
+	igt_spin_t *spin = NULL;
 
 	nengine = 0;
 	if (engine == -1) {
@@ -197,6 +200,9 @@ static void run_test(int fd, unsigned engine, unsigned flags)
 		gem_close(fd, obj[1].handle);
 	}
 
+	if (flags & HANG)
+		spin = igt_spin_batch_new(fd, 0, engine, 0);
+
 	switch (mode(flags)) {
 	case NOSLEEP:
 		break;
@@ -222,6 +228,8 @@ static void run_test(int fd, unsigned engine, unsigned flags)
 		break;
 	}
 
+	igt_spin_batch_free(fd, spin);
+
 	check_bo(fd, obj[0].handle);
 	gem_close(fd, obj[0].handle);
 
@@ -244,6 +252,7 @@ igt_main
 		{ NULL, 0 }
 	}, *m;
 	const struct intel_execution_engine *e;
+	igt_hang_t hang;
 	int fd;
 
 	igt_fixture {
@@ -278,6 +287,16 @@ igt_main
 
 	igt_fixture {
 		igt_stop_hang_detector();
+		hang = igt_allow_hang(fd, 0, 0);
+	}
+
+	igt_subtest("hang-S3")
+		run_test(fd, 0, SUSPEND | HANG);
+	igt_subtest("hang-S4")
+		run_test(fd, 0, HIBERNATE | HANG);
+
+	igt_fixture {
+		igt_disallow_hang(fd, hang);
 		close(fd);
 	}
 }
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#19 lore raw

PATCH 14/24 igt/gem_exec_fence: Exercise merging fences

In reply to Chris Wilson

Execute the same batch on each engine and check that the composite fence across all engines completes only after the batch is completed on every engine.

---
 tests/gem_exec_fence.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 127 insertions(+)
tests/gem_exec_fence.c +127 -0
index 63eb7955..4d7865f9 100644
@@ -207,6 +207,113 @@ static void test_fence_busy(int fd, unsigned ring, unsigned flags)
 	gem_quiescent_gpu(fd);
 }
 
+static void test_fence_busy_all(int fd, unsigned flags)
+{
+	const int gen = intel_gen(intel_get_drm_devid(fd));
+	struct drm_i915_gem_exec_object2 obj;
+	struct drm_i915_gem_relocation_entry reloc;
+	struct drm_i915_gem_execbuffer2 execbuf;
+	struct timespec tv;
+	uint32_t *batch;
+	unsigned int engine;
+	int all, i, timeout;
+
+	gem_quiescent_gpu(fd);
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = to_user_pointer(&obj);
+	execbuf.buffer_count = 1;
+
+	memset(&obj, 0, sizeof(obj));
+	obj.handle = gem_create(fd, 4096);
+
+	obj.relocs_ptr = to_user_pointer(&reloc);
+	obj.relocation_count = 1;
+	memset(&reloc, 0, sizeof(reloc));
+
+	batch = gem_mmap__wc(fd, obj.handle, 0, 4096, PROT_WRITE);
+	gem_set_domain(fd, obj.handle,
+		       I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
+	reloc.target_handle = obj.handle; /* recurse */
+	reloc.presumed_offset = 0;
+	reloc.offset = sizeof(uint32_t);
+	reloc.delta = 0;
+	reloc.read_domains = I915_GEM_DOMAIN_COMMAND;
+	reloc.write_domain = 0;
+
+	i = 0;
+	batch[i] = MI_BATCH_BUFFER_START;
+	if (gen >= 8) {
+		batch[i] |= 1 << 8 | 1;
+		batch[++i] = 0;
+		batch[++i] = 0;
+	} else if (gen >= 6) {
+		batch[i] |= 1 << 8;
+		batch[++i] = 0;
+	} else {
+		batch[i] |= 2 << 6;
+		batch[++i] = 0;
+		if (gen < 4) {
+			batch[i] |= 1;
+			reloc.delta = 1;
+		}
+	}
+	i++;
+
+	all = -1;
+	for_each_engine(fd, engine) {
+		int fence, new;
+
+		execbuf.flags = engine | LOCAL_EXEC_FENCE_OUT;
+		execbuf.rsvd2 = -1;
+		gem_execbuf_wr(fd, &execbuf);
+		fence = execbuf.rsvd2 >> 32;
+		igt_assert(fence != -1);
+
+		if (all < 0) {
+			all = fence;
+			break;
+		}
+
+		new = sync_fence_merge(all, fence);
+		igt_assert_lte(0, new);
+		close(all);
+		close(fence);
+
+		all = new;
+	}
+
+	igt_assert(gem_bo_busy(fd, obj.handle));
+	igt_assert(fence_busy(all));
+
+	timeout = 120;
+	if ((flags & HANG) == 0) {
+		*batch = MI_BATCH_BUFFER_END;
+		__sync_synchronize();
+		timeout = 1;
+	}
+	munmap(batch, 4096);
+
+	if (flags & WAIT) {
+		struct pollfd pfd = { .fd = all, .events = POLLIN };
+		igt_assert(poll(&pfd, 1, timeout*1000) == 1);
+	} else {
+		memset(&tv, 0, sizeof(tv));
+		while (fence_busy(all))
+			igt_assert(igt_seconds_elapsed(&tv) < timeout);
+	}
+
+	igt_assert(!gem_bo_busy(fd, obj.handle));
+	igt_assert_eq(sync_fence_status(all),
+		      flags & HANG ? -EIO : SYNC_FENCE_OK);
+
+	close(all);
+	gem_close(fd, obj.handle);
+
+	gem_quiescent_gpu(fd);
+}
+
 static void test_fence_await(int fd, unsigned ring, unsigned flags)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
@@ -1472,6 +1579,26 @@ igt_main
 		caps = print_welcome(i915);
 	}
 
+	igt_subtest_group {
+		igt_fixture {
+			igt_fork_hang_detector(i915);
+		}
+
+		igt_subtest("basic-busy-all")
+			test_fence_busy_all(i915, 0);
+		igt_subtest("basic-wait-all")
+			test_fence_busy_all(i915, WAIT);
+
+		igt_fixture {
+			igt_stop_hang_detector();
+		}
+
+		igt_subtest("busy-hang-all")
+			test_fence_busy_all(i915, HANG);
+		igt_subtest("wait-hang-all")
+			test_fence_busy_all(i915, WAIT | HANG);
+	}
+
 	for (e = intel_execution_engines; e->name; e++) {
 		igt_subtest_group {
 			igt_fixture {
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#20 lore raw

PATCH 15/24 igt/gem_userptr_blits: Errors from gup are permanent

In reply to Chris Wilson

After triggering an error (such as trying to use userptr on a GTT mmaping), we store the EFAULT on the object permanently. So to test the error, we must sacrifice the object and recreate the userptr handle. We restrict the error to just one of the overlapping userptr handles to check the object independence.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100596

---
 tests/gem_userptr_blits.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/gem_userptr_blits.c +6 -1
index 7767c0ca..849054ad 100644
@@ -681,12 +681,17 @@ static int test_map_fixed_invalidate(int fd, uint32_t flags)
 		gem_set_tiling(fd, mmap_gtt.handle, I915_TILING_NONE, 0);
 		*map = 0xdead;
 
-		if (flags & MAP_FIXED_INVALIDATE_GET_PAGES)
+		if (flags & MAP_FIXED_INVALIDATE_GET_PAGES) {
 			igt_assert_eq(__gem_set_domain(fd, handle[0],
 						       I915_GEM_DOMAIN_GTT,
 						       I915_GEM_DOMAIN_GTT),
 				      -EFAULT);
 
+			/* Errors are permanent, so we have to recreate */
+			gem_close(fd, handle[0]);
+			handle[0] = create_userptr(fd, 0, ptr + PAGE_SIZE/sizeof(*ptr));
+		}
+
 		gem_set_tiling(fd, mmap_gtt.handle, I915_TILING_Y, 512 * 4);
 		*(uint32_t*)map = 0xbeef;
 
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#21 lore raw

PATCH 16/24 igt/gem_eio: i915.reset is no longer a boolean

In reply to Chris Wilson
---
 tests/gem_eio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/gem_eio.c +1 -1
index 3c826626..15120842 100644
@@ -53,7 +53,7 @@ static bool i915_reset_control(bool enable)
 	fd = open(path, O_RDWR);
 	igt_require(fd >= 0);
 
-	ret = write(fd, &"NY"[enable], 1) == 1;
+	ret = write(fd, &"01"[enable], 1) == 1;
 	close(fd);
 
 	return ret;
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#22 lore raw

PATCH 17/24 igt/kms_flip: Warn if the setup between iterations misses a vblank

In reply to Chris Wilson

During the kms_flip test we repeat the test over a short period of time, and the setup of each iteration should not itself be inducing a vblank miss. Warn if we do encounter any missed vblanks during the event setup.

---
 tests/kms_flip.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/kms_flip.c +13 -0
index d701886e..4ea68d4b 100644
@@ -736,6 +736,19 @@ static unsigned int run_test_step(struct test_output *o)
 	if (o->flags & TEST_FB_BAD_TILING)
 		new_fb_id = o->fb_ids[o->current_fb_id];
 
+	if (o->vblank_state.count > 0) {
+		drmVBlank vbl;
+
+		memset(&vbl, 0, sizeof(vbl));
+		vbl.request.type = kmstest_get_vbl_flag(o->pipe);
+		vbl.request.type |= DRM_VBLANK_RELATIVE;
+
+		do_or_die(drmWaitVBlank(drm_fd, &vbl));
+		if (vbl.reply.sequence != o->vblank_state.last_seq)
+			igt_warn("vblank drift since last iteration! expected %x found %x\n",
+				 o->vblank_state.last_seq, vbl.reply.sequence);
+	}
+
 	if (do_vblank && (o->flags & TEST_EINVAL) && o->vblank_state.count > 0)
 		igt_assert(do_wait_for_vblank(o, o->pipe, target_seq, &vbl_reply)
 		       == -EINVAL);
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#23 lore raw

PATCH 18/24 lib/kms: Clear unused fields for getproperty ioctl

In reply to Chris Wilson

==24749== Syscall param ioctl(generic) points to uninitialised byte(s)

==24749==    at 0x6A8ADC7: ioctl (syscall-template.S:84)
==24749==    by 0x5067687: drmIoctl (in /opt/xorg/lib64/libdrm.so.2.4.0)
==24749==    by 0x138531: kmstest_set_connector_dpms (igt_kms.c:1022)
==24749==    by 0x112937: set_dpms (kms_flip.c:263)
==24749==    by 0x112937: run_test_step (kms_flip.c:776)
==24749==    by 0x112937: event_loop (kms_flip.c:1138)
==24749==    by 0x115468: run_test_on_crtc_set (kms_flip.c:1378)
==24749==    by 0x115468: run_test (kms_flip.c:1450)
==24749==    by 0x1111CF: main (kms_flip.c:1673)

==24749== Address 0x1ffefff2a0 is on thread 1's stack
==24749== in frame #2, created by kmstest_set_connector_dpms (igt_kms.c:1012)

---
 lib/igt_kms.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
lib/igt_kms.c +3 -4
index 14e2701c..9bf53359 100644
@@ -1014,11 +1014,10 @@ void kmstest_set_connector_dpms(int fd, drmModeConnector *connector, int mode)
 	bool found_it = false;
 
 	for (i = 0; i < connector->count_props; i++) {
-		struct drm_mode_get_property prop;
+		struct drm_mode_get_property prop = {
+			.prop_id = connector->props[i],
+		};
 
-		prop.prop_id = connector->props[i];
-		prop.count_values = 0;
-		prop.count_enum_blobs = 0;
 		if (drmIoctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop))
 			continue;
 
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#24 lore raw

PATCH 19/24 lib/dummyload: Wrap global list inside its own mutex

In reply to Chris Wilson

Give the list a mutex, for we try to iterate over it from many a random context.

---
 lib/igt_dummyload.c | 7 +++++++
 1 file changed, 7 insertions(+)
lib/igt_dummyload.c +7 -0
index 5ad386a5..5d654825 100644
@@ -50,6 +50,7 @@
 
 static const int BATCH_SIZE = 4096;
 static IGT_LIST(spin_list);
+static pthread_mutex_t list_lock = PTHREAD_MUTEX_INITIALIZER;
 
 static void
 fill_reloc(struct drm_i915_gem_relocation_entry *reloc,
@@ -162,7 +163,9 @@ __igt_spin_batch_new(int fd, uint32_t ctx, unsigned engine, uint32_t dep)
 	emit_recursive_batch(spin, fd, ctx, engine, dep);
 	igt_assert(gem_bo_busy(fd, spin->handle));
 
+	pthread_mutex_lock(&list_lock);
 	igt_list_add(&spin->link, &spin_list);
+	pthread_mutex_unlock(&list_lock);
 
 	return spin;
 }
@@ -261,7 +264,9 @@ void igt_spin_batch_free(int fd, igt_spin_t *spin)
 	if (!spin)
 		return;
 
+	pthread_mutex_lock(&list_lock);
 	igt_list_del(&spin->link);
+	pthread_mutex_unlock(&list_lock);
 
 	if (spin->timer)
 		timer_delete(spin->timer);
@@ -277,6 +282,8 @@ void igt_terminate_spin_batches(void)
 {
 	struct igt_spin *iter;
 
+	pthread_mutex_lock(&list_lock);
 	igt_list_for_each(iter, &spin_list, link)
 		igt_spin_batch_end(iter);
+	pthread_mutex_unlock(&list_lock);
 }
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#25 lore raw

PATCH 20/24 lib/core: Don't leak dummyloads between subtests

In reply to Chris Wilson

If a test fails or skips early, it may not clean up after itself. In lieu of having a framework for test deconstructors, hook igt_terminate_spin_batches() into exit_subtest() itself so that we don't allow a recursive batch from an earlier test to leak into the next and cause an unexpected GPU hang.

Similarly, we also want to terminate the dummyload as the first step in our atexit handlers (currently it is at the start of the last step) as some atexit handlers may be unwittingly exposed to dummyloads and so cause another wait on GPU hang.

We trust that the core already distinguishes correctly between the principal test process and its children.

---
 lib/igt_core.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/igt_core.c +5 -0
index ce8482a1..e96fd4e6 100644
@@ -63,6 +63,7 @@
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
+#include "igt_dummyload.h"
 #include "igt_ftrace.h"
 #include "version.h"
 #include "config.h"
@@ -1039,6 +1040,8 @@ static void exit_subtest(const char *result)
 	       (!__igt_plain_output) ? "\x1b[0m" : "");
 	fflush(stdout);
 
+	igt_terminate_spin_batches();
+
 	in_subtest = NULL;
 	siglongjmp(igt_subtest_jmpbuf, 1);
 }
@@ -1859,6 +1862,8 @@ static void call_exit_handlers(int sig)
 {
 	int i;
 
+	igt_terminate_spin_batches();
+
 	if (!exit_handler_count) {
 		return;
 	}
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#26 lore raw

Re: [PATCH igt 20/24] lib/core: Don't leak dummyloads between subtests

Quoted 32 lines · Chris Wilson

If a test fails or skips early, it may not clean up after itself. In lieu of having a framework for test deconstructors, hook igt_terminate_spin_batches() into exit_subtest() itself so that we don't allow a recursive batch from an earlier test to leak into the next and cause an unexpected GPU hang.

Similarly, we also want to terminate the dummyload as the first step in our atexit handlers (currently it is at the start of the last step) as some atexit handlers may be unwittingly exposed to dummyloads and so cause another wait on GPU hang.

We trust that the core already distinguishes correctly between the principal test process and its children.

---
 lib/igt_core.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/igt_core.c +1 -0
index ce8482a1..e96fd4e6 100644
@@ -63,6 +63,7 @@
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
+#include "igt_dummyload.h"
 #include "igt_ftrace.h"
 #include "version.h"
 #include "config.h"

lib/igt_core.c static void exit_subtest(const char *result) · line 1043

Quoted 4 lines
lib/igt_core.c +1 -0
@@ -1039,6 +1040,8 @@ static void exit_subtest(const char *result)
 	       (!__igt_plain_output) ? "\x1b[0m" : "");
 	fflush(stdout);
 
+	igt_terminate_spin_batches();

Sounds like time for a subtest exit handler infrastructure?

On that, before I start typing: Can we make a simple assumption like:
- exit handler registered from fixture -> clean up in exit handler
- exit handler registered within subtest -> clean up at end of subtest
- do we need anything special for subtest_group?

I guess this also means that we need to properly stack exit handlers.

Sprinkling this all over manually doesn't really feel good ... -Daniel

Quoted 20 lines
lib/igt_core.c +3 -0
+
 	in_subtest = NULL;
 	siglongjmp(igt_subtest_jmpbuf, 1);
 }
@@ -1859,6 +1862,8 @@ static void call_exit_handlers(int sig)
 {
 	int i;
 
+	igt_terminate_spin_batches();
+
 	if (!exit_handler_count) {
 		return;
 	}
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#27 lore raw

Re: [PATCH igt 20/24] lib/core: Don't leak dummyloads between subtests

Quoting Daniel Vetter (2017-08-15 09:01:55)

Quoted 36 lines · Chris Wilson
Quoted 35 lines

If a test fails or skips early, it may not clean up after itself. In lieu of having a framework for test deconstructors, hook igt_terminate_spin_batches() into exit_subtest() itself so that we don't allow a recursive batch from an earlier test to leak into the next and cause an unexpected GPU hang.

Similarly, we also want to terminate the dummyload as the first step in our atexit handlers (currently it is at the start of the last step) as some atexit handlers may be unwittingly exposed to dummyloads and so cause another wait on GPU hang.

We trust that the core already distinguishes correctly between the principal test process and its children.

---
 lib/igt_core.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/igt_core.c +1 -0
index ce8482a1..e96fd4e6 100644
@@ -63,6 +63,7 @@
 #include "intel_chipset.h"
 #include "intel_io.h"
 #include "igt_debugfs.h"
+#include "igt_dummyload.h"
 #include "igt_ftrace.h"
 #include "version.h"
 #include "config.h"
@@ -1039,6 +1040,8 @@ static void exit_subtest(const char *result)
             (!__igt_plain_output) ? "\x1b[0m" : "");
      fflush(stdout);
 
Quoted 3 lines

lib/igt_core.c static void exit_subtest(const char *result) · line 1043

Quoted 1 line
lib/igt_core.c +1 -0
+     igt_terminate_spin_batches();

Sounds like time for a subtest exit handler infrastructure?

It's been time for that for the several years. I keep asking for test constructors and destructors.

Quoted 4 lines

On that, before I start typing: Can we make a simple assumption like:
- exit handler registered from fixture -> clean up in exit handler
- exit handler registered within subtest -> clean up at end of subtest
- do we need anything special for subtest_group?

subtest group just wrap a fixture. But those fixtures are just masquerading for constructors and destructors, as well as doing the pre-requisite tests.

Quoted 4 lines

I guess this also means that we need to properly stack exit handlers.

Sprinkling this all over manually doesn't really feel good ...

But foolproof. Look at the issue with the atexit handler that spinbatch installs for itself, or rather uses the existing one. They run foul of ordering issues where LIFO is not always the best policy. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#28 lore raw

PATCH 21/24 lib/kms: Pass fd to igt_enable_connectors()

In reply to Chris Wilson

Pass the fd along to igt_enable_connectors() so that it actually dtrt when there are multiple drm devices in the system.

---
 lib/igt_kms.c                | 13 ++++---------
 lib/igt_kms.h                |  2 +-
 tests/kms_flip.c             |  2 +-
 tests/kms_invalid_dotclock.c |  2 +-
 tests/kms_pipe_crc_basic.c   |  2 +-
 5 files changed, 8 insertions(+), 13 deletions(-)
lib/igt_kms.c +4 -9
index 9bf53359..d78dee58 100644
@@ -3165,21 +3165,18 @@ void igt_wait_for_vblank(int drm_fd, enum pipe pipe)
  * An exit handler is installed to ensure connectors are reset when the test
  * exits.
  */
-void igt_enable_connectors(void)
+void igt_enable_connectors(int fd)
 {
 	drmModeRes *res;
-	int drm_fd;
 
-	drm_fd = drm_open_driver(DRIVER_ANY);
-
-	res = drmModeGetResources(drm_fd);
+	res = drmModeGetResources(fd);
 	igt_assert(res != NULL);
 
 	for (int i = 0; i < res->count_connectors; i++) {
 		drmModeConnector *c;
 
 		/* Do a probe. This may be the first action after booting */
-		c = drmModeGetConnector(drm_fd, res->connectors[i]);
+		c = drmModeGetConnector(fd, res->connectors[i]);
 		if (!c) {
 			igt_warn("Could not read connector %u: %m\n", res->connectors[i]);
 			continue;
@@ -3192,7 +3189,7 @@ void igt_enable_connectors(void)
 
 		/* just enable VGA for now */
 		if (c->connector_type == DRM_MODE_CONNECTOR_VGA) {
-			if (!kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON))
+			if (!kmstest_force_connector(fd, c, FORCE_CONNECTOR_ON))
 				igt_info("Unable to force state on %s-%d\n",
 					 kmstest_connector_type_str(c->connector_type),
 					 c->connector_type_id);
@@ -3200,8 +3197,6 @@ void igt_enable_connectors(void)
 
 		drmModeFreeConnector(c);
 	}
-
-	close(drm_fd);
 }
 
 /**
lib/igt_kms.h +1 -1
index e5dc329b..ea1846ba 100644
@@ -555,7 +555,7 @@ static inline bool igt_output_is_connected(igt_output_t *output)
 	igt_assert_lt(0, drmModeAtomicAddProperty(req, output->config.connector->connector_id,\
 						  output->config.atomic_props_connector[prop], value))
 
-void igt_enable_connectors(void);
+void igt_enable_connectors(int fd);
 void igt_reset_connectors(void);
 
 uint32_t kmstest_get_vbl_flag(uint32_t pipe_id);
tests/kms_flip.c +1 -1
index 4ea68d4b..89962581 100644
@@ -1641,7 +1641,7 @@ int main(int argc, char **argv)
 	igt_fixture {
 		drm_fd = drm_open_driver_master(DRIVER_ANY);
 
-		igt_enable_connectors();
+		igt_enable_connectors(drm_fd);
 
 		kmstest_set_vt_graphics_mode();
 		igt_install_exit_handler(kms_flip_exit_handler);
tests/kms_invalid_dotclock.c +1 -1
index e6e72f52..b0942e59 100644
@@ -131,7 +131,7 @@ igt_simple_main
 	data.drm_fd = drm_open_driver_master(DRIVER_INTEL);
 	igt_require_intel(data.drm_fd);
 
-	igt_enable_connectors();
+	igt_enable_connectors(data.drm_fd);
 	kmstest_set_vt_graphics_mode();
 	igt_display_init(&data.display, data.drm_fd);
 	data.res = drmModeGetResources(data.drm_fd);
tests/kms_pipe_crc_basic.c +1 -1
index 35adddba..bf51b4cb 100644
@@ -185,7 +185,7 @@ igt_main
 	igt_fixture {
 		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
 
-		igt_enable_connectors();
+		igt_enable_connectors(data.drm_fd);
 
 		kmstest_set_vt_graphics_mode();
 
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 21/24
#29 lore raw

Re: [PATCH igt 21/24] lib/kms: Pass fd to igt_enable_connectors()

Quoted 4 lines · Chris Wilson

Pass the fd along to igt_enable_connectors() so that it actually dtrt when there are multiple drm devices in the system.

Signature · 6 lines
Cheers,
Arek
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#30 lore raw

PATCH 22/24 igt: Add vgem_syncobj

In reply to Chris Wilson

Exercise the drm_syncobj / vGEM coupling.

---
 lib/igt_vgem.c         |  68 +++++++++++-----
 lib/igt_vgem.h         |  15 +++-
 tests/Makefile.sources |   1 +
 tests/vgem_syncobj.c   | 212 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 276 insertions(+), 20 deletions(-)
 create mode 100644 tests/vgem_syncobj.c
lib/igt_vgem.c +49 -19
index 21cccb37..d2f65adb 100644
@@ -64,6 +64,15 @@ void vgem_create(int fd, struct vgem_bo *bo)
 	igt_assert_eq(__vgem_create(fd, bo), 0);
 }
 
+struct vgem_bo vgem_create_dummy(int fd)
+{
+	struct vgem_bo bo = { .width = 1, .height = 1, .bpp = 4 };
+
+	vgem_create(fd, &bo);
+
+	return bo;
+}
+
 void *__vgem_mmap(int fd, struct vgem_bo *bo, unsigned prot)
 {
 	struct drm_mode_map_dumb arg;
@@ -134,26 +143,11 @@ static int __vgem_fence_attach(int fd, struct local_vgem_fence_attach *arg)
 
 bool vgem_fence_has_flag(int fd, unsigned flags)
 {
-	struct local_vgem_fence_attach arg;
-	struct vgem_bo bo;
-	bool ret = false;
+	struct local_vgem_fence_attach arg = {
+		.flags = flags,
+	};
 
-	memset(&bo, 0, sizeof(bo));
-	bo.width = 1;
-	bo.height = 1;
-	bo.bpp = 32;
-	vgem_create(fd, &bo);
-
-	memset(&arg, 0, sizeof(arg));
-	arg.handle = bo.handle;
-	arg.flags = flags;
-	if (__vgem_fence_attach(fd, &arg) == 0) {
-		vgem_fence_signal(fd, arg.out_fence);
-		ret = true;
-	}
-	gem_close(fd, bo.handle);
-
-	return ret;
+	return __vgem_fence_attach(fd, &arg) != -EINVAL;
 }
 
 uint32_t vgem_fence_attach(int fd, struct vgem_bo *bo, unsigned flags)
@@ -167,6 +161,42 @@ uint32_t vgem_fence_attach(int fd, struct vgem_bo *bo, unsigned flags)
 	return arg.out_fence;
 }
 
+int __vgem_fence_attach_to_syncobj(int fd,
+				   struct vgem_bo *bo,
+				   uint32_t syncobj,
+				   unsigned flags,
+				   uint32_t *fence)
+{
+	struct local_vgem_fence_attach arg = {
+		.handle = bo->handle,
+		.flags = VGEM_FENCE_SYNCOBJ | flags,
+		.pad = syncobj,
+	};
+	int err;
+
+	err = __vgem_fence_attach(fd, &arg);
+	if (err)
+		return err;
+
+	*fence = arg.out_fence;
+	return 0;
+}
+
+uint32_t vgem_fence_attach_to_syncobj(int fd,
+				      struct vgem_bo *bo,
+				      uint32_t syncobj,
+				      unsigned flags)
+{
+	struct local_vgem_fence_attach arg = {
+		.handle = bo->handle,
+		.flags = VGEM_FENCE_SYNCOBJ | flags,
+		.pad = syncobj,
+	};
+	igt_assert_eq(__vgem_fence_attach(fd, &arg), 0);
+
+	return arg.out_fence;
+}
+
 static int ioctl_vgem_fence_signal(int fd, struct local_vgem_fence_signal *arg)
 {
 	int err = 0;
lib/igt_vgem.h +14 -1
index 002ad7f0..f50c70b4 100644
@@ -35,15 +35,28 @@ struct vgem_bo {
 
 int __vgem_create(int fd, struct vgem_bo *bo);
 void vgem_create(int fd, struct vgem_bo *bo);
+struct vgem_bo vgem_create_dummy(int fd);
 
 void *__vgem_mmap(int fd, struct vgem_bo *bo, unsigned prot);
 void *vgem_mmap(int fd, struct vgem_bo *bo, unsigned prot);
 
 bool vgem_has_fences(int fd);
 bool vgem_fence_has_flag(int fd, unsigned flags);
+
 uint32_t vgem_fence_attach(int fd, struct vgem_bo *bo, unsigned flags);
 #define VGEM_FENCE_WRITE 0x1
-#define WIP_VGEM_FENCE_NOTIMEOUT 0x2
+#define VGEM_FENCE_SYNCOBJ 0x2
+#define WIP_VGEM_FENCE_NOTIMEOUT (1<<31)
+int __vgem_fence_attach_to_syncobj(int fd,
+				   struct vgem_bo *bo,
+				   uint32_t syncobj,
+				   unsigned flags,
+				   uint32_t *fence);
+uint32_t vgem_fence_attach_to_syncobj(int fd,
+				      struct vgem_bo *bo,
+				      uint32_t syncobj,
+				      unsigned flags);
+
 int __vgem_fence_signal(int fd, uint32_t fence);
 void vgem_fence_signal(int fd, uint32_t fence);
 
tests/Makefile.sources +1 -0
index 7a99cafc..3352aad4 100644
@@ -235,6 +235,7 @@ TESTS_progs = \
 	tools_test \
 	vgem_basic \
 	vgem_slow \
+	vgem_syncobj \
 	$(NULL)
 
 TESTS_progs_X = \
tests/vgem_syncobj.c new file +212 -0

212 lines not on this page · raw message

Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#31 lore raw

PATCH 23/24 benchmark/gem_busy: Compare polling with syncobj_wait

In reply to Chris Wilson
---
 benchmarks/gem_busy.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 72 insertions(+), 1 deletion(-)
benchmarks/gem_busy.c +72 -1
index f050454b..9649ea02 100644
@@ -58,6 +58,15 @@
 #define DMABUF 0x4
 #define WAIT 0x8
 #define SYNC 0x10
+#define SYNCOBJ 0x20
+
+#define LOCAL_I915_EXEC_FENCE_ARRAY (1 << 19)
+struct local_gem_exec_fence {
+	uint32_t handle;
+	uint32_t flags;
+#define LOCAL_EXEC_FENCE_WAIT (1 << 0)
+#define LOCAL_EXEC_FENCE_SIGNAL (1 << 1)
+};
 
 static void gem_busy(int fd, uint32_t handle)
 {
@@ -109,11 +118,54 @@ static int sync_merge(int fd1, int fd2)
 	return data.fence;
 }
 
+static uint32_t __syncobj_create(int fd)
+{
+	struct local_syncobj_create {
+		uint32_t handle, flags;
+	} arg;
+#define LOCAL_IOCTL_SYNCOBJ_CREATE        DRM_IOWR(0xBF, struct local_syncobj_create)
+
+	memset(&arg, 0, sizeof(arg));
+	ioctl(fd, LOCAL_IOCTL_SYNCOBJ_CREATE, &arg);
+
+	return arg.handle;
+}
+
+static uint32_t syncobj_create(int fd)
+{
+	uint32_t ret;
+
+	igt_assert_neq((ret = __syncobj_create(fd)), 0);
+
+	return ret;
+}
+
+#define LOCAL_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)
+#define LOCAL_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
+struct local_syncobj_wait {
+       __u64 handles;
+       /* absolute timeout */
+       __s64 timeout_nsec;
+       __u32 count_handles;
+       __u32 flags;
+       __u32 first_signaled; /* only valid when not waiting all */
+       __u32 pad;
+};
+#define LOCAL_IOCTL_SYNCOBJ_WAIT	DRM_IOWR(0xC3, struct local_syncobj_wait)
+static int __syncobj_wait(int fd, struct local_syncobj_wait *args)
+{
+	int err = 0;
+	if (drmIoctl(fd, LOCAL_IOCTL_SYNCOBJ_WAIT, args))
+		err = -errno;
+	return err;
+}
+
 static int loop(unsigned ring, int reps, int ncpus, unsigned flags)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 obj[2];
 	struct drm_i915_gem_relocation_entry reloc[2];
+	struct local_gem_exec_fence syncobj;
 	unsigned engines[16];
 	unsigned nengine;
 	uint32_t *batch;
@@ -126,6 +178,11 @@ static int loop(unsigned ring, int reps, int ncpus, unsigned flags)
 	fd = drm_open_driver(DRIVER_INTEL);
 	gen = intel_gen(intel_get_drm_devid(fd));
 
+	if (flags & SYNCOBJ) {
+		syncobj.handle = syncobj_create(fd);
+		syncobj.flags = LOCAL_EXEC_FENCE_SIGNAL;
+	}
+
 	memset(obj, 0, sizeof(obj));
 	obj[0].handle = gem_create(fd, 4096);
 	if (flags & WRITE)
@@ -144,6 +201,8 @@ static int loop(unsigned ring, int reps, int ncpus, unsigned flags)
 	execbuf.buffer_count = 2;
 	execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
 	execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
+	if (flags & SYNCOBJ)
+		execbuf.flags |= LOCAL_I915_EXEC_FENCE_ARRAY;
 	if (__gem_execbuf(fd, &execbuf)) {
 		execbuf.flags = 0;
 		if (__gem_execbuf(fd, &execbuf))
@@ -235,6 +294,14 @@ static int loop(unsigned ring, int reps, int ncpus, unsigned flags)
 					struct pollfd pfd = { .fd = dmabuf, .events = POLLOUT };
 					for (int inner = 0; inner < 1024; inner++)
 						poll(&pfd, 1, 0);
+				} else if (flags & SYNCOBJ) {
+					struct local_syncobj_wait arg = {
+						.handles = to_user_pointer(&syncobj.handle),
+						.count_handles = 1,
+					};
+
+					for (int inner = 0; inner < 1024; inner++)
+						__syncobj_wait(fd, &arg);
 				} else if (flags & SYNC) {
 					struct pollfd pfd = { .fd = fence, .events = POLLOUT };
 					for (int inner = 0; inner < 1024; inner++)
@@ -275,7 +342,7 @@ int main(int argc, char **argv)
 	int ncpus = 1;
 	int c;
 
-	while ((c = getopt (argc, argv, "e:r:dfswWI")) != -1) {
+	while ((c = getopt (argc, argv, "e:r:dfsSwWI")) != -1) {
 		switch (c) {
 		case 'e':
 			if (strcmp(optarg, "rcs") == 0)
@@ -314,6 +381,10 @@ int main(int argc, char **argv)
 			flags |= SYNC;
 			break;
 
+		case 'S':
+			flags |= SYNCOBJ;
+			break;
+
 		case 'W':
 			flags |= WRITE;
 			break;
Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#32 lore raw

PATCH 24/24 igt: Add a test to precheck status of kernel taints

In reply to Chris Wilson

Many times an error may occur before the start of igt, leaving the system in a less-than-optimal debugging state (e.g. an oops turning off lockdep). Flag such occasions by checking /proc/sys/kernel/tainted.

---
 tests/Makefile.sources |  1 +
 tests/kernel_taint.c   | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)
 create mode 100644 tests/kernel_taint.c
tests/Makefile.sources +1 -0
index 3352aad4..4dc89517 100644
@@ -168,6 +168,7 @@ TESTS_progs = \
 	gen3_render_tiledy_blits \
 	gen7_forcewake_mt \
 	gvt_basic \
+	kernel_taint \
 	kms_3d \
 	kms_addfb_basic \
 	kms_atomic \
tests/kernel_taint.c new file +74 -0

74 lines not on this page · raw message

Signature · 6 lines
2.13.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#33 lore raw

✗ Fi.CI.BAT: failure for series starting with [01/24] lib/debugfs: Make is_mountpoint() non-fatal

In reply to Chris Wilson
== Series Details ==

== Series Details ==

Series: series starting with [01/24] lib/debugfs: Make is_mountpoint() non-fatal
URL : https://patchwork.freedesktop.org/series/28764/
State : failure

== Summary ==

IGT patchset tested on top of latest successful build 3685dabb0ab25eb1bc2df867f749701777153056 igt/gem_exec_fence: Exercise syncobj API

with latest DRM-Tip kernel build CI_DRM_2961
7906e62b6a40 drm-tip: 2017y-08m-14d-17h-43m-51s UTC integration manifest

Test gem_exec_suspend:

        Subgroup basic-s3:
                pass       -> INCOMPLETE (fi-pnv-d510)
        Subgroup basic-s4-devices:
                pass       -> DMESG-WARN (fi-ilk-650)
                pass       -> INCOMPLETE (fi-byt-j1900)
                pass       -> INCOMPLETE (fi-bsw-n3050)
Test gem_pread:
        Subgroup basic:
                pass       -> DMESG-WARN (fi-blb-e6850)
Test gem_ringfill:
        Subgroup basic-default:
                pass       -> INCOMPLETE (fi-byt-n2820)
Test gem_wait:
        Subgroup basic-busy-all:
                pass       -> SKIP       (fi-blb-e6850)
                pass       -> SKIP       (fi-ilk-650)
                pass       -> SKIP       (fi-snb-2520m)
                pass       -> SKIP       (fi-snb-2600)
                pass       -> SKIP       (fi-ivb-3520m)
                pass       -> SKIP       (fi-ivb-3770)
                pass       -> SKIP       (fi-hsw-4770)
                pass       -> SKIP       (fi-hsw-4770r)
                pass       -> SKIP       (fi-bdw-5557u)
                pass       -> SKIP       (fi-bdw-gvtdvm)
                pass       -> SKIP       (fi-skl-6260u)
                pass       -> SKIP       (fi-skl-6700k)
                pass       -> SKIP       (fi-skl-6770hq)
                pass       -> SKIP       (fi-skl-gvtdvm)
                pass       -> SKIP       (fi-skl-x1585l)
                pass       -> SKIP       (fi-bxt-j4205)
                pass       -> SKIP       (fi-kbl-7500u)
                pass       -> SKIP       (fi-kbl-7560u)
                pass       -> SKIP       (fi-kbl-r)
                pass       -> SKIP       (fi-glk-2a)
        Subgroup basic-wait-all:
                pass       -> SKIP       (fi-blb-e6850)
                pass       -> SKIP       (fi-ilk-650)
                pass       -> SKIP       (fi-snb-2520m)
                pass       -> SKIP       (fi-snb-2600)
                pass       -> SKIP       (fi-ivb-3520m)
                pass       -> SKIP       (fi-ivb-3770)
                pass       -> SKIP       (fi-hsw-4770)
                pass       -> SKIP       (fi-hsw-4770r)
                pass       -> SKIP       (fi-bdw-5557u)
                pass       -> SKIP       (fi-bdw-gvtdvm)
                pass       -> SKIP       (fi-skl-6260u)
                pass       -> SKIP       (fi-skl-6700k)
                pass       -> SKIP       (fi-skl-6770hq)
                pass       -> SKIP       (fi-skl-gvtdvm)
                pass       -> SKIP       (fi-skl-x1585l)
                pass       -> SKIP       (fi-bxt-j4205)
                pass       -> SKIP       (fi-kbl-7500u)
                pass       -> SKIP       (fi-kbl-7560u)
                pass       -> SKIP       (fi-kbl-r)
                pass       -> SKIP       (fi-glk-2a)
        Subgroup basic-await-all:
                pass       -> SKIP       (fi-blb-e6850)
                pass       -> SKIP       (fi-ilk-650)
                pass       -> SKIP       (fi-snb-2520m)
                pass       -> SKIP       (fi-snb-2600)
                pass       -> SKIP       (fi-ivb-3520m)
                pass       -> SKIP       (fi-ivb-3770)
                pass       -> SKIP       (fi-hsw-4770)
                pass       -> SKIP       (fi-hsw-4770r)
                pass       -> SKIP       (fi-bdw-5557u)
                pass       -> SKIP       (fi-bdw-gvtdvm)
                pass       -> SKIP       (fi-skl-6260u)
                pass       -> SKIP       (fi-skl-6700k)
                pass       -> SKIP       (fi-skl-6770hq)
                pass       -> SKIP       (fi-skl-gvtdvm)
                pass       -> SKIP       (fi-skl-x1585l)
                pass       -> SKIP       (fi-bxt-j4205)
                pass       -> SKIP       (fi-kbl-7500u)
                pass       -> SKIP       (fi-kbl-7560u)
                pass       -> SKIP       (fi-kbl-r)
                pass       -> SKIP       (fi-glk-2a)
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-atomic:
                pass       -> DMESG-WARN (fi-bxt-j4205)
        Subgroup basic-busy-flip-before-cursor-legacy:
                pass       -> DMESG-WARN (fi-glk-2a)
        Subgroup basic-flip-after-cursor-atomic:
                pass       -> DMESG-WARN (fi-bdw-5557u)
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                pass       -> SKIP       (fi-skl-x1585l) fdo#101781
                pass       -> DMESG-WARN (fi-kbl-7560u)
        Subgroup basic-plain-flip:
                pass       -> DMESG-WARN (fi-ivb-3520m)
Test kms_setmode:
        Subgroup basic-clone-single-crtc:
                pass       -> DMESG-WARN (fi-skl-6700k)
Test pm_rps:
        Subgroup basic-api:
                pass       -> INCOMPLETE (fi-glk-2a)
Test prime_busy:
        Subgroup basic-after-default:
                pass       -> INCOMPLETE (fi-bxt-j4205)

fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781

fi-bdw-5557u     total:279  pass:264  dwarn:1   dfail:0   fail:0   skip:14  time:705s
fi-bdw-gvtdvm    total:279  pass:262  dwarn:0   dfail:0   fail:0   skip:17  time:811s
fi-blb-e6850     total:279  pass:220  dwarn:2   dfail:0   fail:0   skip:57  time:686s
fi-bsw-n3050     total:110  pass:97   dwarn:0   dfail:0   fail:0   skip:12 
fi-bxt-j4205     total:279  pass:222  dwarn:1   dfail:0   fail:0   skip:21 
fi-byt-j1900     total:110  pass:97   dwarn:0   dfail:0   fail:0   skip:12 
fi-byt-n2820     total:143  pass:129  dwarn:0   dfail:0   fail:0   skip:13 
fi-glk-2a        total:279  pass:222  dwarn:1   dfail:0   fail:0   skip:20 
fi-hsw-4770      total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:677s
fi-hsw-4770r     total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:645s
fi-ilk-650       total:279  pass:225  dwarn:1   dfail:0   fail:0   skip:53  time:930s
fi-ivb-3520m     total:279  pass:257  dwarn:1   dfail:0   fail:0   skip:21  time:778s
fi-ivb-3770      total:279  pass:258  dwarn:0   dfail:0   fail:0   skip:21  time:715s
fi-kbl-7500u     total:279  pass:258  dwarn:0   dfail:0   fail:0   skip:21  time:698s
fi-kbl-7560u     total:279  pass:265  dwarn:1   dfail:0   fail:0   skip:13  time:898s
fi-kbl-r         total:279  pass:258  dwarn:0   dfail:0   fail:0   skip:21  time:867s
fi-pnv-d510      total:109  pass:76   dwarn:0   dfail:0   fail:0   skip:32 
fi-skl-6260u     total:279  pass:266  dwarn:0   dfail:0   fail:0   skip:13  time:797s
fi-skl-6700k     total:279  pass:257  dwarn:1   dfail:0   fail:0   skip:21  time:701s
fi-skl-6770hq    total:279  pass:266  dwarn:0   dfail:0   fail:0   skip:13  time:756s
fi-skl-gvtdvm    total:279  pass:263  dwarn:0   dfail:0   fail:0   skip:16  time:744s
fi-skl-x1585l    total:279  pass:265  dwarn:0   dfail:0   fail:0   skip:14  time:793s
fi-snb-2520m     total:279  pass:248  dwarn:0   dfail:0   fail:0   skip:31  time:858s
fi-snb-2600      total:279  pass:247  dwarn:0   dfail:0   fail:0   skip:32  time:651s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_63/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx