[igt-dev] [RFC v2 33/43] tests/i915/gem_spin_batch: use the gem_engine_topology library

Ramalingam C
2019-06-21T10:02:03Z

tests/i915/gem_spin_batch.c | 40 +++++++++++++++++++------------------
1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/tests/i915/gem_spin_batch.c b/tests/i915/gem_spin_batch.c
index 3b4f90731539..717751bddc1f 100644
--- a/tests/i915/gem_spin_batch.c
+++ b/tests/i915/gem_spin_batch.c
@@ -32,7 +32,8 @@
"'%s' != '%s' (%lld not within %d%% tolerance of %lld)\n",\
#x, #ref, (long long)x, tolerance, (long long)ref)

-static void spin(int fd, unsigned int engine, unsigned int timeout_sec)
+static void spin(int fd, const struct intel_execution_engine2 *e,
+ unsigned int timeout_sec)
{
const uint64_t timeout_100ms = 100000000LL;
unsigned long loops = 0;
@@ -41,9 +42,9 @@ static void spin(int fd, unsigned int engine, unsigned int timeout_sec)
struct timespec itv = { };
uint64_t elapsed;

- spin = __igt_spin_new(fd, .engine = engine);
+ spin = __igt_spin_new(fd, .engine = e->flags);
while ((elapsed = igt_nsec_elapsed(&tv)) >> 30 < timeout_sec) {
- igt_spin_t *next = __igt_spin_new(fd, .engine = engine);
+ igt_spin_t *next = __igt_spin_new(fd, .engine = e->flags);

igt_spin_set_timeout(spin,
timeout_100ms - igt_nsec_elapsed(&itv));
@@ -69,13 +70,14 @@ static void spin(int fd, unsigned int engine, unsigned int timeout_sec)
#define RESUBMIT_NEW_CTX (1 << 0)
#define RESUBMIT_ALL_ENGINES (1 << 1)

-static void spin_resubmit(int fd, unsigned int engine, unsigned int flags)
+static void spin_resubmit(int fd, const struct intel_execution_engine2 *e,
+ unsigned int flags)
{
const uint32_t ctx0 = gem_context_create(fd);
const uint32_t ctx1 = (flags & RESUBMIT_NEW_CTX) ?
gem_context_create(fd) : ctx0;
- igt_spin_t *spin = __igt_spin_new(fd, .ctx = ctx0, .engine = engine);
- unsigned int other;
+ igt_spin_t *spin = __igt_spin_new(fd, .ctx = ctx0, .engine = e->flags);
+ const struct intel_execution_engine2 *other;

struct drm_i915_gem_execbuffer2 eb = {
.buffer_count = 1,
@@ -84,15 +86,15 @@ static void spin_resubmit(int fd, unsigned int engine, unsigned int flags)
};

if (flags & RESUBMIT_ALL_ENGINES) {
- for_each_physical_engine(fd, other) {
- if (other == engine)
+ __for_each_physical_engine(fd, other) {
+ if (other == e)
continue;

- eb.flags = other;
+ eb.flags = other->flags;
gem_execbuf(fd, &eb);
}
} else {
- eb.flags = engine;
+ eb.flags = e->flags;
gem_execbuf(fd, &eb);
}

@@ -115,9 +117,9 @@ static void spin_exit_handler(int sig)

static void spin_on_all_engines(int fd, unsigned int timeout_sec)
{
- unsigned engine;
+ const struct intel_execution_engine2 *engine;

- for_each_physical_engine(fd, engine) {
+ __for_each_physical_engine(fd, engine) {
igt_fork(child, 1) {
igt_install_exit_handler(spin_exit_handler);
spin(fd, engine, timeout_sec);
@@ -129,7 +131,7 @@ static void spin_on_all_engines(int fd, unsigned int timeout_sec)

igt_main
{
- const struct intel_execution_engine *e;
+ const struct intel_execution_engine2 *e;
int fd = -1;

igt_skip_on_simulation();
@@ -140,21 +142,21 @@ igt_main
igt_fork_hang_detector(fd);
}

- for (e = intel_execution_engines; e->name; e++) {
+ __for_each_physical_engine(fd, e) {
igt_subtest_f("basic-%s", e->name)
- spin(fd, e->exec_id, 3);
+ spin(fd, e, 3);

igt_subtest_f("resubmit-%s", e->name)
- spin_resubmit(fd, e->exec_id, 0);
+ spin_resubmit(fd, e, 0);

igt_subtest_f("resubmit-new-%s", e->name)
- spin_resubmit(fd, e->exec_id, RESUBMIT_NEW_CTX);
+ spin_resubmit(fd, e, RESUBMIT_NEW_CTX);

igt_subtest_f("resubmit-all-%s", e->name)
- spin_resubmit(fd, e->exec_id, RESUBMIT_ALL_ENGINES);
+ spin_resubmit(fd, e, RESUBMIT_ALL_ENGINES);

igt_subtest_f("resubmit-new-all-%s", e->name)
- spin_resubmit(fd, e->exec_id,
+ spin_resubmit(fd, e,
RESUBMIT_NEW_CTX |
RESUBMIT_ALL_ENGINES);