All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method
@ 2017-10-16  9:05 Michał Winiarski
  2017-10-16  9:05 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Michał Winiarski @ 2017-10-16  9:05 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.

v2: s/igt_show/gem_show

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: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
Acked-by: Arkadiusz Hiler <arkadiusz.hiler@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..cacc8f98 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 gem_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..1fdb2259 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -278,6 +278,8 @@ void igt_unlock_mem(void);
 	ret_;								\
 })
 
+void gem_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..c30212f4 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);
+		gem_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..326783a1 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);
+		gem_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..ae3760c9 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);
+		gem_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..a942c205 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);
+		gem_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..feb89ee3 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);
+		gem_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..f5c849d0 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);
+		gem_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..e7f7b1f1 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);
+		gem_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..bbd8e54e 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));
+		gem_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..f0c5d76f 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);
+		gem_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] 11+ messages in thread

* [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities
  2017-10-16  9:05 [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method Michał Winiarski
@ 2017-10-16  9:05 ` Michał Winiarski
  2017-10-16  9:05 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Michał Winiarski @ 2017-10-16  9:05 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>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
Acked-by: Arkadiusz Hiler <arkadiusz.hiler@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 feb89ee3..8fd31e83 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);
 		gem_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 f5c849d0..66e24244 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);
 		gem_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 e7f7b1f1..5ff8f396 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 f0c5d76f..fda70344 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);
 		gem_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] 11+ messages in thread

* [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context
  2017-10-16  9:05 [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method Michał Winiarski
  2017-10-16  9:05 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
@ 2017-10-16  9:05 ` Michał Winiarski
  2017-10-16  9:05 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Michał Winiarski @ 2017-10-16  9:05 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>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
Acked-by: Arkadiusz Hiler <arkadiusz.hiler@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] 11+ messages in thread

* [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper
  2017-10-16  9:05 [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method Michał Winiarski
  2017-10-16  9:05 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
  2017-10-16  9:05 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
@ 2017-10-16  9:05 ` Michał Winiarski
  2017-10-16 15:02 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/4] lib: Extract helpers for determining submission method Patchwork
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Michał Winiarski @ 2017-10-16  9:05 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>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
Acked-by: Arkadiusz Hiler <arkadiusz.hiler@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 8fd31e83..37cddd8c 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 66e24244..baf1112d 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 5ff8f396..dfa8a3b4 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 fda70344..6ead76b8 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] 11+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [v2,1/4] lib: Extract helpers for determining submission method
  2017-10-16  9:05 [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method Michał Winiarski
                   ` (2 preceding siblings ...)
  2017-10-16  9:05 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
@ 2017-10-16 15:02 ` Patchwork
  2017-10-17  2:08 ` ✗ Fi.CI.IGT: failure " Patchwork
  2017-10-17 23:01 ` [PATCH i-g-t v2 1/4] " Chris Wilson
  5 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2017-10-16 15:02 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

== Series Details ==

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

== Summary ==

IGT patchset tested on top of latest successful build
d4d976de7e022cb56a2dbfe96c4ab10549e24acc igt/gem_mocs_settings: Skip non-existent engines

with latest DRM-Tip kernel build CI_DRM_3242
d6b500e96a1b drm-tip: 2017y-10m-16d-13h-20m-58s UTC integration manifest

No testlist changes.

Test chamelium:
        Subgroup dp-crc-fast:
                pass       -> FAIL       (fi-kbl-7500u) fdo#102514
Test debugfs_test:
        Subgroup read_all_entries:
                pass       -> DMESG-WARN (fi-kbl-7500u) fdo#103285
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-byt-n2820) fdo#101705

fdo#102514 https://bugs.freedesktop.org/show_bug.cgi?id=102514
fdo#103285 https://bugs.freedesktop.org/show_bug.cgi?id=103285
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:455s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:479s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:391s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:571s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:286s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:527s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:526s
fi-byt-j1900     total:289  pass:253  dwarn:1   dfail:0   fail:0   skip:35  time:550s
fi-byt-n2820     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:528s
fi-cfl-s         total:289  pass:253  dwarn:4   dfail:0   fail:0   skip:32  time:567s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:434s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:278s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:607s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:441s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:460s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:507s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:478s
fi-kbl-7500u     total:289  pass:262  dwarn:2   dfail:0   fail:1   skip:24  time:493s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:585s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:491s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:596s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:654s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:473s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:661s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:534s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:512s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:477s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:591s
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:431s

== Logs ==

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

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

* ✗ Fi.CI.IGT: failure for series starting with [v2,1/4] lib: Extract helpers for determining submission method
  2017-10-16  9:05 [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method Michał Winiarski
                   ` (3 preceding siblings ...)
  2017-10-16 15:02 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/4] lib: Extract helpers for determining submission method Patchwork
@ 2017-10-17  2:08 ` Patchwork
  2017-10-17 23:01 ` [PATCH i-g-t v2 1/4] " Chris Wilson
  5 siblings, 0 replies; 11+ messages in thread
From: Patchwork @ 2017-10-17  2:08 UTC (permalink / raw)
  To: Michał Winiarski; +Cc: intel-gfx

== Series Details ==

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

== Summary ==

Test kms_pipe_crc_basic:
        Subgroup read-crc-pipe-C-frame-sequence:
                pass       -> FAIL       (shard-hsw)
Test kms_setmode:
        Subgroup basic:
                pass       -> FAIL       (shard-hsw) fdo#99912
Test kms_flip:
        Subgroup dpms-vs-vblank-race-interruptible:
                fail       -> PASS       (shard-hsw) fdo#103060

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

shard-hsw        total:2553 pass:1440 dwarn:0   dfail:0   fail:10  skip:1103 time:9685s

== Logs ==

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

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

* Re: [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method
  2017-10-16  9:05 [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method Michał Winiarski
                   ` (4 preceding siblings ...)
  2017-10-17  2:08 ` ✗ Fi.CI.IGT: failure " Patchwork
@ 2017-10-17 23:01 ` Chris Wilson
  2017-10-17 23:05   ` Chris Wilson
  5 siblings, 1 reply; 11+ messages in thread
From: Chris Wilson @ 2017-10-17 23:01 UTC (permalink / raw)
  To: Michał Winiarski, intel-gfx

Quoting Michał Winiarski (2017-10-16 10:05:14)
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index fa6594c3..cacc8f98 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 gem_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" : "");
> +}

You managed to hide it inside an #ifdef HAVE_PROCPS, or how to confuse
me with weird build failures.

Don't we have a lib/i915/gem_scheduler.c for this now?
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method
  2017-10-17 23:01 ` [PATCH i-g-t v2 1/4] " Chris Wilson
@ 2017-10-17 23:05   ` Chris Wilson
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Wilson @ 2017-10-17 23:05 UTC (permalink / raw)
  To: Michał Winiarski, intel-gfx

Quoting Chris Wilson (2017-10-18 00:01:35)
> Quoting Michał Winiarski (2017-10-16 10:05:14)
> > diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> > index fa6594c3..cacc8f98 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 gem_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" : "");
> > +}
> 
> You managed to hide it inside an #ifdef HAVE_PROCPS, or how to confuse
> me with weird build failures.
> 
> Don't we have a lib/i915/gem_scheduler.c for this now?

Ok, scheduler isn't a good fit, do I hear a cry of
lib/i915/gem_submission.c?
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* 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; 11+ 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] 11+ 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; 11+ 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] 11+ 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 " Michał Winiarski
@ 2017-10-13 11:00 ` Michał Winiarski
  2017-10-13 11:26   ` Katarzyna Dec
  2017-10-13 11:31   ` Chris Wilson
  0 siblings, 2 replies; 11+ 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] 11+ messages in thread

end of thread, other threads:[~2017-10-17 23:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-16  9:05 [PATCH i-g-t v2 1/4] lib: Extract helpers for determining submission method Michał Winiarski
2017-10-16  9:05 ` [PATCH i-g-t v2 2/4] lib/i915: Extract helpers for determining scheduler capabilities Michał Winiarski
2017-10-16  9:05 ` [PATCH i-g-t 3/4] lib/i915: Move context related helpers to lib/i915/gem_context Michał Winiarski
2017-10-16  9:05 ` [PATCH i-g-t v2 4/4] lib/i915: Extract context priority setparam to a helper Michał Winiarski
2017-10-16 15:02 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/4] lib: Extract helpers for determining submission method Patchwork
2017-10-17  2:08 ` ✗ Fi.CI.IGT: failure " Patchwork
2017-10-17 23:01 ` [PATCH i-g-t v2 1/4] " Chris Wilson
2017-10-17 23:05   ` Chris Wilson
  -- strict thread matches above, loose matches on Subject: below --
2017-10-13 11:00 [PATCH i-g-t " Michał Winiarski
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

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.