[PATCH i-g-t 1/9] lib/intel_ctx: Add a intel_ctx_cfg_engine_class helper
Jason Ekstrand
jason at jlekstrand.net
Tue Jul 13 18:02:39 UTC 2021
Signed-off-by: Jason Ekstrand <jason at jlekstrand.net>
Acked-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
lib/intel_ctx.c | 42 +++++++++++++++++++++++++++---------------
lib/intel_ctx.h | 1 +
2 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/lib/intel_ctx.c b/lib/intel_ctx.c
index 5495fa764..f28c15544 100644
--- a/lib/intel_ctx.c
+++ b/lib/intel_ctx.c
@@ -267,6 +267,32 @@ const intel_ctx_t *intel_ctx_create_all_physical(int fd)
return intel_ctx_create(fd, &cfg);
}
+/**
+ * intel_ctx_cfg_engine_class:
+ * @cfg: an intel_ctx_cfg_t
+ * @engine: an engine specifier
+ *
+ * Returns the class for the given engine.
+ */
+int intel_ctx_cfg_engine_class(const intel_ctx_cfg_t *cfg, unsigned int engine)
+{
+ if (cfg->load_balance) {
+ if (engine == 0) {
+ /* This is our virtual engine */
+ return cfg->engines[0].engine_class;
+ } else {
+ /* This is a physical engine */
+ igt_assert(engine - 1 < cfg->num_engines);
+ return cfg->engines[engine - 1].engine_class;
+ }
+ } else if (cfg->num_engines > 0) {
+ igt_assert(engine < cfg->num_engines);
+ return cfg->engines[engine].engine_class;
+ } else {
+ return gem_execbuf_flags_to_engine_class(engine);
+ }
+}
+
/**
* intel_ctx_destroy:
* @fd: open i915 drm file descriptor
@@ -292,19 +318,5 @@ 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)
{
- if (ctx->cfg.load_balance) {
- if (engine == 0) {
- /* This is our virtual engine */
- return ctx->cfg.engines[0].engine_class;
- } else {
- /* This is a physical engine */
- igt_assert(engine - 1 < ctx->cfg.num_engines);
- return ctx->cfg.engines[engine - 1].engine_class;
- }
- } else if (ctx->cfg.num_engines) {
- igt_assert(engine < ctx->cfg.num_engines);
- return ctx->cfg.engines[engine].engine_class;
- } else {
- return gem_execbuf_flags_to_engine_class(engine);
- }
+ return intel_ctx_cfg_engine_class(&ctx->cfg, engine);
}
diff --git a/lib/intel_ctx.h b/lib/intel_ctx.h
index d4cb435a7..9649f6d96 100644
--- a/lib/intel_ctx.h
+++ b/lib/intel_ctx.h
@@ -52,6 +52,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);
+int intel_ctx_cfg_engine_class(const intel_ctx_cfg_t *cfg, unsigned int engine);
/**
* intel_ctx_t:
--
2.31.1
More information about the Intel-gfx-trybot
mailing list