All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 0/8] extract cork and ring measure code
@ 2017-10-25 23:08 Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 1/8] lib/igt_dummyload: add igt_cork Daniele Ceraolo Spurio
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

The "cork" bo used to stall execution and the interruptible execbuf
used to measure the ring size are repeated almost identically in
several files. Extracting those to common files helps simplifying
the code and avoiding repetition.

Cc: Chris Wilson <chris@chris-wilson.co.uk>

Daniele Ceraolo Spurio (8):
  lib/igt_dummyload: add igt_cork
  lib/igt_gt: add intel_measure_ring_size
  tests/gem_exec_schedule: use new common functions
  tests/gem_exec_fence: use new common functions
  tests/gem_exec_latency: use new common functions
  tests/gem_wait: use igt_cork
  tests/gem_exec_await: use intel_measure_ring_size
  tests/gem_ringfill: use intel_measure_ring_size

 lib/igt_dummyload.c       |  58 +++++++++++++++++
 lib/igt_dummyload.h       |   8 +++
 lib/igt_gt.c              |  83 ++++++++++++++++++++++++
 lib/igt_gt.h              |   2 +
 tests/gem_exec_await.c    |  90 +-------------------------
 tests/gem_exec_fence.c    | 117 ++++-----------------------------
 tests/gem_exec_latency.c  |  97 ++++------------------------
 tests/gem_exec_schedule.c | 161 ++++++++++++----------------------------------
 tests/gem_ringfill.c      |  96 +--------------------------
 tests/gem_wait.c          |  54 +++-------------
 10 files changed, 226 insertions(+), 540 deletions(-)

-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 1/8] lib/igt_dummyload: add igt_cork
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 2/8] lib/igt_gt: add intel_measure_ring_size Daniele Ceraolo Spurio
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

The "cork" bo (imported bo with attached fence) is used in several
tests to stall execution. Moving it to a common place makes the codebase
cleaner.

Note that the actual test updates is done in follow up patches as it is
simpler to do in one go after one more common function is added in the
next patch.

v2: don't use new/free naming, don't use dynamic alloc (Chris)

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_dummyload.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_dummyload.h |  8 ++++++++
 2 files changed, 66 insertions(+)

diff --git a/lib/igt_dummyload.c b/lib/igt_dummyload.c
index bb2be55..ea21ffe 100644
--- a/lib/igt_dummyload.c
+++ b/lib/igt_dummyload.c
@@ -29,11 +29,13 @@
 #include <i915_drm.h>
 
 #include "igt_core.h"
+#include "drmtest.h"
 #include "igt_dummyload.h"
 #include "igt_gt.h"
 #include "intel_chipset.h"
 #include "intel_reg.h"
 #include "ioctl_wrappers.h"
+#include "igt_vgem.h"
 
 /**
  * SECTION:igt_dummyload
@@ -300,3 +302,59 @@ void igt_terminate_spin_batches(void)
 	igt_list_for_each(iter, &spin_list, link)
 		igt_spin_batch_end(iter);
 }
+
+/**
+ * igt_cork_plug:
+ * @fd: open drm file descriptor
+ * @cork: structure that will be filled with the state of the cork bo
+ *
+ * Imports a vgem bo with a fence attached to it. This bo can be used as a
+ * dependency during submission to stall execution until the fence is signaled.
+ * The parameters required to unblock the execution and to cleanup are stored in
+ * the provided cork structure.
+ *
+ * Returns:
+ * Handle of the imported BO.
+ */
+uint32_t igt_cork_plug(int fd, struct igt_cork *cork)
+{
+	struct vgem_bo bo;
+	int dmabuf;
+	uint32_t handle;
+
+	igt_assert(cork);
+
+	cork->device = drm_open_driver(DRIVER_VGEM);
+
+	igt_require(vgem_has_fences(cork->device));
+
+	bo.width = bo.height = 1;
+	bo.bpp = 4;
+	vgem_create(cork->device, &bo);
+	cork->fence = vgem_fence_attach(cork->device, &bo, VGEM_FENCE_WRITE);
+
+	dmabuf = prime_handle_to_fd(cork->device, bo.handle);
+	handle = prime_fd_to_handle(fd, dmabuf);
+	close(dmabuf);
+
+	return handle;
+}
+
+/**
+ * igt_cork_unplug:
+ * @cork: cork state from igt_cork_plug()
+ *
+ * This function unblocks the execution by signaling the fence attached to the
+ * imported bo and does the necessary post-processing.
+ * NOTE: the imported bo handle returned by igt_cork_plug is not closed during
+ * this phase.
+ */
+void igt_cork_unplug(struct igt_cork *cork)
+{
+	if (!cork || !cork->device)
+		return;
+
+	vgem_fence_signal(cork->device, cork->fence);
+	close(cork->device);
+	cork->device = 0;
+}
diff --git a/lib/igt_dummyload.h b/lib/igt_dummyload.h
index 215425f..8869268 100644
--- a/lib/igt_dummyload.h
+++ b/lib/igt_dummyload.h
@@ -51,4 +51,12 @@ void igt_spin_batch_free(int fd, igt_spin_t *spin);
 
 void igt_terminate_spin_batches(void);
 
+struct igt_cork {
+	int device;
+	uint32_t fence;
+};
+
+uint32_t igt_cork_plug(int fd, struct igt_cork *cork);
+void igt_cork_unplug(struct igt_cork *cork);
+
 #endif /* __IGT_DUMMYLOAD_H__ */
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 2/8] lib/igt_gt: add intel_measure_ring_size
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 1/8] lib/igt_dummyload: add igt_cork Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 3/8] tests/gem_exec_schedule: use new common functions Daniele Ceraolo Spurio
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

The logic to measure the ring size is replicated almost identically in
several tests. Adding it as a common function will make the code
cleaner.

The tests are updated in follow up patches.

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_gt.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_gt.h |  2 ++
 2 files changed, 85 insertions(+)

diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 89727d2..76fdbc5 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -40,6 +40,7 @@
 #include "ioctl_wrappers.h"
 #include "intel_reg.h"
 #include "intel_chipset.h"
+#include "igt_dummyload.h"
 
 /**
  * SECTION:igt_gt
@@ -577,6 +578,88 @@ unsigned intel_detect_and_clear_missed_interrupts(int fd)
 	return missed;
 }
 
+static void alarm_handler(int sig)
+{
+}
+
+/**
+ * intel_measure_ring_size:
+ * @fd: open i915 drm file descriptor
+ * @engine: execbuf engine flag
+ * @new_ctx: use a new context to account for the space used by the lrc init
+ *
+ * This function calculates the maximum number of batches that can be inserted
+ * at the same time in the ring on the selected engine.
+ *
+ * Returns:
+ * Number of batches that fit in the ring
+ */
+unsigned int intel_measure_ring_size(int fd, unsigned int engine, bool new_ctx)
+{
+	struct sigaction old_sa, 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 igt_cork cork;
+
+	igt_require_intel(fd);
+
+	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 = engine;
+	gem_execbuf(fd, &execbuf);
+	gem_sync(fd, obj[1].handle);
+
+	obj[0].handle = igt_cork_plug(fd, &cork);
+
+	execbuf.buffers_ptr = to_user_pointer(obj);
+	execbuf.buffer_count = 2;
+
+	if (new_ctx)
+		execbuf.rsvd1 = gem_context_create(fd);
+
+	sigaction(SIGALRM, &sa, &old_sa);
+	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 (ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0) {
+			count++;
+			continue;
+		}
+
+		if (last == count)
+			break;
+
+		last = count;
+	} while (1);
+
+	memset(&itv, 0, sizeof(itv));
+	setitimer(ITIMER_REAL, &itv, NULL);
+	sigaction(SIGALRM, &old_sa, NULL);
+
+	igt_cork_unplug(&cork);
+	gem_close(fd, obj[0].handle);
+	gem_close(fd, obj[1].handle);
+
+	if (new_ctx)
+		gem_context_destroy(fd, execbuf.rsvd1);
+
+	return count;
+}
+
 const struct intel_execution_engine intel_execution_engines[] = {
 	{ "default", NULL, 0, 0 },
 	{ "render", "rcs0", I915_EXEC_RENDER, 0 },
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 2579cbd..4e4fc01 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -63,6 +63,8 @@ void igt_clflush_range(void *addr, int size);
 
 unsigned intel_detect_and_clear_missed_interrupts(int fd);
 
+unsigned int intel_measure_ring_size(int fd, unsigned int engine, bool new_ctx);
+
 extern const struct intel_execution_engine {
 	const char *name;
 	const char *full_name;
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 3/8] tests/gem_exec_schedule: use new common functions
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 1/8] lib/igt_dummyload: add igt_cork Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 2/8] lib/igt_gt: add intel_measure_ring_size Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 4/8] tests/gem_exec_fence: " Daniele Ceraolo Spurio
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

With intel_measure_ring_size and igt_cork added as common utilities we
can use them instead of the local copy of those utilities

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_exec_schedule.c | 161 ++++++++++++----------------------------------
 1 file changed, 40 insertions(+), 121 deletions(-)

diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
index a2f4419..aa9521c 100644
--- a/tests/gem_exec_schedule.c
+++ b/tests/gem_exec_schedule.c
@@ -98,35 +98,6 @@ static void store_dword(int fd, uint32_t ctx, unsigned ring,
 	gem_close(fd, obj[2].handle);
 }
 
-struct cork {
-	int device;
-	uint32_t handle;
-	uint32_t fence;
-};
-
-static void plug(int fd, struct cork *c)
-{
-	struct vgem_bo bo;
-	int dmabuf;
-
-	c->device = drm_open_driver(DRIVER_VGEM);
-
-	bo.width = bo.height = 1;
-	bo.bpp = 4;
-	vgem_create(c->device, &bo);
-	c->fence = vgem_fence_attach(c->device, &bo, VGEM_FENCE_WRITE);
-
-	dmabuf = prime_handle_to_fd(c->device, bo.handle);
-	c->handle = prime_fd_to_handle(fd, dmabuf);
-	close(dmabuf);
-}
-
-static void unplug(struct cork *c)
-{
-	vgem_fence_signal(c->device, c->fence);
-	close(c->device);
-}
-
 static uint32_t create_highest_priority(int fd)
 {
 	uint32_t ctx = gem_context_create(fd);
@@ -141,7 +112,7 @@ static uint32_t create_highest_priority(int fd)
 	return ctx;
 }
 
-static void unplug_show_queue(int fd, struct cork *c, unsigned int engine)
+static void unplug_show_queue(int fd, struct igt_cork *c, unsigned int engine)
 {
 	igt_spin_t *spin[BUSY_QLEN];
 
@@ -151,7 +122,7 @@ static void unplug_show_queue(int fd, struct cork *c, unsigned int engine)
 		gem_context_destroy(fd, ctx);
 	}
 
-	unplug(c); /* batches will now be queued on the engine */
+	igt_cork_unplug(c); /* batches will now be queued on the engine */
 	igt_debugfs_dump(fd, "i915_engine_info");
 
 	for (int n = 0; n < ARRAY_SIZE(spin); n++)
