[Intel-gfx] [RFC PATCH 14/42] drm/i915: introduce kernel blitter_context

Matthew Auld matthew.auld at intel.com
Thu Feb 14 14:57:12 UTC 2019


We may be without a context to perform various internal blitter
operations, for example when performing object migration. Piggybacking
off the kernel_context is probably a bad idea, since it has other uses.

Signed-off-by: Matthew Auld <matthew.auld at intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
Cc: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h                  |  2 ++
 drivers/gpu/drm/i915/i915_gem_context.c          | 13 +++++++++++++
 drivers/gpu/drm/i915/selftests/mock_gem_device.c |  4 ++++
 3 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index feec3bab0f5f..5b39af57c36c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1544,6 +1544,8 @@ struct drm_i915_private {
 	struct intel_engine_cs *engine[I915_NUM_ENGINES];
 	/* Context used internally to idle the GPU and setup initial state */
 	struct i915_gem_context *kernel_context;
+	/* Context used internally for various blitting operations */
+	struct i915_gem_context *blitter_context;
 	/* Context only to be used for injecting preemption commands */
 	struct i915_gem_context *preempt_context;
 	struct intel_engine_cs *engine_class[MAX_ENGINE_CLASS + 1]
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 280813a4bf82..e814030dd89a 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -583,6 +583,18 @@ int i915_gem_contexts_init(struct drm_i915_private *dev_priv)
 	GEM_BUG_ON(!atomic_read(&ctx->hw_id_pin_count));
 	dev_priv->kernel_context = ctx;
 
+	ctx = i915_gem_context_create_kernel(dev_priv, I915_PRIORITY_NORMAL);
+	if (IS_ERR(ctx)) {
+		DRM_ERROR("Failed to create blitter global context\n");
+		return PTR_ERR(ctx);
+	}
+
+	/*
+	 * XXX: one idea here is do s/kernel_context/idle_context/, then use the
+	 * kernel_context for doing things like blitting...
+	 */
+	dev_priv->blitter_context = ctx;
+
 	/* highest priority; preempting task */
 	if (needs_preempt_context(dev_priv)) {
 		ctx = i915_gem_context_create_kernel(dev_priv, INT_MAX);
@@ -615,6 +627,7 @@ void i915_gem_contexts_fini(struct drm_i915_private *i915)
 
 	if (i915->preempt_context)
 		destroy_kernel_context(&i915->preempt_context);
+	destroy_kernel_context(&i915->blitter_context);
 	destroy_kernel_context(&i915->kernel_context);
 
 	/* Must free all deferred contexts (via flush_workqueue) first */
diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
index f8901cd12180..0b59246c99c8 100644
--- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c
+++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
@@ -248,6 +248,10 @@ struct drm_i915_private *mock_gem_device(void)
 	if (!i915->engine[RCS])
 		goto err_context;
 
+	i915->blitter_context = mock_context(i915, NULL);
+	if (!i915->blitter_context)
+		goto err_context;
+
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	WARN_ON(i915_gemfs_init(i915));
-- 
2.20.1



More information about the Intel-gfx mailing list