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

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

tests/i915/gem_ringfill.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/tests/i915/gem_ringfill.c b/tests/i915/gem_ringfill.c
index c728e1cd3668..a02c7e76ecd9 100644
--- a/tests/i915/gem_ringfill.c
+++ b/tests/i915/gem_ringfill.c
@@ -96,7 +96,7 @@ static int setup_execbuf(int fd,
struct drm_i915_gem_execbuffer2 *execbuf,
struct drm_i915_gem_exec_object2 *obj,
struct drm_i915_gem_relocation_entry *reloc,
- unsigned int ring)
+ unsigned int flags)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
const uint32_t bbe = MI_BATCH_BUFFER_END;
@@ -109,7 +109,7 @@ static int setup_execbuf(int fd,
memset(reloc, 0, 1024*sizeof(*reloc));

execbuf->buffers_ptr = to_user_pointer(obj);
- execbuf->flags = ring | (1 << 11) | (1 << 12);
+ execbuf->flags = flags | (1 << 11) | (1 << 12);

if (gen > 3 && gen < 6)
execbuf->flags |= I915_EXEC_SECURE;
@@ -170,25 +170,25 @@ static int setup_execbuf(int fd,
return 0;
}

-static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
+static void run_test(int fd, const struct intel_execution_engine2 *e,
+ unsigned flags, unsigned timeout)
{
struct drm_i915_gem_exec_object2 obj[2];
struct drm_i915_gem_relocation_entry reloc[1024];
struct drm_i915_gem_execbuffer2 execbuf;
igt_hang_t hang;

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

if (flags & (SUSPEND | HIBERNATE))
- run_test(fd, ring, 0, 0);
+ run_test(fd, e, 0, 0);

gem_quiescent_gpu(fd);
- igt_require(setup_execbuf(fd, &execbuf, obj, reloc, ring) == 0);
+ igt_require(setup_execbuf(fd, &execbuf, obj, reloc, e->flags) == 0);

memset(&hang, 0, sizeof(hang));
if (flags & HANG)
- hang = igt_hang_ring(fd, ring & ~(3<<13));
+ hang = igt_hang_ring(fd, e->flags & ~(3<<13));

if (flags & (CHILD | FORKED | BOMB)) {
int nchild;
@@ -204,7 +204,7 @@ static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
igt_fork(child, nchild) {
if (flags & NEWFD) {
fd = drm_open_driver(DRIVER_INTEL);
- setup_execbuf(fd, &execbuf, obj, reloc, ring);
+ setup_execbuf(fd, &execbuf, obj, reloc, e->flags);
}
fill_ring(fd, &execbuf, flags, timeout);
}
@@ -235,7 +235,7 @@ static void run_test(int fd, unsigned ring, unsigned flags, unsigned timeout)
gem_quiescent_gpu(fd);

if (flags & (SUSPEND | HIBERNATE))
- run_test(fd, ring, 0, 0);
+ run_test(fd, e, 0, 0);
}

igt_main
@@ -278,18 +278,14 @@ igt_main
}

for (m = modes; m->suffix; m++) {
- const struct intel_execution_engine *e;
+ const struct intel_execution_engine2 *e;

- for (e = intel_execution_engines; e->name; e++) {
- igt_subtest_f("%s%s%s",
- m->basic && !e->exec_id ? "basic-" : "",
- e->name,
- m->suffix) {
+ __for_each_physical_engine(fd, e) {
+ igt_subtest_f("%s%s", e->name, m->suffix) {
igt_skip_on(m->flags & NEWFD && master);
if (m->flags & (HANG|SUSPEND|HIBERNATE))
igt_skip_on_simulation();
- run_test(fd, e->exec_id | e->flags,
- m->flags, m->timeout);
+ run_test(fd, e, m->flags, m->timeout);