@@ -161,19 +132,20 @@ static void unplug_show_queue(int fd, struct cork *c, unsigned int engine)
 
 static void fifo(int fd, unsigned ring)
 {
-	struct cork cork;
-	uint32_t scratch;
+	struct igt_cork cork;
+	uint32_t scratch, plug;
 	uint32_t *ptr;
 
 	scratch = gem_create(fd, 4096);
 
-	plug(fd, &cork);
+	plug = igt_cork_plug(fd, &cork);
 
 	/* Same priority, same timeline, final result will be the second eb */
-	store_dword(fd, 0, ring, scratch, 0, 1, cork.handle, 0);
-	store_dword(fd, 0, ring, scratch, 0, 2, cork.handle, 0);
+	store_dword(fd, 0, ring, scratch, 0, 1, plug, 0);
+	store_dword(fd, 0, ring, scratch, 0, 2, plug, 0);
 
 	unplug_show_queue(fd, &cork, ring);
+	gem_close(fd, plug);
 
 	ptr = gem_mmap__gtt(fd, scratch, 4096, PROT_READ);
 	gem_set_domain(fd, scratch, /* no write hazard lies! */
@@ -261,8 +233,8 @@ static void smoketest(int fd, unsigned ring, unsigned timeout)
 static void reorder(int fd, unsigned ring, unsigned flags)
 #define EQUAL 1
 {
-	struct cork cork;
-	uint32_t scratch;
+	struct igt_cork cork;
+	uint32_t scratch, plug;
 	uint32_t *ptr;
 	uint32_t ctx[2];
 
@@ -273,15 +245,16 @@ static void reorder(int fd, unsigned ring, unsigned flags)
 	gem_context_set_priority(fd, ctx[HI], flags & EQUAL ? MIN_PRIO : 0);
 
 	scratch = gem_create(fd, 4096);
-	plug(fd, &cork);
+	plug = igt_cork_plug(fd, &cork);
 
 	/* We expect the high priority context to be executed first, and
 	 * so the final result will be value from the low priority context.
 	 */
-	store_dword(fd, ctx[LO], ring, scratch, 0, ctx[LO], cork.handle, 0);
-	store_dword(fd, ctx[HI], ring, scratch, 0, ctx[HI], cork.handle, 0);
+	store_dword(fd, ctx[LO], ring, scratch, 0, ctx[LO], plug, 0);
+	store_dword(fd, ctx[HI], ring, scratch, 0, ctx[HI], plug, 0);
 
 	unplug_show_queue(fd, &cork, ring);
+	gem_close(fd, plug);
 
 	gem_context_destroy(fd, ctx[LO]);
 	gem_context_destroy(fd, ctx[HI]);
@@ -300,10 +273,11 @@ static void reorder(int fd, unsigned ring, unsigned flags)
 
 static void promotion(int fd, unsigned ring)
 {
-	struct cork cork;
+	struct igt_cork cork;
 	uint32_t result, dep;
 	uint32_t *ptr;
 	uint32_t ctx[3];
+	uint32_t plug;
 
 	ctx[LO] = gem_context_create(fd);
 	gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
@@ -317,15 +291,15 @@ static void promotion(int fd, unsigned ring)
 	result = gem_create(fd, 4096);
 	dep = gem_create(fd, 4096);
 
-	plug(fd, &cork);
+	plug = igt_cork_plug(fd, &cork);
 
 	/* Expect that HI promotes LO, so the order will be LO, HI, NOISE.
 	 *
 	 * fifo would be NOISE, LO, HI.
 	 * strict priority would be  HI, NOISE, LO
 	 */
-	store_dword(fd, ctx[NOISE], ring, result, 0, ctx[NOISE], cork.handle, 0);
-	store_dword(fd, ctx[LO], ring, result, 0, ctx[LO], cork.handle, 0);
+	store_dword(fd, ctx[NOISE], ring, result, 0, ctx[NOISE], plug, 0);
+	store_dword(fd, ctx[LO], ring, result, 0, ctx[LO], plug, 0);
 
 	/* link LO <-> HI via a dependency on another buffer */
 	store_dword(fd, ctx[LO], ring, dep, 0, ctx[LO], 0, I915_GEM_DOMAIN_INSTRUCTION);
@@ -334,6 +308,7 @@ static void promotion(int fd, unsigned ring)
 	store_dword(fd, ctx[HI], ring, result, 0, ctx[HI], 0, 0);
 
 	unplug_show_queue(fd, &cork, ring);
+	gem_close(fd, plug);
 
 	gem_context_destroy(fd, ctx[NOISE]);
 	gem_context_destroy(fd, ctx[LO]);
@@ -513,7 +488,8 @@ static void deep(int fd, unsigned ring)
 	const unsigned int nctx = MAX_PRIO - MIN_PRIO;
 	const unsigned size = ALIGN(4*nctx, 4096);
 	struct timespec tv = {};
-	struct cork cork;
+	struct igt_cork cork;
+	uint32_t plug;
 	uint32_t result, dep[XS];
 	uint32_t expected = 0;
 	uint32_t *ptr;
@@ -554,12 +530,12 @@ static void deep(int fd, unsigned ring)
 		gem_sync(fd, result);
 	}
 
-	plug(fd, &cork);
+	plug = igt_cork_plug(fd, &cork);
 
 	/* Create a deep dependency chain, with a few branches */
 	for (int n = 0; n < nctx && igt_seconds_elapsed(&tv) < 8; n++)
 		for (int m = 0; m < XS; m++)
-			store_dword(fd, ctx[n], ring, dep[m], 4*n, ctx[n], cork.handle, I915_GEM_DOMAIN_INSTRUCTION);
+			store_dword(fd, ctx[n], ring, dep[m], 4*n, ctx[n], plug, I915_GEM_DOMAIN_INSTRUCTION);
 
 	for (int n = 0; n < nctx && igt_seconds_elapsed(&tv) < 6; n++) {
 		for (int m = 0; m < XS; m++) {
@@ -570,6 +546,7 @@ static void deep(int fd, unsigned ring)
 	}
 
 	unplug_show_queue(fd, &cork, ring);
+	gem_close(fd, plug);
 	igt_require(expected); /* too slow */
 
 	for (int n = 0; n < nctx; n++)
@@ -612,72 +589,14 @@ static int __execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
 	return err;
 }
 
-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;
-	execbuf.rsvd1 = gem_context_create(fd);
-
-	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);
-	gem_context_destroy(fd, execbuf.rsvd1);
-
-	return count;
-}
-
 static void wide(int fd, unsigned ring)
 {
 #define NCTX 4096
 	struct timespec tv = {};
-	unsigned int ring_size = measure_ring_size(fd, ring);
+	unsigned int ring_size = intel_measure_ring_size(fd, ring, true);
 
-	struct cork cork;
+	struct igt_cork cork;
+	uint32_t plug;
 	uint32_t result;
 	uint32_t *ptr;
 	uint32_t *ctx;
@@ -689,20 +608,21 @@ static void wide(int fd, unsigned ring)
 
 	result = gem_create(fd, 4*NCTX);
 
-	plug(fd, &cork);
+	plug = igt_cork_plug(fd, &cork);
 
 	/* Lots of in-order requests, plugged and submitted simultaneously */
 	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);
+			store_dword(fd, ctx[n], ring, result, 4*n, ctx[n], plug, I915_GEM_DOMAIN_INSTRUCTION);
 		}
 	}
 	igt_info("Submitted %d requests over %d contexts in %.1fms\n",
 		 count, NCTX, igt_nsec_elapsed(&tv) * 1e-6);
 
 	unplug_show_queue(fd, &cork, ring);
