All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 4/8] tests/gem_exec_fence: use new common functions
Date: Thu, 12 Oct 2017 15:27:30 -0700	[thread overview]
Message-ID: <1507847254-3289-5-git-send-email-daniele.ceraolospurio@intel.com> (raw)
In-Reply-To: <1507847254-3289-1-git-send-email-daniele.ceraolospurio@intel.com>

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 | 115 +++++--------------------------------------------
 1 file changed, 10 insertions(+), 105 deletions(-)

diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
index 477386b..c6b747d 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,15 @@ static void test_parallel(int fd, unsigned int master)
 	uint32_t batch[16];
 	igt_spin_t *spin;
 	unsigned engine;
-	struct cork c;
+	igt_cork_t *c;
 	int i, x = 0;
 
-	plug(fd, &c);
+	c = igt_cork_new(fd);
 
 	/* 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, c->handle);
 	resubmit(fd, spin->handle, master, 16);
 
 	/* Now queue the master request and its secondaries */
@@ -559,7 +464,7 @@ static void test_parallel(int fd, unsigned int master)
 	}
 
 	/* Unblock the master */
-	unplug(fd, &c);
+	igt_cork_free(fd, c);
 	igt_spin_batch_end(spin);
 
 	/* Wait for all secondaries to complete. If we used a regular fence
@@ -597,7 +502,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;
+	igt_cork_t *c;
 
 	limit = -1;
 	if (!gem_uses_full_ppgtt(fd))
@@ -632,8 +537,8 @@ 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;
+	c = igt_cork_new(fd);
+	obj[0].handle = c->handle;
 
 	igt_until_timeout(5) {
 		execbuf.rsvd1 = gem_context_create(fd);
@@ -661,7 +566,7 @@ static void test_long_history(int fd, long ring_size, unsigned flags)
 		if (!--limit)
 			break;
 	}
-	unplug(fd, &c);
+	igt_cork_free(fd, c);
 
 	igt_info("History depth = %d\n", sync_fence_count(all_fences));
 
@@ -1536,7 +1441,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);
@@ -1545,7 +1450,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

  parent reply	other threads:[~2017-10-12 22:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12 22:27 [PATCH i-g-t 0/8] extract cork and ring measure code Daniele Ceraolo Spurio
2017-10-12 22:27 ` [PATCH i-g-t 1/8] lib/igt_dummyload: add igt_cork Daniele Ceraolo Spurio
2017-10-12 22:48   ` Chris Wilson
2017-10-12 22:55   ` Chris Wilson
2017-10-12 22:57   ` Chris Wilson
2017-10-13  8:31     ` Chris Wilson
2017-10-13 16:37       ` Daniele Ceraolo Spurio
2017-10-18 15:49         ` Daniele Ceraolo Spurio
2017-10-18 16:04           ` Chris Wilson
2017-10-18 16:50             ` Daniele Ceraolo Spurio
2017-10-19 18:12               ` Chris Wilson
2017-10-19 20:15                 ` Daniele Ceraolo Spurio
2017-10-12 22:27 ` [PATCH i-g-t 2/8] lib/igt_gt: add intel_measure_ring_size Daniele Ceraolo Spurio
2017-10-12 22:27 ` [PATCH i-g-t 3/8] tests/gem_exec_schedule: use new common functions Daniele Ceraolo Spurio
2017-10-12 22:27 ` Daniele Ceraolo Spurio [this message]
2017-10-12 22:27 ` [PATCH i-g-t 5/8] tests/gem_exec_latency: " Daniele Ceraolo Spurio
2017-10-12 22:27 ` [PATCH i-g-t 6/8] tests/gem_wait: use igt_cork Daniele Ceraolo Spurio
2017-10-12 22:27 ` [PATCH i-g-t 7/8] tests/gem_exec_await: use intel_measure_ring_size Daniele Ceraolo Spurio
2017-10-12 22:27 ` [PATCH i-g-t 8/8] tests/gem_ringfill: " Daniele Ceraolo Spurio
2017-10-12 22:48 ` ✓ Fi.CI.BAT: success for extract cork and ring measure code Patchwork
2017-10-12 23:12 ` [PATCH i-g-t 0/8] " Chris Wilson
2017-10-13  5:32 ` ✓ Fi.CI.IGT: success for " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1507847254-3289-5-git-send-email-daniele.ceraolospurio@intel.com \
    --to=daniele.ceraolospurio@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.