All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method
@ 2017-10-13 11:00 Michał Winiarski
  2017-10-13 11:00 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Michał Winiarski @ 2017-10-13 11:00 UTC (permalink / raw)
  To: intel-gfx

Couple of tests are using either determining submission method, or
pretty printing. Let's move those to helpers in lib.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 lib/igt_aux.c               | 18 +++++++++++++
 lib/igt_aux.h               |  2 ++
 lib/igt_gt.c                | 63 +++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_gt.h                |  7 +++++
 tests/gem_ctx_thrash.c      | 19 ++------------
 tests/gem_eio.c             | 45 ++------------------------------
 tests/gem_exec_await.c      | 39 ++--------------------------
 tests/gem_exec_fence.c      | 41 +++--------------------------
 tests/gem_exec_latency.c    | 31 +---------------------
 tests/gem_exec_nop.c        | 31 +---------------------
 tests/gem_exec_schedule.c   | 40 ++--------------------------
 tests/gem_exec_whisper.c    | 31 +---------------------
 tests/gem_read_read_speed.c | 17 +-----------
 tests/gem_sync.c            | 31 +---------------------
 14 files changed, 106 insertions(+), 309 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index fa6594c3..0c77f85f 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -1455,6 +1455,24 @@ igt_show_stat(proc_t *info, int *state, const char *fn)
 	++*state;
 }
 
+void igt_show_submission_method(int fd)
+{
+	const unsigned flags = gem_submission_method(fd);
+
+	if (flags & GEM_SUBMISSION_GUC) {
+		igt_info("Using GuC submission\n");
+		return;
+	}
+
+	if (flags & GEM_SUBMISSION_EXECLISTS) {
+		igt_info("Using Execlists submission\n");
+		return;
+	}
+
+	igt_info("Using Legacy submission%s\n",
+		 flags & GEM_SUBMISSION_SEMAPHORES ? ", with semaphores" : "");
+}
+
 static void
 __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir)
 {
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 499a1679..b79c8e5c 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -278,6 +278,8 @@ void igt_unlock_mem(void);
 	ret_;								\
 })
 
+void igt_show_submission_method(int fd);
+
 struct igt_mean;
 void igt_start_siglatency(int sig); /* 0 => SIGRTMIN (default) */
 double igt_stop_siglatency(struct igt_mean *result);
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index b3f3b380..de38656a 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -568,3 +568,66 @@ bool gem_can_store_dword(int fd, unsigned int engine)
 
 	return true;
 }
+
+/**
+ * gem_submission_method:
+ * @fd: open i915 drm file descriptor
+ *
+ * Returns: Submission method bitmap.
+ */
+unsigned gem_submission_method(int fd)
+{
+	unsigned flags = 0;
+	bool active;
+	int dir;
+
+	dir = igt_sysfs_open_parameters(fd);
+	if (dir < 0)
+		return 0;
+
+	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
+	if (active) {
+		flags |= GEM_SUBMISSION_GUC | GEM_SUBMISSION_EXECLISTS;
+		goto out;
+	}
+
+	active = igt_sysfs_get_boolean(dir, "enable_execlists");
+	if (active) {
+		flags |= GEM_SUBMISSION_EXECLISTS;
+		goto out;
+	}
+
+	active = igt_sysfs_get_boolean(dir, "semaphores");
+	if (active) {
+		flags |= GEM_SUBMISSION_SEMAPHORES;
+	}
+
+out:
+	close(dir);
+	return flags;
+}
+
+
+/**
+ * gem_has_semaphores:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query whether the driver is using semaphores for
+ * synchronization between engines.
+ */
+bool gem_has_semaphores(int fd)
+{
+	return gem_submission_method(fd) & GEM_SUBMISSION_SEMAPHORES;
+}
+
+/**
+ * gem_has_execlists:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query whether the driver is using execlists as a
+ * hardware submission method.
+ */
+bool gem_has_execlists(int fd)
+{
+	return gem_submission_method(fd) & GEM_SUBMISSION_EXECLISTS;
+}
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 2579cbd3..6b8f78eb 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -80,4 +80,11 @@ extern const struct intel_execution_engine {
 
 bool gem_can_store_dword(int fd, unsigned int engine);
 
+#define GEM_SUBMISSION_SEMAPHORES	(1 << 0)
+#define GEM_SUBMISSION_EXECLISTS	(1 << 1)
+#define GEM_SUBMISSION_GUC		(1 << 2)
+unsigned gem_submission_method(int fd);
+bool gem_has_semaphores(int fd);
+bool gem_has_execlists(int fd);
+
 #endif /* IGT_GT_H */
diff --git a/tests/gem_ctx_thrash.c b/tests/gem_ctx_thrash.c
index f79a1f4f..c0740b9f 100644
--- a/tests/gem_ctx_thrash.c
+++ b/tests/gem_ctx_thrash.c
@@ -42,21 +42,6 @@ static void xchg_int(void *array, unsigned i, unsigned j)
 	igt_swap(A[i], A[j]);
 }
 
-static bool has_execlists(int fd)
-{
-	bool enabled = false;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return false;
-
-	enabled = igt_sysfs_get_boolean(dir, "enable_execlists");
-	close(dir);
-
-	return enabled;
-}
-
 static unsigned context_size(int fd)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
@@ -86,7 +71,7 @@ static unsigned get_num_contexts(int fd, int num_engines)
 	ggtt_size = gem_global_aperture_size(fd);
 
 	size = context_size(fd);
-	if (has_execlists(fd)) {
+	if (gem_has_execlists(fd)) {
 		size += 4 << 12; /* ringbuffer as well */
 		if (num_engines) /* one per engine with execlists */
 			size *= num_engines;
@@ -95,7 +80,7 @@ static unsigned get_num_contexts(int fd, int num_engines)
 	count = 3 * (ggtt_size / size) / 2;
 	igt_info("Creating %lld contexts (assuming of size %lld%s)\n",
 		 (long long)count, (long long)size,
-		 has_execlists(fd) ? " with execlists" : "");
+		 gem_has_execlists(fd) ? " with execlists" : "");
 
 	intel_require_memory(count, size, CHECK_RAM | CHECK_SWAP);
 	return count;
diff --git a/tests/gem_eio.c b/tests/gem_eio.c
index 899cb627..26575292 100644
--- a/tests/gem_eio.c
+++ b/tests/gem_eio.c
@@ -411,45 +411,6 @@ static void test_inflight_internal(int fd)
 	trigger_reset(fd);
 }
 
