summaryrefslogtreecommitdiff
path: root/tests/i915
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-02-14 18:54:51 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2020-02-15 00:53:10 +0000
commitee12558c53651d5e3cd7aa66a18e5a6a351ded9a (patch)
treece3848dd7d84cae1b5b49776fe6412d2152d1538 /tests/i915
parent3361ad74ca08bb470a9a18cc25db2bef0d1311ff (diff)
i915/gem_ctx_engine: Exercise for_each_context_engine() with custom engine[]
Set up a custom engine map with no engines, and check that the for_each_context_engine() correctly iterates over nothing. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Antonio Argenziano <antonio.argenziano@intel.com>
Diffstat (limited to 'tests/i915')
-rw-r--r--tests/i915/gem_ctx_engines.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/i915/gem_ctx_engines.c b/tests/i915/gem_ctx_engines.c
index 063140e0..62f30598 100644
--- a/tests/i915/gem_ctx_engines.c
+++ b/tests/i915/gem_ctx_engines.c
@@ -549,6 +549,74 @@ static void independent(int i915)
gem_context_destroy(i915, param.ctx_id);
}
+static void libapi(int i915)
+{
+ I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, 64) = {};
+ struct drm_i915_gem_context_param p = {
+ .ctx_id = gem_context_create(i915),
+ .param = I915_CONTEXT_PARAM_ENGINES,
+ .value = to_user_pointer(&engines),
+ };
+ const struct intel_execution_engine2 *e;
+ unsigned int count, idx;
+
+ p.size = sizeof(struct i915_context_param_engines);
+ gem_context_set_param(i915, &p);
+
+ /* An empty context should be a short loop */
+ count = 0;
+ for_each_context_engine(i915, p.ctx_id, e)
+ count++;
+ igt_assert_eq(count, 0);
+
+ p.size += sizeof(struct i915_engine_class_instance);
+ engine_class(&engines, 0) = -1;
+ engine_instance(&engines, 0) = -1;
+ gem_context_set_param(i915, &p);
+
+ /* We report all engines from the context, even if invalid/unusable */
+ count = 0;
+ for_each_context_engine(i915, p.ctx_id, e) {
+ igt_assert_eq(e->class, engine_class(&engines, 0));
+ igt_assert_eq(e->instance, engine_instance(&engines, 0));
+ count++;
+ }
+ igt_assert_eq(count, 1);
+
+ /* Check that every known engine can be found from the context map */
+ idx = 0;
+ p.size = sizeof(struct i915_context_param_engines);
+ p.size += sizeof(struct i915_engine_class_instance);
+ for (engine_class(&engines, idx) = 0;
+ engine_class(&engines, idx) < 16;
+ engine_class(&engines, idx)++) {
+ for (engine_instance(&engines, idx) = 0;
+ engine_instance(&engines, idx) < 16;
+ engine_instance(&engines, idx)++) {
+ if (__gem_context_set_param(i915, &p))
+ break;
+
+ count = 0;
+ for_each_context_engine(i915, p.ctx_id, e) {
+ igt_assert_eq(e->class,
+ engine_class(&engines, count));
+ igt_assert_eq(e->instance,
+ engine_instance(&engines, count));
+ count++;
+ }
+ igt_assert_eq(count, idx + 1);
+
+ engines.engines[(idx + 1) % 64] = engines.engines[idx];
+ idx = (idx + 1) % 64;
+
+ p.size = sizeof(struct i915_context_param_engines);
+ p.size += (idx + 1) * sizeof(struct i915_engine_class_instance);
+ }
+ }
+
+ gem_context_destroy(i915, p.ctx_id);
+}
+
igt_main
{
int i915 = -1;
@@ -584,6 +652,9 @@ igt_main
igt_subtest("independent")
independent(i915);
+ igt_subtest("libapi")
+ libapi(i915);
+
igt_fixture
igt_stop_hang_detector();
}