+	gem_close(fd, plug);
 
 	for (int n = 0; n < NCTX; n++)
 		gem_context_destroy(fd, ctx[n]);
@@ -726,21 +646,20 @@ static void reorder_wide(int fd, unsigned ring)
 	struct drm_i915_gem_exec_object2 obj[3];
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct timespec tv = {};
-	unsigned int ring_size = measure_ring_size(fd, ring);
-	struct cork cork;
-	uint32_t result, target;
+	unsigned int ring_size = intel_measure_ring_size(fd, ring, true);
+	struct igt_cork cork;
+	uint32_t result, target, plug;
 	uint32_t *found, *expected;
 
 	result = gem_create(fd, 4096);
 	target = gem_create(fd, 4096);
-
-	plug(fd, &cork);
+	plug = igt_cork_plug(fd, &cork);
 
 	expected = gem_mmap__cpu(fd, target, 0, 4096, PROT_WRITE);
 	gem_set_domain(fd, target, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
 
 	memset(obj, 0, sizeof(obj));
-	obj[0].handle = cork.handle;
+	obj[0].handle = plug;
 	obj[1].handle = result;
 	obj[2].relocs_ptr = to_user_pointer(&reloc);
 	obj[2].relocation_count = 1;
@@ -808,6 +727,7 @@ static void reorder_wide(int fd, unsigned ring)
 	}
 
 	unplug_show_queue(fd, &cork, ring);
+	gem_close(fd, plug);
 
 	found = gem_mmap__gtt(fd, result, 4096, PROT_READ);
 	gem_set_domain(fd, result, /* no write hazard lies! */
@@ -842,7 +762,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 	struct drm_i915_gem_exec_object2 obj[2];
 	unsigned int last, count;
 	struct itimerval itv;
-	struct cork c;
+	struct igt_cork c;
 	bool *result;
 
 	result = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
@@ -864,8 +784,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 	gem_sync(fd, obj[1].handle);
 
 	/* Fill the low-priority ring */
-	plug(fd, &c);
-	obj[0].handle = c.handle;
+	obj[0].handle = igt_cork_plug(fd, &c);
 
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
@@ -939,7 +858,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 	igt_assert_f(result[2],
 		     "High priority child unable to submit within 10ms\n");
 
-	unplug(&c);
+	igt_cork_unplug(&c);
 	igt_waitchildren();
 
 	gem_context_destroy(fd, execbuf.rsvd1);
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 4/8] tests/gem_exec_fence: use new common functions
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
                   ` (2 preceding siblings ...)
  2017-10-25 23:08 ` [PATCH i-g-t v2 3/8] tests/gem_exec_schedule: use new common functions Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 5/8] tests/gem_exec_latency: " Daniele Ceraolo Spurio
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

With intel_measure_ring_size and igt_cork added as common utilities we
can use them instead of the local copy of those utilities

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_exec_fence.c | 117 +++++--------------------------------------------
 1 file changed, 12 insertions(+), 105 deletions(-)

diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
index 2a6da8b..ddd6b51 100644
--- a/tests/gem_exec_fence.c
+++ b/tests/gem_exec_fence.c
@@ -321,101 +321,6 @@ static void resubmit(int fd, uint32_t handle, unsigned int ring, int count)
 		gem_execbuf(fd, &execbuf);
 }
 
