All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v6 20/25] drm/i915: Move the magical deferred context allocation into the request
Date: Tue, 26 Apr 2016 21:06:15 +0100	[thread overview]
Message-ID: <1461701180-895-21-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1461701180-895-1-git-send-email-chris@chris-wilson.co.uk>

We can hide more details of execlists from higher level code by removing
the explicit call to create an execlist context from execbuffer and
into its first use by execlists.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  8 --------
 drivers/gpu/drm/i915/intel_lrc.c           | 19 +++++++++++++------
 drivers/gpu/drm/i915/intel_lrc.h           |  2 --
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 6f4f2a6cdf93..e0ee5d1ac372 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1085,14 +1085,6 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 		return ERR_PTR(-EIO);
 	}
 
-	if (i915.enable_execlists && !ctx->engine[engine->id].state) {
-		int ret = intel_lr_context_deferred_alloc(ctx, engine);
-		if (ret) {
-			DRM_DEBUG("Could not create LRC %u: %d\n", ctx_id, ret);
-			return ERR_PTR(ret);
-		}
-	}
-
 	return ctx;
 }
 
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index f74c77cf2b52..4be11f8d0e04 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -228,6 +228,8 @@ enum {
 #define GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT	0x17
 #define GEN9_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT	0x26
 
+static int execlists_context_deferred_alloc(struct intel_context *ctx,
+					    struct intel_engine_cs *engine);
 static int intel_lr_context_pin(struct intel_context *ctx,
 				struct intel_engine_cs *engine);
 
@@ -685,6 +687,12 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
 	 */
 	request->reserved_space += MIN_SPACE_FOR_ADD_REQUEST;
 
+	if (request->ctx->engine[engine->id].state == NULL) {
+		ret = execlists_context_deferred_alloc(request->ctx, engine);
+		if (ret)
+			return ret;
+	}
+
 	request->ringbuf = request->ctx->engine[engine->id].ringbuf;
 
 	if (i915.enable_guc_submission) {
@@ -2006,7 +2014,7 @@ logical_ring_init(struct drm_device *dev, struct intel_engine_cs *engine)
 	if (ret)
 		goto error;
 
-	ret = intel_lr_context_deferred_alloc(dctx, engine);
+	ret = execlists_context_deferred_alloc(dctx, engine);
 	if (ret)
 		goto error;
 
@@ -2480,9 +2488,9 @@ uint32_t intel_lr_context_size(struct intel_engine_cs *engine)
 }
 
 /**
- * intel_lr_context_deferred_alloc() - create the LRC specific bits of a context
+ * execlists_context_deferred_alloc() - create the LRC specific bits of a context
  * @ctx: LR context to create.
- * @ring: engine to be used with the context.
+ * @engine: engine to be used with the context.
  *
  * This function can be called more than once, with different engines, if we plan
  * to use the context with them. The context backing objects and the ringbuffers
@@ -2492,9 +2500,8 @@ uint32_t intel_lr_context_size(struct intel_engine_cs *engine)
  *
  * Return: non-zero on error.
  */
-
-int intel_lr_context_deferred_alloc(struct intel_context *ctx,
-				    struct intel_engine_cs *engine)
+static int execlists_context_deferred_alloc(struct intel_context *ctx,
+					    struct intel_engine_cs *engine)
 {
 	struct drm_device *dev = engine->dev;
 	struct drm_i915_gem_object *ctx_obj;
diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h
index 9510826f0d90..28ff324ba5dc 100644
--- a/drivers/gpu/drm/i915/intel_lrc.h
+++ b/drivers/gpu/drm/i915/intel_lrc.h
@@ -101,8 +101,6 @@ static inline void intel_logical_ring_emit_reg(struct intel_ringbuffer *ringbuf,
 
 void intel_lr_context_free(struct intel_context *ctx);
 uint32_t intel_lr_context_size(struct intel_engine_cs *engine);
-int intel_lr_context_deferred_alloc(struct intel_context *ctx,
-				    struct intel_engine_cs *engine);
 void intel_lr_context_unpin(struct intel_context *ctx,
 			    struct intel_engine_cs *engine);
 
-- 
2.8.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-04-26 20:06 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26 20:05 Premature unpinning, finally? Chris Wilson
2016-04-26 20:05 ` [PATCH v6 01/25] drm/i915/fbdev: Call intel_unpin_fb_obj() on release Chris Wilson
2016-04-27 12:45   ` Tvrtko Ursulin
2016-04-26 20:05 ` [PATCH v6 02/25] drm/i915/overlay: Replace i915_gem_obj_ggtt_offset() with the known flip_addr Chris Wilson
     [not found] ` <1461701180-895-1-git-send-email-chris-Y6uKTt2uX1cEflXRtASbqLVCufUGDwFn@public.gmane.org>
2016-04-26 20:05   ` [PATCH v6 03/25] io-mapping: Specify mapping size for io_mapping_map_wc() Chris Wilson
2016-04-26 20:05     ` Chris Wilson
2016-04-26 20:05 ` [PATCH v6 04/25] drm/i915: Introduce i915_vm_to_ggtt() Chris Wilson
2016-04-26 20:06 ` [PATCH v6 05/25] drm/i915: Move ioremap_wc tracking onto VMA Chris Wilson
2016-04-26 20:06 ` [PATCH v6 06/25] drm/i915: Use i915_vma_pin_iomap on the ringbuffer object Chris Wilson
2016-04-26 20:06 ` [PATCH v6 07/25] drm/i915: Mark the current context as lost on suspend Chris Wilson
2016-04-26 20:06 ` [PATCH v6 08/25] drm/i915: L3 cache remapping is part of context switching Chris Wilson
2016-04-26 20:06 ` [PATCH v6 09/25] drm/i915: Consolidate L3 remapping LRI Chris Wilson
2016-04-26 20:06 ` [PATCH v6 10/25] drm/i915: Remove early l3-remap Chris Wilson
2016-04-26 20:06 ` [PATCH v6 11/25] drm/i915: Rearrange switch_context to load the aliasing ppgtt on first use Chris Wilson
2016-04-26 20:06 ` [PATCH v6 12/25] drm/i915: Unify intel_ring_begin() Chris Wilson
2016-04-27  9:21   ` Joonas Lahtinen
2016-04-27  9:37     ` Chris Wilson
2016-04-27 10:54       ` Joonas Lahtinen
2016-04-26 20:06 ` [PATCH v6 13/25] drm/i915: Remove the identical implementations of request space reservation Chris Wilson
2016-04-27 10:27   ` Joonas Lahtinen
2016-04-26 20:06 ` [PATCH v6 14/25] drm/i915: Manually unwind after a failed request allocation Chris Wilson
2016-04-27 10:48   ` Joonas Lahtinen
2016-04-27 10:59     ` Chris Wilson
2016-04-27 12:51   ` Tvrtko Ursulin
2016-04-27 12:58     ` Chris Wilson
2016-04-27 13:03       ` Tvrtko Ursulin
2016-04-26 20:06 ` [PATCH v6 15/25] drm/i915: Preallocate enough space for the average request Chris Wilson
2016-04-27 13:15   ` Tvrtko Ursulin
2016-04-27 13:26     ` Chris Wilson
2016-04-26 20:06 ` [PATCH v6 16/25] drm/i915: Update execlists context descriptor format commentary Chris Wilson
2016-04-27 13:22   ` Tvrtko Ursulin
2016-04-26 20:06 ` [PATCH v6 17/25] drm/i915: Assign every HW context a unique ID Chris Wilson
2016-04-26 20:06 ` [PATCH v6 18/25] drm/i915: Replace the pinned context address with its " Chris Wilson
2016-04-26 20:06 ` [PATCH v6 19/25] drm/i915: Refactor execlists default context pinning Chris Wilson
2016-04-26 20:06 ` Chris Wilson [this message]
2016-04-26 20:06 ` [PATCH v6 21/25] drm/i915: Move releasing of the GEM request from free to retire/cancel Chris Wilson
2016-04-26 20:06 ` [PATCH v6 22/25] drm/i915: Track the previous pinned context inside the request Chris Wilson
2016-04-26 20:06 ` [PATCH v6 23/25] drm/i915: Store LRC hardware id in " Chris Wilson
2016-04-26 20:06 ` [PATCH v6 24/25] drm/i915: Stop tracking execlists retired requests Chris Wilson
2016-04-26 20:06 ` [PATCH v6 25/25] drm/i915: Unify GPU resets upon shutdown Chris Wilson
2016-04-27  7:24 ` ✗ Fi.CI.BAT: failure for series starting with [v6,01/25] drm/i915/fbdev: Call intel_unpin_fb_obj() on release Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461701180-895-21-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.