Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_engine_topology: list engines specific to gt
@ 2023-03-13 17:59 Vikas Srivastava
  2023-03-13 17:59 ` [igt-dev] [PATCH i-g-t 2/2] lib/intel_ctx: Create intel_ctx with physical engines in a single gt Vikas Srivastava
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Vikas Srivastava @ 2023-03-13 17:59 UTC (permalink / raw)
  To: igt-dev

From: Riana Tauro <riana.tauro@intel.com>

Add a function that returns all engines belonging to a gt
Currently the function is specific to MTL and returns gt id
based on engine

Signed-off-by: Riana Tauro <riana.tauro@intel.com>
Signed-off-by: Vikas Srivastava <vikas.srivastava@intel.com>
---
 lib/i915/gem_engine_topology.c | 73 ++++++++++++++++++++++++++++++++++
 lib/i915/gem_engine_topology.h |  6 +++
 2 files changed, 79 insertions(+)

diff --git a/lib/i915/gem_engine_topology.c b/lib/i915/gem_engine_topology.c
index ca3333c252..6c8929ec59 100644
--- a/lib/i915/gem_engine_topology.c
+++ b/lib/i915/gem_engine_topology.c
@@ -350,6 +350,79 @@ struct intel_execution_engine2 gem_eb_flags_to_engine(unsigned int flags)
 	return e2__;
 }
 
+/*
+ * MTL has two GT's, one containing render/compute/copy and the other
+ * containing media engines. Return gt id based on engine.
+ */
+static int
+mtl_engine_to_gt_map(const struct i915_engine_class_instance *e)
+{
+	switch (e->engine_class) {
+	case I915_ENGINE_CLASS_RENDER:
+	case I915_ENGINE_CLASS_COMPUTE:
+	case I915_ENGINE_CLASS_COPY:
+		return 0;
+	case I915_ENGINE_CLASS_VIDEO:
+	case I915_ENGINE_CLASS_VIDEO_ENHANCE:
+		return 1;
+	default:
+		igt_assert_f(0, "Unsupported engine class %d\n", e->engine_class);
+	}
+}
+
+static int gem_engine_to_gt_map(int i915, const struct i915_engine_class_instance *engine)
+{
+	igt_require(IS_METEORLAKE(intel_get_drm_devid(i915)));
+	return mtl_engine_to_gt_map(engine);
+}
+
+/**
+ * gem_list_engines:
+ * @i915: i915 drm file descriptor
+ * @gt_mask: gt mask
+ * @class_mask: engine class mask
+ * @out: returned engine count
+ *
+ * Returns: the list of all physical engines belonging to the gt.
+ * Caller must free memory after use
+ */
+struct i915_engine_class_instance *
+gem_list_engines(int i915,
+		 uint32_t gt_mask,
+		 uint32_t class_mask,
+		 unsigned int *out)
+{
+	struct i915_engine_class_instance *engines;
+	struct drm_i915_query_engine_info *info;
+	const int size = 256 << 10; /* enough for 8 classes of 256 engines */
+	unsigned int max = 0, count = 0;
+
+	info = calloc(1, size);
+	igt_assert(!__gem_query_engines(i915, info, size));
+
+	max = info->num_engines;
+	engines = (struct i915_engine_class_instance *)info;
+	for (unsigned int i = 0; i < max; i++) {
+		const struct i915_engine_class_instance *e =
+			&info->engines[i].engine;
+
+		if (!((class_mask >> e->engine_class) & 1))
+			continue;
+		if (!((gt_mask >> gem_engine_to_gt_map(i915, e)) & 1))
+			continue;
+
+		engines[count++] = *e;
+	}
+
+	if (!count) {
+		free(engines);
+		engines = NULL;
+	}
+
+	*out = count;
+	return engines;
+}
+
 bool gem_engine_is_equal(const struct intel_execution_engine2 *e1,
 			 const struct intel_execution_engine2 *e2)
 {
diff --git a/lib/i915/gem_engine_topology.h b/lib/i915/gem_engine_topology.h
index 987f2bf944..89642c3172 100644
--- a/lib/i915/gem_engine_topology.h
+++ b/lib/i915/gem_engine_topology.h
@@ -61,6 +61,12 @@ intel_get_current_physical_engine(struct intel_engine_data *ed);
 
 void intel_next_engine(struct intel_engine_data *ed);
 
+struct i915_engine_class_instance *
+gem_list_engines(int i915,
+		 uint32_t gt_mask,
+		 uint32_t class_mask,
+		 unsigned int *count);
+
 bool gem_engine_is_equal(const struct intel_execution_engine2 *e1,
 			 const struct intel_execution_engine2 *e2);
 
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [igt-dev] [PATCH i-g-t 0/2] List engines belonging to a gt
@ 2023-04-05  6:58 Vikas Srivastava
  2023-04-05  6:58 ` [igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_engine_topology: list engines specific to gt Vikas Srivastava
  0 siblings, 1 reply; 8+ messages in thread
From: Vikas Srivastava @ 2023-04-05  6:58 UTC (permalink / raw)
  To: igt-dev

Add a function that returns all engines belonging to a gt.
Create a intel_ctx_t with physical engines belonging to a gt

Signed-off-by: Vikas Srivastava <vikas.srivastava@intel.com>
Signed-off-by: Riana Tauro <riana.tauro@intel.com>

Ashutosh Dixit (1):
  lib/intel_ctx: Create intel_ctx with physical engines in a single gt

Riana Tauro (1):
  lib/i915/gem_engine_topology: list engines specific to gt

 lib/i915/gem_engine_topology.c | 73 ++++++++++++++++++++++++++++++++++
 lib/i915/gem_engine_topology.h |  6 +++
 lib/intel_ctx.c                | 42 +++++++++++++++++++
 lib/intel_ctx.h                |  2 +
 4 files changed, 123 insertions(+)

-- 
2.25.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-04-07 11:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-13 17:59 [igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_engine_topology: list engines specific to gt Vikas Srivastava
2023-03-13 17:59 ` [igt-dev] [PATCH i-g-t 2/2] lib/intel_ctx: Create intel_ctx with physical engines in a single gt Vikas Srivastava
2023-03-16 17:21   ` Kamil Konieczny
2023-03-13 18:44 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/2] lib/i915/gem_engine_topology: list engines specific to gt Patchwork
2023-03-14 18:53 ` [igt-dev] [PATCH i-g-t 1/2] " Kamil Konieczny
2023-03-14 23:06 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,1/2] " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-04-05  6:58 [igt-dev] [PATCH i-g-t 0/2] List engines belonging to a gt Vikas Srivastava
2023-04-05  6:58 ` [igt-dev] [PATCH i-g-t 1/2] lib/i915/gem_engine_topology: list engines specific to gt Vikas Srivastava
2023-04-07 11:03   ` Kamil Konieczny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox