[igt-dev] [RFC v2 41/43] tests/i915/gem_ctx_shared: use the gem_engine_topology library
Ramalingam C
ramalingam.c at intel.com
Fri Jun 21 10:03:43 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_ctx_shared.c | 105 ++++++++++++++++++------------------
1 file changed, 53 insertions(+), 52 deletions(-)
diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c
index 4b1020b96fed..324959939fd4 100644
--- a/tests/i915/gem_ctx_shared.c
+++ b/tests/i915/gem_ctx_shared.c
@@ -181,7 +181,7 @@ static void exhaust_shared_gtt(int i915, unsigned int flags)
igt_waitchildren();
}
-static void exec_shared_gtt(int i915, unsigned int ring)
+static void exec_shared_gtt(int i915, const struct intel_execution_engine2 *e)
{
const int gen = intel_gen(intel_get_drm_devid(i915));
const uint32_t bbe = MI_BATCH_BUFFER_END;
@@ -189,14 +189,13 @@ static void exec_shared_gtt(int i915, unsigned int ring)
struct drm_i915_gem_execbuffer2 execbuf = {
.buffers_ptr = to_user_pointer(&obj),
.buffer_count = 1,
- .flags = ring,
+ .flags = e->flags,
};
uint32_t scratch, *s;
uint32_t batch[16];
int i;
- gem_require_ring(i915, ring);
- igt_require(gem_can_store_dword(i915, ring));
+ igt_require(gem_class_can_store_dword(i915, e->class));
/* Find a hole big enough for both objects later */
scratch = gem_create(i915, 16384);
@@ -310,7 +309,7 @@ static void single_timeline(int i915)
struct sync_file_info sync_file_info = {
.num_fences = 1,
};
- unsigned int engine;
+ const struct intel_execution_engine2 *engine;
int n;
igt_require(has_single_timeline(i915));
@@ -331,7 +330,7 @@ static void single_timeline(int i915)
I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE);
execbuf.flags = I915_EXEC_FENCE_OUT;
n = 0;
- for_each_engine(i915, engine) {
+ for_each_context_engine(i915, 0, engine) {
gem_execbuf_wr(i915, &execbuf);
sync_file_info.sync_fence_info = to_user_pointer(&rings[n]);
do_ioctl(execbuf.rsvd2 >> 32, SYNC_IOC_FILE_INFO, &sync_file_info);
@@ -350,13 +349,14 @@ static void single_timeline(int i915)
}
}
-static void exec_single_timeline(int i915, unsigned int engine)
+static void exec_single_timeline(int i915,
+ const struct intel_execution_engine2 *engine)
{
- unsigned int other;
+ const struct intel_execution_engine2 *other;
igt_spin_t *spin;
uint32_t ctx;
- igt_require(gem_ring_has_physical_engine(i915, engine));
+ igt_require(gem_ring_has_physical_engine(i915, engine->flags));
igt_require(has_single_timeline(i915));
/*
@@ -365,24 +365,24 @@ static void exec_single_timeline(int i915, unsigned int engine)
*/
ctx = 0;
spin = NULL;
- for_each_physical_engine(i915, other) {
+ __for_each_physical_engine(i915, other) {
if (other == engine)
continue;
if (spin == NULL) {
- spin = __igt_spin_new(i915, .ctx = ctx, .engine = other);
+ spin = __igt_spin_new(i915, .ctx = ctx, .engine = other->flags);
} else {
struct drm_i915_gem_execbuffer2 execbuf = {
.buffers_ptr = spin->execbuf.buffers_ptr,
.buffer_count = spin->execbuf.buffer_count,
- .flags = other,
+ .flags = other->flags,
.rsvd1 = ctx,
};
gem_execbuf(i915, &execbuf);
}
}
igt_require(spin);
- igt_assert_eq(nop_sync(i915, ctx, engine, NSEC_PER_SEC), 0);
+ igt_assert_eq(nop_sync(i915, ctx, engine->flags, NSEC_PER_SEC), 0);
igt_spin_free(i915, spin);
/*
@@ -393,24 +393,24 @@ static void exec_single_timeline(int i915, unsigned int engine)
ctx = gem_context_clone(i915, 0, 0,
I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE);
spin = NULL;
- for_each_physical_engine(i915, other) {
+ __for_each_physical_engine(i915, other) {
if (other == engine)
continue;
if (spin == NULL) {
- spin = __igt_spin_new(i915, .ctx = ctx, .engine = other);
+ spin = __igt_spin_new(i915, .ctx = ctx, .engine = other->flags);
} else {
struct drm_i915_gem_execbuffer2 execbuf = {
.buffers_ptr = spin->execbuf.buffers_ptr,
.buffer_count = spin->execbuf.buffer_count,
- .flags = other,
+ .flags = other->flags,
.rsvd1 = ctx,
};
gem_execbuf(i915, &execbuf);
}
}
igt_assert(spin);
- igt_assert_eq(nop_sync(i915, ctx, engine, NSEC_PER_SEC), -ETIME);
+ igt_assert_eq(nop_sync(i915, ctx, engine->flags, NSEC_PER_SEC), -ETIME);
igt_spin_free(i915, spin);
}
@@ -542,7 +542,8 @@ static uint32_t store_timestamp(int i915,
return obj.handle;
}
-static void independent(int i915, unsigned ring, unsigned flags)
+static void independent(int i915, const struct intel_execution_engine2 *e,
+ unsigned flags)
{
const int TIMESTAMP = 1023;
uint32_t handle[ARRAY_SIZE(priorities)];
@@ -550,7 +551,7 @@ static void independent(int i915, unsigned ring, unsigned flags)
unsigned int mmio_base;
/* XXX i915_query()! */
- switch (ring) {
+ switch (e->flags) {
case I915_EXEC_DEFAULT:
case I915_EXEC_RENDER:
mmio_base = 0x2000;
@@ -580,7 +581,7 @@ static void independent(int i915, unsigned ring, unsigned flags)
for (int n = 0; n < ARRAY_SIZE(spin); n++) {
const struct igt_spin_factory opts = {
.ctx = create_highest_priority(i915),
- .engine = ring,
+ .engine = e->flags,
};
spin[n] = __igt_spin_factory(i915, &opts);
gem_context_destroy(i915, opts.ctx);
@@ -589,7 +590,7 @@ static void independent(int i915, unsigned ring, unsigned flags)
for (int i = 0; i < ARRAY_SIZE(priorities); i++) {
uint32_t ctx = gem_queue_create(i915);
gem_context_set_priority(i915, ctx, priorities[i]);
- handle[i] = store_timestamp(i915, ctx, ring, mmio_base, TIMESTAMP);
+ handle[i] = store_timestamp(i915, ctx, e->flags, mmio_base, TIMESTAMP);
gem_context_destroy(i915, ctx);
}
@@ -614,7 +615,8 @@ static void independent(int i915, unsigned ring, unsigned flags)
igt_assert((int32_t)(handle[HI] - handle[LO]) < 0);
}
-static void reorder(int i915, unsigned ring, unsigned flags)
+static void reorder(int i915, const struct intel_execution_engine2 *e,
+ unsigned flags)
#define EQUAL 1
{
IGT_CORK_HANDLE(cork);
@@ -635,10 +637,10 @@ static void reorder(int i915, unsigned ring, unsigned flags)
/* We expect the high priority context to be executed first, and
* so the final result will be value from the low priority context.
*/
- store_dword(i915, ctx[LO], ring, scratch, 0, ctx[LO], plug, 0);
- store_dword(i915, ctx[HI], ring, scratch, 0, ctx[HI], plug, 0);
+ store_dword(i915, ctx[LO], e->flags, scratch, 0, ctx[LO], plug, 0);
+ store_dword(i915, ctx[HI], e->flags, scratch, 0, ctx[HI], plug, 0);
- unplug_show_queue(i915, &cork, ring);
+ unplug_show_queue(i915, &cork, e->flags);
gem_close(i915, plug);
gem_context_destroy(i915, ctx[LO]);
@@ -656,7 +658,7 @@ static void reorder(int i915, unsigned ring, unsigned flags)
munmap(ptr, 4096);
}
-static void promotion(int i915, unsigned ring)
+static void promotion(int i915, const struct intel_execution_engine2 *e)
{
IGT_CORK_HANDLE(cork);
uint32_t result, dep;
@@ -683,16 +685,16 @@ static void promotion(int i915, unsigned ring)
* fifo would be NOISE, LO, HI.
* strict priority would be HI, NOISE, LO
*/
- store_dword(i915, ctx[NOISE], ring, result, 0, ctx[NOISE], plug, 0);
- store_dword(i915, ctx[LO], ring, result, 0, ctx[LO], plug, 0);
+ store_dword(i915, ctx[NOISE], e->flags, result, 0, ctx[NOISE], plug, 0);
+ store_dword(i915, ctx[LO], e->flags, result, 0, ctx[LO], plug, 0);
/* link LO <-> HI via a dependency on another buffer */
- store_dword(i915, ctx[LO], ring, dep, 0, ctx[LO], 0, I915_GEM_DOMAIN_INSTRUCTION);
- store_dword(i915, ctx[HI], ring, dep, 0, ctx[HI], 0, 0);
+ store_dword(i915, ctx[LO], e->flags, dep, 0, ctx[LO], 0, I915_GEM_DOMAIN_INSTRUCTION);
+ store_dword(i915, ctx[HI], e->flags, dep, 0, ctx[HI], 0, 0);
- store_dword(i915, ctx[HI], ring, result, 0, ctx[HI], 0, 0);
+ store_dword(i915, ctx[HI], e->flags, result, 0, ctx[HI], 0, 0);
- unplug_show_queue(i915, &cork, ring);
+ unplug_show_queue(i915, &cork, e->flags);
gem_close(i915, plug);
gem_context_destroy(i915, ctx[NOISE]);
@@ -716,18 +718,18 @@ static void promotion(int i915, unsigned ring)
munmap(ptr, 4096);
}
-static void smoketest(int i915, unsigned ring, unsigned timeout)
+static void smoketest(int i915, unsigned timeout)
{
const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
unsigned engines[16];
unsigned nengine;
- unsigned engine;
+ const struct intel_execution_engine2 *engine;
uint32_t scratch;
uint32_t *ptr;
nengine = 0;
- for_each_physical_engine(i915, engine)
- engines[nengine++] = engine;
+ __for_each_physical_engine(i915, engine)
+ engines[nengine++] = engine->flags;
igt_require(nengine);
scratch = gem_create(i915, 4096);
@@ -740,16 +742,17 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
ctx = gem_queue_create(i915);
igt_until_timeout(timeout) {
int prio;
+ unsigned flags;
prio = hars_petruska_f54_1_random_unsafe_max(MAX_PRIO - MIN_PRIO) + MIN_PRIO;
gem_context_set_priority(i915, ctx, prio);
- engine = engines[hars_petruska_f54_1_random_unsafe_max(nengine)];
- store_dword(i915, ctx, engine, scratch,
+ flags = engines[hars_petruska_f54_1_random_unsafe_max(nengine)];
+ store_dword(i915, ctx, flags, scratch,
8*child + 0, ~child,
0, 0);
for (unsigned int step = 0; step < 8; step++)
- store_dword(i915, ctx, engine, scratch,
+ store_dword(i915, ctx, flags, scratch,
8*child + 4, count++,
0, 0);
}
@@ -777,7 +780,7 @@ static void smoketest(int i915, unsigned ring, unsigned timeout)
igt_main
{
- const struct intel_execution_engine *e;
+ const struct intel_execution_engine2 *e;
int i915 = -1;
igt_fixture {
@@ -809,13 +812,12 @@ igt_main
igt_subtest("exhaust-shared-gtt-lrc")
exhaust_shared_gtt(i915, EXHAUST_LRC);
- for (e = intel_execution_engines; e->name; e++) {
+ __for_each_physical_engine(i915, e) {
igt_subtest_f("exec-shared-gtt-%s", e->name)
- exec_shared_gtt(i915, e->exec_id | e->flags);
+ exec_shared_gtt(i915, e);
igt_subtest_f("exec-single-timeline-%s", e->name)
- exec_single_timeline(i915,
- e->exec_id | e->flags);
+ exec_single_timeline(i915, e);
/*
* Check that the shared contexts operate independently,
@@ -826,33 +828,32 @@ igt_main
*/
igt_subtest_group {
igt_fixture {
- gem_require_ring(i915, e->exec_id | e->flags);
- igt_require(gem_can_store_dword(i915, e->exec_id | e->flags));
+ igt_require(gem_class_can_store_dword(i915, e->class));
igt_require(gem_scheduler_enabled(i915));
igt_require(gem_scheduler_has_ctx_priority(i915));
}
igt_subtest_f("Q-independent-%s", e->name)
- independent(i915, e->exec_id | e->flags, 0);
+ independent(i915, e, 0);
igt_subtest_f("Q-in-order-%s", e->name)
- reorder(i915, e->exec_id | e->flags, EQUAL);
+ reorder(i915, e, EQUAL);
igt_subtest_f("Q-out-order-%s", e->name)
- reorder(i915, e->exec_id | e->flags, 0);
+ reorder(i915, e, 0);
igt_subtest_f("Q-promotion-%s", e->name)
- promotion(i915, e->exec_id | e->flags);
+ promotion(i915, e);
igt_subtest_f("Q-smoketest-%s", e->name)
- smoketest(i915, e->exec_id | e->flags, 5);
+ smoketest(i915, 5);
}
}
igt_subtest("Q-smoketest-all") {
igt_require(gem_scheduler_enabled(i915));
igt_require(gem_scheduler_has_ctx_priority(i915));
- smoketest(i915, -1, 30);
+ smoketest(i915, 30);
}
igt_fixture {
--
2.19.1
More information about the igt-dev
mailing list