[igt-dev] [PATCH i-g-t 12/93] lib/i915/gem_engine_topology: Add an iterator which doesn't munge contexts (v2)
Jason Ekstrand
jason at jlekstrand.net
Wed Jun 9 04:29:58 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.
v2 (Jason Ekstrand):
- Add docs
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
lib/i915/gem_engine_topology.c | 16 ++++++++++++++++
lib/i915/gem_engine_topology.h | 16 ++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index d1f94761..6bceb909 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/lib/i915/gem_engine_topology.c
@@ -240,6 +240,22 @@ static struct intel_engine_data intel_engine_list_for_static(int fd)
return engine_data;
}
+/**
+ * intel_engine_list_of_physical:
+ * @fd: open i915 drm file descriptor
+ *
+ * Returns the list of all physical engines in the device
+ */
+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 26a7af18..bd93e410 100644
--- a/lib/i915/gem_engine_topology.h
+++ b/lib/i915/gem_engine_topology.h
@@ -50,6 +50,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 */
@@ -85,6 +86,21 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags);
((e__) = intel_get_current_engine(&i__)); \
intel_next_engine(&i__))
+/**
+ * for_each_physical_engine
+ * @fd__: open i915 drm file descriptor
+ * @e__: struct intel_execution_engine2 iterator
+ *
+ * Iterates over each physical engine in device. Be careful when using
+ * this iterator as your context may not have all of these engines and the
+ * intel_execution_engine2::flags field in the iterator may not match your
+ * context configuration.
+ */
+#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