[igt-dev] [PATCH i-g-t 11/74] lib/i915/gem_engine_topology: Add an iterator which doesn't munge contexts
Jason Ekstrand
jason at jlekstrand.net
Tue Apr 13 03:52:47 UTC 2021
the current for_each_physical_engine iterators smash the set of engines
on the context (or ctx0 for the __ version). This new one just gets the
list of engines from i915 and iterates over them.
---
lib/i915/gem_engine_topology.c | 10 ++++++++++
lib/i915/gem_engine_topology.h | 6 ++++++
2 files changed, 16 insertions(+)
diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index 606d3c1d..4319895f 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/lib/i915/gem_engine_topology.c
@@ -224,6 +224,16 @@ static struct intel_engine_data intel_engine_list_for_static(int fd)
return engine_data;
}
+struct intel_engine_data intel_engine_list_of_physical(int fd)
+{
+ struct intel_engine_data engine_data = { };
+
+ if (__query_engine_list(fd, &engine_data) == 0)
+ return engine_data;
+
+ return intel_engine_list_for_static(fd);
+}
+
static int gem_topology_get_param(int fd,
struct drm_i915_gem_context_param *p)
{
diff --git a/lib/i915/gem_engine_topology.h b/lib/i915/gem_engine_topology.h
index 76b7cd4d..69565240 100644
--- a/lib/i915/gem_engine_topology.h
+++ b/lib/i915/gem_engine_topology.h
@@ -41,6 +41,7 @@ struct intel_engine_data {
};
bool gem_has_engine_topology(int fd);
+struct intel_engine_data intel_engine_list_of_physical(int fd);
struct intel_engine_data intel_init_engine_list(int fd, uint32_t ctx_id);
/* iteration functions */
@@ -70,6 +71,11 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags);
((e__) = intel_get_current_engine(&i__)); \
intel_next_engine(&i__))
+#define for_each_physical_engine(fd__, e__) \
+ for (struct intel_engine_data i__##e__ = intel_engine_list_of_physical(fd__); \
+ ((e__) = intel_get_current_physical_engine(&i__##e__)); \
+ intel_next_engine(&i__##e__))
+
/* needs to replace "for_each_physical_engine" when conflicts are fixed */
#define ____for_each_physical_engine(fd__, ctx__, e__) \
for (struct intel_engine_data i__##e__ = intel_init_engine_list(fd__, ctx__); \
--
2.31.1
More information about the igt-dev
mailing list