[igt-dev] [RFC v2 39/43] tests/prime_busy: use the gem_engine_topology library

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

tests/prime_busy.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/tests/prime_busy.c b/tests/prime_busy.c
index a82acbdbc27e..661da2a56688 100644
--- a/tests/prime_busy.c
+++ b/tests/prime_busy.c
@@ -24,6 +24,7 @@
#include "igt.h"

#include <sys/poll.h>
+#include <i915/gem_engine_topology.h>

IGT_TEST_DESCRIPTION("Basic check of polling for prime fences.");

@@ -38,7 +39,8 @@ static bool prime_busy(struct pollfd *pfd, bool excl)
#define HANG 0x4
#define POLL 0x8

-static void busy(int fd, unsigned ring, unsigned flags)
+static void busy(int fd, const struct intel_execution_engine2 *e,
+ unsigned flags)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
struct drm_i915_gem_exec_object2 obj[2];
@@ -57,7 +59,7 @@ static void busy(int fd, unsigned ring, unsigned flags)
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffer_count = 2;
- execbuf.flags = ring;
+ execbuf.flags = e->flags;
if (gen < 6)
execbuf.flags |= I915_EXEC_SECURE;

@@ -175,15 +177,15 @@ static void busy(int fd, unsigned ring, unsigned flags)
}

static void test_engine_mode(int fd,
- const struct intel_execution_engine *e,
+ const struct intel_execution_engine2 *e,
const char *name, unsigned int flags)
{
igt_hang_t hang = {};

igt_subtest_group {
igt_fixture {
- gem_require_ring(fd, e->exec_id | e->flags);
- igt_require(gem_can_store_dword(fd, e->exec_id | e->flags));
+ gem_require_ring(fd, e->flags);
+ igt_require(gem_class_can_store_dword(fd, e->class));

if ((flags & HANG) == 0)
{
@@ -197,14 +199,14 @@ static void test_engine_mode(int fd,
}

igt_subtest_f("%s%s-%s",
- !e->exec_id && !(flags & HANG) ? "basic-" : "",
+ !(flags & HANG) ? "basic-" : "",
name, e->name)
- busy(fd, e->exec_id | e->flags, flags);
+ busy(fd, e, flags);

igt_subtest_f("%swait-%s-%s",
- !e->exec_id && !(flags & HANG) ? "basic-" : "",
+ !(flags & HANG) ? "basic-" : "",
name, e->name)
- busy(fd, e->exec_id | e->flags, flags | POLL);
+ busy(fd, e, flags | POLL);

igt_fixture {
if ((flags & HANG) == 0)
@@ -217,7 +219,7 @@ static void test_engine_mode(int fd,

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

igt_fixture {
@@ -239,7 +241,7 @@ igt_main
igt_fixture
gem_require_mmap_wc(fd);

- for (e = intel_execution_engines; e->name; e++) {
+ __for_each_static_engine(e) {
for (const struct mode *m = modes; m->name; m++)
test_engine_mode(fd, e, m->name, m->flags);