-struct cork {
-	int device;
-	uint32_t handle;
-	uint32_t fence;
-};
-
-static void plug(int fd, struct cork *c)
-{
-	struct vgem_bo bo;
-	int dmabuf;
-
-	c->device = drm_open_driver(DRIVER_VGEM);
-
-	bo.width = bo.height = 1;
-	bo.bpp = 4;
-	vgem_create(c->device, &bo);
-	c->fence = vgem_fence_attach(c->device, &bo, VGEM_FENCE_WRITE);
-
-	dmabuf = prime_handle_to_fd(c->device, bo.handle);
-	c->handle = prime_fd_to_handle(fd, dmabuf);
-	close(dmabuf);
-}
-
-static void unplug(int fd, struct cork *c)
-{
-	vgem_fence_signal(c->device, c->fence);
-	gem_close(fd, c->handle);
-	close(c->device);
-}
-
-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)
-{
-	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;
-	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(fd, &c);
-	gem_close(fd, obj[1].handle);
-
-	return count;
-}
-
 static void test_parallel(int fd, unsigned int master)
 {
 	const int SCRATCH = 0;
@@ -430,15 +335,16 @@ static void test_parallel(int fd, unsigned int master)
 	uint32_t batch[16];
 	igt_spin_t *spin;
 	unsigned engine;
-	struct cork c;
+	struct igt_cork c;
+	uint32_t plug;
 	int i, x = 0;
 
-	plug(fd, &c);
+	plug = igt_cork_plug(fd, &c);
 
 	/* 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, 0, master, c.handle);
+	spin = igt_spin_batch_new(fd, 0, master, plug);
 	resubmit(fd, spin->handle, master, 16);
 
 	/* Now queue the master request and its secondaries */
@@ -559,7 +465,8 @@ static void test_parallel(int fd, unsigned int master)
 	}
 
 	/* Unblock the master */
-	unplug(fd, &c);
+	igt_cork_unplug(&c);
+	gem_close(fd, plug);
 	igt_spin_batch_end(spin);
 
 	/* Wait for all secondaries to complete. If we used a regular fence
@@ -597,7 +504,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 	unsigned int nengine, n, s;
 	unsigned long limit;
 	int all_fences;
-	struct cork c;
+	struct igt_cork c;
 
 	limit = -1;
 	if (!gem_uses_full_ppgtt(fd))
@@ -632,8 +539,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 	execbuf.buffers_ptr = to_user_pointer(obj);
 	execbuf.buffer_count = 2;
 
-	plug(fd, &c);
-	obj[0].handle = c.handle;
+	obj[0].handle = igt_cork_plug(fd, &c);
 
 	igt_until_timeout(5) {
 		execbuf.rsvd1 = gem_context_create(fd);
@@ -661,7 +567,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 		if (!--limit)
 			break;
 	}
-	unplug(fd, &c);
+	igt_cork_unplug(&c);
 
 	igt_info("History depth = %d\n", sync_fence_count(all_fences));
 
@@ -685,6 +591,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 
 	gem_sync(fd, obj[1].handle);
 	gem_close(fd, obj[1].handle);
+	gem_close(fd, obj[0].handle);
 }
 
 static void test_fence_flip(int i915)
@@ -1501,7 +1408,7 @@ igt_main
 	}
 
 	igt_subtest("long-history") {
-		long ring_size = measure_ring_size(i915) - 1;
+		long ring_size = intel_measure_ring_size(i915, 0, false) - 1;
 
 		igt_info("Ring size: %ld batches\n", ring_size);
 		igt_require(ring_size);
@@ -1510,7 +1417,7 @@ igt_main
 	}
 
 	igt_subtest("expired-history") {
-		long ring_size = measure_ring_size(i915) - 1;
+		long ring_size = intel_measure_ring_size(i915, 0, false) - 1;
 
 		igt_info("Ring size: %ld batches\n", ring_size);
 		igt_require(ring_size);
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 5/8] tests/gem_exec_latency: use new common functions
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
                   ` (3 preceding siblings ...)
  2017-10-25 23:08 ` [PATCH i-g-t v2 4/8] tests/gem_exec_fence: " Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 6/8] tests/gem_wait: use igt_cork Daniele Ceraolo Spurio
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

With intel_measure_ring_size and igt_cork added as common utilities we
can use them instead of the local copy of those utilities

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_exec_latency.c | 97 ++++++------------------------------------------
 1 file changed, 11 insertions(+), 86 deletions(-)

diff --git a/tests/gem_exec_latency.c b/tests/gem_exec_latency.c
index e9d9344..c6c4bb2 100644
--- a/tests/gem_exec_latency.c
+++ b/tests/gem_exec_latency.c
@@ -54,83 +54,6 @@
 
 static unsigned int ring_size;
 
-struct cork {
-	int device;
-	uint32_t handle;
-	uint32_t fence;
-};
-
-static void plug(int fd, struct cork *c)
-{
-	struct vgem_bo bo;
-	int dmabuf;
-
-	c->device = drm_open_driver(DRIVER_VGEM);
-
-	bo.width = bo.height = 1;
-	bo.bpp = 4;
-	vgem_create(c->device, &bo);
-	c->fence = vgem_fence_attach(c->device, &bo, VGEM_FENCE_WRITE);
-
-	dmabuf = prime_handle_to_fd(c->device, bo.handle);
-	c->handle = prime_fd_to_handle(fd, dmabuf);
-	close(dmabuf);
-}
-
-static void unplug(struct cork *c)
-{
-	vgem_fence_signal(c->device, c->fence);
-	close(c->device);
-}
-
-static void alarm_handler(int sig)
-{
-}
-
-static void set_timeout(int seconds)
-{
-	struct sigaction sa = { .sa_handler = alarm_handler };
-
-	sigaction(SIGALRM, seconds ? &sa : NULL, NULL);
-	alarm(seconds);
-}
-
-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)
-{
-	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;
-	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));
-
-	plug(fd, &c);
-	obj[0].handle = c.handle;
-
-	memset(&execbuf, 0, sizeof(execbuf));
-	execbuf.buffers_ptr = to_user_pointer(obj);
-	execbuf.buffer_count = 2;
-
-	count = 0;
-	set_timeout(1);
-	while (__execbuf(fd, &execbuf) == 0)
-		count++;
-	set_timeout(0);
-
-	unplug(&c);
-	gem_close(fd, obj[1].handle);
-
-	return count;
-}
-
 #define RCS_TIMESTAMP (0x2000 + 0x358)
 static void latency_on_ring(int fd,
 			    unsigned ring, const char *name,
@@ -141,7 +64,7 @@ static void latency_on_ring(int fd,
 	struct drm_i915_gem_exec_object2 obj[3];
 	struct drm_i915_gem_relocation_entry reloc;
 	struct drm_i915_gem_execbuffer2 execbuf;
-	struct cork c;
+	struct igt_cork c;
 	volatile uint32_t *reg;
 	unsigned repeats = ring_size;
 	uint32_t start, end, *map, *results;
@@ -205,8 +128,7 @@ static void latency_on_ring(int fd,
 	}
 
 	if (flags & CORK) {
-		plug(fd, &c);
-		obj[0].handle = c.handle;
+		obj[0].handle = igt_cork_plug(fd, &c);
 		execbuf.buffers_ptr = to_user_pointer(&obj[0]);
 		execbuf.buffer_count = 3;
 	}
@@ -227,7 +149,7 @@ static void latency_on_ring(int fd,
 	igt_assert(reloc.presumed_offset == obj[1].offset);
 
 	if (flags & CORK)
-		unplug(&c);
+		igt_cork_unplug(&c);
 
 	gem_set_domain(fd, obj[1].handle, I915_GEM_DOMAIN_GTT, 0);
 	gpu_latency = (results[repeats-1] - results[0]) / (double)(repeats-1);
@@ -268,6 +190,8 @@ static void latency_on_ring(int fd,
 
 	munmap(map, 64*1024);
 	munmap(results, 4096);
+	if (flags & CORK)
+		gem_close(fd, obj[0].handle);
 	gem_close(fd, obj[1].handle);
 	gem_close(fd, obj[2].handle);
 }
@@ -319,7 +243,7 @@ static void latency_from_ring(int fd,
 	reloc.target_handle = flags & CORK ? 1 : 0;
 
 	for (e = intel_execution_engines; e->name; e++) {
-		struct cork c;
+		struct igt_cork c;
 
 		if (e->exec_id == 0)
 			continue;
@@ -332,8 +256,7 @@ static void latency_from_ring(int fd,
 			       I915_GEM_DOMAIN_GTT);
 
 		if (flags & CORK) {
-			plug(fd, &c);
-			obj[0].handle = c.handle;
+			obj[0].handle = igt_cork_plug(fd, &c);
 			execbuf.buffers_ptr = to_user_pointer(&obj[0]);
 			execbuf.buffer_count = 3;
 		}
@@ -391,7 +314,7 @@ static void latency_from_ring(int fd,
 		}
 
 		if (flags & CORK)
-			unplug(&c);
+			igt_cork_unplug(&c);
 
 		gem_set_domain(fd, obj[1].handle,
 			       I915_GEM_DOMAIN_GTT,
@@ -403,6 +326,8 @@ static void latency_from_ring(int fd,
 
 	munmap(map, 64*1024);
 	munmap(results, 4096);
+	if (flags & CORK)
+		gem_close(fd, obj[0].handle);
 	gem_close(fd, obj[1].handle);
 	gem_close(fd, obj[2].handle);
 }
@@ -419,7 +344,7 @@ igt_main
 
 		gem_submission_print_method(device);
 
-		ring_size = measure_ring_size(device);
+		ring_size = intel_measure_ring_size(device, 0, false);
 		igt_info("Ring size: %d batches\n", ring_size);
 		igt_require(ring_size > 8);
 		ring_size -= 8; /* leave some spare */
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 6/8] tests/gem_wait: use igt_cork
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
                   ` (4 preceding siblings ...)
  2017-10-25 23:08 ` [PATCH i-g-t v2 5/8] tests/gem_exec_latency: " Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 7/8] tests/gem_exec_await: use intel_measure_ring_size Daniele Ceraolo Spurio
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

With igt_cork added as common utility we can use it instead of the
local copy

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_wait.c | 54 ++++++++++--------------------------------------------
 1 file changed, 10 insertions(+), 44 deletions(-)

diff --git a/tests/gem_wait.c b/tests/gem_wait.c
index cf8c815..2a272cf 100644
--- a/tests/gem_wait.c
+++ b/tests/gem_wait.c
@@ -69,51 +69,15 @@ static void invalid_buf(int fd)
 #define AWAIT 4
 #define WRITE 8
 
