[PATCH 09/20] drm/i915: Add hooks for (per-engine) context allocation/update/free

Michal Wajdeczko michal.wajdeczko at intel.com
Tue Aug 21 14:05:24 UTC 2018


In upcoming GuC patch we will require notification per engine context
allocation/update/free to correctly setup GuC stage descriptors.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
Cc: Michel Thierry <michel.thierry at intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio at intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Cc: Tomasz Lis <tomasz.lis at intel.com>
---
 drivers/gpu/drm/i915/i915_gem_context.c |  6 +++++-
 drivers/gpu/drm/i915/intel_guc.h        | 11 +++++++++++
 drivers/gpu/drm/i915/intel_lrc.c        |  7 +++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index e3b500c..4450ab2 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -126,9 +126,13 @@ static void i915_gem_context_free(struct i915_gem_context *ctx)
 
 	for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++) {
 		struct intel_context *ce = &ctx->__engine[n];
+		struct intel_engine_cs *engine = ctx->i915->engine[n];
 
-		if (ce->ops)
+		if (ce->ops) {
+			if (ctx->i915->guc.ctx_free_hook)
+				ctx->i915->guc.ctx_free_hook(ctx, engine);
 			ce->ops->destroy(ce);
+		}
 	}
 
 	kfree(ctx->name);
diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index ad42faf..d5dafd9 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -93,6 +93,17 @@ struct intel_guc {
 
 	/* GuC's FW specific notify function */
 	void (*notify)(struct intel_guc *guc);
+
+	/*
+	 * Hooks for context (per-engine context, not gem context) allocation,
+	 * deallocation and descriptor update.
+	 */
+	void (*ctx_alloc_hook)(struct i915_gem_context *ctx,
+			       struct intel_engine_cs *engine);
+	void (*ctx_free_hook)(struct i915_gem_context *ctx,
+			      struct intel_engine_cs *engine);
+	void (*ctx_update_hook)(struct i915_gem_context *ctx,
+				struct intel_engine_cs *engine);
 };
 
 static
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 5e189e7..93a8681 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -266,6 +266,9 @@ static inline bool need_preempt(const struct intel_engine_cs *engine,
 	}
 
 	ce->lrc_desc = desc;
+
+	if (ctx->i915->guc.ctx_update_hook)
+		ctx->i915->guc.ctx_update_hook(ctx, engine);
 }
 
 static struct i915_priolist *
@@ -2727,6 +2730,7 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
 					    struct intel_engine_cs *engine,
 					    struct intel_context *ce)
 {
+	struct drm_i915_private *i915 = engine->i915;
 	struct drm_i915_gem_object *ctx_obj;
 	struct i915_vma *vma;
 	uint32_t context_size;
@@ -2782,6 +2786,9 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
 		ce->sw_counter = engine->instance;
 	}
 
+	if (i915->guc.ctx_alloc_hook)
+		i915->guc.ctx_alloc_hook(ctx, engine);
+
 	return 0;
 
 error_ring_free:
-- 
1.9.1



More information about the Intel-gfx-trybot mailing list