summaryrefslogtreecommitdiff
path: root/lib/i915
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2019-06-27 11:53:43 +0100
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2019-06-28 14:08:34 +0100
commitad129d2a583689765eaef31ff57e8cdd219f1d05 (patch)
tree89b710466d8b8dcca546f42dc91367abc4d0a3c8 /lib/i915
parentde07cc8ba86ea46a8f8c174e86d82446afbd9892 (diff)
tests/i915/gem_ctx_switch: Update with engine discovery
I converted this one as an example, or at least to drive the discussion, how more complex tests can be converted. I have kept the legacy execbuf abi testing prefixed with "legacy-". New tests were added to exercise physical engines via engine discovery and also "all" tests have been updated in the same way. To keep things simpler and avoid having to create separate contexts legacy tests have to be first since the __for_each_physical_engine iterator would otherwise configure the default context and confuse the test. So legacy tests run on the unconfigured (with engine map) context and use a new helper gem_eb_flags_to_engine to look up the engine from the intel_execution_engines2 static list. This is only to enable the core test code to be shared. Places where new contexts are created had to be updated to either equally configure the contexts or not. Another new helper, gem_context_has_engine_map was added to enable this. Also beware of drive-by formatting changes. v2: * Fix hyphen mess in subtest names. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Ramalingam C <ramalingam.c@intel.com> Cc: Andi Shyti <andi.shyti@intel.com> Reviewed-by: Andi Shyti <andi.shyti@intel.com>
Diffstat (limited to 'lib/i915')
-rw-r--r--lib/i915/gem_engine_topology.c27
-rw-r--r--lib/i915/gem_engine_topology.h5
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index fdd1b951..6cfe3468 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/lib/i915/gem_engine_topology.c
@@ -289,3 +289,30 @@ bool gem_has_engine_topology(int fd)
return !__gem_context_get_param(fd, &param);
}
+
+const struct intel_execution_engine2 *
+gem_eb_flags_to_engine(unsigned int flags)
+{
+ const struct intel_execution_engine2 *e2;
+
+ __for_each_static_engine(e2) {
+ if (e2->flags == flags)
+ return e2;
+ }
+
+ return NULL;
+}
+
+bool gem_context_has_engine_map(int fd, uint32_t ctx)
+{
+ struct drm_i915_gem_context_param param = {
+ .param = I915_CONTEXT_PARAM_ENGINES,
+ .ctx_id = ctx
+ };
+ int ret;
+
+ ret = __gem_context_get_param(fd, &param);
+ igt_assert_eq(ret, 0);
+
+ return param.size;
+}
diff --git a/lib/i915/gem_engine_topology.h b/lib/i915/gem_engine_topology.h
index 2415fd1e..b175483f 100644
--- a/lib/i915/gem_engine_topology.h
+++ b/lib/i915/gem_engine_topology.h
@@ -53,6 +53,11 @@ int gem_context_lookup_engine(int fd, uint64_t engine, uint32_t ctx_id,
void gem_context_set_all_engines(int fd, uint32_t ctx);
+bool gem_context_has_engine_map(int fd, uint32_t ctx);
+
+const struct intel_execution_engine2 *
+gem_eb_flags_to_engine(unsigned int flags);
+
#define __for_each_static_engine(e__) \
for ((e__) = intel_execution_engines2; (e__)->name; (e__)++)