[Intel-gfx] [PATCH i-g-t] lib/i915: Fix test enumeration on legacy kernels

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Thu May 23 08:39:29 UTC 2019


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Where engine discovery and context engine map are not supported we must
not call the asserting gem_class_instance_to_eb_flags from the engine
list initalizer. (Since not all engines can be addressed using the legacy
execbuf API.)

Instead extract the code into lower level __gem_class_instance_to_eb_flags
helper which can return errors the caller can manually handle then.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: Andi Shyti <andi.shyti at intel.com>
---
 lib/i915/gem_engine_topology.c | 17 +++++++++++++----
 lib/igt_gt.c                   | 28 +++++++++++++++++++---------
 lib/igt_gt.h                   |  5 +++++
 3 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index d0c8bd5aaeac..1748231a1de0 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/lib/i915/gem_engine_topology.c
@@ -222,15 +222,24 @@ struct intel_engine_data intel_init_engine_list(int fd, uint32_t ctx_id)
 		__for_each_static_engine(e2) {
 			struct intel_execution_engine2 *__e2 =
 				&engine_data.engines[engine_data.nengines];
+			int flags;
+
+			flags = __gem_class_instance_to_eb_flags(fd,
+								 e2->class,
+								 e2->instance);
+
+			__e2->flags = flags;
 
 			if (!igt_only_list_subtests()) {
-				__e2->flags = gem_class_instance_to_eb_flags(fd,
-						e2->class, e2->instance);
+				/*
+				 * Skip engines not suported with legacy
+				 * execbuf.
+				 */
+				if (flags < 0)
+					continue;
 
 				if (!gem_has_ring(fd, __e2->flags))
 					continue;
-			} else {
-				__e2->flags = -1; /* 0xfff... */
 			}
 
 			__e2->name       = e2->name;
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 6b7c037e6d10..1a81a1fb405f 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -611,15 +611,13 @@ int gem_execbuf_flags_to_engine_class(unsigned int flags)
 	}
 }
 
-unsigned int
-gem_class_instance_to_eb_flags(int gem_fd,
-			       enum drm_i915_gem_engine_class class,
-			       unsigned int instance)
+int
+__gem_class_instance_to_eb_flags(int gem_fd,
+				 enum drm_i915_gem_engine_class class,
+				 unsigned int instance)
 {
-	if (class != I915_ENGINE_CLASS_VIDEO)
-		igt_assert(instance == 0);
-	else
-		igt_assert(instance >= 0 && instance <= 1);
+	if (instance > 1 || (class != I915_ENGINE_CLASS_VIDEO && instance > 0))
+		return -1;
 
 	switch (class) {
 	case I915_ENGINE_CLASS_RENDER:
@@ -640,10 +638,22 @@ gem_class_instance_to_eb_flags(int gem_fd,
 		return I915_EXEC_VEBOX;
 	case I915_ENGINE_CLASS_INVALID:
 	default:
-		igt_assert(0);
+		return -1;
 	};
 }
 
+unsigned int
+gem_class_instance_to_eb_flags(int gem_fd,
+			       enum drm_i915_gem_engine_class class,
+			       unsigned int instance)
+{
+	int flags = __gem_class_instance_to_eb_flags(gem_fd, class, instance);
+
+	igt_assert(flags >= 0);
+
+	return flags;
+}
+
 bool gem_has_engine(int gem_fd,
 		    enum drm_i915_gem_engine_class class,
 		    unsigned int instance)
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 77318e2a82b8..189b9bf70a8b 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -102,6 +102,11 @@ extern const struct intel_execution_engine2 {
 
 int gem_execbuf_flags_to_engine_class(unsigned int flags);
 
+int
+__gem_class_instance_to_eb_flags(int gem_fd,
+				 enum drm_i915_gem_engine_class class,
+				 unsigned int instance);
+
 unsigned int
 gem_class_instance_to_eb_flags(int gem_fd,
 			       enum drm_i915_gem_engine_class class,
-- 
2.20.1



More information about the Intel-gfx mailing list