@@ -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)
{
@@ -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);
@@ -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;
+}
@@ -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 */
@@ -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;
@@ -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);
}
@@ -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);
@@ -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") {
@@ -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);
@@ -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);
@@ -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++) {
@@ -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);
}
@@ -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++) {
@@ -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);