All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t 1/3] lib: Extract helpers for determining submission method
@ 2017-10-11  9:15 Michał Winiarski
  2017-10-11  9:15 ` [PATCH i-g-t 2/3] lib: Extract helpers for determining scheduler capabilities Michał Winiarski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michał Winiarski @ 2017-10-11  9:15 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 608b2dfd..59d232ec 100644
--- a/tests/gem_eio.c
+++ b/tests/gem_eio.c
@@ -366,45 +366,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
@@ -416,8 +377,6 @@ exit_handler(int sig)
 
 igt_main
 {
-	unsigned int caps = 0;
-
 	igt_skip_on_simulation();
 
 	igt_fixture {
@@ -427,7 +386,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);
 	}
@@ -451,7 +410,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] 6+ messages in thread

* [PATCH i-g-t 2/3] lib: Extract helpers for determining scheduler capabilities
  2017-10-11  9:15 [PATCH i-g-t 1/3] lib: Extract helpers for determining submission method Michał Winiarski
@ 2017-10-11  9:15 ` Michał Winiarski
  2017-10-11  9:25   ` Chris Wilson
  2017-10-11  9:15 ` [PATCH i-g-t 3/3] lib: Extract context priority setparam to a helper Michał Winiarski
  2017-10-11 11:25 ` ✗ Fi.CI.BAT: failure for series starting with [1/3] lib: Extract helpers for determining submission method Patchwork
  2 siblings, 1 reply; 6+ messages in thread
From: Michał Winiarski @ 2017-10-11  9:15 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.

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             | 14 ++++++++++
 lib/igt_aux.h             |  1 +
 lib/ioctl_wrappers.c      | 65 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/ioctl_wrappers.h      |  8 ++++++
 tests/gem_exec_nop.c      | 34 +++----------------------
 tests/gem_exec_schedule.c | 47 +++++-----------------------------
 tests/gem_exec_whisper.c  | 22 ++--------------
 tests/gem_sync.c          | 34 +++----------------------
 8 files changed, 103 insertions(+), 122 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 0c77f85f..80ce9624 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -1473,6 +1473,20 @@ void igt_show_submission_method(int fd)
 		 flags & GEM_SUBMISSION_SEMAPHORES ? ", with semaphores" : "");
 }
 
+void igt_show_scheduler_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");
+}
+
 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 b79c8e5c..36b435ba 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -279,6 +279,7 @@ void igt_unlock_mem(void);
 })
 
 void igt_show_submission_method(int fd);
+void igt_show_scheduler_capability(int fd);
 
 struct igt_mean;
 void igt_start_siglatency(int sig); /* 0 => SIGRTMIN (default) */
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 87511fc6..b9f81d1b 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1668,6 +1668,71 @@ void gem_require_mocs_registers(int fd)
 	igt_require(gem_has_mocs_registers(fd));
 }
 
+#define LOCAL_I915_PARAM_HAS_SCHEDULER		41
+
+/**
+ * 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_has_scheduler(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_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_has_preemption(int fd)
+{
+	return gem_scheduler_capability(fd) &
+	       LOCAL_I915_SCHEDULER_CAP_PREEMPTION;
+}
+
 /* prime */
 
 /**
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 1663b7f8..3531c478 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -187,6 +187,14 @@ void gem_require_ring(int fd, unsigned ring);
 bool gem_has_mocs_registers(int fd);
 void gem_require_mocs_registers(int fd);
 
+#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_has_scheduler(int fd);
+bool gem_has_ctx_priority(int fd);
+bool gem_has_preemption(int fd);
+
 /* prime */
 struct local_dma_buf_sync {
 	uint64_t flags;
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 6d62e94a..e7e9df2d 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);
+		igt_show_scheduler_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_has_ctx_priority(device));
+			igt_require(gem_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..8dda7984 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);
+		igt_show_scheduler_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_has_scheduler(fd));
+			igt_require(gem_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_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_has_scheduler(fd));
+			igt_require(gem_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_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..80204cee 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_has_scheduler(fd));
+		igt_require(gem_has_ctx_priority(fd));
 	}
 
 	debugfs = igt_debugfs_dir(fd);
diff --git a/tests/gem_sync.c b/tests/gem_sync.c
index 754c3202..e0b53905 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);
+		igt_show_scheduler_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_has_ctx_priority(fd));
+			igt_require(gem_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] 6+ messages in thread

* [PATCH i-g-t 3/3] lib: Extract context priority setparam to a helper
  2017-10-11  9:15 [PATCH i-g-t 1/3] lib: Extract helpers for determining submission method Michał Winiarski
  2017-10-11  9:15 ` [PATCH i-g-t 2/3] lib: Extract helpers for determining scheduler capabilities Michał Winiarski
@ 2017-10-11  9:15 ` Michał Winiarski
  2017-10-11  9:31   ` Chris Wilson
  2017-10-11 11:25 ` ✗ Fi.CI.BAT: failure for series starting with [1/3] lib: Extract helpers for determining submission method Patchwork
  2 siblings, 1 reply; 6+ messages in thread
From: Michał Winiarski @ 2017-10-11  9:15 UTC (permalink / raw)
  To: intel-gfx

Another example of something that is used across different tests, and
should be moved to 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/ioctl_wrappers.c      | 40 +++++++++++++++++++++++++++++++
 lib/ioctl_wrappers.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/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index b9f81d1b..0ba36151 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1049,6 +1049,46 @@ 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);
+}
+
 int __gem_userptr(int fd, void *ptr, int size, int read_only, uint32_t flags, uint32_t *handle)
 {
 	struct local_i915_gem_userptr userptr;
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 3531c478..d72c8f5c 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -195,6 +195,12 @@ bool gem_has_scheduler(int fd);
 bool gem_has_ctx_priority(int fd);
 bool gem_has_preemption(int fd);
 
+#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);
+
 /* prime */
 struct local_dma_buf_sync {
 	uint64_t flags;
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index e7e9df2d..368f0e05 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 8dda7984..521807b4 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 80204cee..2df2d584 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 e0b53905..9c21ee54 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] 6+ messages in thread

* Re: [PATCH i-g-t 2/3] lib: Extract helpers for determining scheduler capabilities
  2017-10-11  9:15 ` [PATCH i-g-t 2/3] lib: Extract helpers for determining scheduler capabilities Michał Winiarski
