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

Ramalingam C
2019-06-21T10:01:34Z

tests/i915/gem_exec_flush.c | 72 ++++++++++++++++++-------------------
1 file changed, 35 insertions(+), 37 deletions(-)

diff --git a/tests/i915/gem_exec_flush.c b/tests/i915/gem_exec_flush.c
index f820b2a8d0a4..2f041863e238 100644
--- a/tests/i915/gem_exec_flush.c
+++ b/tests/i915/gem_exec_flush.c
@@ -74,8 +74,8 @@ static uint32_t movnt(uint32_t *map, int i)
}
#endif

-static void run(int fd, unsigned ring, int nchild, int timeout,
- unsigned flags)
+static void run(int fd, const struct intel_execution_engine2 *e,
+ int nchild, int timeout, unsigned flags)
{
const int gen = intel_gen(intel_get_drm_devid(fd));

@@ -162,7 +162,7 @@ static void run(int fd, unsigned ring, int nchild, int timeout,
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 3;
- execbuf.flags = ring | (1 << 11) | (1<<12);
+ execbuf.flags = e->flags | (1 << 11) | (1<<12);
if (gen < 6)
execbuf.flags |= I915_EXEC_SECURE;

@@ -352,7 +352,8 @@ enum batch_mode {
BATCH_GTT,
BATCH_WC,
};
-static void batch(int fd, unsigned ring, int nchild, int timeout,
+static void batch(int fd, const struct intel_execution_engine2 *e,
+ int nchild, int timeout,
enum batch_mode mode, unsigned flags)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
@@ -394,7 +395,7 @@ static void batch(int fd, unsigned ring, int nchild, int timeout,
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
- execbuf.flags = ring | (1 << 11) | (1<<12);
+ execbuf.flags = e->flags | (1 << 11) | (1<<12);
if (gen < 6)
execbuf.flags |= I915_EXEC_SECURE;

@@ -552,7 +553,7 @@ static const char *yesno(bool x)

igt_main
{
- const struct intel_execution_engine *e;
+ const struct intel_execution_engine2 *e;
const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
const struct batch {
const char *name;
@@ -599,78 +600,75 @@ igt_main
igt_fork_hang_detector(fd);
}

- for (e = intel_execution_engines; e->name; e++) igt_subtest_group {
- unsigned ring = e->exec_id | e->flags;
- unsigned timeout = 5 + 120*!!e->exec_id;
+ __for_each_physical_engine(fd, e) igt_subtest_group {
+ unsigned timeout = 5 + 120;

igt_fixture {
- gem_require_ring(fd, ring);
- igt_require(gem_can_store_dword(fd, ring));
+ igt_require(gem_class_can_store_dword(fd, e->class));
}

for (const struct batch *b = batches; b->name; b++) {
igt_subtest_f("%sbatch-%s-%s-uc",
- b == batches && e->exec_id == 0 ? "basic-" : "",
- b->name,
- e->name)
- batch(fd, ring, ncpus, timeout, b->mode, 0);
+ b == batches &&
+ e->class == I915_ENGINE_CLASS_RENDER ?
+ "basic-" : "", b->name, e->name)
+ batch(fd, e, ncpus, timeout, b->mode, 0);
igt_subtest_f("%sbatch-%s-%s-wb",
- b == batches && e->exec_id == 0 ? "basic-" : "",
- b->name,
- e->name)
- batch(fd, ring, ncpus, timeout, b->mode, COHERENT);
+ b == batches &&
+ e->class == I915_ENGINE_CLASS_RENDER ?
+ "basic-" : "", b->name, e->name)
+ batch(fd, e, ncpus, timeout, b->mode, COHERENT);
igt_subtest_f("%sbatch-%s-%s-cmd",
- b == batches && e->exec_id == 0 ? "basic-" : "",
- b->name,
- e->name)
- batch(fd, ring, ncpus, timeout, b->mode,
+ b == batches &&
+ e->class == I915_ENGINE_CLASS_RENDER ?
+ "basic-" : "", b->name, e->name)
+ batch(fd, e, ncpus, timeout, b->mode,
COHERENT | CMDPARSER);
}

for (const struct mode *m = modes; m->name; m++) {
igt_subtest_f("%suc-%s-%s",
- (m->flags & BASIC && e->exec_id == 0) ? "basic-" : "",
- m->name,
- e->name)
- run(fd, ring, ncpus, timeout,
+ (m->flags & BASIC &&
+ e->class == I915_ENGINE_CLASS_RENDER) ?
+ "basic-" : "", m->name, e->name)
+ run(fd, e, ncpus, timeout,
UNCACHED | m->flags);

igt_subtest_f("uc-%s-%s-interruptible",
m->name,
e->name)
- run(fd, ring, ncpus, timeout,
+ run(fd, e, ncpus, timeout,
UNCACHED | m->flags | INTERRUPTIBLE);

igt_subtest_f("%swb-%s-%s",
- e->exec_id == 0 ? "basic-" : "",
- m->name,
- e->name)
- run(fd, ring, ncpus, timeout,
+ e->class == I915_ENGINE_CLASS_RENDER ?
+ "basic-" : "", m->name, e->name)
+ run(fd, e, ncpus, timeout,
COHERENT | m->flags);

igt_subtest_f("wb-%s-%s-interruptible",
m->name,
e->name)
- run(fd, ring, ncpus, timeout,
+ run(fd, e, ncpus, timeout,
COHERENT | m->flags | INTERRUPTIBLE);

igt_subtest_f("wc-%s-%s",
m->name,
e->name)
- run(fd, ring, ncpus, timeout,
+ run(fd, e, ncpus, timeout,
COHERENT | WC | m->flags);

igt_subtest_f("wc-%s-%s-interruptible",
m->name,
e->name)
- run(fd, ring, ncpus, timeout,
+ run(fd, e, ncpus, timeout,
COHERENT | WC | m->flags | INTERRUPTIBLE);

igt_subtest_f("stream-%s-%s",
m->name,
e->name) {
igt_require(cpu & SSE4_1);
- run(fd, ring, ncpus, timeout,
+ run(fd, e, ncpus, timeout,
MOVNT | COHERENT | WC | m->flags);
}

@@ -678,7 +676,7 @@ igt_main
m->name,
e->name) {
igt_require(cpu & SSE4_1);
- run(fd, ring, ncpus, timeout,
+ run(fd, e, ncpus, timeout,
MOVNT | COHERENT | WC | m->flags | INTERRUPTIBLE);