-struct cork {
-	int device;
-	uint32_t handle;
-	uint32_t fence;
-};
-
-static struct cork plug(int fd, unsigned flags)
-{
-	struct cork c;
-	struct vgem_bo bo;
-	int dmabuf;
-
-	if ((flags & (WRITE | AWAIT)) == 0)
-		return (struct cork){0};
-
-	c.device = drm_open_driver(DRIVER_VGEM);
-
-	bo.width = bo.height = 1;
-	bo.bpp = 4;
-	vgem_create(c.device, &bo);
-	c.fence = vgem_fence_attach(c.device, &bo, VGEM_FENCE_WRITE);
-
-	dmabuf = prime_handle_to_fd(c.device, bo.handle);
-	c.handle = prime_fd_to_handle(fd, dmabuf);
-	close(dmabuf);
-
-	return c;
-}
-
-static void unplug(struct cork *c)
-{
-	if (!c->device)
-		return;
-
-	vgem_fence_signal(c->device, c->fence);
-	close(c->device);
-}
-
 static void basic(int fd, unsigned engine, unsigned flags)
 {
-	struct cork cork = plug(fd, flags);
-	igt_spin_t *spin = igt_spin_batch_new(fd, 0, engine, cork.handle);
+	struct igt_cork cork = {0};
+	uint32_t plug =
+		flags & (WRITE | AWAIT) ? igt_cork_plug(fd, &cork) : 0;
+	igt_spin_t *spin = igt_spin_batch_new(fd, 0, engine, plug);
 	struct drm_i915_gem_wait wait = {
-	       	flags & WRITE ? cork.handle : spin->handle
-       	};
+		flags & WRITE ? plug : spin->handle
+	};
 
 	igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
 
@@ -127,7 +91,7 @@ static void basic(int fd, unsigned engine, unsigned flags)
 			timeout = 1;
 		}
 
-		unplug(&cork);
+		igt_cork_unplug(&cork);
 		igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
 
 		while (__gem_wait(fd, &wait) == -ETIME)
@@ -137,7 +101,7 @@ static void basic(int fd, unsigned engine, unsigned flags)
 		igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
 		igt_assert_eq_s64(wait.timeout_ns, 0);
 
-		unplug(&cork);
+		igt_cork_unplug(&cork);
 		wait.timeout_ns = 0;
 		igt_assert_eq(__gem_wait(fd, &wait), -ETIME);
 
@@ -157,6 +121,8 @@ static void basic(int fd, unsigned engine, unsigned flags)
 		igt_assert(wait.timeout_ns == 0);
 	}
 
+	if (plug)
+		gem_close(fd, plug);
 	igt_spin_batch_free(fd, spin);
 }
 
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 7/8] tests/gem_exec_await: use intel_measure_ring_size
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
                   ` (5 preceding siblings ...)
  2017-10-25 23:08 ` [PATCH i-g-t v2 6/8] tests/gem_wait: use igt_cork Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:08 ` [PATCH i-g-t v2 8/8] tests/gem_ringfill: " Daniele Ceraolo Spurio
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

With intel_measure_ring_size added as common function we can use it
instead of the local copy

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_exec_await.c | 90 +-------------------------------------------------
 1 file changed, 1 insertion(+), 89 deletions(-)

diff --git a/tests/gem_exec_await.c b/tests/gem_exec_await.c
index 9c44679..d8fb402 100644
--- a/tests/gem_exec_await.c
+++ b/tests/gem_exec_await.c
@@ -246,94 +246,6 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
 	free(exec);
 }
 
-struct cork {
-	int device;
-	uint32_t handle;
-	uint32_t fence;
-};
-
-static void plug(int fd, struct cork *c)
-{
-	struct vgem_bo bo;
-	int dmabuf;
-
-	c->device = drm_open_driver(DRIVER_VGEM);
-
-	bo.width = bo.height = 1;
-	bo.bpp = 4;
-	vgem_create(c->device, &bo);
-	c->fence = vgem_fence_attach(c->device, &bo, VGEM_FENCE_WRITE);
-
-	dmabuf = prime_handle_to_fd(c->device, bo.handle);
-	c->handle = prime_fd_to_handle(fd, dmabuf);
-	close(dmabuf);
-}
-
-static void unplug(struct cork *c)
-{
-	vgem_fence_signal(c->device, c->fence);
-	close(c->device);
-}
-
-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)
-{
-	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));
-
-	plug(fd, &c);
-	obj[0].handle = c.handle;
-
-	memset(&execbuf, 0, sizeof(execbuf));
-	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 = 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;
-}
-
 igt_main
 {
 	int ring_size = 0;
@@ -345,7 +257,7 @@ igt_main
 		igt_require_gem(device);
 		gem_submission_print_method(device);
 
-		ring_size = measure_ring_size(device) - 10;
+		ring_size = intel_measure_ring_size(device, 0, false) - 10;
 		if (!gem_has_execlists(device))
 			ring_size /= 2;
 		igt_info("Ring size: %d batches\n", ring_size);
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH i-g-t v2 8/8] tests/gem_ringfill: use intel_measure_ring_size
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
                   ` (6 preceding siblings ...)
  2017-10-25 23:08 ` [PATCH i-g-t v2 7/8] tests/gem_exec_await: use intel_measure_ring_size Daniele Ceraolo Spurio
@ 2017-10-25 23:08 ` Daniele Ceraolo Spurio
  2017-10-25 23:29 ` ✓ Fi.CI.BAT: success for extract cork and ring measure code (rev2) Patchwork
  2017-10-26  0:19 ` ✓ Fi.CI.IGT: " Patchwork
  9 siblings, 0 replies; 11+ messages in thread
From: Daniele Ceraolo Spurio @ 2017-10-25 23:08 UTC (permalink / raw)
  To: intel-gfx

With intel_measure_ring_size added as common function we can use it
instead of the local copy

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/gem_ringfill.c | 96 +---------------------------------------------------
 1 file changed, 1 insertion(+), 95 deletions(-)

diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index 84cd49c..cbcadc9 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -236,100 +236,6 @@ static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
 		run_test(fd, ring, 0, 0);
 }
 
-struct cork {
-	int device;
-	uint32_t handle;
-	uint32_t fence;
-};
-
-static void plug(int fd, struct cork *c)
-{
-	struct vgem_bo bo;
-	int dmabuf;
-
-	c->device = drm_open_driver(DRIVER_VGEM);
-
-	bo.width = bo.height = 1;
-	bo.bpp = 4;
-	vgem_create(c->device, &bo);
-	c->fence = vgem_fence_attach(c->device, &bo, VGEM_FENCE_WRITE);
-
-	dmabuf = prime_handle_to_fd(c->device, bo.handle);
-	c->handle = prime_fd_to_handle(fd, dmabuf);
-	close(dmabuf);
-}
-
-static void unplug(struct cork *c)
-{
-	vgem_fence_signal(c->device, c->fence);
-	close(c->device);
-}
-
-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)
-{
-	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;
-	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;
-}
-
 igt_main
 {
 	const struct {
@@ -364,7 +270,7 @@ igt_main
 			master = true;
 		}
 
-		ring_size = measure_ring_size(fd);
+		ring_size = intel_measure_ring_size(fd, 0, false);
 		igt_info("Ring size: %d batches\n", ring_size);
 		igt_require(ring_size);
 	}
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* ✓ Fi.CI.BAT: success for extract cork and ring measure code (rev2)
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
                   ` (7 preceding siblings ...)
  2017-10-25 23:08 ` [PATCH i-g-t v2 8/8] tests/gem_ringfill: " Daniele Ceraolo Spurio
@ 2017-10-25 23:29 ` Patchwork
  2017-10-26  0:19 ` ✓ Fi.CI.IGT: " Patchwork
  9 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2017-10-25 23:29 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio; +Cc: intel-gfx

== Series Details ==

Series: extract cork and ring measure code (rev2)
URL   : https://patchwork.freedesktop.org/series/31858/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
12ee485a1e23bd49b754751fa82859012f751a1a igt/drv_hangman: Skip aliased I915_EXEC_BSD

with latest DRM-Tip kernel build CI_DRM_3285
2ea0b3d47030 drm-tip: 2017y-10m-25d-18h-42m-20s UTC integration manifest

No testlist changes.

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:439s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:454s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:373s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:525s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:266s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:502s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:496s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:503s
fi-byt-n2820     total:289  pass:249  dwarn:1   dfail:0   fail:0   skip:39  time:481s
fi-cfl-s         total:289  pass:253  dwarn:4   dfail:0   fail:0   skip:32  time:551s
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:603s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:416s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:250s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:581s
fi-glk-dsi       total:289  pass:258  dwarn:0   dfail:0   fail:1   skip:30  time:491s
fi-hsw-4770      total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:431s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:426s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:435s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:482s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:466s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:495s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:575s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:475s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:585s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:545s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:451s
fi-skl-6600u     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:591s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:652s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:522s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:500s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:458s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:570s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:429s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_422/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* ✓ Fi.CI.IGT: success for extract cork and ring measure code (rev2)
  2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
                   ` (8 preceding siblings ...)
  2017-10-25 23:29 ` ✓ Fi.CI.BAT: success for extract cork and ring measure code (rev2) Patchwork
@ 2017-10-26  0:19 ` Patchwork
  9 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2017-10-26  0:19 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio; +Cc: intel-gfx

== Series Details ==

Series: extract cork and ring measure code (rev2)
URL   : https://patchwork.freedesktop.org/series/31858/
State : success

== Summary ==

Test perf:
        Subgroup blocking:
                pass       -> FAIL       (shard-hsw) fdo#102252
Test kms_busy:
        Subgroup extended-modeset-hang-oldfb-with-reset-render-B:
                dmesg-warn -> PASS       (shard-hsw) fdo#102249 +2
Test drv_module_reload:
        Subgroup basic-no-display:
                pass       -> DMESG-WARN (shard-hsw) fdo#102707
Test kms_setmode:
        Subgroup basic:
                pass       -> FAIL       (shard-hsw) fdo#99912
Test kms_cursor_legacy:
        Subgroup flip-vs-cursor-legacy:
                fail       -> PASS       (shard-hsw) fdo#102670
Test drv_suspend:
        Subgroup fence-restore-untiled-hibernate:
                dmesg-fail -> FAIL       (shard-hsw) k.org#196691

fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#102249 https://bugs.freedesktop.org/show_bug.cgi?id=102249
fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
k.org#196691 https://bugzilla.kernel.org/show_bug.cgi?id=196691

shard-hsw        total:2539 pass:1430 dwarn:2   dfail:0   fail:10  skip:1097 time:9149s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_422/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-10-26  0:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25 23:08 [PATCH i-g-t v2 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 1/8] lib/igt_dummyload: add igt_cork Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 2/8] lib/igt_gt: add intel_measure_ring_size Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 3/8] tests/gem_exec_schedule: use new common functions Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 4/8] tests/gem_exec_fence: " Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 5/8] tests/gem_exec_latency: " Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 6/8] tests/gem_wait: use igt_cork Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 7/8] tests/gem_exec_await: use intel_measure_ring_size Daniele Ceraolo Spurio
2017-10-25 23:08 ` [PATCH i-g-t v2 8/8] tests/gem_ringfill: " Daniele Ceraolo Spurio
2017-10-25 23:29 ` ✓ Fi.CI.BAT: success for extract cork and ring measure code (rev2) Patchwork
2017-10-26  0:19 ` ✓ Fi.CI.IGT: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.