-#define HAVE_EXECLISTS 0x1
-#define HAVE_GUC 0x2
-#define HAVE_SEMAPHORES 0x4
-
-static unsigned print_welcome(int fd)
-{
-	unsigned flags = 0;
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return 0;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		flags |= HAVE_GUC | HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		flags |= HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	if (active)
-		flags |= HAVE_SEMAPHORES;
-	igt_info("Using Legacy submission%s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-	return flags;
-}
-
 static int fd = -1;
 
 static void
@@ -461,8 +422,6 @@ exit_handler(int sig)
 
 igt_main
 {
-	unsigned int caps = 0;
-
 	igt_skip_on_simulation();
 
 	igt_fixture {
@@ -472,7 +431,7 @@ igt_main
 		igt_force_gpu_reset(fd);
 		igt_install_exit_handler(exit_handler);
 
-		caps = print_welcome(fd);
+		igt_show_submission_method(fd);
 		igt_require_gem(fd);
 		igt_require_hang_ring(fd, I915_EXEC_DEFAULT);
 	}
@@ -496,7 +455,7 @@ igt_main
 		test_inflight_external(fd);
 
 	igt_subtest("in-flight-internal") {
-		igt_skip_on(caps & HAVE_SEMAPHORES);
+		igt_skip_on(gem_has_semaphores(fd));
 		test_inflight_internal(fd);
 	}
 
diff --git a/tests/gem_exec_await.c b/tests/gem_exec_await.c
index fb5c0f30..783accd5 100644
--- a/tests/gem_exec_await.c
+++ b/tests/gem_exec_await.c
@@ -246,40 +246,6 @@ static void wide(int fd, int ring_size, int timeout, unsigned int flags)
 	free(exec);
 }
 
-#define HAVE_EXECLISTS 0x1
-static unsigned int print_welcome(int fd)
-{
-	unsigned int result = 0;
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return 0;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		result |= HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		result |= HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	igt_info("Using Legacy submission%s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-	return result;
-}
-
 struct cork {
 	int device;
 	uint32_t handle;
@@ -374,14 +340,13 @@ igt_main
 	int device = -1;
 
 	igt_fixture {
-		unsigned int caps;
 
 		device = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(device);
-		caps = print_welcome(device);
+		igt_show_submission_method(device);
 
 		ring_size = measure_ring_size(device) - 10;
-		if (!(caps & HAVE_EXECLISTS))
+		if (!gem_has_execlists(device))
 			ring_size /= 2;
 		igt_info("Ring size: %d batches\n", ring_size);
 		igt_require(ring_size > 0);
diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
index 477386b4..4972747e 100644
--- a/tests/gem_exec_fence.c
+++ b/tests/gem_exec_fence.c
@@ -692,40 +692,6 @@ static void test_fence_flip(int i915)
 	igt_skip_on_f(1, "no fence-in for atomic flips\n");
 }
 
-#define HAVE_EXECLISTS 0x1
-static unsigned int print_welcome(int fd)
-{
-	unsigned int result = 0;
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return 0;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		result |= HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		result |= HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	igt_info("Using Legacy submission%s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-	return result;
-}
-
 static bool has_submit_fence(int fd)
 {
 	struct drm_i915_getparam gp;
@@ -1458,7 +1424,6 @@ static void test_syncobj_channel(int fd)
 igt_main
 {
 	const struct intel_execution_engine *e;
-	unsigned int caps = 0;
 	int i915 = -1;
 
 	igt_skip_on_simulation();
@@ -1469,7 +1434,7 @@ igt_main
 		igt_require(gem_has_exec_fence(i915));
 		gem_require_mmap_wc(i915);
 
-		caps = print_welcome(i915);
+		igt_show_submission_method(i915);
 	}
 
 	for (e = intel_execution_engines; e->name; e++) {
@@ -1541,7 +1506,7 @@ igt_main
 		igt_info("Ring size: %ld batches\n", ring_size);
 		igt_require(ring_size);
 
-		test_long_history(i915, ring_size, caps);
+		test_long_history(i915, ring_size, 0);
 	}
 
 	igt_subtest("expired-history") {
@@ -1550,7 +1515,7 @@ igt_main
 		igt_info("Ring size: %ld batches\n", ring_size);
 		igt_require(ring_size);
 
-		test_long_history(i915, ring_size, caps | EXPIRED);
+		test_long_history(i915, ring_size, EXPIRED);
 	}
 
 	igt_subtest("flip") {
diff --git a/tests/gem_exec_latency.c b/tests/gem_exec_latency.c
index f86dfcb5..7b11f593 100644
--- a/tests/gem_exec_latency.c
+++ b/tests/gem_exec_latency.c
@@ -407,35 +407,6 @@ static void latency_from_ring(int fd,
 	gem_close(fd, obj[2].handle);
 }
 
-static void print_welcome(int fd)
-{
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	igt_info("Using Legacy submission%s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-}
-
 igt_main
 {
 	const struct intel_execution_engine *e;
@@ -446,7 +417,7 @@ igt_main
 		igt_require_gem(device);
 		gem_require_mmap_wc(device);
 
-		print_welcome(device);
+		igt_show_submission_method(device);
 
 		ring_size = measure_ring_size(device);
 		igt_info("Ring size: %d batches\n", ring_size);
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 0af64557..6d62e94a 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -665,35 +665,6 @@ static void preempt(int fd, uint32_t handle,
 		 ring_name, count, elapsed(&start, &now)*1e6 / count);
 }
 
-static void print_welcome(int fd)
-{
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	igt_info("Using Legacy submission%s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-}
-
 static unsigned int has_scheduler(int fd)
 {
 	drm_i915_getparam_t gp;
@@ -727,7 +698,7 @@ igt_main
 
 		device = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(device);
-		print_welcome(device);
+		igt_show_submission_method(device);
 		sched_caps = has_scheduler(device);
 
 		handle = gem_create(device, 4096);
diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
index ad3688cf..b65482ce 100644
--- a/tests/gem_exec_schedule.c
+++ b/tests/gem_exec_schedule.c
@@ -1000,45 +1000,9 @@ static unsigned int has_scheduler(int fd)
 	return caps;
 }
 
-#define HAVE_EXECLISTS 0x1
-#define HAVE_GUC 0x2
-static unsigned print_welcome(int fd)
-{
-	unsigned flags = 0;
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return 0;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		flags |= HAVE_GUC | HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		flags |= HAVE_EXECLISTS;
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	igt_info("Using Legacy submission%s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-	return flags;
-}
-
 igt_main
 {
 	const struct intel_execution_engine *e;
-	unsigned int exec_caps = 0;
 	unsigned int sched_caps = 0;
 	int fd = -1;
 
@@ -1046,7 +1010,7 @@ igt_main
 
 	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_INTEL);
-		exec_caps = print_welcome(fd);
+		igt_show_submission_method(fd);
 		sched_caps = has_scheduler(fd);
 		igt_require_gem(fd);
 		gem_require_mmap_wc(fd);
@@ -1135,7 +1099,7 @@ igt_main
 			ctx_has_priority(fd);
 
 			/* need separate rings */
-			igt_require(exec_caps & HAVE_EXECLISTS);
+			igt_require(gem_has_execlists(fd));
 		}
 
 		for (e = intel_execution_engines; e->name; e++) {
diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c
index 15989616..2707171a 100644
--- a/tests/gem_exec_whisper.c
+++ b/tests/gem_exec_whisper.c
@@ -552,35 +552,6 @@ static void whisper(int fd, unsigned engine, unsigned flags)
 	close(debugfs);
 }
 
-static void print_welcome(int fd)
-{
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	igt_info("Using Legacy submission%s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-}
-
 igt_main
 {
 	const struct mode {
@@ -615,7 +586,7 @@ igt_main
 		fd = drm_open_driver_master(DRIVER_INTEL);
 		igt_require_gem(fd);
 		igt_require(gem_can_store_dword(fd, 0));
-		print_welcome(fd);
+		igt_show_submission_method(fd);
 
 		igt_fork_hang_detector(fd);
 	}
diff --git a/tests/gem_read_read_speed.c b/tests/gem_read_read_speed.c
index c1d30f24..523e9c24 100644
--- a/tests/gem_read_read_speed.c
+++ b/tests/gem_read_read_speed.c
@@ -49,21 +49,6 @@ igt_render_copyfunc_t rendercopy;
 struct intel_batchbuffer *batch;
 int width, height;
 
-static int semaphores_enabled(int fd)
-{
-	bool enabled = false;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return false;
-
-	enabled = igt_sysfs_get_boolean(dir, "semaphores");
-	close(dir);
-
-	return enabled;
-}
-
 static drm_intel_bo *rcs_copy_bo(drm_intel_bo *dst, drm_intel_bo *src)
 {
 	struct igt_buf d = {
@@ -212,7 +197,7 @@ igt_main
 
 		batch =  intel_batchbuffer_alloc(bufmgr, devid);
 
-		igt_info("Semaphores: %d\n", semaphores_enabled(fd));
+		igt_show_submission_method(fd);
 	}
 
 	for (i = 0; sizes[i] != 0; i++) {
diff --git a/tests/gem_sync.c b/tests/gem_sync.c
index c9e2f014..754c3202 100644
--- a/tests/gem_sync.c
+++ b/tests/gem_sync.c
@@ -807,35 +807,6 @@ preempt(int fd, unsigned ring, int num_children, int timeout)
 	gem_context_destroy(fd, ctx[0]);
 }
 
-static void print_welcome(int fd)
-{
-	bool active;
-	int dir;
-
-	dir = igt_sysfs_open_parameters(fd);
-	if (dir < 0)
-		return;
-
-	active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
-	if (active) {
-		igt_info("Using GuC submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "enable_execlists");
-	if (active) {
-		igt_info("Using Execlists submission\n");
-		goto out;
-	}
-
-	active = igt_sysfs_get_boolean(dir, "semaphores");
-	igt_info("Using Legacy submission %s\n",
-		 active ? ", with semaphores" : "");
-
-out:
-	close(dir);
-}
-
 static unsigned int has_scheduler(int fd)
 {
 	drm_i915_getparam_t gp;
@@ -869,7 +840,7 @@ igt_main
 	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
-		print_welcome(fd);
+		igt_show_submission_method(fd);
 		sched_caps = has_scheduler(fd);
 
 		igt_fork_hang_detector(fd);
-- 
2.13.5

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

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

* [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities
  2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
@ 2017-10-13 11:00 ` Michał Winiarski
  2017-10-13 11:28   ` Katarzyna Dec
  2017-10-13 11:00 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Michał Winiarski @ 2017-10-13 11:00 UTC (permalink / raw)
  To: intel-gfx

Couple of tests are using either determining scheduler capabilities or
pretty printing. Let's move those to helpers in lib. We can also keep
the value obtained from getparam static.

v2: Break the trend of expanding ioctl_wrappers

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   5 +
 lib/Makefile.sources                               |   2 +
 lib/i915/gem_scheduler.c                           | 125 +++++++++++++++++++++
 lib/i915/gem_scheduler.h                           |  37 ++++++
 lib/ioctl_wrappers.h                               |   2 +
 lib/meson.build                                    |  10 +-
 tests/gem_exec_nop.c                               |  34 +-----
 tests/gem_exec_schedule.c                          |  47 ++------
 tests/gem_exec_whisper.c                           |  22 +---
 tests/gem_sync.c                                   |  34 +-----
 10 files changed, 189 insertions(+), 129 deletions(-)
 create mode 100644 lib/i915/gem_scheduler.c
 create mode 100644 lib/i915/gem_scheduler.h

diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 04a0485c..8c14bd07 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -44,6 +44,11 @@
     <xi:include href="xml/intel_io.xml"/>
     <xi:include href="xml/ioctl_wrappers.xml"/>
     <xi:include href="xml/sw_sync.xml"/>
+
+  </chapter>
+  <chapter>
+    <title>igt/i915 API Reference</title>
+    <xi:include href="xml/gem_scheduler.xml"/>
   </chapter>
   <xi:include href="xml/igt_test_programs.xml"/>
 
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 965e230e..c33723f9 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -3,6 +3,8 @@ lib_source_list =	 	\
 	drmtest.c		\
 	drmtest.h		\
 	i830_reg.h		\
+	i915/gem_scheduler.c	\
+	i915/gem_scheduler.h	\
 	i915_3d.h		\
 	i915_reg.h		\
 	i915_pciids.h		\
diff --git a/lib/i915/gem_scheduler.c b/lib/i915/gem_scheduler.c
new file mode 100644
index 00000000..ad156306
--- /dev/null
+++ b/lib/i915/gem_scheduler.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "igt_core.h"
+#include "ioctl_wrappers.h"
+
+#include "i915/gem_scheduler.h"
+
+#define LOCAL_I915_PARAM_HAS_SCHEDULER		41
+
+/**
+ * SECTION:gem_scheduler
+ * @short_description: Helpers for querying scheduler capabilities
+ * @title: GEM Scheduler
+ *
+ * This helper library contains functions used for getting information on
+ * currently used scheduling model.
+ */
+
+/**
+ * gem_scheduler_capability:
+ * @fd: open i915 drm file descriptor
+ *
+ * Returns: Scheduler capability bitmap.
+ */
+unsigned gem_scheduler_capability(int fd)
+{
+	static int caps = -1;
+
+	if (caps < 0) {
+		struct drm_i915_getparam gp;
+
+		memset(&gp, 0, sizeof(gp));
+		gp.param = LOCAL_I915_PARAM_HAS_SCHEDULER;
+		gp.value = &caps;
+
+		caps = 0;
+		ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		errno = 0;
+	}
+
+	return caps;
+}
+
+/**
+ * gem_has_scheduler:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query whether the driver has scheduling capability.
+ */
+bool gem_scheduler_enabled(int fd)
+{
+	return gem_scheduler_capability(fd) &
+	       LOCAL_I915_SCHEDULER_CAP_ENABLED;
+}
+
+/**
+ * gem_has_ctx_priority:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query whether the driver supports assigning custom
+ * priorities to contexts from userspace.
+ */
+bool gem_scheduler_has_ctx_priority(int fd)
+{
+	return gem_scheduler_capability(fd) &
+	       LOCAL_I915_SCHEDULER_CAP_PRIORITY;
+}
+
+/**
+ * gem_has_preemption:
+ * @fd: open i915 drm file descriptor
+ *
+ * Feature test macro to query whether the driver supports preempting active
+ * (currently executing on HW) workloads.
+ */
+bool gem_scheduler_has_preemption(int fd)
+{
+	return gem_scheduler_capability(fd) &
+	       LOCAL_I915_SCHEDULER_CAP_PREEMPTION;
+}
+
+/**
+ * gem_scheduler_print_capability:
+ * @fd: open i915 drm file descriptor
+ *
+ * Helper for pretty-printing scheduler capability.
+ */
+void gem_scheduler_print_capability(int fd)
+{
+	unsigned caps = gem_scheduler_capability(fd);
+
+	if (!caps)
+		return;
+
+	igt_info("Has kernel scheduler\n");
+	if (caps & LOCAL_I915_SCHEDULER_CAP_PRIORITY)
+		igt_info(" - With priority sorting\n");
+	if (caps & LOCAL_I915_SCHEDULER_CAP_PREEMPTION)
+		igt_info(" - With preemption enabled\n");
+}
diff --git a/lib/i915/gem_scheduler.h b/lib/i915/gem_scheduler.h
new file mode 100644
index 00000000..9fcb0266
--- /dev/null
+++ b/lib/i915/gem_scheduler.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef GEM_SCHEDULER_H
+#define GEM_SCHEDULER_H
+
+#define LOCAL_I915_SCHEDULER_CAP_ENABLED	(1 << 0)
+#define LOCAL_I915_SCHEDULER_CAP_PRIORITY	(1 << 1)
+#define LOCAL_I915_SCHEDULER_CAP_PREEMPTION	(1 << 2)
+
+unsigned gem_scheduler_capability(int fd);
+bool gem_scheduler_enabled(int fd);
+bool gem_scheduler_has_ctx_priority(int fd);
+bool gem_scheduler_has_preemption(int fd);
+void gem_scheduler_print_capability(int fd);
+
+#endif /* GEM_SCHEDULER_H */
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 1663b7f8..76a4e80d 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -36,6 +36,8 @@
 #include <intel_bufmgr.h>
 #include <i915_drm.h>
 
+#include "i915/gem_scheduler.h"
+
 /**
  * igt_ioctl:
  * @fd: file descriptor
diff --git a/lib/meson.build b/lib/meson.build
index 89ed2723..22811743 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -2,6 +2,7 @@ lib_headers = [
 	'debug.h',
 	'drmtest.h',
 	'i830_reg.h',
+	'i915/gem_scheduler.h',
 	'i915_3d.h',
 	'i915_reg.h',
 	'i915_pciids.h',
@@ -48,6 +49,7 @@ lib_headers = [
 
 lib_sources = [
 	'drmtest.c',
+	'i915/gem_scheduler.c',
 	'igt_debugfs.c',
 	'igt_aux.c',
 	'igt_gt.c',
@@ -152,13 +154,7 @@ lib_version = vcs_tag(input : 'version.h.in', output : 'version.h',
 
 lib_intermediates = []
 foreach f: lib_sources
-    # No / in the target name
-    if f.contains('uwildmat')
-        name = 'uwildmat'
-    else
-        name = f
-    endif
-
+    name = f.underscorify(f)
     lib = static_library('igt-' + name,
 	[ f, lib_version ],
 	include_directories: inc,
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 6d62e94a..78f2b1bd 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -44,8 +44,6 @@
 #include <time.h>
 #include "drm.h"
 
-#define BIT(x) (1ul << (x))
-
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
 
@@ -54,10 +52,6 @@
 
 #define ENGINE_FLAGS  (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
 
-#define LOCAL_PARAM_HAS_SCHEDULER 41
-#define   HAS_SCHEDULER		BIT(0)
-#define   HAS_PRIORITY		BIT(1)
-#define   HAS_PREEMPTION	BIT(2)
 #define LOCAL_CONTEXT_PARAM_PRIORITY 6
 #define   MAX_PRIO 1023
 #define   MIN_PRIO -1023
@@ -665,31 +659,9 @@ static void preempt(int fd, uint32_t handle,
 		 ring_name, count, elapsed(&start, &now)*1e6 / count);
 }
 
-static unsigned int has_scheduler(int fd)
-{
-	drm_i915_getparam_t gp;
-	unsigned int caps = 0;
-
-	gp.param = LOCAL_PARAM_HAS_SCHEDULER;
-	gp.value = (int *)&caps;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
-	if (!caps)
-		return 0;
-
-	igt_info("Has kernel scheduler\n");
-	if (caps & HAS_PRIORITY)
-		igt_info(" - With priority sorting\n");
-	if (caps & HAS_PREEMPTION)
-		igt_info(" - With preemption enabled\n");
-
-	return caps;
-}
-
 igt_main
 {
 	const struct intel_execution_engine *e;
-	unsigned int sched_caps = 0;
 	uint32_t handle = 0;
 	int device = -1;
 
@@ -699,7 +671,7 @@ igt_main
 		device = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(device);
 		igt_show_submission_method(device);
-		sched_caps = has_scheduler(device);
+		gem_scheduler_print_capability(device);
 
 		handle = gem_create(device, 4096);
 		gem_write(device, handle, 0, &bbe, sizeof(bbe));
@@ -746,8 +718,8 @@ igt_main
 
 	igt_subtest_group {
 		igt_fixture {
-			igt_require(sched_caps & HAS_PRIORITY);
-			igt_require(sched_caps & HAS_PREEMPTION);
+			igt_require(gem_scheduler_has_ctx_priority(device));
+			igt_require(gem_scheduler_has_preemption(device));
 		}
 
 		for (e = intel_execution_engines; e->name; e++) {
diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
index b65482ce..d3df449a 100644
--- a/tests/gem_exec_schedule.c
+++ b/tests/gem_exec_schedule.c
@@ -33,12 +33,6 @@
 #include "igt_rand.h"
 #include "igt_sysfs.h"
 
-#define BIT(x) (1ul << (x))
-
-#define LOCAL_PARAM_HAS_SCHEDULER 41
-#define   HAS_SCHEDULER		BIT(0)
-#define   HAS_PRIORITY		BIT(1)
-#define   HAS_PREEMPTION	BIT(2)
 #define LOCAL_CONTEXT_PARAM_PRIORITY 6
 
 #define LO 0
@@ -70,11 +64,6 @@ static void ctx_set_priority(int fd, uint32_t ctx, int prio)
 	igt_assert_eq(__ctx_set_priority(fd, ctx, prio), 0);
 }
 
-static void ctx_has_priority(int fd)
-{
-	igt_require(__ctx_set_priority(fd, 0, MAX_PRIO) == 0);
-}
-
 static void store_dword(int fd, uint32_t ctx, unsigned ring,
 			uint32_t target, uint32_t offset, uint32_t value,
 			uint32_t cork, unsigned write_domain)
@@ -979,31 +968,9 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 	munmap(result, 4096);
 }
 
-static unsigned int has_scheduler(int fd)
-{
-	drm_i915_getparam_t gp;
-	unsigned int caps = 0;
-
-	gp.param = LOCAL_PARAM_HAS_SCHEDULER;
-	gp.value = (int *)&caps;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
-	if (!caps)
-		return 0;
-
-	igt_info("Has kernel scheduler\n");
-	if (caps & HAS_PRIORITY)
-		igt_info(" - With priority sorting\n");
-	if (caps & HAS_PREEMPTION)
-		igt_info(" - With preemption enabled\n");
-
-	return caps;
-}
-
 igt_main
 {
 	const struct intel_execution_engine *e;
-	unsigned int sched_caps = 0;
 	int fd = -1;
 
 	igt_skip_on_simulation();
@@ -1011,7 +978,7 @@ igt_main
 	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_INTEL);
 		igt_show_submission_method(fd);
-		sched_caps = has_scheduler(fd);
+		gem_scheduler_print_capability(fd);
 		igt_require_gem(fd);
 		gem_require_mmap_wc(fd);
 		igt_fork_hang_detector(fd);
@@ -1033,8 +1000,8 @@ igt_main
 
 	igt_subtest_group {
 		igt_fixture {
-			igt_require(sched_caps & HAS_SCHEDULER);
-			ctx_has_priority(fd);
+			igt_require(gem_scheduler_enabled(fd));
+			igt_require(gem_scheduler_has_ctx_priority(fd));
 		}
 
 		igt_subtest("smoketest-all")
@@ -1062,7 +1029,7 @@ igt_main
 
 				igt_subtest_group {
 					igt_fixture {
-						igt_require(sched_caps & HAS_PREEMPTION);
+						igt_require(gem_scheduler_has_preemption(fd));
 					}
 
 					igt_subtest_f("preempt-%s", e->name)
@@ -1095,8 +1062,8 @@ igt_main
 
 	igt_subtest_group {
 		igt_fixture {
-			igt_require(sched_caps & HAS_SCHEDULER);
-			ctx_has_priority(fd);
+			igt_require(gem_scheduler_enabled(fd));
+			igt_require(gem_scheduler_has_ctx_priority(fd));
 
 			/* need separate rings */
 			igt_require(gem_has_execlists(fd));
@@ -1106,7 +1073,7 @@ igt_main
 			igt_subtest_group {
 				igt_fixture {
 					gem_require_ring(fd, e->exec_id | e->flags);
-					igt_require(sched_caps & HAS_PREEMPTION);
+					igt_require(gem_scheduler_has_preemption(fd));
 				}
 
 				igt_subtest_f("pi-ringfull-%s", e->name)
diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c
index 2707171a..da5f26aa 100644
--- a/tests/gem_exec_whisper.c
+++ b/tests/gem_exec_whisper.c
@@ -191,21 +191,8 @@ static void fini_hang(struct hang *h)
 	close(h->fd);
 }
 
-#define LOCAL_PARAM_HAS_SCHEDULER 41
 #define LOCAL_CONTEXT_PARAM_PRIORITY 6
 
-static bool __has_scheduler(int fd)
-{
-	drm_i915_getparam_t gp;
-	int has = -1;
-
-	gp.param = LOCAL_PARAM_HAS_SCHEDULER;
-	gp.value = &has;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
-	return has > 0;
-}
-
 static int __ctx_set_priority(int fd, uint32_t ctx, int prio)
 {
 	struct local_i915_gem_context_param param;
@@ -250,13 +237,8 @@ static void whisper(int fd, unsigned engine, unsigned flags)
 	int debugfs;
 
 	if (flags & PRIORITY) {
-		int __fd = drm_open_driver(DRIVER_INTEL);
-		bool has_scheduler = __has_scheduler(__fd);
-		bool ctx_has_priority =
-			__ctx_set_priority(__fd, 0, 1) == 0;
-		close(__fd);
-
-		igt_require(has_scheduler && ctx_has_priority);
+		igt_require(gem_scheduler_enabled(fd));
+		igt_require(gem_scheduler_has_ctx_priority(fd));
 	}
 
 	debugfs = igt_debugfs_dir(fd);
diff --git a/tests/gem_sync.c b/tests/gem_sync.c
index 754c3202..fccc0c0e 100644
--- a/tests/gem_sync.c
+++ b/tests/gem_sync.c
@@ -27,18 +27,12 @@
 #include "igt.h"
 #include "igt_sysfs.h"
 
-#define BIT(x) (1ul << (x))
-
 #define LOCAL_I915_EXEC_NO_RELOC (1<<11)
 #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
 
 #define LOCAL_I915_EXEC_BSD_SHIFT      (13)
 #define LOCAL_I915_EXEC_BSD_MASK       (3 << LOCAL_I915_EXEC_BSD_SHIFT)
 
-#define LOCAL_PARAM_HAS_SCHEDULER 41
-#define   HAS_SCHEDULER		BIT(0)
-#define   HAS_PRIORITY		BIT(1)
-#define   HAS_PREEMPTION	BIT(2)
 #define LOCAL_CONTEXT_PARAM_PRIORITY 6
 #define   MAX_PRIO 1023
 #define   MIN_PRIO -1023
@@ -807,32 +801,10 @@ preempt(int fd, unsigned ring, int num_children, int timeout)
 	gem_context_destroy(fd, ctx[0]);
 }
 
-static unsigned int has_scheduler(int fd)
-{
-	drm_i915_getparam_t gp;
-	unsigned int caps = 0;
-
-	gp.param = LOCAL_PARAM_HAS_SCHEDULER;
-	gp.value = (int *)&caps;
-	drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-
-	if (!caps)
-		return 0;
-
-	igt_info("Has kernel scheduler\n");
-	if (caps & HAS_PRIORITY)
-		igt_info(" - With priority sorting\n");
-	if (caps & HAS_PREEMPTION)
-		igt_info(" - With preemption enabled\n");
-
-	return caps;
-}
-
 igt_main
 {
 	const struct intel_execution_engine *e;
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
-	unsigned int sched_caps = 0;
 	int fd = -1;
 
 	igt_skip_on_simulation();
@@ -841,7 +813,7 @@ igt_main
 		fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(fd);
 		igt_show_submission_method(fd);
-		sched_caps = has_scheduler(fd);
+		gem_scheduler_print_capability(fd);
 
 		igt_fork_hang_detector(fd);
 	}
@@ -886,8 +858,8 @@ igt_main
 
 	igt_subtest_group {
 		igt_fixture {
-			igt_require(sched_caps & HAS_PRIORITY);
-			igt_require(sched_caps & HAS_PREEMPTION);
+			igt_require(gem_scheduler_has_ctx_priority(fd));
+			igt_require(gem_scheduler_has_preemption(fd));
 		}
 
 		igt_subtest("preempt-all")
-- 
2.13.5

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

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

* [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context
  2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
  2017-10-13 11:00 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
@ 2017-10-13 11:00 ` Michał Winiarski
  2017-10-13 11:27   ` Katarzyna Dec
  2017-10-13 11:30   ` Chris Wilson
  2017-10-13 11:00 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 14+ messages in thread
From: Michał Winiarski @ 2017-10-13 11:00 UTC (permalink / raw)
  To: intel-gfx

We'd like to make ioctl_wrappers a bit thinner, and we plan to add new
helpers in the following patch. Let's move context related helpers before
adding more content.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 .../intel-gpu-tools/intel-gpu-tools-docs.xml       |   1 +
 lib/Makefile.sources                               |   2 +
 lib/i915/gem_context.c                             | 199 +++++++++++++++++++++
 lib/i915/gem_context.h                             |  48 +++++
 lib/ioctl_wrappers.c                               | 157 +---------------
 lib/ioctl_wrappers.h                               |  22 +--
 lib/meson.build                                    |   2 +
 7 files changed, 254 insertions(+), 177 deletions(-)
 create mode 100644 lib/i915/gem_context.c
 create mode 100644 lib/i915/gem_context.h

diff --git a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
index 8c14bd07..c5be60d0 100644
--- a/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
+++ b/docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml
@@ -48,6 +48,7 @@
   </chapter>
   <chapter>
     <title>igt/i915 API Reference</title>
+    <xi:include href="xml/gem_context.xml"/>
     <xi:include href="xml/gem_scheduler.xml"/>
   </chapter>
   <xi:include href="xml/igt_test_programs.xml"/>
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index c33723f9..09c9ef9f 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -3,6 +3,8 @@ lib_source_list =	 	\
 	drmtest.c		\
 	drmtest.h		\
 	i830_reg.h		\
+	i915/gem_context.c	\
+	i915/gem_context.h	\
 	i915/gem_scheduler.c	\
 	i915/gem_scheduler.h	\
 	i915_3d.h		\
diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c
new file mode 100644
index 00000000..ba826ae3
--- /dev/null
+++ b/lib/i915/gem_context.c
@@ -0,0 +1,199 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <errno.h>
+#include <string.h>
+
+#include "ioctl_wrappers.h"
+#include "drmtest.h"
+
+#include "i915/gem_context.h"
+
+/**
+ * SECTION:gem_context
+ * @short_description: Helpers for dealing with contexts
+ * @title: GEM Context
+ *
+ * This helper library contains functions used for handling gem contexts.
+ * Conceptually, gem contexts are similar to their CPU counterparts, in that
+ * they are a mix of software and hardware features allowing to isolate some
+ * aspects of task execution. Initially it was just a matter of maintaining
+ * separate state for each context, but more features were added, some
+ * improving contexts isolation (per-context address space), some are just
+ * software features improving submission model (context priority).
+ */
+
+/**
+ * gem_context_create:
+ * @fd: open i915 drm file descriptor
+ *
+ * This wraps the CONTEXT_CREATE ioctl, which is used to allocate a new
+ * context. Note that similarly to gem_set_caching() this wrapper skips on
+ * kernels and platforms where context support is not available.
+ *
+ * Returns: The id of the allocated context.
+ */
+uint32_t gem_context_create(int fd)
+{
+	struct drm_i915_gem_context_create create;
+
+	memset(&create, 0, sizeof(create));
+	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create)) {
+		int err = -errno;
+		igt_skip_on(err == -ENODEV || errno == -EINVAL);
+		igt_assert_eq(err, 0);
+	}
+	igt_assert(create.ctx_id != 0);
+	errno = 0;
+
+	return create.ctx_id;
+}
+
+int __gem_context_destroy(int fd, uint32_t ctx_id)
+{
+	struct drm_i915_gem_context_destroy destroy;
+	int ret;
+
+	memset(&destroy, 0, sizeof(destroy));
+	destroy.ctx_id = ctx_id;
+
+	ret = igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
+	if (ret)
+		return -errno;
+	return 0;
+}
+
+/**
+ * gem_context_destroy:
+ * @fd: open i915 drm file descriptor
+ * @ctx_id: i915 context id
+ *
+ * This wraps the CONTEXT_DESTROY ioctl, which is used to free a context.
+ */
+void gem_context_destroy(int fd, uint32_t ctx_id)
+{
+	struct drm_i915_gem_context_destroy destroy;
+
+	memset(&destroy, 0, sizeof(destroy));
+	destroy.ctx_id = ctx_id;
+
+	do_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
+}
+
+int __gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
+{
+#define LOCAL_I915_GEM_CONTEXT_GETPARAM       0x34
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
+	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p))
+		return -errno;
+
+	errno = 0;
+	return 0;
+}
+
+/**
+ * gem_context_get_param:
+ * @fd: open i915 drm file descriptor
+ * @p: i915 context parameter
+ *
+ * This wraps the CONTEXT_GET_PARAM ioctl, which is used to get a context
+ * parameter.
+ */
+void gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
+{
+	igt_assert(__gem_context_get_param(fd, p) == 0);
+}
+
+
+int __gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
+{
+#define LOCAL_I915_GEM_CONTEXT_SETPARAM       0x35
+#define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
+	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p))
+		return -errno;
+
+	errno = 0;
+	return 0;
+}
+/**
+ * gem_context_set_param:
+ * @fd: open i915 drm file descriptor
+ * @p: i915 context parameter
+ *
+ * This wraps the CONTEXT_SET_PARAM ioctl, which is used to set a context
+ * parameter.
+ */
+void gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
+{
+	igt_assert(__gem_context_set_param(fd, p) == 0);
+}
+
+/**
+ * gem_context_require_param:
+ * @fd: open i915 drm file descriptor
+ * @param: i915 context parameter
+ *
+ * Feature test macro to query whether context parameter support for @param
+ * is available. Automatically skips through igt_require() if not.
+ */
+void gem_context_require_param(int fd, uint64_t param)
+{
+	struct local_i915_gem_context_param p;
+
+	p.context = 0;
+	p.param = param;
+	p.value = 0;
+	p.size = 0;
+
+	igt_require(igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0);
+}
+
+void gem_context_require_bannable(int fd)
+{
+	static int has_ban_period = -1;
+	static int has_bannable = -1;
+
+	if (has_bannable < 0) {
+		struct local_i915_gem_context_param p;
+
+		p.context = 0;
+		p.param = LOCAL_CONTEXT_PARAM_BANNABLE;
+		p.value = 0;
+		p.size = 0;
+
+		has_bannable = igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0;
+	}
+
+	if (has_ban_period < 0) {
+		struct local_i915_gem_context_param p;
+
+		p.context = 0;
+		p.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
+		p.value = 0;
+		p.size = 0;
+
+		has_ban_period = igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0;
+	}
+
+	igt_require(has_ban_period || has_bannable);
+}
diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h
new file mode 100644
index 00000000..06b2ca99
--- /dev/null
+++ b/lib/i915/gem_context.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef GEM_CONTEXT_H
+#define GEM_CONTEXT_H
+
+uint32_t gem_context_create(int fd);
+void gem_context_destroy(int fd, uint32_t ctx_id);
+int __gem_context_destroy(int fd, uint32_t ctx_id);
+struct local_i915_gem_context_param {
+	uint32_t context;
+	uint32_t size;
+	uint64_t param;
+#define LOCAL_CONTEXT_PARAM_BAN_PERIOD	0x1
+#define LOCAL_CONTEXT_PARAM_NO_ZEROMAP	0x2
+#define LOCAL_CONTEXT_PARAM_GTT_SIZE	0x3
+#define LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE	0x4
+#define LOCAL_CONTEXT_PARAM_BANNABLE	0x5
+	uint64_t value;
+};
+void gem_context_require_bannable(int fd);
+void gem_context_require_param(int fd, uint64_t param);
+void gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
+void gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
+int __gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
+int __gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
+
+#endif /* GEM_CONTEXT_H */
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 87511fc6..7ad2b7b0 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -894,161 +894,6 @@ int gem_madvise(int fd, uint32_t handle, int state)
 	return madv.retained;
 }
 
-/**
- * gem_context_create:
- * @fd: open i915 drm file descriptor
- *
- * This wraps the CONTEXT_CREATE ioctl, which is used to allocate a new
- * context. Note that similarly to gem_set_caching() this wrapper skips on
- * kernels and platforms where context support is not available.
- *
- * Returns: The id of the allocated context.
- */
-uint32_t gem_context_create(int fd)
-{
-	struct drm_i915_gem_context_create create;
-
-	memset(&create, 0, sizeof(create));
-	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create)) {
-		int err = -errno;
-		igt_skip_on(err == -ENODEV || errno == -EINVAL);
-		igt_assert_eq(err, 0);
-	}
-	igt_assert(create.ctx_id != 0);
-	errno = 0;
-
-	return create.ctx_id;
-}
-
-int __gem_context_destroy(int fd, uint32_t ctx_id)
-{
-	struct drm_i915_gem_context_destroy destroy;
-	int ret;
-
-	memset(&destroy, 0, sizeof(destroy));
-	destroy.ctx_id = ctx_id;
-
-	ret = igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
-	if (ret)
-		return -errno;
-	return 0;
-}
-
-/**
- * gem_context_destroy:
- * @fd: open i915 drm file descriptor
- * @ctx_id: i915 context id
- *
- * This wraps the CONTEXT_DESTROY ioctl, which is used to free a context.
- */
-void gem_context_destroy(int fd, uint32_t ctx_id)
-{
-	struct drm_i915_gem_context_destroy destroy;
-
-	memset(&destroy, 0, sizeof(destroy));
-	destroy.ctx_id = ctx_id;
-
-	do_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_DESTROY, &destroy);
-}
-
-int __gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
-{
-#define LOCAL_I915_GEM_CONTEXT_GETPARAM       0x34
-#define LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_GETPARAM, struct local_i915_gem_context_param)
-	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, p))
-		return -errno;
-
-	errno = 0;
-	return 0;
-}
-
-/**
- * gem_context_get_param:
- * @fd: open i915 drm file descriptor
- * @p: i915 context parameter
- *
- * This wraps the CONTEXT_GET_PARAM ioctl, which is used to get a context
- * parameter.
- */
-void gem_context_get_param(int fd, struct local_i915_gem_context_param *p)
-{
-	igt_assert(__gem_context_get_param(fd, p) == 0);
-}
-
-
-int __gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
-{
-#define LOCAL_I915_GEM_CONTEXT_SETPARAM       0x35
-#define LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_CONTEXT_SETPARAM, struct local_i915_gem_context_param)
-	if (igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_SETPARAM, p))
-		return -errno;
-
-	errno = 0;
-	return 0;
-}
-/**
- * gem_context_set_param:
- * @fd: open i915 drm file descriptor
- * @p: i915 context parameter
- *
- * This wraps the CONTEXT_SET_PARAM ioctl, which is used to set a context
- * parameter.
- */
-void gem_context_set_param(int fd, struct local_i915_gem_context_param *p)
-{
-	igt_assert(__gem_context_set_param(fd, p) == 0);
-}
-
-/**
- * gem_context_require_param:
- * @fd: open i915 drm file descriptor
- * @param: i915 context parameter
- *
- * Feature test macro to query whether context parameter support for @param
- * is available. Automatically skips through igt_require() if not.
- */
-void gem_context_require_param(int fd, uint64_t param)
-{
-	struct local_i915_gem_context_param p;
-
-	p.context = 0;
-	p.param = param;
-	p.value = 0;
-	p.size = 0;
-
-	igt_require(igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0);
-}
-
-void gem_context_require_bannable(int fd)
-{
-	static int has_ban_period = -1;
-	static int has_bannable = -1;
-
-	if (has_bannable < 0) {
-		struct local_i915_gem_context_param p;
-
-		p.context = 0;
-		p.param = LOCAL_CONTEXT_PARAM_BANNABLE;
-		p.value = 0;
-		p.size = 0;
-
-		has_bannable = igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0;
-	}
-
-	if (has_ban_period < 0) {
-		struct local_i915_gem_context_param p;
-
-		p.context = 0;
-		p.param = LOCAL_CONTEXT_PARAM_BAN_PERIOD;
-		p.value = 0;
-		p.size = 0;
-
-		has_ban_period = igt_ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0;
-	}
-
-	igt_require(has_ban_period || has_bannable);
-}
-
 int __gem_userptr(int fd, void *ptr, int size, int read_only, uint32_t flags, uint32_t *handle)
 {
 	struct local_i915_gem_userptr userptr;
@@ -1455,7 +1300,7 @@ uint64_t gem_aperture_size(int fd)
 
 		memset(&p, 0, sizeof(p));
 		p.param = 0x3;
-		if (ioctl(fd, LOCAL_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0) {
+		if (__gem_context_get_param(fd, &p) == 0) {
 			aperture_size = p.value;
 		} else {
 			struct drm_i915_gem_get_aperture aperture;
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 76a4e80d..f7752aea 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -36,6 +36,7 @@
 #include <intel_bufmgr.h>
 #include <i915_drm.h>
 
+#include "i915/gem_context.h"
 #include "i915/gem_scheduler.h"
 
 /**
@@ -121,27 +122,6 @@ int gem_munmap(void *ptr, uint64_t size);
 
 int gem_madvise(int fd, uint32_t handle, int state);
 
-uint32_t gem_context_create(int fd);
-void gem_context_destroy(int fd, uint32_t ctx_id);
-int __gem_context_destroy(int fd, uint32_t ctx_id);
-struct local_i915_gem_context_param {
-	uint32_t context;
-	uint32_t size;
-	uint64_t param;
-#define LOCAL_CONTEXT_PARAM_BAN_PERIOD	0x1
-#define LOCAL_CONTEXT_PARAM_NO_ZEROMAP	0x2
-#define LOCAL_CONTEXT_PARAM_GTT_SIZE	0x3
-#define LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE	0x4
-#define LOCAL_CONTEXT_PARAM_BANNABLE	0x5
-	uint64_t value;
-};
-void gem_context_require_bannable(int fd);
-void gem_context_require_param(int fd, uint64_t param);
-void gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
-void gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
-int __gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
-int __gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
-
 #define LOCAL_I915_GEM_USERPTR       0x33
 #define LOCAL_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_USERPTR, struct local_i915_gem_userptr)
 struct local_i915_gem_userptr {
diff --git a/lib/meson.build b/lib/meson.build
index 22811743..f0125a6d 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -2,6 +2,7 @@ lib_headers = [
 	'debug.h',
 	'drmtest.h',
 	'i830_reg.h',
+	'i915/gem_context.h',
 	'i915/gem_scheduler.h',
 	'i915_3d.h',
 	'i915_reg.h',
@@ -49,6 +50,7 @@ lib_headers = [
 
 lib_sources = [
 	'drmtest.c',
+	'i915/gem_context.c',
 	'i915/gem_scheduler.c',
 	'igt_debugfs.c',
 	'igt_aux.c',
-- 
2.13.5

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

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

* [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper
  2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
  2017-10-13 11:00 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
  2017-10-13 11:00 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
@ 2017-10-13 11:00 ` Michał Winiarski
  2017-10-13 11:26   ` Katarzyna Dec
  2017-10-13 11:31   ` Chris Wilson
  2017-10-13 11:24 ` [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Katarzyna Dec
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 14+ messages in thread
From: Michał Winiarski @ 2017-10-13 11:00 UTC (permalink / raw)
  To: intel-gfx

Another example of something that is used across different tests, and
should be moved to lib.

v2: Break the trend of expanding ioctl_wrappers

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
---
 lib/i915/gem_context.c    | 40 +++++++++++++++++++++++++++++++
 lib/i915/gem_context.h    |  6 +++++
 tests/gem_exec_nop.c      | 26 ++++----------------
 tests/gem_exec_schedule.c | 60 ++++++++++++++++-------------------------------
 tests/gem_exec_whisper.c  | 23 ++++--------------
 tests/gem_sync.c          | 27 ++++-----------------
 6 files changed, 78 insertions(+), 104 deletions(-)

diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c
index ba826ae3..6d9edf5e 100644
--- a/lib/i915/gem_context.c
+++ b/lib/i915/gem_context.c
@@ -197,3 +197,43 @@ void gem_context_require_bannable(int fd)
 
 	igt_require(has_ban_period || has_bannable);
 }
+
+#define LOCAL_I915_CONTEXT_PARAM_PRIORITY 0x6
+
+/**
+ * __gem_context_set_priority:
+ * @fd: open i915 drm file descriptor
+ * @ctx_id: i915 context id
+ * @prio: desired context priority
+ *
+ * This function modifies priority property of the context.
+ * It is used by the scheduler to decide on the ordering of requests submitted
+ * to the hardware.
+ *
+ * Returns: An integer equal to zero for success and negative for failure
+ */
+int __gem_context_set_priority(int fd, uint32_t ctx_id, int prio)
+{
+	struct local_i915_gem_context_param p;
+
+	memset(&p, 0, sizeof(p));
+	p.context = ctx_id;
+	p.size = 0;
+	p.param = LOCAL_I915_CONTEXT_PARAM_PRIORITY;
+	p.value = prio;
+
+	return __gem_context_set_param(fd, &p);
+}
+
+/**
+ * gem_context_set_priority:
+ * @fd: open i915 drm file descriptor
+ * @ctx_id: i915 context id
+ * @prio: desired context priority
+ *
+ * Like __gem_context_set_priority(), except we assert on failure.
+ */
+void gem_context_set_priority(int fd, uint32_t ctx_id, int prio)
+{
+	igt_assert(__gem_context_set_priority(fd, ctx_id, prio) == 0);
+}
diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h
index 06b2ca99..a2339c4b 100644
--- a/lib/i915/gem_context.h
+++ b/lib/i915/gem_context.h
@@ -45,4 +45,10 @@ void gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
 int __gem_context_set_param(int fd, struct local_i915_gem_context_param *p);
 int __gem_context_get_param(int fd, struct local_i915_gem_context_param *p);
 
+#define LOCAL_I915_CONTEXT_MAX_USER_PRIORITY	1023
+#define LOCAL_I915_CONTEXT_DEFAULT_PRIORITY	0
+#define LOCAL_I915_CONTEXT_MIN_USER_PRIORITY	-1023
+int __gem_context_set_priority(int fd, uint32_t ctx, int prio);
+void gem_context_set_priority(int fd, uint32_t ctx, int prio);
+
 #endif /* GEM_CONTEXT_H */
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 78f2b1bd..2356f3c4 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -52,9 +52,8 @@
 
 #define ENGINE_FLAGS  (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
 
-#define LOCAL_CONTEXT_PARAM_PRIORITY 6
-#define   MAX_PRIO 1023
-#define   MIN_PRIO -1023
+#define MAX_PRIO LOCAL_I915_CONTEXT_MAX_USER_PRIORITY
+#define MIN_PRIO LOCAL_I915_CONTEXT_MIN_USER_PRIORITY
 
 #define FORKED 1
 #define CHAINED 2
@@ -585,23 +584,6 @@ static void fence_signal(int fd, uint32_t handle,
 	igt_info("Signal %s: %'lu cycles (%'lu signals): %.3fus\n",
 		 ring_name, count, signal, elapsed(&start, &now) * 1e6 / count);
 }
-static int __ctx_set_priority(int fd, uint32_t ctx, int prio)
-{
-	struct local_i915_gem_context_param param;
-
-	memset(&param, 0, sizeof(param));
-	param.context = ctx;
-	param.size = 0;
-	param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
-	param.value = prio;
-
-	return __gem_context_set_param(fd, &param);
-}
-
-static void ctx_set_priority(int fd, uint32_t ctx, int prio)
-{
-	igt_assert_eq(__ctx_set_priority(fd, ctx, prio), 0);
-}
 
 static void preempt(int fd, uint32_t handle,
 		   unsigned ring_id, const char *ring_name)
@@ -615,10 +597,10 @@ static void preempt(int fd, uint32_t handle,
 	gem_require_ring(fd, ring_id);
 
 	ctx[0] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[0], MIN_PRIO);
+	gem_context_set_priority(fd, ctx[0], MIN_PRIO);
 
 	ctx[1] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[1], MAX_PRIO);
+	gem_context_set_priority(fd, ctx[1], MAX_PRIO);
 
 	memset(&obj, 0, sizeof(obj));
 	obj.handle = handle;
diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
index d3df449a..6d3d725e 100644
--- a/tests/gem_exec_schedule.c
+++ b/tests/gem_exec_schedule.c
@@ -33,37 +33,17 @@
 #include "igt_rand.h"
 #include "igt_sysfs.h"
 
-#define LOCAL_CONTEXT_PARAM_PRIORITY 6
-
 #define LO 0
 #define HI 1
 #define NOISE 2
 
-#define MAX_PRIO 1023
-#define MIN_PRIO -1023
+#define MAX_PRIO LOCAL_I915_CONTEXT_MAX_USER_PRIORITY
+#define MIN_PRIO LOCAL_I915_CONTEXT_MIN_USER_PRIORITY
 
 #define BUSY_QLEN 8
 
 IGT_TEST_DESCRIPTION("Check that we can control the order of execution");
 
-static int __ctx_set_priority(int fd, uint32_t ctx, int prio)
-{
-	struct local_i915_gem_context_param param;
-
-	memset(&param, 0, sizeof(param));
-	param.context = ctx;
-	param.size = 0;
-	param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
-	param.value = prio;
-
-	return __gem_context_set_param(fd, &param);
-}
-
-static void ctx_set_priority(int fd, uint32_t ctx, int prio)
-{
-	igt_assert_eq(__ctx_set_priority(fd, ctx, prio), 0);
-}
-
 static void store_dword(int fd, uint32_t ctx, unsigned ring,
 			uint32_t target, uint32_t offset, uint32_t value,
 			uint32_t cork, unsigned write_domain)
@@ -156,7 +136,7 @@ static uint32_t create_highest_priority(int fd)
 	 * priority (and therefore the max user priority), so no context
 	 * can overtake us, and we effectively can form a plug.
 	 */
-	__ctx_set_priority(fd, ctx, MAX_PRIO);
+	__gem_context_set_priority(fd, ctx, MAX_PRIO);
 
 	return ctx;
 }
@@ -245,7 +225,7 @@ static void smoketest(int fd, unsigned ring, unsigned timeout)
 			int prio;
 
 			prio = hars_petruska_f54_1_random_unsafe_max(MAX_PRIO - MIN_PRIO) + MIN_PRIO;
-			ctx_set_priority(fd, ctx, prio);
+			gem_context_set_priority(fd, ctx, prio);
 
 			engine = engines[hars_petruska_f54_1_random_unsafe_max(nengine)];
 			store_dword(fd, ctx, engine, scratch,
@@ -287,10 +267,10 @@ static void reorder(int fd, unsigned ring, unsigned flags)
 	uint32_t ctx[2];
 
 	ctx[LO] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[LO], MIN_PRIO);
+	gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
 
 	ctx[HI] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[HI], flags & EQUAL ? MIN_PRIO : 0);
+	gem_context_set_priority(fd, ctx[HI], flags & EQUAL ? MIN_PRIO : 0);
 
 	scratch = gem_create(fd, 4096);
 	plug(fd, &cork);
@@ -326,13 +306,13 @@ static void promotion(int fd, unsigned ring)
 	uint32_t ctx[3];
 
 	ctx[LO] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[LO], MIN_PRIO);
+	gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
 
 	ctx[HI] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[HI], 0);
+	gem_context_set_priority(fd, ctx[HI], 0);
 
 	ctx[NOISE] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[NOISE], MIN_PRIO/2);
+	gem_context_set_priority(fd, ctx[NOISE], MIN_PRIO/2);
 
 	result = gem_create(fd, 4096);
 	dep = gem_create(fd, 4096);
@@ -385,16 +365,16 @@ static void preempt(int fd, unsigned ring, unsigned flags)
 	uint32_t ctx[2];
 
 	ctx[LO] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[LO], MIN_PRIO);
+	gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
 
 	ctx[HI] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[HI], MAX_PRIO);
+	gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
 
 	for (int n = 0; n < 16; n++) {
 		if (flags & NEW_CTX) {
 			gem_context_destroy(fd, ctx[LO]);
 			ctx[LO] = gem_context_create(fd);
-			ctx_set_priority(fd, ctx[LO], MIN_PRIO);
+			gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
 		}
 		spin[n] = __igt_spin_batch_new(fd, ctx[LO], ring, 0);
 		igt_debug("spin[%d].handle=%d\n", n, spin[n]->handle);
@@ -436,12 +416,12 @@ static void preempt_other(int fd, unsigned ring)
 	 */
 
 	ctx[LO] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[LO], MIN_PRIO);
+	gem_context_set_priority(fd, ctx[LO], MIN_PRIO);
 
 	ctx[NOISE] = gem_context_create(fd);
 
 	ctx[HI] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[HI], MAX_PRIO);
+	gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
 
 	n = 0;
 	for_each_engine(fd, other) {
@@ -496,7 +476,7 @@ static void preempt_self(int fd, unsigned ring)
 	ctx[HI] = gem_context_create(fd);
 
 	n = 0;
-	ctx_set_priority(fd, ctx[HI], MIN_PRIO);
+	gem_context_set_priority(fd, ctx[HI], MIN_PRIO);
 	for_each_engine(fd, other) {
 		spin[n] = __igt_spin_batch_new(fd, ctx[NOISE], other, 0);
 		store_dword(fd, ctx[HI], other,
@@ -504,7 +484,7 @@ static void preempt_self(int fd, unsigned ring)
 			    0, I915_GEM_DOMAIN_RENDER);
 		n++;
 	}
-	ctx_set_priority(fd, ctx[HI], MAX_PRIO);
+	gem_context_set_priority(fd, ctx[HI], MAX_PRIO);
 	store_dword(fd, ctx[HI], ring,
 		    result, (n + 1)*sizeof(uint32_t), n + 1,
 		    0, I915_GEM_DOMAIN_RENDER);
@@ -542,7 +522,7 @@ static void deep(int fd, unsigned ring)
 	ctx = malloc(sizeof(*ctx) * nctx);
 	for (int n = 0; n < nctx; n++) {
 		ctx[n] = gem_context_create(fd);
-		ctx_set_priority(fd, ctx[n], MAX_PRIO - nctx + n);
+		gem_context_set_priority(fd, ctx[n], MAX_PRIO - nctx + n);
 	}
 
 	result = gem_create(fd, size);
@@ -784,7 +764,7 @@ static void reorder_wide(int fd, unsigned ring)
 		uint32_t *batch;
 
 		execbuf.rsvd1 = gem_context_create(fd);
-		ctx_set_priority(fd, execbuf.rsvd1, n);
+		gem_context_set_priority(fd, execbuf.rsvd1, n);
 
 		obj[2].handle = gem_create(fd, sz);
 		batch = gem_mmap__gtt(fd, obj[2].handle, sz, PROT_WRITE);
@@ -878,7 +858,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 	execbuf.buffer_count = 1;
 	execbuf.flags = engine;
 	execbuf.rsvd1 = gem_context_create(fd);
-	ctx_set_priority(fd, execbuf.rsvd1, MIN_PRIO);
+	gem_context_set_priority(fd, execbuf.rsvd1, MIN_PRIO);
 
 	gem_execbuf(fd, &execbuf);
 	gem_sync(fd, obj[1].handle);
@@ -926,7 +906,7 @@ static void test_pi_ringfull(int fd, unsigned int engine)
 
 		igt_debug("Creating HP context\n");
 		execbuf.rsvd1 = gem_context_create(fd);
-		ctx_set_priority(fd, execbuf.rsvd1, MAX_PRIO);
+		gem_context_set_priority(fd, execbuf.rsvd1, MAX_PRIO);
 
 		kill(getppid(), SIGALRM);
 		sched_yield();
diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c
index da5f26aa..18c7ea5b 100644
--- a/tests/gem_exec_whisper.c
+++ b/tests/gem_exec_whisper.c
@@ -191,25 +191,10 @@ static void fini_hang(struct hang *h)
 	close(h->fd);
 }
 
-#define LOCAL_CONTEXT_PARAM_PRIORITY 6
-
-static int __ctx_set_priority(int fd, uint32_t ctx, int prio)
-{
-	struct local_i915_gem_context_param param;
-
-	memset(&param, 0, sizeof(param));
-	param.context = ctx;
-	param.size = 0;
-	param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
-	param.value = prio;
-
-	return __gem_context_set_param(fd, &param);
-}
-
-static void ctx_set_priority(int fd, uint32_t ctx)
+static void ctx_set_random_priority(int fd, uint32_t ctx)
 {
 	int prio = hars_petruska_f54_1_random_unsafe_max(1024) - 512;
-	igt_assert_eq(__ctx_set_priority(fd, ctx, prio), 0);
+	gem_context_set_priority(fd, ctx, prio);
 };
 
 static void whisper(int fd, unsigned engine, unsigned flags)
@@ -430,7 +415,7 @@ static void whisper(int fd, unsigned engine, unsigned flags)
 							gem_open(this_fd,
 									gem_flink(fd, handle[1]));
 						if (flags & PRIORITY)
-							ctx_set_priority(this_fd, 0);
+							ctx_set_random_priority(this_fd, 0);
 					}
 
 					if (!(flags & CHAIN)) {
@@ -440,7 +425,7 @@ static void whisper(int fd, unsigned engine, unsigned flags)
 					if (flags & CONTEXTS) {
 						execbuf.rsvd1 = contexts[rand() % 64];
 						if (flags & PRIORITY)
-							ctx_set_priority(this_fd, execbuf.rsvd1);
+							ctx_set_random_priority(this_fd, execbuf.rsvd1);
 					}
 
 					gem_execbuf(this_fd, &execbuf);
diff --git a/tests/gem_sync.c b/tests/gem_sync.c
index fccc0c0e..e558682a 100644
--- a/tests/gem_sync.c
+++ b/tests/gem_sync.c
@@ -33,9 +33,8 @@
 #define LOCAL_I915_EXEC_BSD_SHIFT      (13)
 #define LOCAL_I915_EXEC_BSD_MASK       (3 << LOCAL_I915_EXEC_BSD_SHIFT)
 
-#define LOCAL_CONTEXT_PARAM_PRIORITY 6
-#define   MAX_PRIO 1023
-#define   MIN_PRIO -1023
+#define MAX_PRIO LOCAL_I915_CONTEXT_MAX_USER_PRIORITY
+#define MIN_PRIO LOCAL_I915_CONTEXT_MIN_USER_PRIORITY
 
 #define ENGINE_MASK  (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
 
@@ -690,24 +689,6 @@ store_all(int fd, int num_children, int timeout)
 	igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
 }
 
-static int __ctx_set_priority(int fd, uint32_t ctx, int prio)
-{
-	struct local_i915_gem_context_param param;
-
-	memset(&param, 0, sizeof(param));
-	param.context = ctx;
-	param.size = 0;
-	param.param = LOCAL_CONTEXT_PARAM_PRIORITY;
-	param.value = prio;
-
-	return __gem_context_set_param(fd, &param);
-}
-
-static void ctx_set_priority(int fd, uint32_t ctx, int prio)
-{
-	igt_assert_eq(__ctx_set_priority(fd, ctx, prio), 0);
-}
-
 static void
 preempt(int fd, unsigned ring, int num_children, int timeout)
 {
@@ -746,10 +727,10 @@ preempt(int fd, unsigned ring, int num_children, int timeout)
 	}
 
 	ctx[0] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[0], MIN_PRIO);
+	gem_context_set_priority(fd, ctx[0], MIN_PRIO);
 
 	ctx[1] = gem_context_create(fd);
-	ctx_set_priority(fd, ctx[1], MAX_PRIO);
+	gem_context_set_priority(fd, ctx[1], MAX_PRIO);
 
 	intel_detect_and_clear_missed_interrupts(fd);
 	igt_fork(child, num_children) {
-- 
2.13.5

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

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

* Re: [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method
  2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
                   ` (2 preceding siblings ...)
  2017-10-13 11:00 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
@ 2017-10-13 11:24 ` Katarzyna Dec
  2017-10-13 11:26 ` ✓ Fi.CI.BAT: success for series starting with [1/4] " Patchwork
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 14+ messages in thread
From: Katarzyna Dec @ 2017-10-13 11:24 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

On Fri, Oct 13, 2017 at 01:00:17PM +0200, Michał Winiarski wrote:
> Couple of tests are using either determining submission method, or
> pretty printing. Let's move those to helpers in lib.
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
 
 Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> ---
Cheers,
Kasia
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper
  2017-10-13 11:00 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
@ 2017-10-13 11:26   ` Katarzyna Dec
  2017-10-13 11:31   ` Chris Wilson
  1 sibling, 0 replies; 14+ messages in thread
From: Katarzyna Dec @ 2017-10-13 11:26 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

On Fri, Oct 13, 2017 at 01:00:20PM +0200, Michał Winiarski wrote:
> Another example of something that is used across different tests, and
> should be moved to lib.
> 
> v2: Break the trend of expanding ioctl_wrappers
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>

Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>

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

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

* ✓ Fi.CI.BAT: success for series starting with [1/4] lib: Extract helpers for determining submission method
  2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
                   ` (3 preceding siblings ...)
  2017-10-13 11:24 ` [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Katarzyna Dec
@ 2017-10-13 11:26 ` Patchwork
  2017-10-13 11:26 ` [PATCH i-g-t 1/4] " Chris Wilson
  2017-10-13 13:54 ` ✓ Fi.CI.IGT: success for series starting with [1/4] " Patchwork
  6 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2017-10-13 11:26 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/4] lib: Extract helpers for determining submission method
URL   : https://patchwork.freedesktop.org/series/31904/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
58616272b23efce1e62a3ee0d37e13de6ffc012f igt/gem_eio: Check hang/eio recovery during suspend

with latest DRM-Tip kernel build CI_DRM_3228
b2c76c5c6dce drm-tip: 2017y-10m-13d-09h-16m-12s UTC integration manifest

No testlist changes.

Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-c:
                pass       -> INCOMPLETE (fi-kbl-r) fdo#102846

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

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:456s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:468s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:392s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:572s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:287s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:528s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:524s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:542s
fi-byt-n2820     total:289  pass:249  dwarn:1   dfail:0   fail:0   skip:39  time:528s
fi-cfl-s         total:289  pass:253  dwarn:4   dfail:0   fail:0   skip:32  time:564s
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:639s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:438s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:275s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:601s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:444s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:464s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:498s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:488s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:504s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:497s
fi-kbl-r         total:247  pass:222  dwarn:0   dfail:0   fail:0   skip:24 
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:665s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:481s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:660s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:541s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:506s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:483s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:593s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:435s

== Logs ==

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

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

* Re: [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method
  2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
                   ` (4 preceding siblings ...)
  2017-10-13 11:26 ` ✓ Fi.CI.BAT: success for series starting with [1/4] " Patchwork
@ 2017-10-13 11:26 ` Chris Wilson
  2017-10-16  8:40   ` Arkadiusz Hiler
  2017-10-13 13:54 ` ✓ Fi.CI.IGT: success for series starting with [1/4] " Patchwork
  6 siblings, 1 reply; 14+ messages in thread
From: Chris Wilson @ 2017-10-13 11:26 UTC (permalink / raw)
  To: Michał Winiarski, intel-gfx

Quoting Michał Winiarski (2017-10-13 12:00:17)
> Couple of tests are using either determining submission method, or
> pretty printing. Let's move those to helpers in lib.
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> ---
>  lib/igt_aux.c               | 18 +++++++++++++
>  lib/igt_aux.h               |  2 ++
>  lib/igt_gt.c                | 63 +++++++++++++++++++++++++++++++++++++++++++++
>  lib/igt_gt.h                |  7 +++++
>  tests/gem_ctx_thrash.c      | 19 ++------------
>  tests/gem_eio.c             | 45 ++------------------------------
>  tests/gem_exec_await.c      | 39 ++--------------------------
>  tests/gem_exec_fence.c      | 41 +++--------------------------
>  tests/gem_exec_latency.c    | 31 +---------------------
>  tests/gem_exec_nop.c        | 31 +---------------------
>  tests/gem_exec_schedule.c   | 40 ++--------------------------
>  tests/gem_exec_whisper.c    | 31 +---------------------
>  tests/gem_read_read_speed.c | 17 +-----------
>  tests/gem_sync.c            | 31 +---------------------
>  14 files changed, 106 insertions(+), 309 deletions(-)
> 
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index fa6594c3..0c77f85f 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -1455,6 +1455,24 @@ igt_show_stat(proc_t *info, int *state, const char *fn)
>         ++*state;
>  }
>  
> +void igt_show_submission_method(int fd)

Still igt when it appears to be gem specific.

I know I'm just as guilty of overusing the igt prefix, but I really do
think we should try to claw it back so that we know the platform
agnostic test tooling from the rest.

> +unsigned gem_submission_method(int fd)
> +{
> +       unsigned flags = 0;
> +       bool active;
> +       int dir;
> +
> +       dir = igt_sysfs_open_parameters(fd);
> +       if (dir < 0)
> +               return 0;

Ok, we really need to kill of the modparam probing here and get this out
of say PARAM_HAS_EXECBUF2 (by expanding that to this capability mask).

Because in about 4 weeks, we're going to lose some more of these
modparams... And planning for future expansion is a bonus.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context
  2017-10-13 11:00 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
@ 2017-10-13 11:27   ` Katarzyna Dec
  2017-10-13 11:30   ` Chris Wilson
  1 sibling, 0 replies; 14+ messages in thread
From: Katarzyna Dec @ 2017-10-13 11:27 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

Reviewed-by: 	Katarzyna Dec <katarzyna.dec@intel.com>,

Cheers,
Kasia

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

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

* Re: [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities
  2017-10-13 11:00 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
@ 2017-10-13 11:28   ` Katarzyna Dec
  0 siblings, 0 replies; 14+ messages in thread
From: Katarzyna Dec @ 2017-10-13 11:28 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>

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

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

* Re: [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context
  2017-10-13 11:00 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
  2017-10-13 11:27   ` Katarzyna Dec
@ 2017-10-13 11:30   ` Chris Wilson
  1 sibling, 0 replies; 14+ messages in thread
From: Chris Wilson @ 2017-10-13 11:30 UTC (permalink / raw)
  To: Michał Winiarski, intel-gfx

Quoting Michał Winiarski (2017-10-13 12:00:19)
> We'd like to make ioctl_wrappers a bit thinner, and we plan to add new
> helpers in the following patch. Let's move context related helpers before
> adding more content.
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>

Only that one quibble for igt_show_gem_scheduler_capability() or
whatever it was that it shouldn't be, series is
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper
  2017-10-13 11:00 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
  2017-10-13 11:26   ` Katarzyna Dec
@ 2017-10-13 11:31   ` Chris Wilson
  1 sibling, 0 replies; 14+ messages in thread
From: Chris Wilson @ 2017-10-13 11:31 UTC (permalink / raw)
  To: Michał Winiarski, intel-gfx

Quoting Michał Winiarski (2017-10-13 12:00:20)
> Another example of something that is used across different tests, and
> should be moved to lib.
> 
> v2: Break the trend of expanding ioctl_wrappers
> 
> Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>

Sneaky 4/4 is ok as well, so
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.IGT: success for series starting with [1/4] lib: Extract helpers for determining submission method
  2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
                   ` (5 preceding siblings ...)
  2017-10-13 11:26 ` [PATCH i-g-t 1/4] " Chris Wilson
@ 2017-10-13 13:54 ` Patchwork
  6 siblings, 0 replies; 14+ messages in thread
From: Patchwork @ 2017-10-13 13:54 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/4] lib: Extract helpers for determining submission method
URL   : https://patchwork.freedesktop.org/series/31904/
State : success

== Summary ==

Test kms_setmode:
        Subgroup basic:
                fail       -> PASS       (shard-hsw) fdo#99912
Test kms_atomic_transition:
        Subgroup plane-toggle-modeset-transition:
                dmesg-warn -> PASS       (shard-hsw) fdo#102614

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

shard-hsw        total:2553 pass:1441 dwarn:1   dfail:0   fail:8   skip:1103 time:9665s

== Logs ==

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

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

* Re: [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method
  2017-10-13 11:26 ` [PATCH i-g-t 1/4] " Chris Wilson
@ 2017-10-16  8:40   ` Arkadiusz Hiler
  0 siblings, 0 replies; 14+ messages in thread
From: Arkadiusz Hiler @ 2017-10-16  8:40 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

On Fri, Oct 13, 2017 at 12:26:59PM +0100, Chris Wilson wrote:
> Quoting Michał Winiarski (2017-10-13 12:00:17)
> > Couple of tests are using either determining submission method, or
> > pretty printing. Let's move those to helpers in lib.
> > 
> > Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
> > Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Katarzyna Dec <katarzyna.dec@intel.com>
> > Cc: Petri Latvala <petri.latvala@intel.com>
> > ---
> >  lib/igt_aux.c               | 18 +++++++++++++
> >  lib/igt_aux.h               |  2 ++
> >  lib/igt_gt.c                | 63 +++++++++++++++++++++++++++++++++++++++++++++
> >  lib/igt_gt.h                |  7 +++++
> >  tests/gem_ctx_thrash.c      | 19 ++------------
> >  tests/gem_eio.c             | 45 ++------------------------------
> >  tests/gem_exec_await.c      | 39 ++--------------------------
> >  tests/gem_exec_fence.c      | 41 +++--------------------------
> >  tests/gem_exec_latency.c    | 31 +---------------------
> >  tests/gem_exec_nop.c        | 31 +---------------------
> >  tests/gem_exec_schedule.c   | 40 ++--------------------------
> >  tests/gem_exec_whisper.c    | 31 +---------------------
> >  tests/gem_read_read_speed.c | 17 +-----------
> >  tests/gem_sync.c            | 31 +---------------------
> >  14 files changed, 106 insertions(+), 309 deletions(-)
> > 
> > diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> > index fa6594c3..0c77f85f 100644
> > --- a/lib/igt_aux.c
> > +++ b/lib/igt_aux.c
> > @@ -1455,6 +1455,24 @@ igt_show_stat(proc_t *info, int *state, const char *fn)
> >         ++*state;
> >  }
> >  
> > +void igt_show_submission_method(int fd)
> 
> Still igt when it appears to be gem specific.
> 
> I know I'm just as guilty of overusing the igt prefix, but I really do
> think we should try to claw it back so that we know the platform
> agnostic test tooling from the rest.

That's a valid point. gem_ sounds about right, especially for this one.

Seems like a bigger renaming effort and we may need to contain those in
a separate igt_gem.{c,h} files (like one we have for vgem_ stuff).

But generally,
Acked-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>

> > +unsigned gem_submission_method(int fd)
> > +{
> > +       unsigned flags = 0;
> > +       bool active;
> > +       int dir;
> > +
> > +       dir = igt_sysfs_open_parameters(fd);
> > +       if (dir < 0)
> > +               return 0;
> 
> Ok, we really need to kill of the modparam probing here and get this out
> of say PARAM_HAS_EXECBUF2 (by expanding that to this capability mask).
> 
> Because in about 4 weeks, we're going to lose some more of these
> modparams... And planning for future expansion is a bonus.
> -Chris

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

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

end of thread, other threads:[~2017-10-16  8:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-13 11:00 [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Michał Winiarski
2017-10-13 11:00 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
2017-10-13 11:28   ` Katarzyna Dec
2017-10-13 11:00 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
2017-10-13 11:27   ` Katarzyna Dec
2017-10-13 11:30   ` Chris Wilson
2017-10-13 11:00 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
2017-10-13 11:26   ` Katarzyna Dec
2017-10-13 11:31   ` Chris Wilson
2017-10-13 11:24 ` [PATCH i-g-t 1/4] lib: Extract helpers for determining submission method Katarzyna Dec
2017-10-13 11:26 ` ✓ Fi.CI.BAT: success for series starting with [1/4] " Patchwork
2017-10-13 11:26 ` [PATCH i-g-t 1/4] " Chris Wilson
2017-10-16  8:40   ` Arkadiusz Hiler
2017-10-13 13:54 ` ✓ Fi.CI.IGT: success for series starting with [1/4] " 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.