[igt-dev] [RFC v2 08/43] tests/i915/gem_sync: use the gem_engine_topology library
Ramalingam C
ramalingam.c at intel.com
Fri Jun 21 10:03:10 UTC 2019
Replace the legacy for_each_engine* defines with the ones
implemented in the gem_engine_topology library.
Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
---
tests/i915/gem_sync.c | 234 +++++++++++++++++++++---------------------
1 file changed, 118 insertions(+), 116 deletions(-)
diff --git a/tests/i915/gem_sync.c b/tests/i915/gem_sync.c
index 8c5aaa144a12..629decfcfe18 100644
--- a/tests/i915/gem_sync.c
+++ b/tests/i915/gem_sync.c
@@ -79,25 +79,26 @@ out:
}
static void
-sync_ring(int fd, unsigned ring, int num_children, int timeout)
+sync_ring(int fd, const struct intel_execution_engine2 *e, int num_children,
+ int timeout)
{
unsigned engines[16];
const char *names[16];
int num_engines = 0;
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- names[num_engines] = e__->name;
- engines[num_engines++] = ring;
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ names[num_engines] = e->name;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
num_children *= num_engines;
} else {
- gem_require_ring(fd, ring);
+ gem_require_ring(fd, e->flags);
names[num_engines] = NULL;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
}
intel_detect_and_clear_missed_interrupts(fd);
@@ -139,7 +140,7 @@ sync_ring(int fd, unsigned ring, int num_children, int timeout)
}
static void
-idle_ring(int fd, unsigned ring, int timeout)
+idle_ring(int fd, const struct intel_execution_engine2 *e, int timeout)
{
const uint32_t bbe = MI_BATCH_BUFFER_END;
struct drm_i915_gem_exec_object2 object;
@@ -147,7 +148,7 @@ idle_ring(int fd, unsigned ring, int timeout)
double start, elapsed;
unsigned long cycles;
- gem_require_ring(fd, ring);
+ gem_require_ring(fd, e->flags);
memset(&object, 0, sizeof(object));
object.handle = gem_create(fd, 4096);
@@ -156,7 +157,7 @@ idle_ring(int fd, unsigned ring, int timeout)
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = to_user_pointer(&object);
execbuf.buffer_count = 1;
- execbuf.flags = ring;
+ execbuf.flags = e->flags;
gem_execbuf(fd, &execbuf);
gem_sync(fd, object.handle);
@@ -178,28 +179,29 @@ idle_ring(int fd, unsigned ring, int timeout)
}
static void
-wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
+wakeup_ring(int fd, const struct intel_execution_engine2 *e, int timeout,
+ int wlen)
{
unsigned engines[16];
const char *names[16];
int num_engines = 0;
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- if (!gem_can_store_dword(fd, ring))
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ if (!gem_class_can_store_dword(fd, e->class))
continue;
- names[num_engines] = e__->name;
- engines[num_engines++] = ring;
+ names[num_engines] = e->name;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
igt_require(num_engines);
} else {
- gem_require_ring(fd, ring);
- igt_require(gem_can_store_dword(fd, ring));
+ gem_require_ring(fd, e->flags);
+ igt_require(gem_class_can_store_dword(fd, e->class));
names[num_engines] = NULL;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
}
intel_detect_and_clear_missed_interrupts(fd);
@@ -221,7 +223,7 @@ wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
execbuf.flags = engines[child % num_engines];
spin = __igt_spin_new(fd,
- .engine = execbuf.flags,
+ .engine = engines[child % num_engines],
.flags = (IGT_SPIN_POLL_RUN |
IGT_SPIN_FAST));
igt_assert(igt_spin_has_poll(spin));
@@ -290,28 +292,28 @@ wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
}
-static void active_ring(int fd, unsigned ring, int timeout)
+static void active_ring(int fd, const struct intel_execution_engine2 *e, int timeout)
{
unsigned engines[16];
const char *names[16];
int num_engines = 0;
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- if (!gem_can_store_dword(fd, ring))
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ if (!gem_class_can_store_dword(fd, e->class))
continue;
- names[num_engines] = e__->name;
- engines[num_engines++] = ring;
+ names[num_engines] = e->name;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
igt_require(num_engines);
} else {
- gem_require_ring(fd, ring);
- igt_require(gem_can_store_dword(fd, ring));
+ gem_require_ring(fd, e->flags);
+ igt_require(gem_class_can_store_dword(fd, e->class));
names[num_engines] = NULL;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
}
intel_detect_and_clear_missed_interrupts(fd);
@@ -321,11 +323,11 @@ static void active_ring(int fd, unsigned ring, int timeout)
igt_spin_t *spin[2];
spin[0] = __igt_spin_new(fd,
- .engine = ring,
+ .engine = e->flags,
.flags = IGT_SPIN_FAST);
spin[1] = __igt_spin_new(fd,
- .engine = ring,
+ .engine = e->flags,
.flags = IGT_SPIN_FAST);
start = gettime();
@@ -357,28 +359,29 @@ static void active_ring(int fd, unsigned ring, int timeout)
}
static void
-active_wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
+active_wakeup_ring(int fd, const struct intel_execution_engine2 *e, int timeout,
+ int wlen)
{
unsigned engines[16];
const char *names[16];
int num_engines = 0;
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- if (!gem_can_store_dword(fd, ring))
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ if (!gem_class_can_store_dword(fd, e->class))
continue;
- names[num_engines] = e__->name;
- engines[num_engines++] = ring;
+ names[num_engines] = e->name;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
igt_require(num_engines);
} else {
- gem_require_ring(fd, ring);
- igt_require(gem_can_store_dword(fd, ring));
+ gem_require_ring(fd, e->flags);
+ igt_require(gem_class_can_store_dword(fd, e->class));
names[num_engines] = NULL;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
}
intel_detect_and_clear_missed_interrupts(fd);
@@ -400,13 +403,13 @@ active_wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
execbuf.flags = engines[child % num_engines];
spin[0] = __igt_spin_new(fd,
- .engine = execbuf.flags,
+ .engine = engines[child % num_engines],
.flags = (IGT_SPIN_POLL_RUN |
IGT_SPIN_FAST));
igt_assert(igt_spin_has_poll(spin[0]));
spin[1] = __igt_spin_new(fd,
- .engine = execbuf.flags,
+ .engine = engines[child % num_engines],
.flags = (IGT_SPIN_POLL_RUN |
IGT_SPIN_FAST));
@@ -491,30 +494,30 @@ active_wakeup_ring(int fd, unsigned ring, int timeout, int wlen)
}
static void
-store_ring(int fd, unsigned ring, int num_children, int timeout)
+store_ring(int fd, const struct intel_execution_engine2 *e, int num_children, int timeout)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
unsigned engines[16];
const char *names[16];
int num_engines = 0;
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- if (!gem_can_store_dword(fd, ring))
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ if (!gem_class_can_store_dword(fd, e->class))
continue;
- names[num_engines] = e__->name;
- engines[num_engines++] = ring;
+ names[num_engines] = e->name;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
num_children *= num_engines;
} else {
- gem_require_ring(fd, ring);
- igt_require(gem_can_store_dword(fd, ring));
+ gem_require_ring(fd, e->flags);
+ igt_require(gem_class_can_store_dword(fd, e->class));
names[num_engines] = NULL;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
}
intel_detect_and_clear_missed_interrupts(fd);
@@ -606,7 +609,7 @@ store_ring(int fd, unsigned ring, int num_children, int timeout)
}
static void
-switch_ring(int fd, unsigned ring, int num_children, int timeout)
+switch_ring(int fd, const struct intel_execution_engine2 *e, int num_children, int timeout)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
unsigned engines[16];
@@ -615,23 +618,23 @@ switch_ring(int fd, unsigned ring, int num_children, int timeout)
gem_require_contexts(fd);
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- if (!gem_can_store_dword(fd, ring))
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ if (!gem_class_can_store_dword(fd, e->class))
continue;
- names[num_engines] = e__->name;
- engines[num_engines++] = ring;
+ names[num_engines] = e->name;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
num_children *= num_engines;
} else {
- gem_require_ring(fd, ring);
- igt_require(gem_can_store_dword(fd, ring));
+ gem_require_ring(fd, e->flags);
+ igt_require(gem_class_can_store_dword(fd, e->class));
names[num_engines] = NULL;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
}
intel_detect_and_clear_missed_interrupts(fd);
@@ -803,7 +806,7 @@ static void *waiter(void *arg)
}
static void
-__store_many(int fd, unsigned ring, int timeout, unsigned long *cycles)
+__store_many(int fd, const struct intel_execution_engine2 *e, int timeout, unsigned long *cycles)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
const uint32_t bbe = MI_BATCH_BUFFER_END;
@@ -817,7 +820,7 @@ __store_many(int fd, unsigned ring, int timeout, unsigned long *cycles)
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = to_user_pointer(object);
- execbuf.flags = ring;
+ execbuf.flags = e->flags;
execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
if (gen < 6)
@@ -931,7 +934,7 @@ __store_many(int fd, unsigned ring, int timeout, unsigned long *cycles)
}
static void
-store_many(int fd, unsigned ring, int timeout)
+store_many(int fd, const struct intel_execution_engine2 *e, int timeout)
{
unsigned long *shared;
const char *names[16];
@@ -942,24 +945,22 @@ store_many(int fd, unsigned ring, int timeout)
intel_detect_and_clear_missed_interrupts(fd);
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- if (!gem_can_store_dword(fd, ring))
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ if (!gem_class_can_store_dword(fd, e->class))
continue;
igt_fork(child, 1)
- __store_many(fd,
- ring,
- timeout,
+ __store_many(fd, e, timeout,
&shared[n]);
- names[n++] = e__->name;
+ names[n++] = e->name;
}
igt_waitchildren();
} else {
- gem_require_ring(fd, ring);
- igt_require(gem_can_store_dword(fd, ring));
- __store_many(fd, ring, timeout, &shared[n]);
+ gem_require_ring(fd, e->flags);
+ igt_require(gem_class_can_store_dword(fd, e->class));
+ __store_many(fd, e, timeout, &shared[n]);
names[n++] = NULL;
}
@@ -974,11 +975,12 @@ store_many(int fd, unsigned ring, int timeout)
static void
sync_all(int fd, int num_children, int timeout)
{
- unsigned engines[16], engine;
+ unsigned engines[16];
+ const struct intel_execution_engine2 *engine;
int num_engines = 0;
- for_each_physical_engine(fd, engine) {
- engines[num_engines++] = engine;
+ __for_each_physical_engine(fd, engine) {
+ engines[num_engines++] = engine->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
@@ -1028,13 +1030,13 @@ store_all(int fd, int num_children, int timeout)
const int gen = intel_gen(intel_get_drm_devid(fd));
unsigned engines[16];
int num_engines = 0;
- unsigned int ring;
+ const struct intel_execution_engine2 *e;
- for_each_physical_engine(fd, ring) {
- if (!gem_can_store_dword(fd, ring))
+ __for_each_physical_engine(fd, e) {
+ if (!gem_class_can_store_dword(fd, e->class))
continue;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
@@ -1131,26 +1133,26 @@ store_all(int fd, int num_children, int timeout)
}
static void
-preempt(int fd, unsigned ring, int num_children, int timeout)
+preempt(int fd, const struct intel_execution_engine2 *e, int num_children, int timeout)
{
unsigned engines[16];
const char *names[16];
int num_engines = 0;
uint32_t ctx[2];
- if (ring == ALL_ENGINES) {
- for_each_physical_engine(fd, ring) {
- names[num_engines] = e__->name;
- engines[num_engines++] = ring;
+ if (!e) {
+ __for_each_physical_engine(fd, e) {
+ names[num_engines] = e->name;
+ engines[num_engines++] = e->flags;
if (num_engines == ARRAY_SIZE(engines))
break;
}
num_children *= num_engines;
} else {
- gem_require_ring(fd, ring);
+ gem_require_ring(fd, e->flags);
names[num_engines] = NULL;
- engines[num_engines++] = ring;
+ engines[num_engines++] = e->flags;
}
ctx[0] = gem_context_create(fd);
@@ -1185,7 +1187,7 @@ preempt(int fd, unsigned ring, int num_children, int timeout)
igt_spin_t *spin =
__igt_spin_new(fd,
.ctx = ctx[0],
- .engine = execbuf.flags);
+ .engine = engines[child % num_engines]);
do {
gem_execbuf(fd, &execbuf);
@@ -1210,7 +1212,7 @@ preempt(int fd, unsigned ring, int num_children, int timeout)
igt_main
{
- const struct intel_execution_engine *e;
+ const struct intel_execution_engine2 *e;
const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
int fd = -1;
@@ -1225,55 +1227,55 @@ igt_main
igt_fork_hang_detector(fd);
}
- for (e = intel_execution_engines; e->name; e++) {
+ __for_each_physical_engine(fd, e) {
igt_subtest_f("%s", e->name)
- sync_ring(fd, e->exec_id | e->flags, 1, 150);
+ sync_ring(fd, e, 1, 150);
igt_subtest_f("idle-%s", e->name)
- idle_ring(fd, e->exec_id | e->flags, 150);
+ idle_ring(fd, e, 150);
igt_subtest_f("active-%s", e->name)
- active_ring(fd, e->exec_id | e->flags, 150);
+ active_ring(fd, e, 150);
igt_subtest_f("wakeup-%s", e->name)
- wakeup_ring(fd, e->exec_id | e->flags, 150, 1);
+ wakeup_ring(fd, e, 150, 1);
igt_subtest_f("active-wakeup-%s", e->name)
- active_wakeup_ring(fd, e->exec_id | e->flags, 150, 1);
+ active_wakeup_ring(fd, e, 150, 1);
igt_subtest_f("double-wakeup-%s", e->name)
- wakeup_ring(fd, e->exec_id | e->flags, 150, 2);
+ wakeup_ring(fd, e, 150, 2);
igt_subtest_f("store-%s", e->name)
- store_ring(fd, e->exec_id | e->flags, 1, 150);
+ store_ring(fd, e, 1, 150);
igt_subtest_f("switch-%s", e->name)
- switch_ring(fd, e->exec_id | e->flags, 1, 150);
+ switch_ring(fd, e, 1, 150);
igt_subtest_f("forked-switch-%s", e->name)
- switch_ring(fd, e->exec_id | e->flags, ncpus, 150);
+ switch_ring(fd, e, ncpus, 150);
igt_subtest_f("many-%s", e->name)
- store_many(fd, e->exec_id | e->flags, 150);
+ store_many(fd, e, 150);
igt_subtest_f("forked-%s", e->name)
- sync_ring(fd, e->exec_id | e->flags, ncpus, 150);
+ sync_ring(fd, e, ncpus, 150);
igt_subtest_f("forked-store-%s", e->name)
- store_ring(fd, e->exec_id | e->flags, ncpus, 150);
+ store_ring(fd, e, ncpus, 150);
}
igt_subtest("basic-each")
- sync_ring(fd, ALL_ENGINES, 1, 5);
+ sync_ring(fd, NULL, 1, 5);
igt_subtest("basic-store-each")
- store_ring(fd, ALL_ENGINES, 1, 5);
+ store_ring(fd, NULL, 1, 5);
igt_subtest("basic-many-each")
- store_many(fd, ALL_ENGINES, 5);
+ store_many(fd, NULL, 5);
igt_subtest("switch-each")
- switch_ring(fd, ALL_ENGINES, 1, 150);
+ switch_ring(fd, NULL, 1, 150);
igt_subtest("forked-switch-each")
- switch_ring(fd, ALL_ENGINES, ncpus, 150);
+ switch_ring(fd, NULL, ncpus, 150);
igt_subtest("forked-each")
- sync_ring(fd, ALL_ENGINES, ncpus, 150);
+ sync_ring(fd, NULL, ncpus, 150);
igt_subtest("forked-store-each")
- store_ring(fd, ALL_ENGINES, ncpus, 150);
+ store_ring(fd, NULL, ncpus, 150);
igt_subtest("active-each")
- active_ring(fd, ALL_ENGINES, 150);
+ active_ring(fd, NULL, 150);
igt_subtest("wakeup-each")
- wakeup_ring(fd, ALL_ENGINES, 150, 1);
+ wakeup_ring(fd, NULL, 150, 1);
igt_subtest("active-wakeup-each")
- active_wakeup_ring(fd, ALL_ENGINES, 150, 1);
+ active_wakeup_ring(fd, NULL, 150, 1);
igt_subtest("double-wakeup-each")
- wakeup_ring(fd, ALL_ENGINES, 150, 2);
+ wakeup_ring(fd, NULL, 150, 2);
igt_subtest("basic-all")
sync_all(fd, 1, 5);
@@ -1297,11 +1299,11 @@ igt_main
}
igt_subtest("preempt-all")
- preempt(fd, ALL_ENGINES, 1, 20);
+ preempt(fd, NULL, 1, 20);
- for (e = intel_execution_engines; e->name; e++) {
+ __for_each_physical_engine(fd, e) {
igt_subtest_f("preempt-%s", e->name)
- preempt(fd, e->exec_id | e->flags, ncpus, 150);
+ preempt(fd, e, ncpus, 150);
}
}
--
2.19.1
More information about the igt-dev
mailing list