@ 2017-10-11  9:25   ` Chris Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2017-10-11  9:25 UTC (permalink / raw)
  To: Michał Winiarski, intel-gfx

Quoting Michał Winiarski (2017-10-11 10:15:25)
> 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.
> 
> 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>

Bah humbug.

> ---
>  lib/igt_aux.c             | 14 ++++++++++
>  lib/igt_aux.h             |  1 +
>  lib/ioctl_wrappers.c      | 65 +++++++++++++++++++++++++++++++++++++++++++++++
>  lib/ioctl_wrappers.h      |  8 ++++++

If we have a choice, not here.

lib/i915/gem_scheduler.c ?

>  tests/gem_exec_nop.c      | 34 +++----------------------
>  tests/gem_exec_schedule.c | 47 +++++-----------------------------
>  tests/gem_exec_whisper.c  | 22 ++--------------
>  tests/gem_sync.c          | 34 +++----------------------
>  8 files changed, 103 insertions(+), 122 deletions(-)

> @@ -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);
> +               igt_show_scheduler_capability(device);

Is it really generic? My suggestion would be
gem_scheduler_show_capability(), or
gem_show_scheduler_capability() if we stick to the gem_has_*() format.

>  
>                 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_has_ctx_priority(device));
> +                       igt_require(gem_has_preemption(device));

gem_has_scheduler_preemption() ? Looking to keep some sort of verbose
oop-in-C, and room for future expansion.

(And we need to kill all of the gem == i915 at some point. And classes.)
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t 3/3] lib: Extract context priority setparam to a helper
  2017-10-11  9:15 ` [PATCH i-g-t 3/3] lib: Extract context priority setparam to a helper Michał Winiarski
@ 2017-10-11  9:31   ` Chris Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2017-10-11  9:31 UTC (permalink / raw)
  To: Michał Winiarski, intel-gfx

Quoting Michał Winiarski (2017-10-11 10:15:26)
> Another example of something that is used across different tests, and
> should be moved to 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>

Happier with the gem_context naming, but

> ---
>  lib/ioctl_wrappers.c      | 40 +++++++++++++++++++++++++++++++
>  lib/ioctl_wrappers.h      |  6 +++++

Let's break this habit if we can.

(Happier, but there's still the i915 == gem overshadowing us.)
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.BAT: failure for series starting with [1/3] lib: Extract helpers for determining submission method
  2017-10-11  9:15 [PATCH i-g-t 1/3] lib: Extract helpers for determining submission method Michał Winiarski
  2017-10-11  9:15 ` [PATCH i-g-t 2/3] lib: Extract helpers for determining scheduler capabilities Michał Winiarski
  2017-10-11  9:15 ` [PATCH i-g-t 3/3] lib: Extract context priority setparam to a helper Michał Winiarski
@ 2017-10-11 11:25 ` Patchwork
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2017-10-11 11:25 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/3] lib: Extract helpers for determining submission method
URL   : https://patchwork.freedesktop.org/series/31726/
State : failure

== Summary ==

IGT patchset tested on top of latest successful build
136100c2f00b590bc9485100cce012282c1217cf igt/syncobj_wait: Don't close the timeline early in wait_snapshot

with latest DRM-Tip kernel build CI_DRM_3211
2dcc40d169e6 drm-tip: 2017y-10m-11d-08h-54m-27s UTC integration manifest

No testlist changes.

Test kms_frontbuffer_tracking:
        Subgroup basic:
                pass       -> INCOMPLETE (fi-cfl-s)

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:462s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:470s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:397s
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:288s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:526s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:530s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:538s
fi-byt-n2820     total:289  pass:249  dwarn:1   dfail:0   fail:0   skip:39  time:530s
fi-cfl-s         total:225  pass:198  dwarn:1   dfail:0   fail:0   skip:25 
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:633s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:438s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:608s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:439s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:472s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:510s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:475s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:504s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:587s
fi-kbl-7567u     total:289  pass:265  dwarn:4   dfail:0   fail:0   skip:20  time:489s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:591s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:674s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:480s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:658s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:533s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:515s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:478s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:585s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:440s

== Logs ==

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

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

end of thread, other threads:[~2017-10-11 11:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-11  9:15 [PATCH i-g-t 1/3] lib: Extract helpers for determining submission method Michał Winiarski
2017-10-11  9:15 ` [PATCH i-g-t 2/3] lib: Extract helpers for determining scheduler capabilities Michał Winiarski
2017-10-11  9:25   ` Chris Wilson
2017-10-11  9:15 ` [PATCH i-g-t 3/3] lib: Extract context priority setparam to a helper Michał Winiarski
2017-10-11  9:31   ` Chris Wilson
2017-10-11 11:25 ` ✗ Fi.CI.BAT: failure for series starting with [1/3] lib: Extract helpers for determining submission method 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.