summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichał Winiarski <michal.winiarski@intel.com>2017-10-16 11:05:14 +0200
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2017-10-17 10:26:30 +0300
commitf6dfe556659f5473e4bf13cc8d4770ac39c7d678 (patch)
treed28fb03f0832c680e67771df4722cc3ccd3b9302 /tests
parentd4d976de7e022cb56a2dbfe96c4ab10549e24acc (diff)
lib: Extract helpers for determining submission method
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/gem_ctx_thrash.c19
-rw-r--r--tests/gem_eio.c45
-rw-r--r--tests/gem_exec_await.c39
-rw-r--r--tests/gem_exec_fence.c41
-rw-r--r--tests/gem_exec_latency.c31
-rw-r--r--tests/gem_exec_nop.c31
-rw-r--r--tests/gem_exec_schedule.c40
-rw-r--r--tests/gem_exec_whisper.c31
-rw-r--r--tests/gem_read_read_speed.c17
-rw-r--r--tests/gem_sync.c31
10 files changed, 16 insertions, 309 deletions
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);