[igt-dev] [PATCH i-g-t 5/6] lib/intel_ctx: Create intel_ctx with physical engines in a single gt
priyanka.dandamudi at intel.com
priyanka.dandamudi at intel.com
Thu Apr 21 14:52:10 UTC 2022
From: Ashutosh Dixit <ashutosh.dixit at intel.com>
Introduce intel_ctx_create_for_gt for creating an intel_ctx_t containing
all physical engines belonging to a single gt.
Cc: Zbigniew Kempczynski <zbigniew.kempczynski at intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi at intel.com>
---
lib/intel_ctx.c | 41 +++++++++++++++++++++++++++++++++++++++++
lib/intel_ctx.h | 2 ++
2 files changed, 43 insertions(+)
diff --git a/lib/intel_ctx.c b/lib/intel_ctx.c
index e19a54a8..14866511 100644
--- a/lib/intel_ctx.c
+++ b/lib/intel_ctx.c
@@ -61,6 +61,27 @@ intel_ctx_cfg_t intel_ctx_cfg_all_physical(int fd)
return cfg;
}
+/**
+ * intel_ctx_cfg_for_gt:
+ * @fd: open i915 drm file descriptor
+ * @gt: gt id
+ *
+ * Returns an intel_ctx_cfg_t containing all physical engines belonging to @gt
+ */
+intel_ctx_cfg_t intel_ctx_cfg_for_gt(int fd, int gt)
+{
+ struct i915_engine_class_instance *ci;
+ intel_ctx_cfg_t cfg = {};
+ unsigned int count;
+
+ ci = gem_list_engines(fd, 1u << gt, ~0u, &count);
+ memcpy(&cfg.engines, ci, count * sizeof(*ci));
+ cfg.num_engines = count;
+ free(ci);
+
+ return cfg;
+}
+
/**
* intel_ctx_cfg_for_engine:
* @class: engine class
@@ -295,6 +316,26 @@ const intel_ctx_t *intel_ctx_create_all_physical(int fd)
return intel_ctx_create(fd, &cfg);
}
+/**
+ * intel_ctx_create_for_gt:
+ * @fd: open i915 drm file descriptor
+ * @gt: gt id
+ *
+ * Creates an intel_ctx_t containing all physical engines belonging to @gt
+ */
+const intel_ctx_t *intel_ctx_create_for_gt(int fd, int gt)
+{
+ intel_ctx_cfg_t cfg;
+
+ igt_require(gem_has_contexts(fd) || !gt);
+
+ if (!gem_has_contexts(fd))
+ return intel_ctx_0(fd);
+
+ cfg = intel_ctx_cfg_for_gt(fd, gt);
+ return intel_ctx_create(fd, &cfg);
+}
+
/**
* intel_ctx_cfg_engine_class:
* @cfg: an intel_ctx_cfg_t
diff --git a/lib/intel_ctx.h b/lib/intel_ctx.h
index 89c65fcd..3cfeaae8 100644
--- a/lib/intel_ctx.h
+++ b/lib/intel_ctx.h
@@ -54,6 +54,7 @@ typedef struct intel_ctx_cfg {
intel_ctx_cfg_t intel_ctx_cfg_for_engine(unsigned int class, unsigned int inst);
intel_ctx_cfg_t intel_ctx_cfg_all_physical(int fd);
+intel_ctx_cfg_t intel_ctx_cfg_for_gt(int fd, int gt);
int intel_ctx_cfg_engine_class(const intel_ctx_cfg_t *cfg, unsigned int engine);
/**
@@ -75,6 +76,7 @@ const intel_ctx_t *intel_ctx_0(int fd);
const intel_ctx_t *intel_ctx_create_for_engine(int fd, unsigned int class,
unsigned int inst);
const intel_ctx_t *intel_ctx_create_all_physical(int fd);
+const intel_ctx_t *intel_ctx_create_for_gt(int fd, int gt);
void intel_ctx_destroy(int fd, const intel_ctx_t *ctx);
unsigned int intel_ctx_engine_class(const intel_ctx_t *ctx, unsigned int engine);
--
2.25.1
More information about the igt-dev
mailing list