Re: [PATCH 19/53] drm/i915: Add explicit request management to i915_gem_init_hw()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 19/02/2015 17:17, John.C.Harrison@xxxxxxxxx wrote:
From: John Harrison <John.C.Harrison@xxxxxxxxx>

Now that a single per ring loop is being done for all the different
intialisation steps in i915_gem_init_hw(), it is possible to add proper request
management as well. The last remaining issue is that the context enable call
eventually ends up within *_render_state_init() and this does it's own private
_i915_add_request() call.

This patch adds explicit request creation and submission to the top level loop
and removes the add_request() from deep within the sub-functions. Note that the
old add_request() call was being passed a batch object. This is now explicitly
written to the request object instead. A warning has also been added to
i915_add_request() to ensure that there is never an attempt to add two batch
objects to a single request - e.g. because render_state_init() was called during
execbuffer processing.

For: VIZ-5115
Signed-off-by: John Harrison <John.C.Harrison@xxxxxxxxx>
---
  drivers/gpu/drm/i915/i915_drv.h              |    3 ++-
  drivers/gpu/drm/i915/i915_gem.c              |   18 ++++++++++++++++++
  drivers/gpu/drm/i915/i915_gem_render_state.c |    3 ++-
  drivers/gpu/drm/i915/intel_lrc.c             |    8 +++-----
  4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 653c82d..ea0da6b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2158,7 +2158,8 @@ struct drm_i915_gem_request {
  	struct intel_context *ctx;
  	struct intel_ringbuffer *ringbuf;

-	/** Batch buffer related to this request if any */
+	/** Batch buffer related to this request if any (used for
+	    error state dump only) */
  	struct drm_i915_gem_object *batch_obj;

  	/** Time at which this request was emitted, in jiffies. */
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 5850991..efed49a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2467,6 +2467,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
  	 * inactive_list and lose its active reference. Hence we do not need
  	 * to explicitly hold another reference here.
  	 */
+	WARN_ON(request->batch_obj && obj);
  	request->batch_obj = obj;

  	if (!i915.enable_execlists) {
@@ -4861,8 +4862,16 @@ i915_gem_init_hw(struct drm_device *dev)

  	/* Now it is safe to go back round and do everything else: */
  	for_each_ring(ring, dev_priv, i) {
+		struct drm_i915_gem_request *req;
+
  		WARN_ON(!ring->default_context);

+		ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
+		if (ret) {
+			i915_gem_cleanup_ringbuffer(dev);
+			return ret;
+		}
+
  		if (ring->id == RCS) {
  			for (i = 0; i < NUM_L3_SLICES(dev); i++)
  				i915_gem_l3_remap(ring, i);
@@ -4871,6 +4880,7 @@ i915_gem_init_hw(struct drm_device *dev)
  		ret = i915_ppgtt_init_ring(ring);
  		if (ret && ret != -EIO) {
  			DRM_ERROR("PPGTT enable ring #%d failed %d\n", i, ret);
+			i915_gem_request_unreference(req);
  			i915_gem_cleanup_ringbuffer(dev);
  			return ret;
  		}
@@ -4878,8 +4888,16 @@ i915_gem_init_hw(struct drm_device *dev)
  		ret = i915_gem_context_enable(ring);
  		if (ret && ret != -EIO) {
  			DRM_ERROR("Context enable ring #%d failed %d\n", i, ret);
+			i915_gem_request_unreference(req);
  			i915_gem_cleanup_ringbuffer(dev);
+			return ret;
+		}

+		ret = i915_add_request_no_flush(ring);
+		if (ret) {
+			DRM_ERROR("Add request ring #%d failed: %d\n", i, ret);
+			i915_gem_request_unreference(req);
+			i915_gem_cleanup_ringbuffer(dev);
  			return ret;
  		}
  	}
diff --git a/drivers/gpu/drm/i915/i915_gem_render_state.c b/drivers/gpu/drm/i915/i915_gem_render_state.c
index aba39c3..989476e 100644
--- a/drivers/gpu/drm/i915/i915_gem_render_state.c
+++ b/drivers/gpu/drm/i915/i915_gem_render_state.c
@@ -173,7 +173,8 @@ int i915_gem_render_state_init(struct intel_engine_cs *ring)

  	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), ring);

-	ret = __i915_add_request(ring, NULL, so.obj, true);
+	WARN_ON(ring->outstanding_lazy_request->batch_obj);
+	ring->outstanding_lazy_request->batch_obj = so.obj;
  	/* __i915_add_request moves object to inactive if it fails */
  out:
  	i915_gem_render_state_fini(&so);
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 0d88e9c..dff7829 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -1350,8 +1350,6 @@ static int intel_lr_context_render_state_init(struct intel_engine_cs *ring,
  {
  	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
  	struct render_state so;
-	struct drm_i915_file_private *file_priv = ctx->file_priv;
-	struct drm_file *file = file_priv ? file_priv->file : NULL;
  	int ret;

  	ret = i915_gem_render_state_prepare(ring, &so);
@@ -1370,9 +1368,9 @@ static int intel_lr_context_render_state_init(struct intel_engine_cs *ring,

  	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), ring);

-	ret = __i915_add_request(ring, file, so.obj, true);
-	/* intel_logical_ring_add_request moves object to inactive if it
-	 * fails */
+	WARN_ON(ring->outstanding_lazy_request->batch_obj);
+	ring->outstanding_lazy_request->batch_obj = so.obj;
+	/* __i915_add_request moves object to inactive if it fails */
  out:
  	i915_gem_render_state_fini(&so);
  	return ret;


Reviewed-by: Tomas Elf <tomas.elf@xxxxxxxxx>

Thanks,
Tomas

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





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux