Skip to contentSkip to conversation

Remove the outstanding_lazy_request

PATCH In review [email protected] 8 participants 234 messages Feb 13, 2015 – Mar 13, 2015 1 message not in the archive Page 2 of 3

Subsystems (2)
lore
Share & tools
lore
#106 lore raw

PATCH 2/53 drm/i915: Add missing trace point to LRC execbuff code path

In reply to [email protected]

From: John Harrison <[email protected]>

There is a trace point in the legacy execbuffer execution path that is missing from the execlist path. Trace points are extremely useful for debugging and are used by various automated validation tests. Hence, this patch adds the missing trace point back in.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_lrc.c +2 -0
index f30a8e3..637cbb7 100644
@@ -710,6 +710,8 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 	if (ret)
 		return ret;
 
+	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), dispatch_flags);
+
 	i915_gem_execbuffer_move_to_active(vmas, ring);
 	i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 2/53
#107 lore raw

Re: [PATCH 02/53] drm/i915: Add missing trace point to LRC execbuff code path

Quoted 19 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

There is a trace point in the legacy execbuffer execution path that is missing from the execlist path. Trace points are extremely useful for debugging and are used by various automated validation tests. Hence, this patch adds the missing trace point back in.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_lrc.c |    2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index f30a8e3..637cbb7 100644

drivers/gpu/drm/i915/intel_lrc.c int intel_execlists_submission(struct drm_device *dev, struct drm_file *file, · line 717

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -0
@@ -710,6 +710,8 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
  	if (ret)
  		return ret;
 
+	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), dispatch_flags);
+
  	i915_gem_execbuffer_move_to_active(vmas, ring);
  	i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#108 lore raw

PATCH 3/53 drm/i915: Cache ringbuf pointer in request structure

In reply to [email protected]

From: John Harrison <[email protected]>

In execlist mode, the ringbuf is a function of the ring and context whereas in legacy mode, it is derived from the ring alone. Thus the calculation required to determine the ringbuf pointer from the ring (and context) also needs to test execlist mode or not. This is messy.

Further, the request structure holds a pointer to both the ring and the context for which it was created. Thus, given a request, it is possible to derive the ringbuf in either legacy or execlist mode. Hence it is necessary to pass just the request in to all the low level functions rather than some combination of request, ring, context and ringbuf. However, rather than recalculating it each time, it is much simpler to just cache the ringbuf pointer in the request structure itself.

Caching the pointer means the calculation is done one at request creation time and all further code and simply read it directly from the request structure.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    3 ++-
 drivers/gpu/drm/i915/i915_gem.c         |   14 +-------------
 drivers/gpu/drm/i915/intel_lrc.c        |    6 ++++--
 drivers/gpu/drm/i915/intel_ringbuffer.c |    1 +
 4 files changed, 8 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 2dedd43..ba09137 100644
@@ -2144,8 +2144,9 @@ struct drm_i915_gem_request {
 	/** Position in the ringbuffer of the end of the whole request */
 	u32 tail;
 
-	/** Context related to this request */
+	/** Context and ring buffer related to this request */
 	struct intel_context *ctx;
+	struct intel_ringbuffer *ringbuf;
 
 	/** Batch buffer related to this request if any */
 	struct drm_i915_gem_object *batch_obj;
drivers/gpu/drm/i915/i915_gem.c +1 -13
index 61134ab..7a0dc7c 100644
@@ -2763,7 +2763,6 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
 
 	while (!list_empty(&ring->request_list)) {
 		struct drm_i915_gem_request *request;
-		struct intel_ringbuffer *ringbuf;
 
 		request = list_first_entry(&ring->request_list,
 					   struct drm_i915_gem_request,
@@ -2774,23 +2773,12 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
 
 		trace_i915_gem_request_retire(request);
 
-		/* This is one of the few common intersection points
-		 * between legacy ringbuffer submission and execlists:
-		 * we need to tell them apart in order to find the correct
-		 * ringbuffer to which the request belongs to.
-		 */
-		if (i915.enable_execlists) {
-			struct intel_context *ctx = request->ctx;
-			ringbuf = ctx->engine[ring->id].ringbuf;
-		} else
-			ringbuf = ring->buffer;
-
 		/* We know the GPU must have read the request to have
 		 * sent us the seqno + interrupt, so use the position
 		 * of tail of the request to update the last known position
 		 * of the GPU head.
 		 */
-		ringbuf->last_retired_head = request->postfix;
+		request->ringbuf->last_retired_head = request->postfix;
 
 		i915_gem_free_request(request);
 	}
drivers/gpu/drm/i915/intel_lrc.c +4 -2
index 637cbb7..f14b517 100644
@@ -888,12 +888,14 @@ static int logical_ring_alloc_request(struct intel_engine_cs *ring,
 		return ret;
 	}
 
-	/* Hold a reference to the context this request belongs to
+	/*
+	 * Hold a reference to the context this request belongs to
 	 * (we will need it when the time comes to emit/retire the
-	 * request).
+	 * request). Likewise, the ringbuff is useful to keep track of.
 	 */
 	request->ctx = ctx;
 	i915_gem_context_reference(request->ctx);
+	request->ringbuf = ctx->engine[ring->id].ringbuf;
 
 	ring->outstanding_lazy_request = request;
 	return 0;
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
index ca7de3d..7fd89e5 100644
@@ -2179,6 +2179,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring)
 
 	kref_init(&request->ref);
 	request->ring = ring;
+	request->ringbuf = ring->buffer;
 	request->uniq = dev_private->request_uniq++;
 
 	ret = i915_gem_get_seqno(ring->dev, &request->seqno);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 3/53
#109 lore raw

Re: [PATCH 03/53] drm/i915: Cache ringbuf pointer in request structure

Quoted 15 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

In execlist mode, the ringbuf is a function of the ring and context whereas in legacy mode, it is derived from the ring alone. Thus the calculation required to determine the ringbuf pointer from the ring (and context) also needs to test execlist mode or not. This is messy.

Further, the request structure holds a pointer to both the ring and the context for which it was created. Thus, given a request, it is possible to derive the ringbuf in either legacy or execlist mode. Hence it is necessary to pass just the request in to all the low level functions rather than some combination of request, ring, context and ringbuf. However, rather than recalculating it each time, it is much simpler to just cache the ringbuf pointer in the request structure itself.

Quoted 3 lines

Caching the pointer means the calculation is done one at request creation time and all further code and simply read it directly from the request structure.

"Caching the pointer means the calculation is done one at request creation time and all further code and simply read it directly from the request structure"

Nitpick: Broken sentence, you might want to fix that. Aside from that, no major problems with this patch.

Thanks,
Tomas

Quoted 88 lines

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    3 ++-
  drivers/gpu/drm/i915/i915_gem.c         |   14 +-------------
  drivers/gpu/drm/i915/intel_lrc.c        |    6 ++++--
  drivers/gpu/drm/i915/intel_ringbuffer.c |    1 +
  4 files changed, 8 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 2dedd43..ba09137 100644
@@ -2144,8 +2144,9 @@ struct drm_i915_gem_request {
  	/** Position in the ringbuffer of the end of the whole request */
  	u32 tail;
 
-	/** Context related to this request */
+	/** Context and ring buffer related to this request */
  	struct intel_context *ctx;
+	struct intel_ringbuffer *ringbuf;
 
  	/** Batch buffer related to this request if any */
  	struct drm_i915_gem_object *batch_obj;
drivers/gpu/drm/i915/i915_gem.c +1 -13
index 61134ab..7a0dc7c 100644
@@ -2763,7 +2763,6 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
 
  	while (!list_empty(&ring->request_list)) {
  		struct drm_i915_gem_request *request;
-		struct intel_ringbuffer *ringbuf;
 
  		request = list_first_entry(&ring->request_list,
  					   struct drm_i915_gem_request,
@@ -2774,23 +2773,12 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
 
  		trace_i915_gem_request_retire(request);
 
-		/* This is one of the few common intersection points
-		 * between legacy ringbuffer submission and execlists:
-		 * we need to tell them apart in order to find the correct
-		 * ringbuffer to which the request belongs to.
-		 */
-		if (i915.enable_execlists) {
-			struct intel_context *ctx = request->ctx;
-			ringbuf = ctx->engine[ring->id].ringbuf;
-		} else
-			ringbuf = ring->buffer;
-
  		/* We know the GPU must have read the request to have
  		 * sent us the seqno + interrupt, so use the position
  		 * of tail of the request to update the last known position
  		 * of the GPU head.
  		 */
-		ringbuf->last_retired_head = request->postfix;
+		request->ringbuf->last_retired_head = request->postfix;
 
  		i915_gem_free_request(request);
  	}
drivers/gpu/drm/i915/intel_lrc.c +4 -2
index 637cbb7..f14b517 100644
@@ -888,12 +888,14 @@ static int logical_ring_alloc_request(struct intel_engine_cs *ring,
  		return ret;
  	}
 
-	/* Hold a reference to the context this request belongs to
+	/*
+	 * Hold a reference to the context this request belongs to
  	 * (we will need it when the time comes to emit/retire the
-	 * request).
+	 * request). Likewise, the ringbuff is useful to keep track of.
  	 */
  	request->ctx = ctx;
  	i915_gem_context_reference(request->ctx);
+	request->ringbuf = ctx->engine[ring->id].ringbuf;
 
  	ring->outstanding_lazy_request = request;
  	return 0;
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -0
index ca7de3d..7fd89e5 100644

drivers/gpu/drm/i915/intel_ringbuffer.c intel_ring_alloc_request(struct intel_engine_cs *ring) · line 2185

Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
@@ -2179,6 +2179,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring)
 
  	kref_init(&request->ref);
  	request->ring = ring;
+	request->ringbuf = ring->buffer;
  	request->uniq = dev_private->request_uniq++;
 
  	ret = i915_gem_get_seqno(ring->dev, &request->seqno);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#110 lore raw

Re: [PATCH 03/53] drm/i915: Cache ringbuf pointer in request structure

Quoted 16 lines · Tomas Elf
Quoted 15 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

In execlist mode, the ringbuf is a function of the ring and context whereas in legacy mode, it is derived from the ring alone. Thus the calculation required to determine the ringbuf pointer from the ring (and context) also needs to test execlist mode or not. This is messy.

Further, the request structure holds a pointer to both the ring and the context for which it was created. Thus, given a request, it is possible to derive the ringbuf in either legacy or execlist mode. Hence it is necessary to pass just the request in to all the low level functions rather than some combination of request, ring, context and ringbuf. However, rather than recalculating it each time, it is much simpler to just cache the ringbuf pointer in the request structure itself.

Quoted 7 lines
Quoted 3 lines

Caching the pointer means the calculation is done one at request creation time and all further code and simply read it directly from the request structure.

"Caching the pointer means the calculation is done one at request creation time and all further code and simply read it directly from the request structure"

Nitpick: Broken sentence, you might want to fix that. Aside from that, no major problems with this patch.

Bit late now, it has already been merged as is.

Quoted 98 lines

Thanks,
Tomas

Quoted 92 lines

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    3 ++-
  drivers/gpu/drm/i915/i915_gem.c         |   14 +-------------
  drivers/gpu/drm/i915/intel_lrc.c        |    6 ++++--
  drivers/gpu/drm/i915/intel_ringbuffer.c |    1 +
  4 files changed, 8 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 2dedd43..ba09137 100644
@@ -2144,8 +2144,9 @@ struct drm_i915_gem_request {
      /** Position in the ringbuffer of the end of the whole request */
      u32 tail;
 
-    /** Context related to this request */
+    /** Context and ring buffer related to this request */
      struct intel_context *ctx;
+    struct intel_ringbuffer *ringbuf;
 
      /** Batch buffer related to this request if any */
      struct drm_i915_gem_object *batch_obj;
drivers/gpu/drm/i915/i915_gem.c +0 -1
index 61134ab..7a0dc7c 100644
@@ -2763,7 +2763,6 @@ i915_gem_retire_requests_ring(struct 
 intel_engine_cs *ring)
 
      while (!list_empty(&ring->request_list)) {
          struct drm_i915_gem_request *request;
-        struct intel_ringbuffer *ringbuf;
 
          request = list_first_entry(&ring->request_list,

struct drm_i915_gem_request,

drivers/gpu/drm/i915/i915_gem.c +1 -12
@@ -2774,23 +2773,12 @@ i915_gem_retire_requests_ring(struct 
 intel_engine_cs *ring)
 
          trace_i915_gem_request_retire(request);
 
-        /* This is one of the few common intersection points
-         * between legacy ringbuffer submission and execlists:
-         * we need to tell them apart in order to find the correct
-         * ringbuffer to which the request belongs to.
-         */
-        if (i915.enable_execlists) {
-            struct intel_context *ctx = request->ctx;
-            ringbuf = ctx->engine[ring->id].ringbuf;
-        } else
-            ringbuf = ring->buffer;
-
          /* We know the GPU must have read the request to have
           * sent us the seqno + interrupt, so use the position
           * of tail of the request to update the last known position
           * of the GPU head.
           */
-        ringbuf->last_retired_head = request->postfix;
+        request->ringbuf->last_retired_head = request->postfix;
 
          i915_gem_free_request(request);
      }
drivers/gpu/drm/i915/intel_lrc.c +4 -2
index 637cbb7..f14b517 100644
@@ -888,12 +888,14 @@ static int logical_ring_alloc_request(struct 
 intel_engine_cs *ring,
          return ret;
      }
 
-    /* Hold a reference to the context this request belongs to
+    /*
+     * Hold a reference to the context this request belongs to
       * (we will need it when the time comes to emit/retire the
-     * request).
+     * request). Likewise, the ringbuff is useful to keep track of.
       */
      request->ctx = ctx;
      i915_gem_context_reference(request->ctx);
+    request->ringbuf = ctx->engine[ring->id].ringbuf;
 
      ring->outstanding_lazy_request = request;
      return 0;
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -0
index ca7de3d..7fd89e5 100644
@@ -2179,6 +2179,7 @@ intel_ring_alloc_request(struct intel_engine_cs 
 *ring)
 
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
      kref_init(&request->ref);
      request->ring = ring;
+    request->ringbuf = ring->buffer;
      request->uniq = dev_private->request_uniq++;
 
      ret = i915_gem_get_seqno(ring->dev, &request->seqno);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#111 lore raw

PATCH 4/53 drm/i915: Merged the many do_execbuf() parameters into a structure

In reply to [email protected]

From: John Harrison <[email protected]>

The do_execbuf() function takes quite a few parameters. The actual set of parameters is going to change with the conversion to passing requests around. Further, it is due to grow massively with the arrival of the GPU scheduler.

This patch simplies the prototype by passing a parameter structure instead. Changing the parameter set in the future is then simply a matter of adding/removing items to the structure.

Note that the structure does not contain absolutely everything that is passed in. This is because the intention is to use this structure more extensively later in this patch series and more especially in the GPU scheduler that is coming soon. The latter requires hanging on to the structure as the final hardware submission can be delayed until long after the execbuf IOCTL has returned to user land. Thus it is unsafe to put anything in the structure that is local to the IOCTL call itself - such as the 'args' parameter. All entries must be copies of data or pointers to structures that are reference counted in someway and guaranteed to exist for the duration of the batch buffer's life.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |   27 +++++++-------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   56 ++++++++++++++++++----------
 drivers/gpu/drm/i915/intel_lrc.c           |   26 +++++++------
 drivers/gpu/drm/i915/intel_lrc.h           |    9 ++---
 4 files changed, 67 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +14 -13
index ba09137..fdd63ab 100644
@@ -1645,6 +1645,16 @@ struct i915_virtual_gpu {
 	bool active;
 };
 
+struct i915_execbuffer_params {
+	struct drm_device               *dev;
+	struct drm_file                 *file;
+	uint32_t                        dispatch_flags;
+	uint32_t                        batch_obj_vm_offset;
+	struct intel_engine_cs          *ring;
+	struct drm_i915_gem_object      *batch_obj;
+	struct intel_context            *ctx;
+};
+
 struct drm_i915_private {
 	struct drm_device *dev;
 	struct kmem_cache *slab;
@@ -1898,13 +1908,9 @@ struct drm_i915_private {
 
 	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
 	struct {
-		int (*do_execbuf)(struct drm_device *dev, struct drm_file *file,
-				  struct intel_engine_cs *ring,
-				  struct intel_context *ctx,
+		int (*do_execbuf)(struct i915_execbuffer_params *params,
 				  struct drm_i915_gem_execbuffer2 *args,
-				  struct list_head *vmas,
-				  struct drm_i915_gem_object *batch_obj,
-				  u64 exec_start, u32 flags);
+				  struct list_head *vmas);
 		int (*init_rings)(struct drm_device *dev);
 		void (*cleanup_ring)(struct intel_engine_cs *ring);
 		void (*stop_ring)(struct intel_engine_cs *ring);
@@ -2638,14 +2644,9 @@ void i915_gem_execbuffer_retire_commands(struct drm_device *dev,
 					 struct drm_file *file,
 					 struct intel_engine_cs *ring,
 					 struct drm_i915_gem_object *obj);
-int i915_gem_ringbuffer_submission(struct drm_device *dev,
-				   struct drm_file *file,
-				   struct intel_engine_cs *ring,
-				   struct intel_context *ctx,
+int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 				   struct drm_i915_gem_execbuffer2 *args,
-				   struct list_head *vmas,
-				   struct drm_i915_gem_object *batch_obj,
-				   u64 exec_start, u32 flags);
+				   struct list_head *vmas);
 int i915_gem_execbuffer(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
 int i915_gem_execbuffer2(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/i915_gem_execbuffer.c +36 -20

121 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.c +14 -12
index f14b517..f6a24e8a2 100644
@@ -627,16 +627,15 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  *
  * Return: non-zero if the submission fails.
  */
-int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
-			       struct intel_engine_cs *ring,
-			       struct intel_context *ctx,
+int intel_execlists_submission(struct i915_execbuffer_params *params,
 			       struct drm_i915_gem_execbuffer2 *args,
-			       struct list_head *vmas,
-			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 dispatch_flags)
+			       struct list_head *vmas)
 {
+	struct drm_device       *dev = params->dev;
+	struct intel_engine_cs  *ring = params->ring;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
+	struct intel_ringbuffer *ringbuf = params->ctx->engine[ring->id].ringbuf;
+	u64 exec_start;
 	int instp_mode;
 	u32 instp_mask;
 	int ret;
@@ -687,13 +686,13 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 		return -EINVAL;
 	}
 
-	ret = execlists_move_to_gpu(ringbuf, ctx, vmas);
+	ret = execlists_move_to_gpu(ringbuf, params->ctx, vmas);
 	if (ret)
 		return ret;
 
 	if (ring == &dev_priv->ring[RCS] &&
 	    instp_mode != dev_priv->relative_constants_mode) {
-		ret = intel_logical_ring_begin(ringbuf, ctx, 4);
+		ret = intel_logical_ring_begin(ringbuf, params->ctx, 4);
 		if (ret)
 			return ret;
 
@@ -706,14 +705,17 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 		dev_priv->relative_constants_mode = instp_mode;
 	}
 
-	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
+	exec_start = params->batch_obj_vm_offset +
+		     args->batch_start_offset;
+
+	ret = ring->emit_bb_start(ringbuf, params->ctx, exec_start, params->dispatch_flags);
 	if (ret)
 		return ret;
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), dispatch_flags);
+	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
+	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring, params->batch_obj);
 
 	return 0;
 }
drivers/gpu/drm/i915/intel_lrc.h +3 -6
index b66fc4d..3a6abce 100644
@@ -76,13 +76,10 @@ void intel_lr_context_unpin(struct intel_engine_cs *ring,
 
 /* Execlists */
 int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists);
-int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
-			       struct intel_engine_cs *ring,
-			       struct intel_context *ctx,
+struct i915_execbuffer_params;
+int intel_execlists_submission(struct i915_execbuffer_params *params,
 			       struct drm_i915_gem_execbuffer2 *args,
-			       struct list_head *vmas,
-			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 dispatch_flags);
+			       struct list_head *vmas);
 u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
 void intel_lrc_irq_handler(struct intel_engine_cs *ring);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#112 lore raw

PATCH 4/53 drm/i915: Merged the many do_execbuf() parameters into a structure

From: John Harrison <[email protected]>

The do_execbuf() function takes quite a few parameters. The actual set of parameters is going to change with the conversion to passing requests around. Further, it is due to grow massively with the arrival of the GPU scheduler.

This patch simplies the prototype by passing a parameter structure instead. Changing the parameter set in the future is then simply a matter of adding/removing items to the structure.

Note that the structure does not contain absolutely everything that is passed in. This is because the intention is to use this structure more extensively later in this patch series and more especially in the GPU scheduler that is coming soon. The latter requires hanging on to the structure as the final hardware submission can be delayed until long after the execbuf IOCTL has returned to user land. Thus it is unsafe to put anything in the structure that is local to the IOCTL call itself - such as the 'args' parameter. All entries must be copies of data or pointers to structures that are reference counted in someway and guaranteed to exist for the duration of the batch buffer's life.

v2: Rebased to newer tree and updated for changes to the command parser. Specifically, a code shuffle has required saving the batch start address in the params structure.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |   28 +++++++------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   61 ++++++++++++++++++----------
 drivers/gpu/drm/i915/intel_lrc.c           |   26 ++++++------
 drivers/gpu/drm/i915/intel_lrc.h           |    9 ++--
 4 files changed, 71 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +15 -13
index 05f106d..8dc08bc 100644
@@ -1525,6 +1525,17 @@ struct i915_virtual_gpu {
 	bool active;
 };
 
+struct i915_execbuffer_params {
+	struct drm_device               *dev;
+	struct drm_file                 *file;
+	uint32_t                        dispatch_flags;
+	uint32_t                        args_batch_start_offset;
+	uint32_t                        batch_obj_vm_offset;
+	struct intel_engine_cs          *ring;
+	struct drm_i915_gem_object      *batch_obj;
+	struct intel_context            *ctx;
+};
+
 struct drm_i915_private {
 	struct drm_device *dev;
 	struct kmem_cache *slab;
@@ -1778,13 +1789,9 @@ struct drm_i915_private {
 
 	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
 	struct {
-		int (*do_execbuf)(struct drm_device *dev, struct drm_file *file,
-				  struct intel_engine_cs *ring,
-				  struct intel_context *ctx,
+		int (*do_execbuf)(struct i915_execbuffer_params *params,
 				  struct drm_i915_gem_execbuffer2 *args,
-				  struct list_head *vmas,
-				  struct drm_i915_gem_object *batch_obj,
-				  u64 exec_start, u32 flags);
+				  struct list_head *vmas);
 		int (*init_rings)(struct drm_device *dev);
 		void (*cleanup_ring)(struct intel_engine_cs *ring);
 		void (*stop_ring)(struct intel_engine_cs *ring);
@@ -2531,14 +2538,9 @@ void i915_gem_execbuffer_retire_commands(struct drm_device *dev,
 					 struct drm_file *file,
 					 struct intel_engine_cs *ring,
 					 struct drm_i915_gem_object *obj);
-int i915_gem_ringbuffer_submission(struct drm_device *dev,
-				   struct drm_file *file,
-				   struct intel_engine_cs *ring,
-				   struct intel_context *ctx,
+int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 				   struct drm_i915_gem_execbuffer2 *args,
-				   struct list_head *vmas,
-				   struct drm_i915_gem_object *batch_obj,
-				   u64 exec_start, u32 flags);
+				   struct list_head *vmas);
 int i915_gem_execbuffer(struct drm_device *dev, void *data,
 			struct drm_file *file_priv);
 int i915_gem_execbuffer2(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/i915_gem_execbuffer.c +39 -22

132 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.c +14 -12
index fcb074b..32fabbc 100644
@@ -628,16 +628,15 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  *
  * Return: non-zero if the submission fails.
  */
-int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
-			       struct intel_engine_cs *ring,
-			       struct intel_context *ctx,
+int intel_execlists_submission(struct i915_execbuffer_params *params,
 			       struct drm_i915_gem_execbuffer2 *args,
-			       struct list_head *vmas,
-			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 dispatch_flags)
+			       struct list_head *vmas)
 {
+	struct drm_device       *dev = params->dev;
+	struct intel_engine_cs  *ring = params->ring;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
+	struct intel_ringbuffer *ringbuf = params->ctx->engine[ring->id].ringbuf;
+	u64 exec_start;
 	int instp_mode;
 	u32 instp_mask;
 	int ret;
@@ -688,13 +687,13 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 		return -EINVAL;
 	}
 
-	ret = execlists_move_to_gpu(ringbuf, ctx, vmas);
+	ret = execlists_move_to_gpu(ringbuf, params->ctx, vmas);
 	if (ret)
 		return ret;
 
 	if (ring == &dev_priv->ring[RCS] &&
 	    instp_mode != dev_priv->relative_constants_mode) {
-		ret = intel_logical_ring_begin(ringbuf, ctx, 4);
+		ret = intel_logical_ring_begin(ringbuf, params->ctx, 4);
 		if (ret)
 			return ret;
 
@@ -707,14 +706,17 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 		dev_priv->relative_constants_mode = instp_mode;
 	}
 
-	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
+	exec_start = params->batch_obj_vm_offset +
+		     args->batch_start_offset;
+
+	ret = ring->emit_bb_start(ringbuf, params->ctx, exec_start, params->dispatch_flags);
 	if (ret)
 		return ret;
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), dispatch_flags);
+	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
+	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring, params->batch_obj);
 
 	return 0;
 }
drivers/gpu/drm/i915/intel_lrc.h +3 -6
index adb731e4..a64e344 100644
@@ -78,13 +78,10 @@ void intel_lr_context_reset(struct drm_device *dev,
 
 /* Execlists */
 int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists);
-int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
-			       struct intel_engine_cs *ring,
-			       struct intel_context *ctx,
+struct i915_execbuffer_params;
+int intel_execlists_submission(struct i915_execbuffer_params *params,
 			       struct drm_i915_gem_execbuffer2 *args,
-			       struct list_head *vmas,
-			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 dispatch_flags);
+			       struct list_head *vmas);
 u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
 void intel_lrc_irq_handler(struct intel_engine_cs *ring);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 4/53
#113 lore raw

Re: [PATCH 04/53] drm/i915: Merged the many do_execbuf() parameters into a structure

In reply to [email protected]
Quoted 7 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The do_execbuf() function takes quite a few parameters. The actual set of parameters is going to change with the conversion to passing requests around. Further, it is due to grow massively with the arrival of the GPU scheduler.

This patch simplies the prototype by passing a parameter structure instead.

Nitpick: simplies -> simplifies.

Quoted 12 lines

Changing the parameter set in the future is then simply a matter of adding/removing items to the structure.

Note that the structure does not contain absolutely everything that is passed in. This is because the intention is to use this structure more extensively later in this patch series and more especially in the GPU scheduler that is coming soon. The latter requires hanging on to the structure as the final hardware submission can be delayed until long after the execbuf IOCTL has returned to user land. Thus it is unsafe to put anything in the structure that is local to the IOCTL call itself - such as the 'args' parameter. All entries must be copies of data or pointers to structures that are reference counted in someway and guaranteed to exist for the duration of the batch buffer's life.

Nitpick: someway -> some way

Quoted 147 lines

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |   27 +++++++-------
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   56 ++++++++++++++++++----------
  drivers/gpu/drm/i915/intel_lrc.c           |   26 +++++++------
  drivers/gpu/drm/i915/intel_lrc.h           |    9 ++---
  4 files changed, 67 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +14 -13
index ba09137..fdd63ab 100644
@@ -1645,6 +1645,16 @@ struct i915_virtual_gpu {
  	bool active;
  };
 
+struct i915_execbuffer_params {
+	struct drm_device               *dev;
+	struct drm_file                 *file;
+	uint32_t                        dispatch_flags;
+	uint32_t                        batch_obj_vm_offset;
+	struct intel_engine_cs          *ring;
+	struct drm_i915_gem_object      *batch_obj;
+	struct intel_context            *ctx;
+};
+
  struct drm_i915_private {
  	struct drm_device *dev;
  	struct kmem_cache *slab;
@@ -1898,13 +1908,9 @@ struct drm_i915_private {
 
  	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
  	struct {
-		int (*do_execbuf)(struct drm_device *dev, struct drm_file *file,
-				  struct intel_engine_cs *ring,
-				  struct intel_context *ctx,
+		int (*do_execbuf)(struct i915_execbuffer_params *params,
  				  struct drm_i915_gem_execbuffer2 *args,
-				  struct list_head *vmas,
-				  struct drm_i915_gem_object *batch_obj,
-				  u64 exec_start, u32 flags);
+				  struct list_head *vmas);
  		int (*init_rings)(struct drm_device *dev);
  		void (*cleanup_ring)(struct intel_engine_cs *ring);
  		void (*stop_ring)(struct intel_engine_cs *ring);
@@ -2638,14 +2644,9 @@ void i915_gem_execbuffer_retire_commands(struct drm_device *dev,
  					 struct drm_file *file,
  					 struct intel_engine_cs *ring,
  					 struct drm_i915_gem_object *obj);
-int i915_gem_ringbuffer_submission(struct drm_device *dev,
-				   struct drm_file *file,
-				   struct intel_engine_cs *ring,
-				   struct intel_context *ctx,
+int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  				   struct drm_i915_gem_execbuffer2 *args,
-				   struct list_head *vmas,
-				   struct drm_i915_gem_object *batch_obj,
-				   u64 exec_start, u32 flags);
+				   struct list_head *vmas);
  int i915_gem_execbuffer(struct drm_device *dev, void *data,
  			struct drm_file *file_priv);
  int i915_gem_execbuffer2(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/i915_gem_execbuffer.c +16 -14
index ec9ea45..93b0ef0 100644
@@ -1132,17 +1132,15 @@ i915_gem_execbuffer_parse(struct intel_engine_cs *ring,
  }
 
  int
-i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
-			       struct intel_engine_cs *ring,
-			       struct intel_context *ctx,
+i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  			       struct drm_i915_gem_execbuffer2 *args,
-			       struct list_head *vmas,
-			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 dispatch_flags)
+			       struct list_head *vmas)
  {
  	struct drm_clip_rect *cliprects = NULL;
+	struct drm_device *dev = params->dev;
+	struct intel_engine_cs *ring = params->ring;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	u64 exec_len;
+	u64 exec_start, exec_len;
  	int instp_mode;
  	u32 instp_mask;
  	int i, ret = 0;
@@ -1194,7 +1192,7 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
  	if (ret)
  		goto error;
 
-	ret = i915_switch_context(ring, ctx);
+	ret = i915_switch_context(ring, params->ctx);
  	if (ret)
  		goto error;
 
@@ -1251,12 +1249,15 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
  	}
 
  	if (args->flags & I915_EXEC_GEN7_SOL_RESET) {
-		ret = i915_reset_gen7_sol_offsets(dev, ring);
+		ret = i915_reset_gen7_sol_offsets(params->dev, ring);
  		if (ret)
  			goto error;
  	}
 
-	exec_len = args->batch_len;
+	exec_len   = args->batch_len;
+	exec_start = params->batch_obj_vm_offset +
+		     args->batch_start_offset;
+
  	if (cliprects) {
  		for (i = 0; i < args->num_cliprects; i++) {
  			ret = i915_emit_box(ring, &cliprects[i],
@@ -1266,22 +1267,23 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 
  			ret = ring->dispatch_execbuffer(ring,
  							exec_start, exec_len,
-							dispatch_flags);
+							params->dispatch_flags);
  			if (ret)
  				goto error;
  		}
  	} else {
  		ret = ring->dispatch_execbuffer(ring,
  						exec_start, exec_len,
-						dispatch_flags);
+						params->dispatch_flags);
  		if (ret)
  			return ret;
  	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), dispatch_flags);
+	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
  	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
+	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring,
+					    params->batch_obj);
 
  error:
  	kfree(cliprects);

drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1356

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -0
@@ -1351,8 +1353,9 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	struct intel_engine_cs *ring;
  	struct intel_context *ctx;
  	struct i915_address_space *vm;
+	struct i915_execbuffer_params params_master; /* XXX: will be removed later */

params_master is not removed anywhere in this patch series. What is the plan for this variable?

(Update: John has in later discussions said that it will be dropped once the scheduler lands, also it is explained further in comment below where the params variable is populated. Still, the comment above could say "will be removed once the scheduler lands" or something. Not a big deal, though.)

Thanks,
Tomas

Quoted 121 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +19 -6
+	struct i915_execbuffer_params *params = &params_master;
  	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
-	u64 exec_start = args->batch_start_offset;
  	u32 dispatch_flags;
  	int ret;
  	bool need_relocs;
@@ -1445,6 +1448,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	else
  		vm = &dev_priv->gtt.base;
 
+	memset(&params_master, 0x00, sizeof(params_master));
+
  	eb = eb_create(args);
  	if (eb == NULL) {
  		i915_gem_context_unreference(ctx);
@@ -1522,13 +1527,24 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  		if (ret)
  			goto err;
 
-		exec_start += i915_gem_obj_ggtt_offset(batch_obj);
+		params->batch_obj_vm_offset = i915_gem_obj_ggtt_offset(batch_obj);
  	} else
-		exec_start += i915_gem_obj_offset(batch_obj, vm);
+		params->batch_obj_vm_offset = i915_gem_obj_offset(batch_obj, vm);
 
-	ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-				      &eb->vmas, batch_obj, exec_start,
-				      dispatch_flags);
+	/*
+	 * Save assorted stuff away to pass through to *_submission().
+	 * NB: This data should be 'persistent' and not local as it will
+	 * kept around beyond the duration of the IOCTL once the GPU
+	 * scheduler arrives.
+	 */
+	params->dev                     = dev;
+	params->file                    = file;
+	params->ring                    = ring;
+	params->dispatch_flags          = dispatch_flags;
+	params->batch_obj               = batch_obj;
+	params->ctx                     = ctx;
+
+	ret = dev_priv->gt.do_execbuf(params, args, &eb->vmas);
 
  	/*
  	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
drivers/gpu/drm/i915/intel_lrc.c +14 -12
index f14b517..f6a24e8a2 100644
@@ -627,16 +627,15 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
   *
   * Return: non-zero if the submission fails.
   */
-int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
-			       struct intel_engine_cs *ring,
-			       struct intel_context *ctx,
+int intel_execlists_submission(struct i915_execbuffer_params *params,
  			       struct drm_i915_gem_execbuffer2 *args,
-			       struct list_head *vmas,
-			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 dispatch_flags)
+			       struct list_head *vmas)
  {
+	struct drm_device       *dev = params->dev;
+	struct intel_engine_cs  *ring = params->ring;
  	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
+	struct intel_ringbuffer *ringbuf = params->ctx->engine[ring->id].ringbuf;
+	u64 exec_start;
  	int instp_mode;
  	u32 instp_mask;
  	int ret;
@@ -687,13 +686,13 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
  		return -EINVAL;
  	}
 
-	ret = execlists_move_to_gpu(ringbuf, ctx, vmas);
+	ret = execlists_move_to_gpu(ringbuf, params->ctx, vmas);
  	if (ret)
  		return ret;
 
  	if (ring == &dev_priv->ring[RCS] &&
  	    instp_mode != dev_priv->relative_constants_mode) {
-		ret = intel_logical_ring_begin(ringbuf, ctx, 4);
+		ret = intel_logical_ring_begin(ringbuf, params->ctx, 4);
  		if (ret)
  			return ret;
 
@@ -706,14 +705,17 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
  		dev_priv->relative_constants_mode = instp_mode;
  	}
 
-	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
+	exec_start = params->batch_obj_vm_offset +
+		     args->batch_start_offset;
+
+	ret = ring->emit_bb_start(ringbuf, params->ctx, exec_start, params->dispatch_flags);
  	if (ret)
  		return ret;
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), dispatch_flags);
+	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
  	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
+	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring, params->batch_obj);
 
  	return 0;
  }
drivers/gpu/drm/i915/intel_lrc.h +0 -3
index b66fc4d..3a6abce 100644
@@ -76,13 +76,10 @@ void intel_lr_context_unpin(struct intel_engine_cs *ring,
 
  /* Execlists */
  int intel_sanitize_enable_execlists(struct drm_device *dev, int enable_execlists);
-int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
-			       struct intel_engine_cs *ring,
-			       struct intel_context *ctx,

drivers/gpu/drm/i915/intel_lrc.h void intel_lr_context_unpin(struct intel_engine_cs *ring, · line 85

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.h +3 -3
+struct i915_execbuffer_params;
+int intel_execlists_submission(struct i915_execbuffer_params *params,
  			       struct drm_i915_gem_execbuffer2 *args,
-			       struct list_head *vmas,
-			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 dispatch_flags);
+			       struct list_head *vmas);
  u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
  void intel_lrc_irq_handler(struct intel_engine_cs *ring);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#114 lore raw

PATCH 5/53 drm/i915: Add return code check to i915_gem_execbuffer_retire_commands()

In reply to [email protected]

From: John Harrison <[email protected]>

For some reason, the i915_add_request() call in i915_gem_execbuffer_retire_commands() was explicitly having its return code ignored. The _retire_commands() function itself was 'void'. Given that _add_request() can fail without dispatching the batch buffer, this seems odd.

Also shrunk the parameter list to a single structure as everything it requires is available in the execbuff_params object.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    5 +----
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   16 +++++++---------
 drivers/gpu/drm/i915/intel_lrc.c           |    3 +--
 3 files changed, 9 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -4
index fdd63ab..b350910 100644
@@ -2640,10 +2640,7 @@ int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
 			     struct drm_file *file_priv);
 void i915_gem_execbuffer_move_to_active(struct list_head *vmas,
 					struct intel_engine_cs *ring);
-void i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-					 struct drm_file *file,
-					 struct intel_engine_cs *ring,
-					 struct drm_i915_gem_object *obj);
+int i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params);
 int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 				   struct drm_i915_gem_execbuffer2 *args,
 				   struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -9
index 93b0ef0..ca85803 100644
@@ -989,17 +989,15 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
 	}
 }
 
-void
-i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-				    struct drm_file *file,
-				    struct intel_engine_cs *ring,
-				    struct drm_i915_gem_object *obj)
+int
+i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
 {
 	/* Unconditionally force add_request to emit a full flush. */
-	ring->gpu_caches_dirty = true;
+	params->ring->gpu_caches_dirty = true;
 
 	/* Add a breadcrumb for the completion of the batch buffer */
-	(void)__i915_add_request(ring, file, obj);
+	return __i915_add_request(params->ring, params->file,
+				  params->batch_obj);
 }
 
 static int
@@ -1282,8 +1280,8 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring,
-					    params->batch_obj);
+
+	ret = i915_gem_execbuffer_retire_commands(params);
 
 error:
 	kfree(cliprects);
drivers/gpu/drm/i915/intel_lrc.c +1 -2
index f6a24e8a2..dc474b4 100644
@@ -715,9 +715,8 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring, params->batch_obj);
 
-	return 0;
+	return i915_gem_execbuffer_retire_commands(params);
 }
 
 void intel_execlists_retire_requests(struct intel_engine_cs *ring)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 5/53
#115 lore raw

Re: [PATCH 05/53] drm/i915: Add return code check to i915_gem_execbuffer_retire_commands()

Quoted 78 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

For some reason, the i915_add_request() call in i915_gem_execbuffer_retire_commands() was explicitly having its return code ignored. The _retire_commands() function itself was 'void'. Given that _add_request() can fail without dispatching the batch buffer, this seems odd.

Also shrunk the parameter list to a single structure as everything it requires is available in the execbuff_params object.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    5 +----
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   16 +++++++---------
  drivers/gpu/drm/i915/intel_lrc.c           |    3 +--
  3 files changed, 9 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -4
index fdd63ab..b350910 100644
@@ -2640,10 +2640,7 @@ int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
  			     struct drm_file *file_priv);
  void i915_gem_execbuffer_move_to_active(struct list_head *vmas,
  					struct intel_engine_cs *ring);
-void i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-					 struct drm_file *file,
-					 struct intel_engine_cs *ring,
-					 struct drm_i915_gem_object *obj);
+int i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params);
  int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  				   struct drm_i915_gem_execbuffer2 *args,
  				   struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -9
index 93b0ef0..ca85803 100644
@@ -989,17 +989,15 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
  	}
  }
 
-void
-i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-				    struct drm_file *file,
-				    struct intel_engine_cs *ring,
-				    struct drm_i915_gem_object *obj)
+int
+i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
  {
  	/* Unconditionally force add_request to emit a full flush. */
-	ring->gpu_caches_dirty = true;
+	params->ring->gpu_caches_dirty = true;
 
  	/* Add a breadcrumb for the completion of the batch buffer */
-	(void)__i915_add_request(ring, file, obj);
+	return __i915_add_request(params->ring, params->file,
+				  params->batch_obj);
  }
 
  static int
@@ -1282,8 +1280,8 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
  	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring,
-					    params->batch_obj);
+
+	ret = i915_gem_execbuffer_retire_commands(params);
 
  error:
  	kfree(cliprects);
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index f6a24e8a2..dc474b4 100644

drivers/gpu/drm/i915/intel_lrc.c int intel_execlists_submission(struct i915_execbuffer_params *params, · line 722

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -2
@@ -715,9 +715,8 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
  	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
  	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring, params->batch_obj);
 
-	return 0;
+	return i915_gem_execbuffer_retire_commands(params);
  }
 
  void intel_execlists_retire_requests(struct intel_engine_cs *ring)

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#116 lore raw

Re: [PATCH 05/53] drm/i915: Add return code check to i915_gem_execbuffer_retire_commands()

Quoted 83 lines · Tomas Elf
Quoted 82 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

For some reason, the i915_add_request() call in i915_gem_execbuffer_retire_commands() was explicitly having its return code ignored. The _retire_commands() function itself was 'void'. Given that _add_request() can fail without dispatching the batch buffer, this seems odd.

Also shrunk the parameter list to a single structure as everything it requires is available in the execbuff_params object.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    5 +----
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   16 +++++++---------
 drivers/gpu/drm/i915/intel_lrc.c           |    3 +--
 3 files changed, 9 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -4
index fdd63ab..b350910 100644
@@ -2640,10 +2640,7 @@ int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
 			     struct drm_file *file_priv);
 void i915_gem_execbuffer_move_to_active(struct list_head *vmas,
 					struct intel_engine_cs *ring);
-void i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-					 struct drm_file *file,
-					 struct intel_engine_cs *ring,
-					 struct drm_i915_gem_object *obj);
+int i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params);
 int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 				   struct drm_i915_gem_execbuffer2 *args,
 				   struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -9
index 93b0ef0..ca85803 100644
@@ -989,17 +989,15 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
 	}
 }
 
-void
-i915_gem_execbuffer_retire_commands(struct drm_device *dev,
-				    struct drm_file *file,
-				    struct intel_engine_cs *ring,
-				    struct drm_i915_gem_object *obj)
+int
+i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
 {
 	/* Unconditionally force add_request to emit a full flush. */
-	ring->gpu_caches_dirty = true;
+	params->ring->gpu_caches_dirty = true;
 
 	/* Add a breadcrumb for the completion of the batch buffer */
-	(void)__i915_add_request(ring, file, obj);
+	return __i915_add_request(params->ring, params->file,
+				  params->batch_obj);
 }
 
 static int
@@ -1282,8 +1280,8 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring,
-					    params->batch_obj);
+
+	ret = i915_gem_execbuffer_retire_commands(params);
 
 error:
 	kfree(cliprects);
drivers/gpu/drm/i915/intel_lrc.c +0 -1
index f6a24e8a2..dc474b4 100644
@@ -715,9 +715,8 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
-	i915_gem_execbuffer_retire_commands(params->dev, params->file, ring, params->batch_obj);
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c int intel_execlists_submission(struct i915_execbuffer_params *params, · line 722

Quoted 6 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
-	return 0;
+	return i915_gem_execbuffer_retire_commands(params);
 }
 
 void intel_execlists_retire_requests(struct intel_engine_cs *ring)

Patch discussion unfortunately split since I've made all my comments on the earlier iteration. Anyway there's a big discussion there, you might want to look into that and reconsder your r-b ;-)
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#117 lore raw

PATCH 6/53 drm/i915: Wrap request allocation with a function pointer

In reply to [email protected]

From: John Harrison <[email protected]>

In order to explicitly manage requests from creation to submission, it is necessary to be able to explicitly create them in the first place. This patch adds an indirection wrapper to the request creation function so that it can be called from generic code without having to worry about execlist vs legacy mode.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 ++
 drivers/gpu/drm/i915/i915_gem.c         |    2 ++
 drivers/gpu/drm/i915/intel_lrc.c        |    6 +++---
 drivers/gpu/drm/i915/intel_lrc.h        |    2 ++
 drivers/gpu/drm/i915/intel_ringbuffer.c |    6 +++---
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 ++
 6 files changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index b350910..87a4a2e 100644
@@ -1908,6 +1908,8 @@ struct drm_i915_private {
 
 	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
 	struct {
+		int (*alloc_request)(struct intel_engine_cs *ring,
+				     struct intel_context *ctx);
 		int (*do_execbuf)(struct i915_execbuffer_params *params,
 				  struct drm_i915_gem_execbuffer2 *args,
 				  struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem.c +2 -0
index 7a0dc7c..cf959e3 100644
@@ -4860,11 +4860,13 @@ int i915_gem_init(struct drm_device *dev)
 	}
 
 	if (!i915.enable_execlists) {
+		dev_priv->gt.alloc_request = intel_ring_alloc_request;
 		dev_priv->gt.do_execbuf = i915_gem_ringbuffer_submission;
 		dev_priv->gt.init_rings = i915_gem_init_rings;
 		dev_priv->gt.cleanup_ring = intel_cleanup_ring_buffer;
 		dev_priv->gt.stop_ring = intel_stop_ring_buffer;
 	} else {
+		dev_priv->gt.alloc_request = intel_logical_ring_alloc_request;
 		dev_priv->gt.do_execbuf = intel_execlists_submission;
 		dev_priv->gt.init_rings = intel_logical_rings_init;
 		dev_priv->gt.cleanup_ring = intel_logical_ring_cleanup;
drivers/gpu/drm/i915/intel_lrc.c +3 -3
index dc474b4..8628abf 100644
@@ -856,8 +856,8 @@ void intel_lr_context_unpin(struct intel_engine_cs *ring,
 	}
 }
 
-static int logical_ring_alloc_request(struct intel_engine_cs *ring,
-				      struct intel_context *ctx)
+int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
+				     struct intel_context *ctx)
 {
 	struct drm_i915_gem_request *request;
 	struct drm_i915_private *dev_private = ring->dev->dev_private;
@@ -1066,7 +1066,7 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
 		return ret;
 
 	/* Preallocate the olr before touching the ring */
-	ret = logical_ring_alloc_request(ring, ctx);
+	ret = intel_logical_ring_alloc_request(ring, ctx);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +2 -0
index 3a6abce..3cc38bd 100644
@@ -36,6 +36,8 @@
 #define RING_CONTEXT_STATUS_PTR(ring)	((ring)->mmio_base+0x3a0)
 
 /* Logical Rings */
+int __must_check intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
+						  struct intel_context *ctx);
 void intel_logical_ring_stop(struct intel_engine_cs *ring);
 void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
 int intel_logical_rings_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
index 7fd89e5..635707a 100644
@@ -2163,8 +2163,8 @@ int intel_ring_idle(struct intel_engine_cs *ring)
 	return i915_wait_request(req);
 }
 
-static int
-intel_ring_alloc_request(struct intel_engine_cs *ring)
+int
+intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx)
 {
 	int ret;
 	struct drm_i915_gem_request *request;
@@ -2229,7 +2229,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
 		return ret;
 
 	/* Preallocate the olr before touching the ring */
-	ret = intel_ring_alloc_request(ring);
+	ret = intel_ring_alloc_request(ring, NULL);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
index ffa3724..2fd960a 100644
@@ -392,6 +392,8 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
 
 int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
 int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
+int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
+					  struct intel_context *ctx);
 static inline void intel_ring_emit(struct intel_engine_cs *ring,
 				   u32 data)
 {
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 6/53
#118 lore raw

Re: [PATCH 06/53] drm/i915: Wrap request allocation with a function pointer

Quoted 116 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

In order to explicitly manage requests from creation to submission, it is necessary to be able to explicitly create them in the first place. This patch adds an indirection wrapper to the request creation function so that it can be called from generic code without having to worry about execlist vs legacy mode.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    2 ++
  drivers/gpu/drm/i915/i915_gem.c         |    2 ++
  drivers/gpu/drm/i915/intel_lrc.c        |    6 +++---
  drivers/gpu/drm/i915/intel_lrc.h        |    2 ++
  drivers/gpu/drm/i915/intel_ringbuffer.c |    6 +++---
  drivers/gpu/drm/i915/intel_ringbuffer.h |    2 ++
  6 files changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index b350910..87a4a2e 100644
@@ -1908,6 +1908,8 @@ struct drm_i915_private {
 
  	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
  	struct {
+		int (*alloc_request)(struct intel_engine_cs *ring,
+				     struct intel_context *ctx);
  		int (*do_execbuf)(struct i915_execbuffer_params *params,
  				  struct drm_i915_gem_execbuffer2 *args,
  				  struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem.c +2 -0
index 7a0dc7c..cf959e3 100644
@@ -4860,11 +4860,13 @@ int i915_gem_init(struct drm_device *dev)
  	}
 
  	if (!i915.enable_execlists) {
+		dev_priv->gt.alloc_request = intel_ring_alloc_request;
  		dev_priv->gt.do_execbuf = i915_gem_ringbuffer_submission;
  		dev_priv->gt.init_rings = i915_gem_init_rings;
  		dev_priv->gt.cleanup_ring = intel_cleanup_ring_buffer;
  		dev_priv->gt.stop_ring = intel_stop_ring_buffer;
  	} else {
+		dev_priv->gt.alloc_request = intel_logical_ring_alloc_request;
  		dev_priv->gt.do_execbuf = intel_execlists_submission;
  		dev_priv->gt.init_rings = intel_logical_rings_init;
  		dev_priv->gt.cleanup_ring = intel_logical_ring_cleanup;
drivers/gpu/drm/i915/intel_lrc.c +3 -3
index dc474b4..8628abf 100644
@@ -856,8 +856,8 @@ void intel_lr_context_unpin(struct intel_engine_cs *ring,
  	}
  }
 
-static int logical_ring_alloc_request(struct intel_engine_cs *ring,
-				      struct intel_context *ctx)
+int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
+				     struct intel_context *ctx)
  {
  	struct drm_i915_gem_request *request;
  	struct drm_i915_private *dev_private = ring->dev->dev_private;
@@ -1066,7 +1066,7 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
  		return ret;
 
  	/* Preallocate the olr before touching the ring */
-	ret = logical_ring_alloc_request(ring, ctx);
+	ret = intel_logical_ring_alloc_request(ring, ctx);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +2 -0
index 3a6abce..3cc38bd 100644
@@ -36,6 +36,8 @@
  #define RING_CONTEXT_STATUS_PTR(ring)	((ring)->mmio_base+0x3a0)
 
  /* Logical Rings */
+int __must_check intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
+						  struct intel_context *ctx);
  void intel_logical_ring_stop(struct intel_engine_cs *ring);
  void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
  int intel_logical_rings_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
index 7fd89e5..635707a 100644
@@ -2163,8 +2163,8 @@ int intel_ring_idle(struct intel_engine_cs *ring)
  	return i915_wait_request(req);
  }
 
-static int
-intel_ring_alloc_request(struct intel_engine_cs *ring)
+int
+intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx)
  {
  	int ret;
  	struct drm_i915_gem_request *request;
@@ -2229,7 +2229,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
  		return ret;
 
  	/* Preallocate the olr before touching the ring */
-	ret = intel_ring_alloc_request(ring);
+	ret = intel_ring_alloc_request(ring, NULL);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index ffa3724..2fd960a 100644

drivers/gpu/drm/i915/intel_ringbuffer.h void intel_cleanup_ring_buffer(struct intel_engine_cs *ring); · line 399

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
@@ -392,6 +392,8 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
 
  int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
  int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
+int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
+					  struct intel_context *ctx);
  static inline void intel_ring_emit(struct intel_engine_cs *ring,
  				   u32 data)
  {

I find the whole idea of having virtual functions pointing to public functions kind of strange since it allows for two ways of accessing the function. If you look at the way we set up the virtual ring buffer functions those virtual functions are static and the set up is done in intel_ringbuffer.c without exposing the functions to the outside world. Having the set up take place in i915_gem.c forces the virtual functions to be public, which is not very nice. It would've been a better idea to pass the virtual function struct for initialization inside intel_lrc.c and intel_ringbuffer.c, which would have avoided making those functions public.

I'd like to hear some input from someone else on this on this, like e.g. Daniel Vetter (since he was a strong proponent of the legacy/execlist split, which was the underlying reason for this construct in the first place - not saying that it couldn't have been done in some other way, though).

Obviously, this is not the fault of the patch at hand and you're just following the already established pattern of setting up these virtual functions so I can't fault you for that.

Therefore I'm ok with this change (but not the construct as a whole):

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#119 lore raw

Re: [PATCH 06/53] drm/i915: Wrap request allocation with a function pointer

Quoted 136 lines · Tomas Elf
Quoted 116 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

In order to explicitly manage requests from creation to submission, it is necessary to be able to explicitly create them in the first place. This patch adds an indirection wrapper to the request creation function so that it can be called from generic code without having to worry about execlist vs legacy mode.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 ++
 drivers/gpu/drm/i915/i915_gem.c         |    2 ++
 drivers/gpu/drm/i915/intel_lrc.c        |    6 +++---
 drivers/gpu/drm/i915/intel_lrc.h        |    2 ++
 drivers/gpu/drm/i915/intel_ringbuffer.c |    6 +++---
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 ++
 6 files changed, 14 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index b350910..87a4a2e 100644
@@ -1908,6 +1908,8 @@ struct drm_i915_private {
 
 	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
 	struct {
+		int (*alloc_request)(struct intel_engine_cs *ring,
+				     struct intel_context *ctx);
 		int (*do_execbuf)(struct i915_execbuffer_params *params,
 				  struct drm_i915_gem_execbuffer2 *args,
 				  struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem.c +2 -0
index 7a0dc7c..cf959e3 100644
@@ -4860,11 +4860,13 @@ int i915_gem_init(struct drm_device *dev)
 	}
 
 	if (!i915.enable_execlists) {
+		dev_priv->gt.alloc_request = intel_ring_alloc_request;
 		dev_priv->gt.do_execbuf = i915_gem_ringbuffer_submission;
 		dev_priv->gt.init_rings = i915_gem_init_rings;
 		dev_priv->gt.cleanup_ring = intel_cleanup_ring_buffer;
 		dev_priv->gt.stop_ring = intel_stop_ring_buffer;
 	} else {
+		dev_priv->gt.alloc_request = intel_logical_ring_alloc_request;
 		dev_priv->gt.do_execbuf = intel_execlists_submission;
 		dev_priv->gt.init_rings = intel_logical_rings_init;
 		dev_priv->gt.cleanup_ring = intel_logical_ring_cleanup;
drivers/gpu/drm/i915/intel_lrc.c +3 -3
index dc474b4..8628abf 100644
@@ -856,8 +856,8 @@ void intel_lr_context_unpin(struct intel_engine_cs *ring,
 	}
 }
 
-static int logical_ring_alloc_request(struct intel_engine_cs *ring,
-				      struct intel_context *ctx)
+int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
+				     struct intel_context *ctx)
 {
 	struct drm_i915_gem_request *request;
 	struct drm_i915_private *dev_private = ring->dev->dev_private;
@@ -1066,7 +1066,7 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
 		return ret;
 
 	/* Preallocate the olr before touching the ring */
-	ret = logical_ring_alloc_request(ring, ctx);
+	ret = intel_logical_ring_alloc_request(ring, ctx);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +2 -0
index 3a6abce..3cc38bd 100644
@@ -36,6 +36,8 @@
 #define RING_CONTEXT_STATUS_PTR(ring)	((ring)->mmio_base+0x3a0)
 
 /* Logical Rings */
+int __must_check intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
+						  struct intel_context *ctx);
 void intel_logical_ring_stop(struct intel_engine_cs *ring);
 void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
 int intel_logical_rings_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
index 7fd89e5..635707a 100644
@@ -2163,8 +2163,8 @@ int intel_ring_idle(struct intel_engine_cs *ring)
 	return i915_wait_request(req);
 }
 
-static int
-intel_ring_alloc_request(struct intel_engine_cs *ring)
+int
+intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx)
 {
 	int ret;
 	struct drm_i915_gem_request *request;
@@ -2229,7 +2229,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
 		return ret;
 
 	/* Preallocate the olr before touching the ring */
-	ret = intel_ring_alloc_request(ring);
+	ret = intel_ring_alloc_request(ring, NULL);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index ffa3724..2fd960a 100644

drivers/gpu/drm/i915/intel_ringbuffer.h void intel_cleanup_ring_buffer(struct intel_engine_cs *ring); · line 399

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
@@ -392,6 +392,8 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
 
 int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
 int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
+int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
+					  struct intel_context *ctx);
 static inline void intel_ring_emit(struct intel_engine_cs *ring,
 				   u32 data)
 {

I find the whole idea of having virtual functions pointing to public functions kind of strange since it allows for two ways of accessing the function. If you look at the way we set up the virtual ring buffer functions those virtual functions are static and the set up is done in intel_ringbuffer.c without exposing the functions to the outside world. Having the set up take place in i915_gem.c forces the virtual functions to be public, which is not very nice. It would've been a better idea to pass the virtual function struct for initialization inside intel_lrc.c and intel_ringbuffer.c, which would have avoided making those functions public.

Quoted 4 lines

I'd like to hear some input from someone else on this on this, like e.g. Daniel Vetter (since he was a strong proponent of the legacy/execlist split, which was the underlying reason for this construct in the first place - not saying that it couldn't have been done in some other way, though).

Yeah generally the pattern is to have one public _init function per file which sets up the vfunc tables as needed. Follow-up patches would be really nice though indeed.
-Daniel

Quoted 16 lines

Obviously, this is not the fault of the patch at hand and you're just following the already established pattern of setting up these virtual functions so I can't fault you for that.

Therefore I'm ok with this change (but not the construct as a whole):

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#120 lore raw

PATCH 7/53 drm/i915: Early alloc request in execbuff

In reply to [email protected]

From: John Harrison <[email protected]>

Start of explicit request management in the execbuffer code path. This patch adds a call to allocate a request structure before all the actual hardware work is done. Thus guaranteeing that all that work is tagged by a known request. At present, nothing further is done with the request, the rest comes later in the series.

The only noticable change is that failure to get a request (e.g. due to lack of memory) will be caught earlier in the sequence. It now occurs right at the start before any un-undoable work has been done.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +10 -3
index ca85803..61471e9 100644
@@ -1356,7 +1356,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
 	u32 dispatch_flags;
 	int ret;
-	bool need_relocs;
+	bool need_relocs, batch_pinned = false;
 
 	if (!i915_gem_check_execbuffer(args))
 		return -EINVAL;
@@ -1525,10 +1525,16 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		if (ret)
 			goto err;
 
+		batch_pinned = true;
 		params->batch_obj_vm_offset = i915_gem_obj_ggtt_offset(batch_obj);
 	} else
 		params->batch_obj_vm_offset = i915_gem_obj_offset(batch_obj, vm);
 
+	/* Allocate a request for this batch buffer nice and early. */
+	ret = dev_priv->gt.alloc_request(ring, ctx);
+	if (ret)
+		goto err;
+
 	/*
 	 * Save assorted stuff away to pass through to *_submission().
 	 * NB: This data should be 'persistent' and not local as it will
@@ -1544,15 +1550,16 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 
 	ret = dev_priv->gt.do_execbuf(params, args, &eb->vmas);
 
+err:
 	/*
 	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
 	 * batch vma for correctness. For less ugly and less fragility this
 	 * needs to be adjusted to also track the ggtt batch vma properly as
 	 * active.
 	 */
-	if (dispatch_flags & I915_DISPATCH_SECURE)
+	if (batch_pinned)
 		i915_gem_object_ggtt_unpin(batch_obj);
-err:
+
 	/* the request owns the ref now */
 	i915_gem_context_unreference(ctx);
 	eb_destroy(eb);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 7/53
#121 lore raw

Re: [PATCH 07/53] drm/i915: Early alloc request in execbuff

Quoted 58 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Start of explicit request management in the execbuffer code path. This patch adds a call to allocate a request structure before all the actual hardware work is done. Thus guaranteeing that all that work is tagged by a known request. At present, nothing further is done with the request, the rest comes later in the series.

The only noticable change is that failure to get a request (e.g. due to lack of memory) will be caught earlier in the sequence. It now occurs right at the start before any un-undoable work has been done.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   13 ++++++++++---
  1 file changed, 10 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +8 -1
index ca85803..61471e9 100644
@@ -1356,7 +1356,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
  	u32 dispatch_flags;
  	int ret;
-	bool need_relocs;
+	bool need_relocs, batch_pinned = false;
 
  	if (!i915_gem_check_execbuffer(args))
  		return -EINVAL;
@@ -1525,10 +1525,16 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  		if (ret)
  			goto err;
 
+		batch_pinned = true;
  		params->batch_obj_vm_offset = i915_gem_obj_ggtt_offset(batch_obj);
  	} else
  		params->batch_obj_vm_offset = i915_gem_obj_offset(batch_obj, vm);
 
+	/* Allocate a request for this batch buffer nice and early. */
+	ret = dev_priv->gt.alloc_request(ring, ctx);
+	if (ret)
+		goto err;
+
  	/*
  	 * Save assorted stuff away to pass through to *_submission().
  	 * NB: This data should be 'persistent' and not local as it will
@@ -1544,15 +1550,16 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 
  	ret = dev_priv->gt.do_execbuf(params, args, &eb->vmas);
 
+err:
  	/*
  	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
  	 * batch vma for correctness. For less ugly and less fragility this
  	 * needs to be adjusted to also track the ggtt batch vma properly as

drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1565

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -2
  	 * active.
  	 */
-	if (dispatch_flags & I915_DISPATCH_SECURE)
+	if (batch_pinned)
  		i915_gem_object_ggtt_unpin(batch_obj);
-err:
+
  	/* the request owns the ref now */
  	i915_gem_context_unreference(ctx);
  	eb_destroy(eb);

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#122 lore raw

PATCH 8/53 drm/i915: Update alloc_request to return the allocated request

In reply to [email protected]

From: John Harrison <[email protected]>

The alloc_request() function does not actually return the newly allocated request. Instead, it must be pulled from ring->outstanding_lazy_request. This patch fixes this so that code can create a request and start using it knowing exactly which request it actually owns.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    3 ++-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
 drivers/gpu/drm/i915/intel_lrc.c           |   13 +++++++++----
 drivers/gpu/drm/i915/intel_lrc.h           |    3 ++-
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   14 ++++++++++----
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    3 ++-
 6 files changed, 27 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 87a4a2e..90223f208 100644
@@ -1909,7 +1909,8 @@ struct drm_i915_private {
 	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
 	struct {
 		int (*alloc_request)(struct intel_engine_cs *ring,
-				     struct intel_context *ctx);
+				     struct intel_context *ctx,
+				     struct drm_i915_gem_request **req_out);
 		int (*do_execbuf)(struct i915_execbuffer_params *params,
 				  struct drm_i915_gem_execbuffer2 *args,
 				  struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -1
index 61471e9..37dcc6f 100644
@@ -1353,6 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct i915_address_space *vm;
 	struct i915_execbuffer_params params_master; /* XXX: will be removed later */
 	struct i915_execbuffer_params *params = &params_master;
+	struct drm_i915_gem_request *request;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
 	u32 dispatch_flags;
 	int ret;
@@ -1531,7 +1532,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		params->batch_obj_vm_offset = i915_gem_obj_offset(batch_obj, vm);
 
 	/* Allocate a request for this batch buffer nice and early. */
-	ret = dev_priv->gt.alloc_request(ring, ctx);
+	ret = dev_priv->gt.alloc_request(ring, ctx, &request);
 	if (ret)
 		goto err;
 
drivers/gpu/drm/i915/intel_lrc.c +9 -4
index 8628abf..c3c783f 100644
@@ -857,13 +857,17 @@ void intel_lr_context_unpin(struct intel_engine_cs *ring,
 }
 
 int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
-				     struct intel_context *ctx)
+				     struct intel_context *ctx,
+				     struct drm_i915_gem_request **req_out)
 {
 	struct drm_i915_gem_request *request;
 	struct drm_i915_private *dev_private = ring->dev->dev_private;
 	int ret;
 
-	if (ring->outstanding_lazy_request)
+	if (!req_out)
+		return -EINVAL;
+
+	if ((*req_out = ring->outstanding_lazy_request) != NULL)
 		return 0;
 
 	request = kzalloc(sizeof(*request), GFP_KERNEL);
@@ -898,7 +902,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
 	i915_gem_context_reference(request->ctx);
 	request->ringbuf = ctx->engine[ring->id].ringbuf;
 
-	ring->outstanding_lazy_request = request;
+	*req_out = ring->outstanding_lazy_request = request;
 	return 0;
 }
 
@@ -1051,6 +1055,7 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,
 int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
 			     struct intel_context *ctx, int num_dwords)
 {
+	struct drm_i915_gem_request *req;
 	struct intel_engine_cs *ring = ringbuf->ring;
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1066,7 +1071,7 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
 		return ret;
 
 	/* Preallocate the olr before touching the ring */
-	ret = intel_logical_ring_alloc_request(ring, ctx);
+	ret = intel_logical_ring_alloc_request(ring, ctx, &req);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +2 -1
index 3cc38bd..77de8ac 100644
@@ -37,7 +37,8 @@
 
 /* Logical Rings */
 int __must_check intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
-						  struct intel_context *ctx);
+						  struct intel_context *ctx,
+						  struct drm_i915_gem_request **req_out);
 void intel_logical_ring_stop(struct intel_engine_cs *ring);
 void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
 int intel_logical_rings_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_ringbuffer.c +10 -4
index 635707a..1a9f884 100644
@@ -2164,13 +2164,18 @@ int intel_ring_idle(struct intel_engine_cs *ring)
 }
 
 int
-intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx)
+intel_ring_alloc_request(struct intel_engine_cs *ring,
+			 struct intel_context *ctx,
+			 struct drm_i915_gem_request **req_out)
 {
 	int ret;
 	struct drm_i915_gem_request *request;
 	struct drm_i915_private *dev_private = ring->dev->dev_private;
 
-	if (ring->outstanding_lazy_request)
+	if (!req_out)
+		return -EINVAL;
+
+	if ((*req_out = ring->outstanding_lazy_request) != NULL)
 		return 0;
 
 	request = kzalloc(sizeof(*request), GFP_KERNEL);
@@ -2188,7 +2193,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx
 		return ret;
 	}
 
-	ring->outstanding_lazy_request = request;
+	*req_out = ring->outstanding_lazy_request = request;
 	return 0;
 }
 
@@ -2216,6 +2221,7 @@ static int __intel_ring_prepare(struct intel_engine_cs *ring,
 int intel_ring_begin(struct intel_engine_cs *ring,
 		     int num_dwords)
 {
+	struct drm_i915_gem_request *req;
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	int ret;
 
@@ -2229,7 +2235,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
 		return ret;
 
 	/* Preallocate the olr before touching the ring */
-	ret = intel_ring_alloc_request(ring, NULL);
+	ret = intel_ring_alloc_request(ring, NULL, &req);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -1
index 2fd960a..4f8a14a 100644
@@ -393,7 +393,8 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
 int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
 int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
 int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
-					  struct intel_context *ctx);
+					  struct intel_context *ctx,
+					  struct drm_i915_gem_request **req_out);
 static inline void intel_ring_emit(struct intel_engine_cs *ring,
 				   u32 data)
 {
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#123 lore raw

Re: [PATCH 08/53] drm/i915: Update alloc_request to return the allocated request

Quoted 37 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The alloc_request() function does not actually return the newly allocated request. Instead, it must be pulled from ring->outstanding_lazy_request. This patch fixes this so that code can create a request and start using it knowing exactly which request it actually owns.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    3 ++-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
  drivers/gpu/drm/i915/intel_lrc.c           |   13 +++++++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    3 ++-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   14 ++++++++++----
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    3 ++-
  6 files changed, 27 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 87a4a2e..90223f208 100644
@@ -1909,7 +1909,8 @@ struct drm_i915_private {
  	/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
  	struct {
  		int (*alloc_request)(struct intel_engine_cs *ring,
-				     struct intel_context *ctx);
+				     struct intel_context *ctx,
+				     struct drm_i915_gem_request **req_out);
  		int (*do_execbuf)(struct i915_execbuffer_params *params,
  				  struct drm_i915_gem_execbuffer2 *args,
  				  struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index 61471e9..37dcc6f 100644

drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1356

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -0
@@ -1353,6 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	struct i915_address_space *vm;
  	struct i915_execbuffer_params params_master; /* XXX: will be removed later */
  	struct i915_execbuffer_params *params = &params_master;
+	struct drm_i915_gem_request *request;

Please initialize request to NULL. If you accidentally dereference it before it is allocated (seeing as the allocation is several pages down from here) you get a null pointer exception, which is a clear indication that you did something stupid. Otherwise it's not clear what will happen (sure, page fault, but null pointer exception is a better failure indication).

Thanks,
Tomas

Quoted 133 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
  	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
  	u32 dispatch_flags;
  	int ret;
@@ -1531,7 +1532,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  		params->batch_obj_vm_offset = i915_gem_obj_offset(batch_obj, vm);
 
  	/* Allocate a request for this batch buffer nice and early. */
-	ret = dev_priv->gt.alloc_request(ring, ctx);
+	ret = dev_priv->gt.alloc_request(ring, ctx, &request);
  	if (ret)
  		goto err;
 
drivers/gpu/drm/i915/intel_lrc.c +9 -4
index 8628abf..c3c783f 100644
@@ -857,13 +857,17 @@ void intel_lr_context_unpin(struct intel_engine_cs *ring,
  }
 
  int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
-				     struct intel_context *ctx)
+				     struct intel_context *ctx,
+				     struct drm_i915_gem_request **req_out)
  {
  	struct drm_i915_gem_request *request;
  	struct drm_i915_private *dev_private = ring->dev->dev_private;
  	int ret;
 
-	if (ring->outstanding_lazy_request)
+	if (!req_out)
+		return -EINVAL;
+
+	if ((*req_out = ring->outstanding_lazy_request) != NULL)
  		return 0;
 
  	request = kzalloc(sizeof(*request), GFP_KERNEL);
@@ -898,7 +902,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
  	i915_gem_context_reference(request->ctx);
  	request->ringbuf = ctx->engine[ring->id].ringbuf;
 
-	ring->outstanding_lazy_request = request;
+	*req_out = ring->outstanding_lazy_request = request;
  	return 0;
  }
 
@@ -1051,6 +1055,7 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,
  int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
  			     struct intel_context *ctx, int num_dwords)
  {
+	struct drm_i915_gem_request *req;
  	struct intel_engine_cs *ring = ringbuf->ring;
  	struct drm_device *dev = ring->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1066,7 +1071,7 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
  		return ret;
 
  	/* Preallocate the olr before touching the ring */
-	ret = intel_logical_ring_alloc_request(ring, ctx);
+	ret = intel_logical_ring_alloc_request(ring, ctx, &req);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +2 -1
index 3cc38bd..77de8ac 100644
@@ -37,7 +37,8 @@
 
  /* Logical Rings */
  int __must_check intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
-						  struct intel_context *ctx);
+						  struct intel_context *ctx,
+						  struct drm_i915_gem_request **req_out);
  void intel_logical_ring_stop(struct intel_engine_cs *ring);
  void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
  int intel_logical_rings_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_ringbuffer.c +10 -4
index 635707a..1a9f884 100644
@@ -2164,13 +2164,18 @@ int intel_ring_idle(struct intel_engine_cs *ring)
  }
 
  int
-intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx)
+intel_ring_alloc_request(struct intel_engine_cs *ring,
+			 struct intel_context *ctx,
+			 struct drm_i915_gem_request **req_out)
  {
  	int ret;
  	struct drm_i915_gem_request *request;
  	struct drm_i915_private *dev_private = ring->dev->dev_private;
 
-	if (ring->outstanding_lazy_request)
+	if (!req_out)
+		return -EINVAL;
+
+	if ((*req_out = ring->outstanding_lazy_request) != NULL)
  		return 0;
 
  	request = kzalloc(sizeof(*request), GFP_KERNEL);
@@ -2188,7 +2193,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring, struct intel_context *ctx
  		return ret;
  	}
 
-	ring->outstanding_lazy_request = request;
+	*req_out = ring->outstanding_lazy_request = request;
  	return 0;
  }
 
@@ -2216,6 +2221,7 @@ static int __intel_ring_prepare(struct intel_engine_cs *ring,
  int intel_ring_begin(struct intel_engine_cs *ring,
  		     int num_dwords)
  {
+	struct drm_i915_gem_request *req;
  	struct drm_i915_private *dev_priv = ring->dev->dev_private;
  	int ret;
 
@@ -2229,7 +2235,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
  		return ret;
 
  	/* Preallocate the olr before touching the ring */
-	ret = intel_ring_alloc_request(ring, NULL);
+	ret = intel_ring_alloc_request(ring, NULL, &req);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 2fd960a..4f8a14a 100644

drivers/gpu/drm/i915/intel_ringbuffer.h void intel_cleanup_ring_buffer(struct intel_engine_cs *ring); · line 400

Quoted 9 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -1
@@ -393,7 +393,8 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
  int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
  int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
  int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
-					  struct intel_context *ctx);
+					  struct intel_context *ctx,
+					  struct drm_i915_gem_request **req_out);
  static inline void intel_ring_emit(struct intel_engine_cs *ring,
  				   u32 data)
  {

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#124 lore raw

Re: [PATCH 08/53] drm/i915: Update alloc_request to return the allocated request

Quoted 39 lines · Tomas Elf
Quoted 38 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The alloc_request() function does not actually return the newly allocated request. Instead, it must be pulled from ring->outstanding_lazy_request. This patch fixes this so that code can create a request and start using it knowing exactly which request it actually owns.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    3 ++-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
  drivers/gpu/drm/i915/intel_lrc.c           |   13 +++++++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    3 ++-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   14 ++++++++++----
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    3 ++-
  6 files changed, 27 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 87a4a2e..90223f208 100644
@@ -1909,7 +1909,8 @@ struct drm_i915_private {
      /* Abstract the submission mechanism (legacy ringbuffer or 

execlists) away */
struct {
int (*alloc_request)(struct intel_engine_cs *ring,

drivers/gpu/drm/i915/i915_drv.h +2 -1
-                     struct intel_context *ctx);
+                     struct intel_context *ctx,
+                     struct drm_i915_gem_request **req_out);
          int (*do_execbuf)(struct i915_execbuffer_params *params,
                    struct drm_i915_gem_execbuffer2 *args,
                    struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index 61471e9..37dcc6f 100644
@@ -1353,6 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, 
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
 void *data,
      struct i915_address_space *vm;
      struct i915_execbuffer_params params_master; /* XXX: will be 

removed later */

      struct i915_execbuffer_params *params = &params_master;

+ struct drm_i915_gem_request *request;

Please initialize request to NULL. If you accidentally dereference it before it is allocated (seeing as the allocation is several pages down from here) you get a null pointer exception, which is a clear indication that you did something stupid. Otherwise it's not clear what will happen (sure, page fault, but null pointer exception is a better failure indication).

That should generate a 'use before assignment' compiler warning.

Quoted 153 lines

Thanks,
Tomas

Quoted 149 lines
      const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
      u32 dispatch_flags;
      int ret;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1531,7 +1532,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, 
 void *data,
          params->batch_obj_vm_offset = 
 i915_gem_obj_offset(batch_obj, vm);
 
      /* Allocate a request for this batch buffer nice and early. */
-    ret = dev_priv->gt.alloc_request(ring, ctx);
+    ret = dev_priv->gt.alloc_request(ring, ctx, &request);
      if (ret)
          goto err;
drivers/gpu/drm/i915/intel_lrc.c +6 -2
index 8628abf..c3c783f 100644
@@ -857,13 +857,17 @@ void intel_lr_context_unpin(struct 
 intel_engine_cs *ring,
  }
 
  int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
-                     struct intel_context *ctx)
+                     struct intel_context *ctx,
+                     struct drm_i915_gem_request **req_out)
  {
      struct drm_i915_gem_request *request;
      struct drm_i915_private *dev_private = ring->dev->dev_private;
      int ret;
 
-    if (ring->outstanding_lazy_request)
+    if (!req_out)
+        return -EINVAL;
+
+    if ((*req_out = ring->outstanding_lazy_request) != NULL)
          return 0;
 
      request = kzalloc(sizeof(*request), GFP_KERNEL);
drivers/gpu/drm/i915/intel_lrc.c +2 -1
@@ -898,7 +902,7 @@ int intel_logical_ring_alloc_request(struct 
 intel_engine_cs *ring,
      i915_gem_context_reference(request->ctx);
      request->ringbuf = ctx->engine[ring->id].ringbuf;
 
-    ring->outstanding_lazy_request = request;
+    *req_out = ring->outstanding_lazy_request = request;
      return 0;
  }
@@ -1051,6 +1055,7 @@ static int logical_ring_prepare(struct 
 intel_ringbuffer *ringbuf,
  int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
                   struct intel_context *ctx, int num_dwords)
  {
+    struct drm_i915_gem_request *req;
      struct intel_engine_cs *ring = ringbuf->ring;
      struct drm_device *dev = ring->dev;
      struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -1066,7 +1071,7 @@ int intel_logical_ring_begin(struct 
 intel_ringbuffer *ringbuf,
          return ret;
 
      /* Preallocate the olr before touching the ring */
-    ret = intel_logical_ring_alloc_request(ring, ctx);
+    ret = intel_logical_ring_alloc_request(ring, ctx, &req);
      if (ret)
          return ret;
drivers/gpu/drm/i915/intel_lrc.h +2 -1
index 3cc38bd..77de8ac 100644
@@ -37,7 +37,8 @@
 
  /* Logical Rings */
  int __must_check intel_logical_ring_alloc_request(struct 
 intel_engine_cs *ring,
-                          struct intel_context *ctx);
+                          struct intel_context *ctx,
+                          struct drm_i915_gem_request **req_out);
  void intel_logical_ring_stop(struct intel_engine_cs *ring);
  void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
  int intel_logical_rings_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_ringbuffer.c +7 -2
index 635707a..1a9f884 100644
@@ -2164,13 +2164,18 @@ int intel_ring_idle(struct intel_engine_cs 
 *ring)
  }
 
  int
-intel_ring_alloc_request(struct intel_engine_cs *ring, struct 
 intel_context *ctx)
+intel_ring_alloc_request(struct intel_engine_cs *ring,
+             struct intel_context *ctx,
+             struct drm_i915_gem_request **req_out)
  {
      int ret;
      struct drm_i915_gem_request *request;
      struct drm_i915_private *dev_private = ring->dev->dev_private;
 
-    if (ring->outstanding_lazy_request)
+    if (!req_out)
+        return -EINVAL;
+
+    if ((*req_out = ring->outstanding_lazy_request) != NULL)
          return 0;
      request = kzalloc(sizeof(*request), GFP_KERNEL);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -2
@@ -2188,7 +2193,7 @@ intel_ring_alloc_request(struct intel_engine_cs 
 *ring, struct intel_context *ctx
          return ret;
      }
 
-    ring->outstanding_lazy_request = request;
+    *req_out = ring->outstanding_lazy_request = request;
      return 0;
  }
@@ -2216,6 +2221,7 @@ static int __intel_ring_prepare(struct 
 intel_engine_cs *ring,
  int intel_ring_begin(struct intel_engine_cs *ring,
               int num_dwords)
  {
+    struct drm_i915_gem_request *req;
      struct drm_i915_private *dev_priv = ring->dev->dev_private;
      int ret;
@@ -2229,7 +2235,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
          return ret;
 
      /* Preallocate the olr before touching the ring */
-    ret = intel_ring_alloc_request(ring, NULL);
+    ret = intel_ring_alloc_request(ring, NULL, &req);
      if (ret)
          return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 2fd960a..4f8a14a 100644
@@ -393,7 +393,8 @@ void intel_cleanup_ring_buffer(struct 
 intel_engine_cs *ring);
  int __must_check intel_ring_begin(struct intel_engine_cs *ring, int 
 n);
  int __must_check intel_ring_cacheline_align(struct intel_engine_cs 
 *ring);
  int __must_check intel_ring_alloc_request(struct intel_engine_cs 
Quoted 9 lines

drivers/gpu/drm/i915/intel_ringbuffer.h void intel_cleanup_ring_buffer(struct intel_engine_cs *ring); · line 400

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -1
 *ring,
-                      struct intel_context *ctx);
+                      struct intel_context *ctx,
+                      struct drm_i915_gem_request **req_out);
  static inline void intel_ring_emit(struct intel_engine_cs *ring,
                     u32 data)
  {

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#125 lore raw

Re: [PATCH 08/53] drm/i915: Update alloc_request to return the allocated request

Quoted 59 lines · John Harrison
Quoted 49 lines · Tomas Elf
Quoted 48 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The alloc_request() function does not actually return the newly allocated
request. Instead, it must be pulled from ring->outstanding_lazy_request. This
patch fixes this so that code can create a request and start using it knowing
exactly which request it actually owns.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    3 ++-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
  drivers/gpu/drm/i915/intel_lrc.c           |   13 +++++++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    3 ++-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   14 ++++++++++----
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    3 ++-
  6 files changed, 27 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 87a4a2e..90223f208 100644
@@ -1909,7 +1909,8 @@ struct drm_i915_private {
      /* Abstract the submission mechanism (legacy ringbuffer or

execlists) away */
struct {
int (*alloc_request)(struct intel_engine_cs *ring,

drivers/gpu/drm/i915/i915_drv.h +2 -1
-                     struct intel_context *ctx);
+                     struct intel_context *ctx,
+                     struct drm_i915_gem_request **req_out);
          int (*do_execbuf)(struct i915_execbuffer_params *params,
                    struct drm_i915_gem_execbuffer2 *args,
                    struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index 61471e9..37dcc6f 100644
@@ -1353,6 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 void *data,
      struct i915_address_space *vm;
      struct i915_execbuffer_params params_master; /* XXX: will be

removed later */

      struct i915_execbuffer_params *params = &params_master;
Quoted 8 lines
Quoted 1 line

+ struct drm_i915_gem_request *request;

Please initialize request to NULL. If you accidentally dereference it before it is allocated (seeing as the allocation is several pages down from here) you get a null pointer exception, which is a clear indication that you did something stupid. Otherwise it's not clear what will happen (sure, page fault, but null pointer exception is a better failure indication).

Quoted 1 line

That should generate a 'use before assignment' compiler warning.

That assumes that the developer in question isn't too busy hacking to check for warnings (in all honesty that developer probably would've been me ;)). Sure, you should always check for warnings but if we can save this developer some time by giving them a clear run-time indication aside from the compile-time warning then that would not be a bad thing. I've been there myself a few times and I know times in the past where this would've saved me the time it takes to rebuild and redeploy the kernel once.

Thanks,
Tomas

Quoted 159 lines
Quoted 159 lines

Thanks,
Tomas

Quoted 154 lines
      const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
      u32 dispatch_flags;
      int ret;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1531,7 +1532,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 void *data,
          params->batch_obj_vm_offset =
 i915_gem_obj_offset(batch_obj, vm);
 
      /* Allocate a request for this batch buffer nice and early. */
-    ret = dev_priv->gt.alloc_request(ring, ctx);
+    ret = dev_priv->gt.alloc_request(ring, ctx, &request);
      if (ret)
          goto err;
drivers/gpu/drm/i915/intel_lrc.c +6 -2
index 8628abf..c3c783f 100644
@@ -857,13 +857,17 @@ void intel_lr_context_unpin(struct
 intel_engine_cs *ring,
  }
 
  int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
-                     struct intel_context *ctx)
+                     struct intel_context *ctx,
+                     struct drm_i915_gem_request **req_out)
  {
      struct drm_i915_gem_request *request;
      struct drm_i915_private *dev_private = ring->dev->dev_private;
      int ret;
 
-    if (ring->outstanding_lazy_request)
+    if (!req_out)
+        return -EINVAL;
+
+    if ((*req_out = ring->outstanding_lazy_request) != NULL)
          return 0;
 
      request = kzalloc(sizeof(*request), GFP_KERNEL);
drivers/gpu/drm/i915/intel_lrc.c +2 -1
@@ -898,7 +902,7 @@ int intel_logical_ring_alloc_request(struct
 intel_engine_cs *ring,
      i915_gem_context_reference(request->ctx);
      request->ringbuf = ctx->engine[ring->id].ringbuf;
 
-    ring->outstanding_lazy_request = request;
+    *req_out = ring->outstanding_lazy_request = request;
      return 0;
  }
@@ -1051,6 +1055,7 @@ static int logical_ring_prepare(struct
 intel_ringbuffer *ringbuf,
  int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
                   struct intel_context *ctx, int num_dwords)
  {
+    struct drm_i915_gem_request *req;
      struct intel_engine_cs *ring = ringbuf->ring;
      struct drm_device *dev = ring->dev;
      struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -1066,7 +1071,7 @@ int intel_logical_ring_begin(struct
 intel_ringbuffer *ringbuf,
          return ret;
 
      /* Preallocate the olr before touching the ring */
-    ret = intel_logical_ring_alloc_request(ring, ctx);
+    ret = intel_logical_ring_alloc_request(ring, ctx, &req);
      if (ret)
          return ret;
drivers/gpu/drm/i915/intel_lrc.h +2 -1
index 3cc38bd..77de8ac 100644
@@ -37,7 +37,8 @@
 
  /* Logical Rings */
  int __must_check intel_logical_ring_alloc_request(struct
 intel_engine_cs *ring,
-                          struct intel_context *ctx);
+                          struct intel_context *ctx,
+                          struct drm_i915_gem_request **req_out);
  void intel_logical_ring_stop(struct intel_engine_cs *ring);
  void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
  int intel_logical_rings_init(struct drm_device *dev);
drivers/gpu/drm/i915/intel_ringbuffer.c +7 -2
index 635707a..1a9f884 100644
@@ -2164,13 +2164,18 @@ int intel_ring_idle(struct intel_engine_cs
 *ring)
  }
 
  int
-intel_ring_alloc_request(struct intel_engine_cs *ring, struct
 intel_context *ctx)
+intel_ring_alloc_request(struct intel_engine_cs *ring,
+             struct intel_context *ctx,
+             struct drm_i915_gem_request **req_out)
  {
      int ret;
      struct drm_i915_gem_request *request;
      struct drm_i915_private *dev_private = ring->dev->dev_private;
 
-    if (ring->outstanding_lazy_request)
+    if (!req_out)
+        return -EINVAL;
+
+    if ((*req_out = ring->outstanding_lazy_request) != NULL)
          return 0;
      request = kzalloc(sizeof(*request), GFP_KERNEL);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -2
@@ -2188,7 +2193,7 @@ intel_ring_alloc_request(struct intel_engine_cs
 *ring, struct intel_context *ctx
          return ret;
      }
 
-    ring->outstanding_lazy_request = request;
+    *req_out = ring->outstanding_lazy_request = request;
      return 0;
  }
@@ -2216,6 +2221,7 @@ static int __intel_ring_prepare(struct
 intel_engine_cs *ring,
  int intel_ring_begin(struct intel_engine_cs *ring,
               int num_dwords)
  {
+    struct drm_i915_gem_request *req;
      struct drm_i915_private *dev_priv = ring->dev->dev_private;
      int ret;
@@ -2229,7 +2235,7 @@ int intel_ring_begin(struct intel_engine_cs *ring,
          return ret;
 
      /* Preallocate the olr before touching the ring */
-    ret = intel_ring_alloc_request(ring, NULL);
+    ret = intel_ring_alloc_request(ring, NULL, &req);
      if (ret)
          return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 2fd960a..4f8a14a 100644
@@ -393,7 +393,8 @@ void intel_cleanup_ring_buffer(struct
 intel_engine_cs *ring);
  int __must_check intel_ring_begin(struct intel_engine_cs *ring, int
 n);
  int __must_check intel_ring_cacheline_align(struct intel_engine_cs
 *ring);
  int __must_check intel_ring_alloc_request(struct intel_engine_cs
 *ring,
Quoted 9 lines
Quoted 8 lines

drivers/gpu/drm/i915/intel_ringbuffer.h void intel_cleanup_ring_buffer(struct intel_engine_cs *ring); · line 400

Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -1
-                      struct intel_context *ctx);
+                      struct intel_context *ctx,
+                      struct drm_i915_gem_request **req_out);
  static inline void intel_ring_emit(struct intel_engine_cs *ring,
                     u32 data)
  {

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#126 lore raw

Re: [PATCH 08/53] drm/i915: Update alloc_request to return the allocated request

Quoted 62 lines · Tomas Elf
Quoted 59 lines · John Harrison
Quoted 49 lines · Tomas Elf
Quoted 48 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The alloc_request() function does not actually return the newly allocated
request. Instead, it must be pulled from ring->outstanding_lazy_request. This
patch fixes this so that code can create a request and start using it knowing
exactly which request it actually owns.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    3 ++-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
 drivers/gpu/drm/i915/intel_lrc.c           |   13 +++++++++----
 drivers/gpu/drm/i915/intel_lrc.h           |    3 ++-
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   14 ++++++++++----
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    3 ++-
 6 files changed, 27 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 87a4a2e..90223f208 100644
@@ -1909,7 +1909,8 @@ struct drm_i915_private {
     /* Abstract the submission mechanism (legacy ringbuffer or

execlists) away */
struct {
int (*alloc_request)(struct intel_engine_cs *ring,

drivers/gpu/drm/i915/i915_drv.h +2 -1
-                     struct intel_context *ctx);
+                     struct intel_context *ctx,
+                     struct drm_i915_gem_request **req_out);
         int (*do_execbuf)(struct i915_execbuffer_params *params,
                   struct drm_i915_gem_execbuffer2 *args,
                   struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index 61471e9..37dcc6f 100644
@@ -1353,6 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 void *data,
     struct i915_address_space *vm;
     struct i915_execbuffer_params params_master; /* XXX: will be

removed later */

     struct i915_execbuffer_params *params = &params_master;
Quoted 8 lines
Quoted 1 line

+ struct drm_i915_gem_request *request;

Please initialize request to NULL. If you accidentally dereference it before it is allocated (seeing as the allocation is several pages down from here) you get a null pointer exception, which is a clear indication that you did something stupid. Otherwise it's not clear what will happen (sure, page fault, but null pointer exception is a better failure indication).

Quoted 1 line

That should generate a 'use before assignment' compiler warning.

Quoted 7 lines

That assumes that the developer in question isn't too busy hacking to check for warnings (in all honesty that developer probably would've been me ;)). Sure, you should always check for warnings but if we can save this developer some time by giving them a clear run-time indication aside from the compile-time warning then that would not be a bad thing. I've been there myself a few times and I know times in the past where this would've saved me the time it takes to rebuild and redeploy the kernel once.

kbuild is _very_ good at catching and reporting these. And the linux kernel generally has a 0 warnings rule, which means even when it slips through a lot of developers will get mad at me for not spotting it.

I think relying upon gcc to do its job here is safe enough. We only initialize stack variables if it's really needed, or if gcc is too dense to figure it out itself.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#127 lore raw

Re: [PATCH 08/53] drm/i915: Update alloc_request to return the allocated request

Quoted 67 lines · Daniel Vetter
Quoted 58 lines · Tomas Elf
Quoted 57 lines · John Harrison
Quoted 56 lines · Tomas Elf
Quoted 47 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The alloc_request() function does not actually return the newly allocated
request. Instead, it must be pulled from ring->outstanding_lazy_request. This
patch fixes this so that code can create a request and start using it knowing
exactly which request it actually owns.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    3 ++-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
  drivers/gpu/drm/i915/intel_lrc.c           |   13 +++++++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    3 ++-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   14 ++++++++++----
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    3 ++-
  6 files changed, 27 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 87a4a2e..90223f208 100644
@@ -1909,7 +1909,8 @@ struct drm_i915_private {
      /* Abstract the submission mechanism (legacy ringbuffer or

execlists) away */
struct {
int (*alloc_request)(struct intel_engine_cs *ring,

drivers/gpu/drm/i915/i915_drv.h +2 -1
-                     struct intel_context *ctx);
+                     struct intel_context *ctx,
+                     struct drm_i915_gem_request **req_out);
          int (*do_execbuf)(struct i915_execbuffer_params *params,
                    struct drm_i915_gem_execbuffer2 *args,
                    struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index 61471e9..37dcc6f 100644
@@ -1353,6 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 void *data,
      struct i915_address_space *vm;
      struct i915_execbuffer_params params_master; /* XXX: will be

removed later */

Quoted 2 lines
      struct i915_execbuffer_params *params = &params_master;

+ struct drm_i915_gem_request *request;

Please initialize request to NULL. If you accidentally dereference it before it is allocated (seeing as the allocation is several pages down from here) you get a null pointer exception, which is a clear indication that you did something stupid. Otherwise it's not clear what will happen (sure, page fault, but null pointer exception is a better failure indication).

Quoted 8 lines
Quoted 1 line

That should generate a 'use before assignment' compiler warning.

That assumes that the developer in question isn't too busy hacking to check for warnings (in all honesty that developer probably would've been me ;)). Sure, you should always check for warnings but if we can save this developer some time by giving them a clear run-time indication aside from the compile-time warning then that would not be a bad thing. I've been there myself a few times and I know times in the past where this would've saved me the time it takes to rebuild and redeploy the kernel once.

Quoted 8 lines

kbuild is _very_ good at catching and reporting these. And the linux kernel generally has a 0 warnings rule, which means even when it slips through a lot of developers will get mad at me for not spotting it.

I think relying upon gcc to do its job here is safe enough. We only initialize stack variables if it's really needed, or if gcc is too dense to figure it out itself.
-Daniel

I agree with Daniel. If you ignore warnings in your own test builds, you get what you deserve. If you check warnings into the tree then you should be shot. Or worse.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by
#128 lore raw

Re: [PATCH 08/53] drm/i915: Update alloc_request to return the allocated request

Quoted 76 lines · John Harrison
Quoted 75 lines · Daniel Vetter
Quoted 59 lines · Tomas Elf
Quoted 57 lines · John Harrison
Quoted 48 lines · Tomas Elf
Quoted 47 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The alloc_request() function does not actually return the newly allocated
request. Instead, it must be pulled from ring->outstanding_lazy_request. This
patch fixes this so that code can create a request and start using it knowing
exactly which request it actually owns.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    3 ++-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    3 ++-
  drivers/gpu/drm/i915/intel_lrc.c           |   13 +++++++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    3 ++-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   14 ++++++++++----
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    3 ++-
  6 files changed, 27 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 87a4a2e..90223f208 100644
@@ -1909,7 +1909,8 @@ struct drm_i915_private {
      /* Abstract the submission mechanism (legacy ringbuffer or

execlists) away */
struct {
int (*alloc_request)(struct intel_engine_cs *ring,

drivers/gpu/drm/i915/i915_drv.h +2 -1
-                     struct intel_context *ctx);
+                     struct intel_context *ctx,
+                     struct drm_i915_gem_request **req_out);
          int (*do_execbuf)(struct i915_execbuffer_params *params,
                    struct drm_i915_gem_execbuffer2 *args,
                    struct list_head *vmas);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index 61471e9..37dcc6f 100644
@@ -1353,6 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 void *data,
      struct i915_address_space *vm;
      struct i915_execbuffer_params params_master; /* XXX: will be

removed later */

Quoted 8 lines
Quoted 2 lines
      struct i915_execbuffer_params *params = &params_master;

+ struct drm_i915_gem_request *request;

Please initialize request to NULL. If you accidentally dereference it before it is allocated (seeing as the allocation is several pages down from here) you get a null pointer exception, which is a clear indication that you did something stupid. Otherwise it's not clear what will happen (sure, page fault, but null pointer exception is a better failure indication).

Quoted 1 line

That should generate a 'use before assignment' compiler warning.

Quoted 11 lines

That assumes that the developer in question isn't too busy hacking to check
for warnings (in all honesty that developer probably would've been me ;)).
Sure, you should always check for warnings but if we can save this developer
some time by giving them a clear run-time indication aside from the compile-time warning then that would not be a bad thing. I've been there myself a few times and I know times in the past where this would've saved me
the time it takes to rebuild and redeploy the kernel once.

kbuild is _very_ good at catching and reporting these. And the linux kernel generally has a 0 warnings rule, which means even when it slips through a lot of developers will get mad at me for not spotting it.

Quoted 10 lines
Quoted 4 lines

I think relying upon gcc to do its job here is safe enough. We only initialize stack variables if it's really needed, or if gcc is too dense to figure it out itself.
-Daniel

I agree with Daniel. If you ignore warnings in your own test builds, you get what you deserve. If you check warnings into the tree then you should be shot. Or worse.

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#129 lore raw

PATCH 9/53 drm/i915: Add request to execbuf params and add explicit cleanup

In reply to [email protected]

From: John Harrison <[email protected]>

Rather than just having a local request variable in the execbuff code, the request pointer is now stored in the execbuff params structure. Also added explicit cleanup of the request (plus wiping the OLR to match) in the error case. This means that the execbuff code is no longer dependent upon the OLR keeping track of the request so as to not leak it when things do go wrong. Note that in the success case, the i915_add_request() at the end of the submission function will tidy up the request and clear the OLR.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    1 +
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 90223f208..678b190 100644
@@ -1653,6 +1653,7 @@ struct i915_execbuffer_params {
 	struct intel_engine_cs          *ring;
 	struct drm_i915_gem_object      *batch_obj;
 	struct intel_context            *ctx;
+	struct drm_i915_gem_request     *request;
 };
 
 struct drm_i915_private {
drivers/gpu/drm/i915/i915_gem_execbuffer.c +11 -2
index 37dcc6f..10462f6 100644
@@ -1353,7 +1353,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct i915_address_space *vm;
 	struct i915_execbuffer_params params_master; /* XXX: will be removed later */
 	struct i915_execbuffer_params *params = &params_master;
-	struct drm_i915_gem_request *request;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
 	u32 dispatch_flags;
 	int ret;
@@ -1532,7 +1531,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		params->batch_obj_vm_offset = i915_gem_obj_offset(batch_obj, vm);
 
 	/* Allocate a request for this batch buffer nice and early. */
-	ret = dev_priv->gt.alloc_request(ring, ctx, &request);
+	ret = dev_priv->gt.alloc_request(ring, ctx, &params->request);
 	if (ret)
 		goto err;
 
@@ -1565,6 +1564,16 @@ err:
 	i915_gem_context_unreference(ctx);
 	eb_destroy(eb);
 
+	/*
+	 * If the request was created but not successfully submitted then it
+	 * must be freed again. If it was submitted then it is being tracked
+	 * on the active request list and no clean up is required here.
+	 */
+	if (ret && params->request) {
+		i915_gem_request_unreference(params->request);
+		ring->outstanding_lazy_request = NULL;
+	}
+
 	mutex_unlock(&dev->struct_mutex);
 
 pre_mutex_err:
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 9/53
#130 lore raw

Re: [PATCH 09/53] drm/i915: Add request to execbuf params and add explicit cleanup

Quoted 58 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Rather than just having a local request variable in the execbuff code, the request pointer is now stored in the execbuff params structure. Also added explicit cleanup of the request (plus wiping the OLR to match) in the error case. This means that the execbuff code is no longer dependent upon the OLR keeping track of the request so as to not leak it when things do go wrong. Note that in the success case, the i915_add_request() at the end of the submission function will tidy up the request and clear the OLR.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    1 +
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   13 +++++++++++--
  2 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 90223f208..678b190 100644
@@ -1653,6 +1653,7 @@ struct i915_execbuffer_params {
  	struct intel_engine_cs          *ring;
  	struct drm_i915_gem_object      *batch_obj;
  	struct intel_context            *ctx;
+	struct drm_i915_gem_request     *request;
  };
 
  struct drm_i915_private {
drivers/gpu/drm/i915/i915_gem_execbuffer.c +4 -2
index 37dcc6f..10462f6 100644
@@ -1353,7 +1353,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	struct i915_address_space *vm;
  	struct i915_execbuffer_params params_master; /* XXX: will be removed later */
  	struct i915_execbuffer_params *params = &params_master;
-	struct drm_i915_gem_request *request;
  	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
  	u32 dispatch_flags;
  	int ret;
@@ -1532,7 +1531,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  		params->batch_obj_vm_offset = i915_gem_obj_offset(batch_obj, vm);
 
  	/* Allocate a request for this batch buffer nice and early. */
-	ret = dev_priv->gt.alloc_request(ring, ctx, &request);
+	ret = dev_priv->gt.alloc_request(ring, ctx, &params->request);
  	if (ret)
  		goto err;
 
@@ -1565,6 +1564,16 @@ err:
  	i915_gem_context_unreference(ctx);
  	eb_destroy(eb);
 
+	/*
+	 * If the request was created but not successfully submitted then it
+	 * must be freed again. If it was submitted then it is being tracked

drivers/gpu/drm/i915/i915_gem_execbuffer.c err: · line 1579

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -0
+	 * on the active request list and no clean up is required here.
+	 */
+	if (ret && params->request) {
+		i915_gem_request_unreference(params->request);
+		ring->outstanding_lazy_request = NULL;
+	}
+
  	mutex_unlock(&dev->struct_mutex);
 
  pre_mutex_err:

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#131 lore raw

PATCH 10/53 drm/i915: Update the dispatch tracepoint to use params->request

In reply to [email protected]

From: John Harrison <[email protected]>

Updated a couple of trace points to use the now cached request pointer rather than extracting it from the ring.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 10462f6..883cabd 100644
@@ -1277,7 +1277,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 			return ret;
 	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
+	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
 
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index c3c783f..c42af08 100644
@@ -712,7 +712,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 	if (ret)
 		return ret;
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
+	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
 	i915_gem_execbuffer_move_to_active(vmas, ring);
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 10/53
#132 lore raw

Re: [PATCH 10/53] drm/i915: Update the dispatch tracepoint to use params->request

Quoted 31 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated a couple of trace points to use the now cached request pointer rather than extracting it from the ring.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
  drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 10462f6..883cabd 100644
@@ -1277,7 +1277,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  			return ret;
  	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
+	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
  	i915_gem_execbuffer_move_to_active(vmas, ring);
 
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index c3c783f..c42af08 100644

drivers/gpu/drm/i915/intel_lrc.c int intel_execlists_submission(struct i915_execbuffer_params *params, · line 718

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -712,7 +712,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
  	if (ret)
  		return ret;
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), params->dispatch_flags);
+	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
  	i915_gem_execbuffer_move_to_active(vmas, ring);
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#133 lore raw

PATCH 11/53 drm/i915: Update move_to_gpu() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

The plan is to pass requests around as the basic submission tracking structure rather than rings and contexts. This patch updates the move_to_gpu() code paths.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   10 +++++-----
 drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++------
 2 files changed, 9 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +5 -5
index 883cabd..da1e232 100644
@@ -828,7 +828,7 @@ err:
 }
 
 static int
-i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
+i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req,
 				struct list_head *vmas)
 {
 	struct i915_vma *vma;
@@ -838,7 +838,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
 
 	list_for_each_entry(vma, vmas, exec_list) {
 		struct drm_i915_gem_object *obj = vma->obj;
-		ret = i915_gem_object_sync(obj, ring);
+		ret = i915_gem_object_sync(obj, req->ring);
 		if (ret)
 			return ret;
 
@@ -849,7 +849,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
 	}
 
 	if (flush_chipset)
-		i915_gem_chipset_flush(ring->dev);
+		i915_gem_chipset_flush(req->ring->dev);
 
 	if (flush_domains & I915_GEM_DOMAIN_GTT)
 		wmb();
@@ -857,7 +857,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
 	/* Unconditionally invalidate gpu caches and ensure that we do flush
 	 * any residual writes from the previous batch.
 	 */
-	return intel_ring_invalidate_all_caches(ring);
+	return intel_ring_invalidate_all_caches(req->ring);
 }
 
 static bool
@@ -1186,7 +1186,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 		}
 	}
 
-	ret = i915_gem_execbuffer_move_to_gpu(ring, vmas);
+	ret = i915_gem_execbuffer_move_to_gpu(params->request, vmas);
 	if (ret)
 		goto error;
 
drivers/gpu/drm/i915/intel_lrc.c +4 -6
index c42af08..efe970f 100644
@@ -578,11 +578,9 @@ static int logical_ring_invalidate_all_caches(struct intel_ringbuffer *ringbuf,
 	return 0;
 }
 
-static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
-				 struct intel_context *ctx,
+static int execlists_move_to_gpu(struct drm_i915_gem_request *req,
 				 struct list_head *vmas)
 {
-	struct intel_engine_cs *ring = ringbuf->ring;
 	struct i915_vma *vma;
 	uint32_t flush_domains = 0;
 	bool flush_chipset = false;
@@ -591,7 +589,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
 	list_for_each_entry(vma, vmas, exec_list) {
 		struct drm_i915_gem_object *obj = vma->obj;
 
-		ret = i915_gem_object_sync(obj, ring);
+		ret = i915_gem_object_sync(obj, req->ring);
 		if (ret)
 			return ret;
 
@@ -607,7 +605,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
 	/* Unconditionally invalidate gpu caches and ensure that we do flush
 	 * any residual writes from the previous batch.
 	 */
-	return logical_ring_invalidate_all_caches(ringbuf, ctx);
+	return logical_ring_invalidate_all_caches(req->ringbuf, req->ctx);
 }
 
 /**
@@ -686,7 +684,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 		return -EINVAL;
 	}
 
-	ret = execlists_move_to_gpu(ringbuf, params->ctx, vmas);
+	ret = execlists_move_to_gpu(params->request, vmas);
 	if (ret)
 		return ret;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 11/53
#134 lore raw

Re: [PATCH 11/53] drm/i915: Update move_to_gpu() to take a request structure

Quoted 98 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The plan is to pass requests around as the basic submission tracking structure rather than rings and contexts. This patch updates the move_to_gpu() code paths.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   10 +++++-----
  drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++------
  2 files changed, 9 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +5 -5
index 883cabd..da1e232 100644
@@ -828,7 +828,7 @@ err:
  }
 
  static int
-i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
+i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req,
  				struct list_head *vmas)
  {
  	struct i915_vma *vma;
@@ -838,7 +838,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
 
  	list_for_each_entry(vma, vmas, exec_list) {
  		struct drm_i915_gem_object *obj = vma->obj;
-		ret = i915_gem_object_sync(obj, ring);
+		ret = i915_gem_object_sync(obj, req->ring);
  		if (ret)
  			return ret;
 
@@ -849,7 +849,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
  	}
 
  	if (flush_chipset)
-		i915_gem_chipset_flush(ring->dev);
+		i915_gem_chipset_flush(req->ring->dev);
 
  	if (flush_domains & I915_GEM_DOMAIN_GTT)
  		wmb();
@@ -857,7 +857,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine_cs *ring,
  	/* Unconditionally invalidate gpu caches and ensure that we do flush
  	 * any residual writes from the previous batch.
  	 */
-	return intel_ring_invalidate_all_caches(ring);
+	return intel_ring_invalidate_all_caches(req->ring);
  }
 
  static bool
@@ -1186,7 +1186,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  		}
  	}
 
-	ret = i915_gem_execbuffer_move_to_gpu(ring, vmas);
+	ret = i915_gem_execbuffer_move_to_gpu(params->request, vmas);
  	if (ret)
  		goto error;
 
drivers/gpu/drm/i915/intel_lrc.c +3 -5
index c42af08..efe970f 100644
@@ -578,11 +578,9 @@ static int logical_ring_invalidate_all_caches(struct intel_ringbuffer *ringbuf,
  	return 0;
  }
 
-static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
-				 struct intel_context *ctx,
+static int execlists_move_to_gpu(struct drm_i915_gem_request *req,
  				 struct list_head *vmas)
  {
-	struct intel_engine_cs *ring = ringbuf->ring;
  	struct i915_vma *vma;
  	uint32_t flush_domains = 0;
  	bool flush_chipset = false;
@@ -591,7 +589,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  	list_for_each_entry(vma, vmas, exec_list) {
  		struct drm_i915_gem_object *obj = vma->obj;
 
-		ret = i915_gem_object_sync(obj, ring);
+		ret = i915_gem_object_sync(obj, req->ring);
  		if (ret)
  			return ret;
 
@@ -607,7 +605,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  	/* Unconditionally invalidate gpu caches and ensure that we do flush
  	 * any residual writes from the previous batch.
  	 */
-	return logical_ring_invalidate_all_caches(ringbuf, ctx);
+	return logical_ring_invalidate_all_caches(req->ringbuf, req->ctx);
  }
 
  /**

drivers/gpu/drm/i915/intel_lrc.c int intel_execlists_submission(struct i915_execbuffer_params *params, · line 690

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -686,7 +684,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
  		return -EINVAL;
  	}
 
-	ret = execlists_move_to_gpu(ringbuf, params->ctx, vmas);
+	ret = execlists_move_to_gpu(params->request, vmas);
  	if (ret)
  		return ret;
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#135 lore raw

PATCH 12/53 drm/i915: Update execbuffer_move_to_active() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

The plan is to pass requests around as the basic submission tracking structure rather than rings and contexts. This patch updates the execbuffer_move_to_active() code path.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    2 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    6 +++---
 drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 678b190..68d6dec 100644
@@ -2643,7 +2643,7 @@ int i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
 int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
 			     struct drm_file *file_priv);
 void i915_gem_execbuffer_move_to_active(struct list_head *vmas,
-					struct intel_engine_cs *ring);
+					struct drm_i915_gem_request *req);
 int i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params);
 int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 				   struct drm_i915_gem_execbuffer2 *args,
drivers/gpu/drm/i915/i915_gem_execbuffer.c +3 -3
index da1e232..f7c19bc 100644
@@ -950,9 +950,9 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 
 void
 i915_gem_execbuffer_move_to_active(struct list_head *vmas,
-				   struct intel_engine_cs *ring)
+				   struct drm_i915_gem_request *req)
 {
-	struct drm_i915_gem_request *req = intel_ring_get_request(ring);
+	struct intel_engine_cs *ring = i915_gem_request_get_ring(req);
 	struct i915_vma *vma;
 
 	list_for_each_entry(vma, vmas, exec_list) {
@@ -1279,7 +1279,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 
 	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
-	i915_gem_execbuffer_move_to_active(vmas, ring);
+	i915_gem_execbuffer_move_to_active(vmas, params->request);
 
 	ret = i915_gem_execbuffer_retire_commands(params);
 
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index efe970f..bc3809e 100644
@@ -712,7 +712,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 
 	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
-	i915_gem_execbuffer_move_to_active(vmas, ring);
+	i915_gem_execbuffer_move_to_active(vmas, params->request);
 
 	return i915_gem_execbuffer_retire_commands(params);
 }
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 12/53
#136 lore raw

Re: [PATCH 12/53] drm/i915: Update execbuffer_move_to_active() to take a request structure

Quoted 58 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The plan is to pass requests around as the basic submission tracking structure rather than rings and contexts. This patch updates the execbuffer_move_to_active() code path.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    2 +-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    6 +++---
  drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
  3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 678b190..68d6dec 100644
@@ -2643,7 +2643,7 @@ int i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
  int i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
  			     struct drm_file *file_priv);
  void i915_gem_execbuffer_move_to_active(struct list_head *vmas,
-					struct intel_engine_cs *ring);
+					struct drm_i915_gem_request *req);
  int i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params);
  int i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  				   struct drm_i915_gem_execbuffer2 *args,
drivers/gpu/drm/i915/i915_gem_execbuffer.c +3 -3
index da1e232..f7c19bc 100644
@@ -950,9 +950,9 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 
  void
  i915_gem_execbuffer_move_to_active(struct list_head *vmas,
-				   struct intel_engine_cs *ring)
+				   struct drm_i915_gem_request *req)
  {
-	struct drm_i915_gem_request *req = intel_ring_get_request(ring);
+	struct intel_engine_cs *ring = i915_gem_request_get_ring(req);
  	struct i915_vma *vma;
 
  	list_for_each_entry(vma, vmas, exec_list) {
@@ -1279,7 +1279,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 
  	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
-	i915_gem_execbuffer_move_to_active(vmas, ring);
+	i915_gem_execbuffer_move_to_active(vmas, params->request);
 
  	ret = i915_gem_execbuffer_retire_commands(params);
 
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index efe970f..bc3809e 100644

drivers/gpu/drm/i915/intel_lrc.c int intel_execlists_submission(struct i915_execbuffer_params *params, · line 718

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -712,7 +712,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 
  	trace_i915_gem_ring_dispatch(params->request, params->dispatch_flags);
 
-	i915_gem_execbuffer_move_to_active(vmas, ring);
+	i915_gem_execbuffer_move_to_active(vmas, params->request);
 
  	return i915_gem_execbuffer_retire_commands(params);
  }

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#137 lore raw

PATCH 13/53 drm/i915: Add flag to i915_add_request() to skip the cache flush

In reply to [email protected]

From: John Harrison <[email protected]>

In order to explcitly track all GPU work (and completely remove the outstanding lazy request), it is necessary to add extra i915_add_request() calls to various places. Some of these do not need the implicit cache flush done as part of the standard batch buffer submission process.

This patch adds a flag to _add_request() to specify whether the flush is required or not.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h              |    7 +++++--
 drivers/gpu/drm/i915/i915_gem.c              |   25 +++++++++++--------------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   |    2 +-
 drivers/gpu/drm/i915/i915_gem_render_state.c |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c             |    2 +-
 5 files changed, 19 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -2
index 68d6dec..375d4f9 100644
@@ -2831,9 +2831,12 @@ int __must_check i915_gpu_idle(struct drm_device *dev);
 int __must_check i915_gem_suspend(struct drm_device *dev);
 int __i915_add_request(struct intel_engine_cs *ring,
 		       struct drm_file *file,
-		       struct drm_i915_gem_object *batch_obj);
+		       struct drm_i915_gem_object *batch_obj,
+		       bool flush_caches);
 #define i915_add_request(ring) \
-	__i915_add_request(ring, NULL, NULL)
+	__i915_add_request(ring, NULL, NULL, true)
+#define i915_add_request_no_flush(ring) \
+	__i915_add_request(ring, NULL, NULL, false)
 int __i915_wait_request(struct drm_i915_gem_request *req,
 			unsigned reset_counter,
 			bool interruptible,
drivers/gpu/drm/i915/i915_gem.c +11 -14
index cf959e3..4c29177 100644
@@ -2409,7 +2409,8 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
 
 int __i915_add_request(struct intel_engine_cs *ring,
 		       struct drm_file *file,
-		       struct drm_i915_gem_object *obj)
+		       struct drm_i915_gem_object *obj,
+		       bool flush_caches)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	struct drm_i915_gem_request *request;
@@ -2434,12 +2435,11 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	 * is that the flush _must_ happen before the next request, no matter
 	 * what.
 	 */
-	if (i915.enable_execlists) {
-		ret = logical_ring_flush_all_caches(ringbuf, request->ctx);
-		if (ret)
-			return ret;
-	} else {
-		ret = intel_ring_flush_all_caches(ring);
+	if (flush_caches) {
+		if (i915.enable_execlists)
+			ret = logical_ring_flush_all_caches(ringbuf, request->ctx);
+		else
+			ret = intel_ring_flush_all_caches(ring);
 		if (ret)
 			return ret;
 	}
@@ -2451,15 +2451,12 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	 */
 	request->postfix = intel_ring_get_tail(ringbuf);
 
-	if (i915.enable_execlists) {
+	if (i915.enable_execlists)
 		ret = ring->emit_request(ringbuf, request);
-		if (ret)
-			return ret;
-	} else {
+	else
 		ret = ring->add_request(ring);
-		if (ret)
-			return ret;
-	}
+	if (ret)
+		return ret;
 
 	request->head = request_start;
 	request->tail = intel_ring_get_tail(ringbuf);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index f7c19bc..76f6dcf 100644
@@ -997,7 +997,7 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
 
 	/* Add a breadcrumb for the completion of the batch buffer */
 	return __i915_add_request(params->ring, params->file,
-				  params->batch_obj);
+				  params->batch_obj, true);
 }
 
 static int
drivers/gpu/drm/i915/i915_gem_render_state.c +1 -1
index 521548a..aba39c3 100644
@@ -173,7 +173,7 @@ 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);
+	ret = __i915_add_request(ring, NULL, so.obj, true);
 	/* __i915_add_request moves object to inactive if it fails */
 out:
 	i915_gem_render_state_fini(&so);
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index bc3809e..4b42346 100644
@@ -1370,7 +1370,7 @@ 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);
+	ret = __i915_add_request(ring, file, so.obj, true);
 	/* intel_logical_ring_add_request moves object to inactive if it
 	 * fails */
 out:
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#138 lore raw

PATCH 14/53 drm/i915: Update pin_to_display_plane() to do explicit request management

In reply to [email protected]

From: John Harrison <[email protected]>

Added explicit creation creation and submission of the request structure to the display object pinning code. This removes any reliance on the OLR keeping track of the request and the unknown randomness that can ensue with other work becoming part of the same request.

v2: Added semaphore enabled check to prevent allocating a pointless request structure in the case where the sync just calls wait_rendering().

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +18 -3
index 4c29177..5897d54 100644
@@ -3943,9 +3943,24 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 	int ret;
 
 	if (pipelined != i915_gem_request_get_ring(obj->last_read_req)) {
-		ret = i915_gem_object_sync(obj, pipelined);
-		if (ret)
-			return ret;
+		if (!pipelined || !i915_semaphore_is_enabled(obj->base.dev)) {
+			ret = i915_gem_object_wait_rendering(obj, false);
+		} else {
+			struct drm_i915_private *dev_priv = pipelined->dev->dev_private;
+			struct drm_i915_gem_request *req;
+
+			ret = dev_priv->gt.alloc_request(pipelined, pipelined->default_context, &req);
+			if (ret)
+				return ret;
+
+			ret = i915_gem_object_sync(obj, req->ring);
+			if (ret)
+				return ret;
+
+			ret = i915_add_request_no_flush(req->ring);
+			if (ret)
+				return ret;
+		}
 	}
 
 	/* Mark the pin_display early so that we account for the
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#139 lore raw

Re: [PATCH 14/53] drm/i915: Update pin_to_display_plane() to do explicit request management

Quoted 3 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Added explicit creation creation and submission of the request structure to the

Nitpick: "creation creation"

Quoted 18 lines

display object pinning code. This removes any reliance on the OLR keeping track of the request and the unknown randomness that can ensue with other work becoming part of the same request.

v2: Added semaphore enabled check to prevent allocating a pointless request structure in the case where the sync just calls wait_rendering().

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c |   21 ++++++++++++++++++---
  1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 4c29177..5897d54 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, · line 3948

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem.c +3 -3
@@ -3943,9 +3943,24 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
  	int ret;
 
  	if (pipelined != i915_gem_request_get_ring(obj->last_read_req)) {
-		ret = i915_gem_object_sync(obj, pipelined);
-		if (ret)
-			return ret;
+		if (!pipelined || !i915_semaphore_is_enabled(obj->base.dev)) {
+			ret = i915_gem_object_wait_rendering(obj, false);
+		} else {

The call to i915_gem_object_wait_rendering() was taken from the implementation of i915_gem_object_sync() below. Ripping out code from the function you're calling just to do it in advance is not very nice. Just imagine a scenario where the i915_gem_object_sync() implementation were to change but the code outside the function would not. We need to figure out a better way of doing this. In fact, allocating and managing a request that never gets to be used inside the i915_gem_object_sync() function could be a better way to go since it poses less potential future problem even though it's more wasteful. But there are probably better ways of doing this.

Thanks,
Tomas

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem.c +8 -0
+			struct drm_i915_private *dev_priv = pipelined->dev->dev_private;
+			struct drm_i915_gem_request *req;
+
+			ret = dev_priv->gt.alloc_request(pipelined, pipelined->default_context, &req);
+			if (ret)
+				return ret;
+
+			ret = i915_gem_object_sync(obj, req->ring);

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, · line 3966

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +7 -0
+			if (ret)
+				return ret;
+
+			ret = i915_add_request_no_flush(req->ring);
+			if (ret)
+				return ret;
+		}
  	}
 
  	/* Mark the pin_display early so that we account for the

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#140 lore raw

Re: [PATCH 14/53] drm/i915: Update pin_to_display_plane() to do explicit request management

In reply to [email protected]
Quoted 21 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Added explicit creation creation and submission of the request structure to the display object pinning code. This removes any reliance on the OLR keeping track of the request and the unknown randomness that can ensue with other work becoming part of the same request.

v2: Added semaphore enabled check to prevent allocating a pointless request structure in the case where the sync just calls wait_rendering().

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c |   21 ++++++++++++++++++---
  1 file changed, 18 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 4c29177..5897d54 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, · line 3947

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +2 -3
@@ -3943,9 +3943,24 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
  	int ret;
 
  	if (pipelined != i915_gem_request_get_ring(obj->last_read_req)) {
-		ret = i915_gem_object_sync(obj, pipelined);
-		if (ret)
-			return ret;
+		if (!pipelined || !i915_semaphore_is_enabled(obj->base.dev)) {
+			ret = i915_gem_object_wait_rendering(obj, false);

... Also, the ret value here is never checked and returned. It's overwritten a few lines further down.

Thanks,
Tomas

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +9 -0
+		} else {
+			struct drm_i915_private *dev_priv = pipelined->dev->dev_private;
+			struct drm_i915_gem_request *req;
+
+			ret = dev_priv->gt.alloc_request(pipelined, pipelined->default_context, &req);
+			if (ret)
+				return ret;
+
+			ret = i915_gem_object_sync(obj, req->ring);

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj, · line 3966

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +7 -0
+			if (ret)
+				return ret;
+
+			ret = i915_add_request_no_flush(req->ring);
+			if (ret)
+				return ret;
+		}
  	}
 
  	/* Mark the pin_display early so that we account for the

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#141 lore raw

PATCH 15/53 drm/i915: Update i915_gem_object_sync() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

The plan is to pass requests around as the basic submission tracking structure rather than rings and contexts. This patch updates the i915_gem_object_sync() code path.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    2 +-
 drivers/gpu/drm/i915/i915_gem.c            |    7 ++++---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 375d4f9..bfd7b47 100644
@@ -2744,7 +2744,7 @@ static inline void i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)
 
 int __must_check i915_mutex_lock_interruptible(struct drm_device *dev);
 int i915_gem_object_sync(struct drm_i915_gem_object *obj,
-			 struct intel_engine_cs *to);
+			 struct drm_i915_gem_request *to_req);
 void i915_vma_move_to_active(struct i915_vma *vma,
 			     struct intel_engine_cs *ring);
 int i915_gem_dumb_create(struct drm_file *file_priv,
drivers/gpu/drm/i915/i915_gem.c +4 -3
index 5897d54..c5b9bc7 100644
@@ -2956,7 +2956,7 @@ out:
  * i915_gem_object_sync - sync an object to a ring.
  *
  * @obj: object which may be in use on another ring.
- * @to: ring we wish to use the object on. May be NULL.
+ * @to_req: request we wish to use the object for. May be NULL.
  *
  * This code is meant to abstract object synchronization with the GPU.
  * Calling with NULL implies synchronizing the object with the CPU
@@ -2966,8 +2966,9 @@ out:
  */
 int
 i915_gem_object_sync(struct drm_i915_gem_object *obj,
-		     struct intel_engine_cs *to)
+		     struct drm_i915_gem_request *to_req)
 {
+	struct intel_engine_cs *to = to_req ? to_req->ring : NULL;
 	struct intel_engine_cs *from;
 	u32 seqno;
 	int ret, idx;
@@ -3953,7 +3954,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 			if (ret)
 				return ret;
 
-			ret = i915_gem_object_sync(obj, req->ring);
+			ret = i915_gem_object_sync(obj, req);
 			if (ret)
 				return ret;
 
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 76f6dcf..2cd0579 100644
@@ -838,7 +838,7 @@ i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req,
 
 	list_for_each_entry(vma, vmas, exec_list) {
 		struct drm_i915_gem_object *obj = vma->obj;
-		ret = i915_gem_object_sync(obj, req->ring);
+		ret = i915_gem_object_sync(obj, req);
 		if (ret)
 			return ret;
 
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index 4b42346..0d88e9c 100644
@@ -589,7 +589,7 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req,
 	list_for_each_entry(vma, vmas, exec_list) {
 		struct drm_i915_gem_object *obj = vma->obj;
 
-		ret = i915_gem_object_sync(obj, req->ring);
+		ret = i915_gem_object_sync(obj, req);
 		if (ret)
 			return ret;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 15/53
#142 lore raw

Re: [PATCH 15/53] drm/i915: Update i915_gem_object_sync() to take a request structure

Quoted 80 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The plan is to pass requests around as the basic submission tracking structure rather than rings and contexts. This patch updates the i915_gem_object_sync() code path.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    2 +-
  drivers/gpu/drm/i915/i915_gem.c            |    7 ++++---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
  drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
  4 files changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 375d4f9..bfd7b47 100644
@@ -2744,7 +2744,7 @@ static inline void i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)
 
  int __must_check i915_mutex_lock_interruptible(struct drm_device *dev);
  int i915_gem_object_sync(struct drm_i915_gem_object *obj,
-			 struct intel_engine_cs *to);
+			 struct drm_i915_gem_request *to_req);
  void i915_vma_move_to_active(struct i915_vma *vma,
  			     struct intel_engine_cs *ring);
  int i915_gem_dumb_create(struct drm_file *file_priv,
drivers/gpu/drm/i915/i915_gem.c +4 -3
index 5897d54..c5b9bc7 100644
@@ -2956,7 +2956,7 @@ out:
   * i915_gem_object_sync - sync an object to a ring.
   *
   * @obj: object which may be in use on another ring.
- * @to: ring we wish to use the object on. May be NULL.
+ * @to_req: request we wish to use the object for. May be NULL.
   *
   * This code is meant to abstract object synchronization with the GPU.
   * Calling with NULL implies synchronizing the object with the CPU
@@ -2966,8 +2966,9 @@ out:
   */
  int
  i915_gem_object_sync(struct drm_i915_gem_object *obj,
-		     struct intel_engine_cs *to)
+		     struct drm_i915_gem_request *to_req)
  {
+	struct intel_engine_cs *to = to_req ? to_req->ring : NULL;
  	struct intel_engine_cs *from;
  	u32 seqno;
  	int ret, idx;
@@ -3953,7 +3954,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
  			if (ret)
  				return ret;
 
-			ret = i915_gem_object_sync(obj, req->ring);
+			ret = i915_gem_object_sync(obj, req);
  			if (ret)
  				return ret;
 
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 76f6dcf..2cd0579 100644
@@ -838,7 +838,7 @@ i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req,
 
  	list_for_each_entry(vma, vmas, exec_list) {
  		struct drm_i915_gem_object *obj = vma->obj;
-		ret = i915_gem_object_sync(obj, req->ring);
+		ret = i915_gem_object_sync(obj, req);
  		if (ret)
  			return ret;
 
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index 4b42346..0d88e9c 100644

drivers/gpu/drm/i915/intel_lrc.c static int execlists_move_to_gpu(struct drm_i915_gem_request *req, · line 595

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -589,7 +589,7 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req,
  	list_for_each_entry(vma, vmas, exec_list) {
  		struct drm_i915_gem_object *obj = vma->obj;
 
-		ret = i915_gem_object_sync(obj, req->ring);
+		ret = i915_gem_object_sync(obj, req);
  		if (ret)
  			return ret;
 

This seems to be just fine but if the requests of any of the existing i915_gem_object_sync() call sites were to be null they would cause local null pointer exceptions in the calling functions even though i915_gem_object_sync() itself supports an incoming null request. There does not seem to be any call sites in the driver that actually passes or supports passing null requests into i915_gem_object_sync(). Does the driver do that anywhere today or how does that fit in?

Aside from that open question:

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#143 lore raw

PATCH 16/53 drm/i915: Update i915_gpu_idle() to manage its own request

In reply to [email protected]

From: John Harrison <[email protected]>

Added explicit request creation and submission to the GPU idle code path.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +17 -1
index c5b9bc7..51f719c 100644
@@ -3114,11 +3114,27 @@ int i915_gpu_idle(struct drm_device *dev)
 	/* Flush everything onto the inactive list. */
 	for_each_ring(ring, dev_priv, i) {
 		if (!i915.enable_execlists) {
-			ret = i915_switch_context(ring, ring->default_context);
+			struct drm_i915_gem_request *req;
+
+			ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
 			if (ret)
 				return ret;
+
+			ret = i915_switch_context(req->ring, ring->default_context);
+			if (ret) {
+				i915_gem_request_unreference(req);
+				return ret;
+			}
+
+			ret = i915_add_request_no_flush(req->ring);
+			if (ret) {
+				i915_gem_request_unreference(req);
+				return ret;
+			}
 		}
 
+		WARN_ON(ring->outstanding_lazy_request);
+
 		ret = intel_ring_idle(ring);
 		if (ret)
 			return ret;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 16/53
#144 lore raw

Re: [PATCH 16/53] drm/i915: Update i915_gpu_idle() to manage its own request

Quoted 34 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Added explicit request creation and submission to the GPU idle code path.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c |   18 +++++++++++++++++-
  1 file changed, 17 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +12 -1
index c5b9bc7..51f719c 100644
@@ -3114,11 +3114,27 @@ int i915_gpu_idle(struct drm_device *dev)
  	/* Flush everything onto the inactive list. */
  	for_each_ring(ring, dev_priv, i) {
  		if (!i915.enable_execlists) {
-			ret = i915_switch_context(ring, ring->default_context);
+			struct drm_i915_gem_request *req;
+
+			ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
  			if (ret)
  				return ret;
+
+			ret = i915_switch_context(req->ring, ring->default_context);
+			if (ret) {
+				i915_gem_request_unreference(req);
+				return ret;
+			}
+
+			ret = i915_add_request_no_flush(req->ring);
+			if (ret) {

drivers/gpu/drm/i915/i915_gem.c int i915_gpu_idle(struct drm_device *dev) · line 3140

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +5 -0
+				i915_gem_request_unreference(req);
+				return ret;
+			}
  		}
 
+		WARN_ON(ring->outstanding_lazy_request);
+
  		ret = intel_ring_idle(ring);
  		if (ret)
  			return ret;

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#145 lore raw

PATCH 17/53 drm/i915: Split i915_ppgtt_init_hw() in half - generic and per ring

In reply to [email protected]

From: John Harrison <[email protected]>

The i915_gem_init_hw() function calls a bunch of smaller initialisation functions. Multiple of which have generic sections and per ring sections. This means multiple passes are done over the rings. Each pass writes data to the ring which floats around in that ring's OLR until some random point in the future when an add_request() is done by some random other piece of code.

This patch breaks i915_ppgtt_init_hw() in two with the per ring initialisation now being done in i915_ppgtt_init_ring(). The ring looping is now done at the top level in i915_gem_init_hw().

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c     |   25 +++++++++++++++++++------
 drivers/gpu/drm/i915/i915_gem_gtt.c |   25 ++++++++++++-------------
 drivers/gpu/drm/i915/i915_gem_gtt.h |    1 +
 3 files changed, 32 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +19 -6
index 51f719c..9bc60d7 100644
@@ -4844,19 +4844,32 @@ i915_gem_init_hw(struct drm_device *dev)
 	 */
 	init_unused_rings(dev);
 
+	ret = i915_ppgtt_init_hw(dev);
+	if (ret) {
+		DRM_ERROR("PPGTT enable HW failed %d\n", ret);
+		return ret;
+	}
+
+	/* Need to do basic initialisation of all rings first: */
 	for_each_ring(ring, dev_priv, i) {
 		ret = ring->init_hw(ring);
 		if (ret)
 			return ret;
 	}
 
-	for (i = 0; i < NUM_L3_SLICES(dev); i++)
-		i915_gem_l3_remap(&dev_priv->ring[RCS], i);
+	/* Now it is safe to go back round and do everything else: */
+	for_each_ring(ring, dev_priv, i) {
+		if (ring->id == RCS) {
+			for (i = 0; i < NUM_L3_SLICES(dev); i++)
+				i915_gem_l3_remap(ring, i);
+		}
 
-	ret = i915_ppgtt_init_hw(dev);
-	if (ret && ret != -EIO) {
-		DRM_ERROR("PPGTT enable failed %d\n", ret);
-		i915_gem_cleanup_ringbuffer(dev);
+		ret = i915_ppgtt_init_ring(ring);
+		if (ret && ret != -EIO) {
+			DRM_ERROR("PPGTT enable ring #%d failed %d\n", i, ret);
+			i915_gem_cleanup_ringbuffer(dev);
+			return ret;
+		}
 	}
 
 	ret = i915_gem_context_enable(dev_priv);
drivers/gpu/drm/i915/i915_gem_gtt.c +12 -13
index e54b2a0..428d2f6 100644
@@ -1206,11 +1206,6 @@ int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
 
 int i915_ppgtt_init_hw(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_engine_cs *ring;
-	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
-	int i, ret = 0;
-
 	/* In the case of execlists, PPGTT is enabled by the context descriptor
 	 * and the PDPs are contained within the context itself.  We don't
 	 * need to do anything here. */
@@ -1229,16 +1224,20 @@ int i915_ppgtt_init_hw(struct drm_device *dev)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	if (ppgtt) {
-		for_each_ring(ring, dev_priv, i) {
-			ret = ppgtt->switch_mm(ppgtt, ring);
-			if (ret != 0)
-				return ret;
-		}
-	}
+	return 0;
+}
 
-	return ret;
+int i915_ppgtt_init_ring(struct intel_engine_cs *ring)
+{
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
+
+	if (!ppgtt)
+		return 0;
+
+	return ppgtt->switch_mm(ppgtt, ring);
 }
+
 struct i915_hw_ppgtt *
 i915_ppgtt_create(struct drm_device *dev, struct drm_i915_file_private *fpriv)
 {
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
index 8f76990..5a6cef9 100644
@@ -300,6 +300,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev);
 
 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
 int i915_ppgtt_init_hw(struct drm_device *dev);
+int i915_ppgtt_init_ring(struct intel_engine_cs *ring);
 void i915_ppgtt_release(struct kref *kref);
 struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
 					struct drm_i915_file_private *fpriv);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#146 lore raw

Re: [PATCH 17/53] drm/i915: Split i915_ppgtt_init_hw() in half - generic and per ring

Quoted 106 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of [email protected]
Sent: Thursday, February 19, 2015 5:17 PM
To: [email protected]
Subject: [Intel-gfx] [PATCH 17/53] drm/i915: Split i915_ppgtt_init_hw() in half - generic and per ring

From: John Harrison <[email protected]>

The i915_gem_init_hw() function calls a bunch of smaller initialisation functions. Multiple of which have generic sections and per ring sections. This means multiple passes are done over the rings. Each pass writes data to the ring which floats around in that ring's OLR until some random point in the future when an add_request() is done by some random other piece of code.

This patch breaks i915_ppgtt_init_hw() in two with the per ring initialisation now being done in i915_ppgtt_init_ring(). The ring looping is now done at the top level in i915_gem_init_hw().

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c     |   25 +++++++++++++++++++------
 drivers/gpu/drm/i915/i915_gem_gtt.c |   25 ++++++++++++-------------
 drivers/gpu/drm/i915/i915_gem_gtt.h |    1 +
 3 files changed, 32 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +19 -6
index 51f719c..9bc60d7 100644
@@ -4844,19 +4844,32 @@ i915_gem_init_hw(struct drm_device *dev)
 	 */
 	init_unused_rings(dev);
 
+	ret = i915_ppgtt_init_hw(dev);
+	if (ret) {
+		DRM_ERROR("PPGTT enable HW failed %d\n", ret);
+		return ret;
+	}
+
+	/* Need to do basic initialisation of all rings first: */
 	for_each_ring(ring, dev_priv, i) {
 		ret = ring->init_hw(ring);
 		if (ret)
 			return ret;
 	}
 
-	for (i = 0; i < NUM_L3_SLICES(dev); i++)
-		i915_gem_l3_remap(&dev_priv->ring[RCS], i);
+	/* Now it is safe to go back round and do everything else: */
+	for_each_ring(ring, dev_priv, i) {
+		if (ring->id == RCS) {
+			for (i = 0; i < NUM_L3_SLICES(dev); i++)
+				i915_gem_l3_remap(ring, i);
+		}
 
-	ret = i915_ppgtt_init_hw(dev);
-	if (ret && ret != -EIO) {
-		DRM_ERROR("PPGTT enable failed %d\n", ret);
-		i915_gem_cleanup_ringbuffer(dev);
+		ret = i915_ppgtt_init_ring(ring);
+		if (ret && ret != -EIO) {
+			DRM_ERROR("PPGTT enable ring #%d failed %d\n", i,
 ret);
+			i915_gem_cleanup_ringbuffer(dev);
+			return ret;
+		}
 	}
 
drivers/gpu/drm/i915/i915_gem.c +0 -0
 	ret = i915_gem_context_enable(dev_priv);
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -5
index e54b2a0..428d2f6 100644
@@ -1206,11 +1206,6 @@ int i915_ppgtt_init(struct drm_device *dev, struct
 i915_hw_ppgtt *ppgtt)
 
 int i915_ppgtt_init_hw(struct drm_device *dev)
 {
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_engine_cs *ring;
-	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
-	int i, ret = 0;
-
 	/* In the case of execlists, PPGTT is enabled by the context descriptor
 	 * and the PDPs are contained within the context itself.  We don't
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -8
 	 * need to do anything here. */
@@ -1229,16 +1224,20 @@ int i915_ppgtt_init_hw(struct drm_device *dev)
 	else
 		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	if (ppgtt) {
-		for_each_ring(ring, dev_priv, i) {
-			ret = ppgtt->switch_mm(ppgtt, ring);
-			if (ret != 0)
-				return ret;
-		}
-	}
+	return 0;
+}
 
-	return ret;

drivers/gpu/drm/i915/i915_gem_gtt.c int i915_ppgtt_init_hw(struct drm_device *dev) · line 1239

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +9 -0
+int i915_ppgtt_init_ring(struct intel_engine_cs *ring)
+{
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
+
+	if (!ppgtt)
+		return 0;
+
+	return ppgtt->switch_mm(ppgtt, ring);
 }

This breaks alias PPGTT for execlists.
I915_ppgtt_init_hw() is a noop for execlists mode, but the new i915_ppgtt_init_ring() will try to do a switch_mm() which should not be done for execlists.

Thomas.

Quoted 20 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -0
+
 struct i915_hw_ppgtt *
 i915_ppgtt_create(struct drm_device *dev, struct drm_i915_file_private *fpriv)
 {
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
index 8f76990..5a6cef9 100644
@@ -300,6 +300,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev);
 
 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
 int i915_ppgtt_init_hw(struct drm_device *dev);
+int i915_ppgtt_init_ring(struct intel_engine_cs *ring);
 void i915_ppgtt_release(struct kref *kref);
 struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
 					struct drm_i915_file_private *fpriv);
--

1.7.9.5

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 17/53
#147 lore raw

Re: [PATCH 17/53] drm/i915: Split i915_ppgtt_init_hw() in half - generic and per ring

In reply to [email protected]
Quoted 25 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_init_hw() function calls a bunch of smaller initialisation functions. Multiple of which have generic sections and per ring sections. This means multiple passes are done over the rings. Each pass writes data to the ring which floats around in that ring's OLR until some random point in the future when an add_request() is done by some random other piece of code.

This patch breaks i915_ppgtt_init_hw() in two with the per ring initialisation now being done in i915_ppgtt_init_ring(). The ring looping is now done at the top level in i915_gem_init_hw().

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c     |   25 +++++++++++++++++++------
  drivers/gpu/drm/i915/i915_gem_gtt.c |   25 ++++++++++++-------------
  drivers/gpu/drm/i915/i915_gem_gtt.h |    1 +
  3 files changed, 32 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 51f719c..9bc60d7 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_init_hw(struct drm_device *dev) · line 4853

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +7 -0
@@ -4844,19 +4844,32 @@ i915_gem_init_hw(struct drm_device *dev)
  	 */
  	init_unused_rings(dev);
 
+	ret = i915_ppgtt_init_hw(dev);
+	if (ret) {
+		DRM_ERROR("PPGTT enable HW failed %d\n", ret);
+		return ret;
+	}
+
+	/* Need to do basic initialisation of all rings first: */

Nitpick: No need for trailing colon in comment

drivers/gpu/drm/i915/i915_gem.c i915_gem_init_hw(struct drm_device *dev) · line 4860

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem.c +1 -2
  	for_each_ring(ring, dev_priv, i) {
  		ret = ring->init_hw(ring);
  		if (ret)
  			return ret;
  	}
 
-	for (i = 0; i < NUM_L3_SLICES(dev); i++)
-		i915_gem_l3_remap(&dev_priv->ring[RCS], i);
+	/* Now it is safe to go back round and do everything else: */

Nitpick: No need for trailing colon in comment

Thanks,
Tomas

Quoted 70 lines
drivers/gpu/drm/i915/i915_gem.c +11 -4
+	for_each_ring(ring, dev_priv, i) {
+		if (ring->id == RCS) {
+			for (i = 0; i < NUM_L3_SLICES(dev); i++)
+				i915_gem_l3_remap(ring, i);
+		}
 
-	ret = i915_ppgtt_init_hw(dev);
-	if (ret && ret != -EIO) {
-		DRM_ERROR("PPGTT enable failed %d\n", ret);
-		i915_gem_cleanup_ringbuffer(dev);
+		ret = i915_ppgtt_init_ring(ring);
+		if (ret && ret != -EIO) {
+			DRM_ERROR("PPGTT enable ring #%d failed %d\n", i, ret);
+			i915_gem_cleanup_ringbuffer(dev);
+			return ret;
+		}
  	}
 
  	ret = i915_gem_context_enable(dev_priv);
drivers/gpu/drm/i915/i915_gem_gtt.c +12 -13
index e54b2a0..428d2f6 100644
@@ -1206,11 +1206,6 @@ int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
 
  int i915_ppgtt_init_hw(struct drm_device *dev)
  {
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_engine_cs *ring;
-	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
-	int i, ret = 0;
-
  	/* In the case of execlists, PPGTT is enabled by the context descriptor
  	 * and the PDPs are contained within the context itself.  We don't
  	 * need to do anything here. */
@@ -1229,16 +1224,20 @@ int i915_ppgtt_init_hw(struct drm_device *dev)
  	else
  		MISSING_CASE(INTEL_INFO(dev)->gen);
 
-	if (ppgtt) {
-		for_each_ring(ring, dev_priv, i) {
-			ret = ppgtt->switch_mm(ppgtt, ring);
-			if (ret != 0)
-				return ret;
-		}
-	}
+	return 0;
+}
 
-	return ret;
+int i915_ppgtt_init_ring(struct intel_engine_cs *ring)
+{
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
+
+	if (!ppgtt)
+		return 0;
+
+	return ppgtt->switch_mm(ppgtt, ring);
  }
+
  struct i915_hw_ppgtt *
  i915_ppgtt_create(struct drm_device *dev, struct drm_i915_file_private *fpriv)
  {
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index 8f76990..5a6cef9 100644

drivers/gpu/drm/i915/i915_gem_gtt.h void i915_global_gtt_cleanup(struct drm_device *dev); · line 306

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -0
@@ -300,6 +300,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev);
 
  int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
  int i915_ppgtt_init_hw(struct drm_device *dev);
+int i915_ppgtt_init_ring(struct intel_engine_cs *ring);
  void i915_ppgtt_release(struct kref *kref);
  struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
  					struct drm_i915_file_private *fpriv);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#148 lore raw

PATCH 18/53 drm/i915: Moved the for_each_ring loop outside of i915_gem_context_enable()

In reply to [email protected]

From: John Harrison <[email protected]>

The start of day context initialisation code in i915_gem_context_enable() loops over each ring and calls the legacy switch context or the execlist init context code as appropriate.

This patch moves the ring looping out of that function in to the top level caller i915_gem_init_hw(). This means the a single pass can be made over all rings doing the PPGTT, L3 remap and context initialisation of each ring altogether.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 +-
 drivers/gpu/drm/i915/i915_gem.c         |   18 ++++++++++-------
 drivers/gpu/drm/i915/i915_gem_context.c |   32 +++++++++++--------------------
 3 files changed, 23 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index bfd7b47..653c82d 100644
@@ -2989,7 +2989,7 @@ int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
-int i915_gem_context_enable(struct drm_i915_private *dev_priv);
+int i915_gem_context_enable(struct intel_engine_cs *ring);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
 int i915_switch_context(struct intel_engine_cs *ring,
 			struct intel_context *to);
drivers/gpu/drm/i915/i915_gem.c +11 -7
index 9bc60d7..5850991 100644
@@ -4844,6 +4844,8 @@ i915_gem_init_hw(struct drm_device *dev)
 	 */
 	init_unused_rings(dev);
 
+	BUG_ON(!dev_priv->ring[RCS].default_context);
+
 	ret = i915_ppgtt_init_hw(dev);
 	if (ret) {
 		DRM_ERROR("PPGTT enable HW failed %d\n", ret);
@@ -4859,6 +4861,8 @@ 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) {
+		WARN_ON(!ring->default_context);
+
 		if (ring->id == RCS) {
 			for (i = 0; i < NUM_L3_SLICES(dev); i++)
 				i915_gem_l3_remap(ring, i);
@@ -4870,17 +4874,17 @@ i915_gem_init_hw(struct drm_device *dev)
 			i915_gem_cleanup_ringbuffer(dev);
 			return ret;
 		}
-	}
 
-	ret = i915_gem_context_enable(dev_priv);
-	if (ret && ret != -EIO) {
-		DRM_ERROR("Context enable failed %d\n", ret);
-		i915_gem_cleanup_ringbuffer(dev);
+		ret = i915_gem_context_enable(ring);
+		if (ret && ret != -EIO) {
+			DRM_ERROR("Context enable ring #%d failed %d\n", i, ret);
+			i915_gem_cleanup_ringbuffer(dev);
 
-		return ret;
+			return ret;
+		}
 	}
 
-	return ret;
+	return 0;
 }
 
 int i915_gem_init(struct drm_device *dev)
drivers/gpu/drm/i915/i915_gem_context.c +11 -21
index 8603bf4..dd83d61 100644
@@ -403,32 +403,22 @@ void i915_gem_context_fini(struct drm_device *dev)
 	i915_gem_context_unreference(dctx);
 }
 
-int i915_gem_context_enable(struct drm_i915_private *dev_priv)
+int i915_gem_context_enable(struct intel_engine_cs *ring)
 {
-	struct intel_engine_cs *ring;
-	int ret, i;
-
-	BUG_ON(!dev_priv->ring[RCS].default_context);
+	int ret;
 
 	if (i915.enable_execlists) {
-		for_each_ring(ring, dev_priv, i) {
-			if (ring->init_context) {
-				ret = ring->init_context(ring,
-						ring->default_context);
-				if (ret) {
-					DRM_ERROR("ring init context: %d\n",
-							ret);
-					return ret;
-				}
-			}
-		}
+		if (ring->init_context == NULL)
+			return 0;
 
+		ret = ring->init_context(ring, ring->default_context);
 	} else
-		for_each_ring(ring, dev_priv, i) {
-			ret = i915_switch_context(ring, ring->default_context);
-			if (ret)
-				return ret;
-		}
+		ret = i915_switch_context(ring, ring->default_context);
+
+	if (ret) {
+		DRM_ERROR("ring init context: %d\n", ret);
+		return ret;
+	}
 
 	return 0;
 }
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 18/53
#149 lore raw

Re: [PATCH 18/53] drm/i915: Moved the for_each_ring loop outside of i915_gem_context_enable()

Quoted 118 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The start of day context initialisation code in i915_gem_context_enable() loops over each ring and calls the legacy switch context or the execlist init context code as appropriate.

This patch moves the ring looping out of that function in to the top level caller i915_gem_init_hw(). This means the a single pass can be made over all rings doing the PPGTT, L3 remap and context initialisation of each ring altogether.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    2 +-
  drivers/gpu/drm/i915/i915_gem.c         |   18 ++++++++++-------
  drivers/gpu/drm/i915/i915_gem_context.c |   32 +++++++++++--------------------
  3 files changed, 23 insertions(+), 29 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index bfd7b47..653c82d 100644
@@ -2989,7 +2989,7 @@ int __must_check i915_gem_context_init(struct drm_device *dev);
  void i915_gem_context_fini(struct drm_device *dev);
  void i915_gem_context_reset(struct drm_device *dev);
  int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
-int i915_gem_context_enable(struct drm_i915_private *dev_priv);
+int i915_gem_context_enable(struct intel_engine_cs *ring);
  void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
  int i915_switch_context(struct intel_engine_cs *ring,
  			struct intel_context *to);
drivers/gpu/drm/i915/i915_gem.c +11 -7
index 9bc60d7..5850991 100644
@@ -4844,6 +4844,8 @@ i915_gem_init_hw(struct drm_device *dev)
  	 */
  	init_unused_rings(dev);
 
+	BUG_ON(!dev_priv->ring[RCS].default_context);
+
  	ret = i915_ppgtt_init_hw(dev);
  	if (ret) {
  		DRM_ERROR("PPGTT enable HW failed %d\n", ret);
@@ -4859,6 +4861,8 @@ 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) {
+		WARN_ON(!ring->default_context);
+
  		if (ring->id == RCS) {
  			for (i = 0; i < NUM_L3_SLICES(dev); i++)
  				i915_gem_l3_remap(ring, i);
@@ -4870,17 +4874,17 @@ i915_gem_init_hw(struct drm_device *dev)
  			i915_gem_cleanup_ringbuffer(dev);
  			return ret;
  		}
-	}
 
-	ret = i915_gem_context_enable(dev_priv);
-	if (ret && ret != -EIO) {
-		DRM_ERROR("Context enable failed %d\n", ret);
-		i915_gem_cleanup_ringbuffer(dev);
+		ret = i915_gem_context_enable(ring);
+		if (ret && ret != -EIO) {
+			DRM_ERROR("Context enable ring #%d failed %d\n", i, ret);
+			i915_gem_cleanup_ringbuffer(dev);
 
-		return ret;
+			return ret;
+		}
  	}
 
-	return ret;
+	return 0;
  }
 
  int i915_gem_init(struct drm_device *dev)
drivers/gpu/drm/i915/i915_gem_context.c +5 -20
index 8603bf4..dd83d61 100644
@@ -403,32 +403,22 @@ void i915_gem_context_fini(struct drm_device *dev)
  	i915_gem_context_unreference(dctx);
  }
 
-int i915_gem_context_enable(struct drm_i915_private *dev_priv)
+int i915_gem_context_enable(struct intel_engine_cs *ring)
  {
-	struct intel_engine_cs *ring;
-	int ret, i;
-
-	BUG_ON(!dev_priv->ring[RCS].default_context);
+	int ret;
 
  	if (i915.enable_execlists) {
-		for_each_ring(ring, dev_priv, i) {
-			if (ring->init_context) {
-				ret = ring->init_context(ring,
-						ring->default_context);
-				if (ret) {
-					DRM_ERROR("ring init context: %d\n",
-							ret);
-					return ret;
-				}
-			}
-		}
+		if (ring->init_context == NULL)
+			return 0;
 
+		ret = ring->init_context(ring, ring->default_context);
  	} else
-		for_each_ring(ring, dev_priv, i) {
-			ret = i915_switch_context(ring, ring->default_context);
-			if (ret)
-				return ret;

drivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_fini(struct drm_device *dev) · line 424

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c +6 -1
-		}
+		ret = i915_switch_context(ring, ring->default_context);
+
+	if (ret) {
+		DRM_ERROR("ring init context: %d\n", ret);
+		return ret;
+	}
 
  	return 0;
  }

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#150 lore raw

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

In reply to [email protected]

From: John Harrison <[email protected]>

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

---
 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(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 653c82d..ea0da6b 100644
@@ -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. */
drivers/gpu/drm/i915/i915_gem.c +18 -0
index 5850991..efed49a 100644
@@ -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;
 		}
 	}
drivers/gpu/drm/i915/i915_gem_render_state.c +2 -1
index aba39c3..989476e 100644
@@ -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);
drivers/gpu/drm/i915/intel_lrc.c +3 -5
index 0d88e9c..dff7829 100644
@@ -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;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 19/53
#151 lore raw

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

Quoted 124 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

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

---
  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(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 653c82d..ea0da6b 100644
@@ -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. */
drivers/gpu/drm/i915/i915_gem.c +18 -0
index 5850991..efed49a 100644
@@ -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;
  		}
  	}
drivers/gpu/drm/i915/i915_gem_render_state.c +2 -1
index aba39c3..989476e 100644
@@ -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);
drivers/gpu/drm/i915/intel_lrc.c +0 -2
index 0d88e9c..dff7829 100644
@@ -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);

drivers/gpu/drm/i915/intel_lrc.c static int intel_lr_context_render_state_init(struct intel_engine_cs *ring, · line 1376

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -3
 
-	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;

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#152 lore raw

PATCH 20/53 drm/i915: Update ppgtt_init_ring() & context_enable() to take requests

In reply to [email protected]

From: John Harrison <[email protected]>

The final step in removing the OLR from i915_gem_init_hw() is to pass the newly allocated request structure in to each step rather than passing a ring structure. This patch updates both i915_ppgtt_init_ring() and i915_gem_context_enable() to take request pointers.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 +-
 drivers/gpu/drm/i915/i915_gem.c         |    4 ++--
 drivers/gpu/drm/i915/i915_gem_context.c |    7 ++++---
 drivers/gpu/drm/i915/i915_gem_gtt.c     |    6 +++---
 drivers/gpu/drm/i915/i915_gem_gtt.h     |    2 +-
 5 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index ea0da6b..618a841 100644
@@ -2990,7 +2990,7 @@ int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
-int i915_gem_context_enable(struct intel_engine_cs *ring);
+int i915_gem_context_enable(struct drm_i915_gem_request *req);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
 int i915_switch_context(struct intel_engine_cs *ring,
 			struct intel_context *to);
drivers/gpu/drm/i915/i915_gem.c +2 -2
index efed49a..379bf44 100644
@@ -4877,7 +4877,7 @@ i915_gem_init_hw(struct drm_device *dev)
 				i915_gem_l3_remap(ring, i);
 		}
 
-		ret = i915_ppgtt_init_ring(ring);
+		ret = i915_ppgtt_init_ring(req);
 		if (ret && ret != -EIO) {
 			DRM_ERROR("PPGTT enable ring #%d failed %d\n", i, ret);
 			i915_gem_request_unreference(req);
@@ -4885,7 +4885,7 @@ i915_gem_init_hw(struct drm_device *dev)
 			return ret;
 		}
 
-		ret = i915_gem_context_enable(ring);
+		ret = i915_gem_context_enable(req);
 		if (ret && ret != -EIO) {
 			DRM_ERROR("Context enable ring #%d failed %d\n", i, ret);
 			i915_gem_request_unreference(req);
drivers/gpu/drm/i915/i915_gem_context.c +4 -3
index dd83d61..04d2a20 100644
@@ -403,17 +403,18 @@ void i915_gem_context_fini(struct drm_device *dev)
 	i915_gem_context_unreference(dctx);
 }
 
-int i915_gem_context_enable(struct intel_engine_cs *ring)
+int i915_gem_context_enable(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	if (i915.enable_execlists) {
 		if (ring->init_context == NULL)
 			return 0;
 
-		ret = ring->init_context(ring, ring->default_context);
+		ret = ring->init_context(req->ring, ring->default_context);
 	} else
-		ret = i915_switch_context(ring, ring->default_context);
+		ret = i915_switch_context(req->ring, ring->default_context);
 
 	if (ret) {
 		DRM_ERROR("ring init context: %d\n", ret);
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -3
index 428d2f6..cd00080 100644
@@ -1227,15 +1227,15 @@ int i915_ppgtt_init_hw(struct drm_device *dev)
 	return 0;
 }
 
-int i915_ppgtt_init_ring(struct intel_engine_cs *ring)
+int i915_ppgtt_init_ring(struct drm_i915_gem_request *req)
 {
-	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	struct drm_i915_private *dev_priv = req->ring->dev->dev_private;
 	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
 
 	if (!ppgtt)
 		return 0;
 
-	return ppgtt->switch_mm(ppgtt, ring);
+	return ppgtt->switch_mm(ppgtt, req->ring);
 }
 
 struct i915_hw_ppgtt *
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
index 5a6cef9..e7e202f 100644
@@ -300,7 +300,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev);
 
 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
 int i915_ppgtt_init_hw(struct drm_device *dev);
-int i915_ppgtt_init_ring(struct intel_engine_cs *ring);
+int i915_ppgtt_init_ring(struct drm_i915_gem_request *req);
 void i915_ppgtt_release(struct kref *kref);
 struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
 					struct drm_i915_file_private *fpriv);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#153 lore raw

Re: [PATCH 20/53] drm/i915: Update ppgtt_init_ring() & context_enable() to take requests

Quoted 65 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The final step in removing the OLR from i915_gem_init_hw() is to pass the newly allocated request structure in to each step rather than passing a ring structure. This patch updates both i915_ppgtt_init_ring() and i915_gem_context_enable() to take request pointers.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    2 +-
  drivers/gpu/drm/i915/i915_gem.c         |    4 ++--
  drivers/gpu/drm/i915/i915_gem_context.c |    7 ++++---
  drivers/gpu/drm/i915/i915_gem_gtt.c     |    6 +++---
  drivers/gpu/drm/i915/i915_gem_gtt.h     |    2 +-
  5 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index ea0da6b..618a841 100644
@@ -2990,7 +2990,7 @@ int __must_check i915_gem_context_init(struct drm_device *dev);
  void i915_gem_context_fini(struct drm_device *dev);
  void i915_gem_context_reset(struct drm_device *dev);
  int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
-int i915_gem_context_enable(struct intel_engine_cs *ring);
+int i915_gem_context_enable(struct drm_i915_gem_request *req);
  void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
  int i915_switch_context(struct intel_engine_cs *ring,
  			struct intel_context *to);
drivers/gpu/drm/i915/i915_gem.c +2 -2
index efed49a..379bf44 100644
@@ -4877,7 +4877,7 @@ i915_gem_init_hw(struct drm_device *dev)
  				i915_gem_l3_remap(ring, i);
  		}
 
-		ret = i915_ppgtt_init_ring(ring);
+		ret = i915_ppgtt_init_ring(req);
  		if (ret && ret != -EIO) {
  			DRM_ERROR("PPGTT enable ring #%d failed %d\n", i, ret);
  			i915_gem_request_unreference(req);
@@ -4885,7 +4885,7 @@ i915_gem_init_hw(struct drm_device *dev)
  			return ret;
  		}
 
-		ret = i915_gem_context_enable(ring);
+		ret = i915_gem_context_enable(req);
  		if (ret && ret != -EIO) {
  			DRM_ERROR("Context enable ring #%d failed %d\n", i, ret);
  			i915_gem_request_unreference(req);
drivers/gpu/drm/i915/i915_gem_context.c +2 -1
index dd83d61..04d2a20 100644
@@ -403,17 +403,18 @@ void i915_gem_context_fini(struct drm_device *dev)
  	i915_gem_context_unreference(dctx);
  }
 
-int i915_gem_context_enable(struct intel_engine_cs *ring)
+int i915_gem_context_enable(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;

drivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_fini(struct drm_device *dev) · line 417

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c +2 -2
 
  	if (i915.enable_execlists) {
  		if (ring->init_context == NULL)
  			return 0;
 
-		ret = ring->init_context(ring, ring->default_context);
+		ret = ring->init_context(req->ring, ring->default_context);
  	} else
-		ret = i915_switch_context(ring, ring->default_context);
+		ret = i915_switch_context(req->ring, ring->default_context);

You don't have to make any more changes to this function aside from setting up the ring variable at the top. ring = req->ring and if you don't change these lines the will by default use ring like they always did.

Quoted 15 lines
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
  	if (ret) {
  		DRM_ERROR("ring init context: %d\n", ret);
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -2
index 428d2f6..cd00080 100644
@@ -1227,15 +1227,15 @@ int i915_ppgtt_init_hw(struct drm_device *dev)
  	return 0;
  }
 
-int i915_ppgtt_init_ring(struct intel_engine_cs *ring)
+int i915_ppgtt_init_ring(struct drm_i915_gem_request *req)
  {
-	struct drm_i915_private *dev_priv = ring->dev->dev_private;

drivers/gpu/drm/i915/i915_gem_gtt.c int i915_ppgtt_init_hw(struct drm_device *dev) · line 1240

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -1
+	struct drm_i915_private *dev_priv = req->ring->dev->dev_private;
  	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
 
  	if (!ppgtt)
  		return 0;
 
-	return ppgtt->switch_mm(ppgtt, ring);
+	return ppgtt->switch_mm(ppgtt, req->ring);
  }
 

If you want to uphold a pattern that you've already established you could just make a single change in the function above by setting up ring = req->ring and then make no more changes to the function body. In this case it's one new line vs. two changes of existing code so it's doesn't make that much of a difference but it is nice to stick to patterns. Also, you wouldn't have to make a 4-level indirection (req->ring->dev->dev_private), only a 3-level one.

Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -0
  struct i915_hw_ppgtt *
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index 5a6cef9..e7e202f 100644

drivers/gpu/drm/i915/i915_gem_gtt.h void i915_global_gtt_cleanup(struct drm_device *dev); · line 306

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
@@ -300,7 +300,7 @@ void i915_global_gtt_cleanup(struct drm_device *dev);
 
  int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt);
  int i915_ppgtt_init_hw(struct drm_device *dev);
-int i915_ppgtt_init_ring(struct intel_engine_cs *ring);
+int i915_ppgtt_init_ring(struct drm_i915_gem_request *req);
  void i915_ppgtt_release(struct kref *kref);
  struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,
  					struct drm_i915_file_private *fpriv);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#155 lore raw

Re: [PATCH 20/53] drm/i915: Update ppgtt_init_ring() & context_enable() to take requests

Quoted 124 lines · John Harrison
Quoted 111 lines · Tomas Elf
Quoted 72 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The final step in removing the OLR from i915_gem_init_hw() is to pass the newly
allocated request structure in to each step rather than passing a ring structure. This patch updates both i915_ppgtt_init_ring() and i915_gem_context_enable() to take request pointers.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    2 +-
  drivers/gpu/drm/i915/i915_gem.c         |    4 ++--
  drivers/gpu/drm/i915/i915_gem_context.c |    7 ++++---
  drivers/gpu/drm/i915/i915_gem_gtt.c     |    6 +++---
  drivers/gpu/drm/i915/i915_gem_gtt.h     |    2 +-
  5 files changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index ea0da6b..618a841 100644
@@ -2990,7 +2990,7 @@ int __must_check i915_gem_context_init(struct
 drm_device *dev);
  void i915_gem_context_fini(struct drm_device *dev);
  void i915_gem_context_reset(struct drm_device *dev);
  int i915_gem_context_open(struct drm_device *dev, struct drm_file
 *file);
-int i915_gem_context_enable(struct intel_engine_cs *ring);
+int i915_gem_context_enable(struct drm_i915_gem_request *req);
  void i915_gem_context_close(struct drm_device *dev, struct drm_file

*file);
int i915_switch_context(struct intel_engine_cs *ring,

              struct intel_context *to);
drivers/gpu/drm/i915/i915_gem.c +2 -2
index efed49a..379bf44 100644
@@ -4877,7 +4877,7 @@ i915_gem_init_hw(struct drm_device *dev)
                  i915_gem_l3_remap(ring, i);
          }
 
-        ret = i915_ppgtt_init_ring(ring);
+        ret = i915_ppgtt_init_ring(req);
          if (ret && ret != -EIO) {
              DRM_ERROR("PPGTT enable ring #%d failed %d\n", i, ret);
              i915_gem_request_unreference(req);
@@ -4885,7 +4885,7 @@ i915_gem_init_hw(struct drm_device *dev)
              return ret;
          }
 
-        ret = i915_gem_context_enable(ring);
+        ret = i915_gem_context_enable(req);
          if (ret && ret != -EIO) {
              DRM_ERROR("Context enable ring #%d failed %d\n", i, ret);
              i915_gem_request_unreference(req);
drivers/gpu/drm/i915/i915_gem_context.c +2 -1
index dd83d61..04d2a20 100644
@@ -403,17 +403,18 @@ void i915_gem_context_fini(struct drm_device *dev)
      i915_gem_context_unreference(dctx);
  }
 
-int i915_gem_context_enable(struct intel_engine_cs *ring)
+int i915_gem_context_enable(struct drm_i915_gem_request *req)
  {
+    struct intel_engine_cs *ring = req->ring;
      int ret;

drivers/gpu/drm/i915/i915_gem_context.c void i915_gem_context_fini(struct drm_device *dev) · line 417

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_context.c +2 -2
 
      if (i915.enable_execlists) {
          if (ring->init_context == NULL)
              return 0;
 
-        ret = ring->init_context(ring, ring->default_context);
+        ret = ring->init_context(req->ring, ring->default_context);
      } else
-        ret = i915_switch_context(ring, ring->default_context);
+        ret = i915_switch_context(req->ring, ring->default_context);

You don't have to make any more changes to this function aside from setting up the ring variable at the top. ring = req->ring and if you don't change these lines the will by default use ring like they always did.

Quoted 22 lines
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
      if (ret) {
          DRM_ERROR("ring init context: %d\n", ret);
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -2
index 428d2f6..cd00080 100644
@@ -1227,15 +1227,15 @@ int i915_ppgtt_init_hw(struct drm_device *dev)
      return 0;
  }
 
-int i915_ppgtt_init_ring(struct intel_engine_cs *ring)
+int i915_ppgtt_init_ring(struct drm_i915_gem_request *req)
  {
-    struct drm_i915_private *dev_priv = ring->dev->dev_private;
+    struct drm_i915_private *dev_priv = req->ring->dev->dev_private;
      struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
 
      if (!ppgtt)
          return 0;
 
Quoted 12 lines

drivers/gpu/drm/i915/i915_gem_gtt.c int i915_ppgtt_init_hw(struct drm_device *dev) · line 1240

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
-    return ppgtt->switch_mm(ppgtt, ring);
+    return ppgtt->switch_mm(ppgtt, req->ring);
  }
 

If you want to uphold a pattern that you've already established you could just make a single change in the function above by setting up ring = req->ring and then make no more changes to the function body. In this case it's one new line vs. two changes of existing code so it's doesn't make that much of a difference but it is nice to stick to patterns. Also, you wouldn't have to make a 4-level indirection (req->ring->dev->dev_private), only a 3-level one.

Quoted 6 lines

It all depends how often the ring variable would get used. In this case, there are only two references. One of which, the switch_mm(), will disappear later in the series anyway. So for the sake of a single usage, it isn't worth adding in the extra line. The dev_priv is only really there because if you don't use an explicit variable, you have to do a messy type cast in the middle of the dereference chain.

If switch_mm won't require the ring parameter later in the patch series (which I should've noticed) then it admittedly becomes kind of unnecessary to have a local ring variable. Never mind!

Thanks,
Tomas

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -0
  struct i915_hw_ppgtt *
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index 5a6cef9..e7e202f 100644
@@ -300,7 +300,7 @@ void i915_global_gtt_cleanup(struct drm_device
 *dev);
 
Quoted 11 lines
Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
  int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt
 *ppgtt);
  int i915_ppgtt_init_hw(struct drm_device *dev);
-int i915_ppgtt_init_ring(struct intel_engine_cs *ring);
+int i915_ppgtt_init_ring(struct drm_i915_gem_request *req);
  void i915_ppgtt_release(struct kref *kref);

struct i915_hw_ppgtt *i915_ppgtt_create(struct drm_device *dev,

                      struct drm_i915_file_private *fpriv);

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#156 lore raw

PATCH 21/53 drm/i915: Set context in request from creation even in legacy mode

In reply to [email protected]

From: John Harrison <[email protected]>

In execlist mode, the context object pointer is written in to the request structure (and reference counted) at the point of request creation. In legacy mode, this only happens inside i915_add_request().

This patch updates the legacy code path to match the execlist version. This allows all the intermediate code between request creation and request submission to get at the context object given only a request structure. Thus negating the need to pass context pointers here, there and everywhere.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c         |    9 +--------
 drivers/gpu/drm/i915/intel_ringbuffer.c |    2 ++
 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -8
index 379bf44..64288e3 100644
@@ -2470,14 +2470,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	WARN_ON(request->batch_obj && obj);
 	request->batch_obj = obj;
 
-	if (!i915.enable_execlists) {
-		/* Hold a reference to the current context so that we can inspect
-		 * it later in case a hangcheck error event fires.
-		 */
-		request->ctx = ring->last_context;
-		if (request->ctx)
-			i915_gem_context_reference(request->ctx);
-	}
+	WARN_ON(request->ctx != ring->last_context);
 
 	request->emitted_jiffies = jiffies;
 	list_add_tail(&request->list, &ring->request_list);
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -0
index 1a9f884..05a7e33 100644
@@ -2186,6 +2186,8 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,
 	request->ring = ring;
 	request->ringbuf = ring->buffer;
 	request->uniq = dev_private->request_uniq++;
+	request->ctx = ctx;
+	i915_gem_context_reference(request->ctx);
 
 	ret = i915_gem_get_seqno(ring->dev, &request->seqno);
 	if (ret) {
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#157 lore raw

PATCH 21/53 drm/i915: Set context in request from creation even in legacy mode

From: John Harrison <[email protected]>

In execlist mode, the context object pointer is written in to the request structure (and reference counted) at the point of request creation. In legacy mode, this only happens inside i915_add_request().

This patch updates the legacy code path to match the execlist version. This allows all the intermediate code between request creation and request submission to get at the context object given only a request structure. Thus negating the need to pass context pointers here, there and everywhere.

v2: Moved the context reference so it does not need to be undone if the get_seqno() fails.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c         |    9 +--------
 drivers/gpu/drm/i915/intel_ringbuffer.c |    3 +++
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -8
index 151ddb5..e237aa0 100644
@@ -2482,14 +2482,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	WARN_ON(request->batch_obj && obj);
 	request->batch_obj = obj;
 
-	if (!i915.enable_execlists) {
-		/* Hold a reference to the current context so that we can inspect
-		 * it later in case a hangcheck error event fires.
-		 */
-		request->ctx = ring->last_context;
-		if (request->ctx)
-			i915_gem_context_reference(request->ctx);
-	}
+	WARN_ON(request->ctx != ring->last_context);
 
 	request->emitted_jiffies = jiffies;
 	list_add_tail(&request->list, &ring->request_list);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -0
index e7dd3cf..4550676 100644
@@ -2244,6 +2244,9 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,
 		return ret;
 	}
 
+	request->ctx = ctx;
+	i915_gem_context_reference(request->ctx);
+
 	*req_out = ring->outstanding_lazy_request = request;
 	return 0;
 }
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#158 lore raw

Re: [PATCH 21/53] drm/i915: Set context in request from creation even in legacy mode

In reply to [email protected]
Quoted 25 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

In execlist mode, the context object pointer is written in to the request structure (and reference counted) at the point of request creation. In legacy mode, this only happens inside i915_add_request().

This patch updates the legacy code path to match the execlist version. This allows all the intermediate code between request creation and request submission to get at the context object given only a request structure. Thus negating the need to pass context pointers here, there and everywhere.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c         |    9 +--------
  drivers/gpu/drm/i915/intel_ringbuffer.c |    2 ++
  2 files changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 379bf44..64288e3 100644
@@ -2470,14 +2470,7 @@ int __i915_add_request(struct intel_engine_cs *ring,
  	WARN_ON(request->batch_obj && obj);
  	request->batch_obj = obj;

drivers/gpu/drm/i915/i915_gem.c int __i915_add_request(struct intel_engine_cs *ring, · line 2473

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +1 -8
 
-	if (!i915.enable_execlists) {
-		/* Hold a reference to the current context so that we can inspect
-		 * it later in case a hangcheck error event fires.
-		 */
-		request->ctx = ring->last_context;
-		if (request->ctx)
-			i915_gem_context_reference(request->ctx);
-	}
+	WARN_ON(request->ctx != ring->last_context);

__i915_add_request is gen agnostic but ring->last_context is only used in legacy mode. Maybe you want to check for !i915.enable_execlists just like in the block you removed above?

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
  	request->emitted_jiffies = jiffies;
  	list_add_tail(&request->list, &ring->request_list);
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -0
index 1a9f884..05a7e33 100644

drivers/gpu/drm/i915/intel_ringbuffer.c intel_ring_alloc_request(struct intel_engine_cs *ring, · line 2193

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -0
@@ -2186,6 +2186,8 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,
  	request->ring = ring;
  	request->ringbuf = ring->buffer;
  	request->uniq = dev_private->request_uniq++;
+	request->ctx = ctx;
+	i915_gem_context_reference(request->ctx);
 
  	ret = i915_gem_get_seqno(ring->dev, &request->seqno);
  	if (ret) {

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#159 lore raw

PATCH 22/53 drm/i915: Update i915_switch_context() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Now that the request is guaranteed to specify the context, it is possible to update the context switch code to use requests rather than ring and context pairs. This patch updates i915_switch_context() accordingly.

Also removed the warning that the request's context must match the last context switch's context. As the context switch now gets the context object from the request structure, there is no longer any scope for the two to become out of step.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    3 +--
 drivers/gpu/drm/i915/i915_gem.c            |    4 +---
 drivers/gpu/drm/i915/i915_gem_context.c    |   19 +++++++++----------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
 4 files changed, 12 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -2
index 618a841..e9cc343 100644
@@ -2992,8 +2992,7 @@ void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
 int i915_gem_context_enable(struct drm_i915_gem_request *req);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
-int i915_switch_context(struct intel_engine_cs *ring,
-			struct intel_context *to);
+int i915_switch_context(struct drm_i915_gem_request *req);
 struct intel_context *
 i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);
 void i915_gem_context_free(struct kref *ctx_ref);
drivers/gpu/drm/i915/i915_gem.c +1 -3
index 64288e3..0c7e1bd 100644
@@ -2470,8 +2470,6 @@ int __i915_add_request(struct intel_engine_cs *ring,
 	WARN_ON(request->batch_obj && obj);
 	request->batch_obj = obj;
 
-	WARN_ON(request->ctx != ring->last_context);
-
 	request->emitted_jiffies = jiffies;
 	list_add_tail(&request->list, &ring->request_list);
 	request->file_priv = NULL;
@@ -3114,7 +3112,7 @@ int i915_gpu_idle(struct drm_device *dev)
 			if (ret)
 				return ret;
 
-			ret = i915_switch_context(req->ring, ring->default_context);
+			ret = i915_switch_context(req);
 			if (ret) {
 				i915_gem_request_unreference(req);
 				return ret;
drivers/gpu/drm/i915/i915_gem_context.c +9 -10
index 04d2a20..b326f8d 100644
@@ -414,7 +414,7 @@ int i915_gem_context_enable(struct drm_i915_gem_request *req)
 
 		ret = ring->init_context(req->ring, ring->default_context);
 	} else
-		ret = i915_switch_context(req->ring, ring->default_context);
+		ret = i915_switch_context(req);
 
 	if (ret) {
 		DRM_ERROR("ring init context: %d\n", ret);
@@ -693,8 +693,7 @@ unpin_out:
 
 /**
  * i915_switch_context() - perform a GPU context switch.
- * @ring: ring for which we'll execute the context switch
- * @to: the context to switch to
+ * @req: request for which we'll execute the context switch
  *
  * The context life cycle is simple. The context refcount is incremented and
  * decremented by 1 and create and destroy. If the context is in use by the GPU,
@@ -705,25 +704,25 @@ unpin_out:
  * switched by writing to the ELSP and requests keep a reference to their
  * context.
  */
-int i915_switch_context(struct intel_engine_cs *ring,
-			struct intel_context *to)
+int i915_switch_context(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 
 	WARN_ON(i915.enable_execlists);
 	WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex));
 
-	if (to->legacy_hw_ctx.rcs_state == NULL) { /* We have the fake context */
-		if (to != ring->last_context) {
-			i915_gem_context_reference(to);
+	if (req->ctx->legacy_hw_ctx.rcs_state == NULL) { /* We have the fake context */
+		if (req->ctx != ring->last_context) {
+			i915_gem_context_reference(req->ctx);
 			if (ring->last_context)
 				i915_gem_context_unreference(ring->last_context);
-			ring->last_context = to;
+			ring->last_context = req->ctx;
 		}
 		return 0;
 	}
 
-	return do_switch(ring, to);
+	return do_switch(req->ring, req->ctx);
 }
 
 static bool contexts_enabled(struct drm_device *dev)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 2cd0579..1e2fc80 100644
@@ -1190,7 +1190,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 	if (ret)
 		goto error;
 
-	ret = i915_switch_context(ring, params->ctx);
+	ret = i915_switch_context(params->request);
 	if (ret)
 		goto error;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 22/53
#160 lore raw

Re: [PATCH 22/53] drm/i915: Update i915_switch_context() to take a request structure

Quoted 118 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Now that the request is guaranteed to specify the context, it is possible to update the context switch code to use requests rather than ring and context pairs. This patch updates i915_switch_context() accordingly.

Also removed the warning that the request's context must match the last context switch's context. As the context switch now gets the context object from the request structure, there is no longer any scope for the two to become out of step.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    3 +--
  drivers/gpu/drm/i915/i915_gem.c            |    4 +---
  drivers/gpu/drm/i915/i915_gem_context.c    |   19 +++++++++----------
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
  4 files changed, 12 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -2
index 618a841..e9cc343 100644
@@ -2992,8 +2992,7 @@ void i915_gem_context_reset(struct drm_device *dev);
  int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
  int i915_gem_context_enable(struct drm_i915_gem_request *req);
  void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
-int i915_switch_context(struct intel_engine_cs *ring,
-			struct intel_context *to);
+int i915_switch_context(struct drm_i915_gem_request *req);
  struct intel_context *
  i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);
  void i915_gem_context_free(struct kref *ctx_ref);
drivers/gpu/drm/i915/i915_gem.c +1 -3
index 64288e3..0c7e1bd 100644
@@ -2470,8 +2470,6 @@ int __i915_add_request(struct intel_engine_cs *ring,
  	WARN_ON(request->batch_obj && obj);
  	request->batch_obj = obj;
 
-	WARN_ON(request->ctx != ring->last_context);
-
  	request->emitted_jiffies = jiffies;
  	list_add_tail(&request->list, &ring->request_list);
  	request->file_priv = NULL;
@@ -3114,7 +3112,7 @@ int i915_gpu_idle(struct drm_device *dev)
  			if (ret)
  				return ret;
 
-			ret = i915_switch_context(req->ring, ring->default_context);
+			ret = i915_switch_context(req);
  			if (ret) {
  				i915_gem_request_unreference(req);
  				return ret;
drivers/gpu/drm/i915/i915_gem_context.c +9 -10
index 04d2a20..b326f8d 100644
@@ -414,7 +414,7 @@ int i915_gem_context_enable(struct drm_i915_gem_request *req)
 
  		ret = ring->init_context(req->ring, ring->default_context);
  	} else
-		ret = i915_switch_context(req->ring, ring->default_context);
+		ret = i915_switch_context(req);
 
  	if (ret) {
  		DRM_ERROR("ring init context: %d\n", ret);
@@ -693,8 +693,7 @@ unpin_out:
 
  /**
   * i915_switch_context() - perform a GPU context switch.
- * @ring: ring for which we'll execute the context switch
- * @to: the context to switch to
+ * @req: request for which we'll execute the context switch
   *
   * The context life cycle is simple. The context refcount is incremented and
   * decremented by 1 and create and destroy. If the context is in use by the GPU,
@@ -705,25 +704,25 @@ unpin_out:
   * switched by writing to the ELSP and requests keep a reference to their
   * context.
   */
-int i915_switch_context(struct intel_engine_cs *ring,
-			struct intel_context *to)
+int i915_switch_context(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 
  	WARN_ON(i915.enable_execlists);
  	WARN_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex));
 
-	if (to->legacy_hw_ctx.rcs_state == NULL) { /* We have the fake context */
-		if (to != ring->last_context) {
-			i915_gem_context_reference(to);
+	if (req->ctx->legacy_hw_ctx.rcs_state == NULL) { /* We have the fake context */
+		if (req->ctx != ring->last_context) {
+			i915_gem_context_reference(req->ctx);
  			if (ring->last_context)
  				i915_gem_context_unreference(ring->last_context);
-			ring->last_context = to;
+			ring->last_context = req->ctx;
  		}
  		return 0;
  	}
 
-	return do_switch(ring, to);
+	return do_switch(req->ring, req->ctx);
  }
 
  static bool contexts_enabled(struct drm_device *dev)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index 2cd0579..1e2fc80 100644

drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params, · line 1196

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1190,7 +1190,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  	if (ret)
  		goto error;
 
-	ret = i915_switch_context(ring, params->ctx);
+	ret = i915_switch_context(params->request);
  	if (ret)
  		goto error;
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#161 lore raw

PATCH 23/53 drm/i915: Update do_switch() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated do_switch() to take a request pointer instead of a ring/context pair.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_context.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +9 -8
index b326f8d..eedb994 100644
@@ -556,9 +556,10 @@ mi_set_context(struct intel_engine_cs *ring,
 	return ret;
 }
 
-static int do_switch(struct intel_engine_cs *ring,
-		     struct intel_context *to)
+static int do_switch(struct drm_i915_gem_request *req)
 {
+	struct intel_context *to = req->ctx;
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	struct intel_context *from = ring->last_context;
 	u32 hw_flags = 0;
@@ -591,7 +592,7 @@ static int do_switch(struct intel_engine_cs *ring,
 
 	if (to->ppgtt) {
 		trace_switch_mm(ring, to);
-		ret = to->ppgtt->switch_mm(to->ppgtt, ring);
+		ret = to->ppgtt->switch_mm(to->ppgtt, req->ring);
 		if (ret)
 			goto unpin_out;
 	}
@@ -627,7 +628,7 @@ static int do_switch(struct intel_engine_cs *ring,
 	if (!to->legacy_hw_ctx.initialized || i915_gem_context_is_default(to))
 		hw_flags |= MI_RESTORE_INHIBIT;
 
-	ret = mi_set_context(ring, to, hw_flags);
+	ret = mi_set_context(req->ring, to, hw_flags);
 	if (ret)
 		goto unpin_out;
 
@@ -635,7 +636,7 @@ static int do_switch(struct intel_engine_cs *ring,
 		if (!(to->remap_slice & (1<<i)))
 			continue;
 
-		ret = i915_gem_l3_remap(ring, i);
+		ret = i915_gem_l3_remap(req->ring, i);
 		/* If it failed, try again next round */
 		if (ret)
 			DRM_DEBUG_DRIVER("L3 remapping failed\n");
@@ -651,7 +652,7 @@ static int do_switch(struct intel_engine_cs *ring,
 	 */
 	if (from != NULL) {
 		from->legacy_hw_ctx.rcs_state->base.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
-		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), ring);
+		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), req->ring);
 		/* As long as MI_SET_CONTEXT is serializing, ie. it flushes the
 		 * whole damn pipeline, we don't need to explicitly mark the
 		 * object dirty. The only exception is that the context must be
@@ -677,7 +678,7 @@ done:
 
 	if (uninitialized) {
 		if (ring->init_context) {
-			ret = ring->init_context(ring, to);
+			ret = ring->init_context(req->ring, to);
 			if (ret)
 				DRM_ERROR("ring init context: %d\n", ret);
 		}
@@ -722,7 +723,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
 		return 0;
 	}
 
-	return do_switch(req->ring, req->ctx);
+	return do_switch(req);
 }
 
 static bool contexts_enabled(struct drm_device *dev)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#162 lore raw

Re: [PATCH 23/53] drm/i915: Update do_switch() to take a request structure

Quoted 28 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated do_switch() to take a request pointer instead of a ring/context pair.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_context.c |   17 +++++++++--------
  1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +3 -2
index b326f8d..eedb994 100644
@@ -556,9 +556,10 @@ mi_set_context(struct intel_engine_cs *ring,
  	return ret;
  }
 
-static int do_switch(struct intel_engine_cs *ring,
-		     struct intel_context *to)
+static int do_switch(struct drm_i915_gem_request *req)
  {
+	struct intel_context *to = req->ctx;
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_i915_private *dev_priv = ring->dev->dev_private;
  	struct intel_context *from = ring->last_context;
  	u32 hw_flags = 0;

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 595

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
@@ -591,7 +592,7 @@ static int do_switch(struct intel_engine_cs *ring,
 
  	if (to->ppgtt) {
  		trace_switch_mm(ring, to);
-		ret = to->ppgtt->switch_mm(to->ppgtt, ring);
+		ret = to->ppgtt->switch_mm(to->ppgtt, req->ring);

No need for this change, ring = req->ring has already been set up. Just leave the code as it was.

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 631

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
  		if (ret)
  			goto unpin_out;
  	}
@@ -627,7 +628,7 @@ static int do_switch(struct intel_engine_cs *ring,
  	if (!to->legacy_hw_ctx.initialized || i915_gem_context_is_default(to))
  		hw_flags |= MI_RESTORE_INHIBIT;
 
-	ret = mi_set_context(ring, to, hw_flags);
+	ret = mi_set_context(req->ring, to, hw_flags);

No need for this change, ring = req->ring has already been set up. Just leave the code as it was.

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 639

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
  	if (ret)
  		goto unpin_out;
 
@@ -635,7 +636,7 @@ static int do_switch(struct intel_engine_cs *ring,
  		if (!(to->remap_slice & (1<<i)))
  			continue;
 
-		ret = i915_gem_l3_remap(ring, i);
+		ret = i915_gem_l3_remap(req->ring, i);

No need for this change, ring = req->ring has already been set up. Just leave the code as it was.

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct intel_engine_cs *ring, · line 655

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
  		/* If it failed, try again next round */
  		if (ret)
  			DRM_DEBUG_DRIVER("L3 remapping failed\n");
@@ -651,7 +652,7 @@ static int do_switch(struct intel_engine_cs *ring,
  	 */
  	if (from != NULL) {
  		from->legacy_hw_ctx.rcs_state->base.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
-		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), ring);
+		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), req->ring);

No need for this change, ring = req->ring has already been set up. Just leave the code as it was.

drivers/gpu/drm/i915/i915_gem_context.c done: · line 681

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
  		/* As long as MI_SET_CONTEXT is serializing, ie. it flushes the
  		 * whole damn pipeline, we don't need to explicitly mark the
  		 * object dirty. The only exception is that the context must be
@@ -677,7 +678,7 @@ done:
 
  	if (uninitialized) {
  		if (ring->init_context) {
-			ret = ring->init_context(ring, to);
+			ret = ring->init_context(req->ring, to);

No need for this change, ring = req->ring has already been set up. Just leave the code as it was.

drivers/gpu/drm/i915/i915_gem_context.c int i915_switch_context(struct drm_i915_gem_request *req) · line 729

Quoted 13 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
  			if (ret)
  				DRM_ERROR("ring init context: %d\n", ret);
  		}
@@ -722,7 +723,7 @@ int i915_switch_context(struct drm_i915_gem_request *req)
  		return 0;
  	}
 
-	return do_switch(req->ring, req->ctx);
+	return do_switch(req);
  }
 
  static bool contexts_enabled(struct drm_device *dev)

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#163 lore raw

PATCH 24/53 drm/i915: Update deferred context creation to do explicit request management

In reply to [email protected]

From: John Harrison <[email protected]>

In execlist mode, context initialisation is deferred until first use of the given context. This is because execlist mode has many more contexts than legacy mode and many are never actually used. Previously, the initialisation commands were written to the ring and tagged with some random request structure via the OLR. This seemed to be causing a null pointer deference bug under certain circumstances (BZ:40112).

This patch adds explicit request creation and submission to the deferred initialisation code path. Thus removing any reliance on or randomness caused by the OLR.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_lrc.c +16 -1
index dff7829..4bcb70e 100644
@@ -1849,6 +1849,7 @@ static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring,
 int intel_lr_context_deferred_create(struct intel_context *ctx,
 				     struct intel_engine_cs *ring)
 {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	const bool is_global_default_ctx = (ctx == ring->default_context);
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_gem_object *ctx_obj;
@@ -1929,13 +1930,27 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
 		lrc_setup_hardware_status_page(ring, ctx_obj);
 	else if (ring->id == RCS && !ctx->rcs_initialized) {
 		if (ring->init_context) {
-			ret = ring->init_context(ring, ctx);
+			struct drm_i915_gem_request *req;
+
+			ret = dev_priv->gt.alloc_request(ring, ctx, &req);
+			if (ret)
+				return ret;
+
+			ret = ring->init_context(req->ring, ctx);
 			if (ret) {
 				DRM_ERROR("ring init context: %d\n", ret);
+				i915_gem_request_unreference(req);
 				ctx->engine[ring->id].ringbuf = NULL;
 				ctx->engine[ring->id].state = NULL;
 				goto error;
 			}
+
+			ret = i915_add_request_no_flush(req->ring);
+			if (ret) {
+				DRM_ERROR("ring init context: %d\n", ret);
+				i915_gem_request_unreference(req);
+				goto error;
+			}
 		}
 
 		ctx->rcs_initialized = true;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 24/53
#164 lore raw

Re: [PATCH 24/53] drm/i915: Update deferred context creation to do explicit request management

Quoted 51 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

In execlist mode, context initialisation is deferred until first use of the given context. This is because execlist mode has many more contexts than legacy mode and many are never actually used. Previously, the initialisation commands were written to the ring and tagged with some random request structure via the OLR. This seemed to be causing a null pointer deference bug under certain circumstances (BZ:40112).

This patch adds explicit request creation and submission to the deferred initialisation code path. Thus removing any reliance on or randomness caused by the OLR.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_lrc.c |   17 ++++++++++++++++-
  1 file changed, 16 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_lrc.c +9 -1
index dff7829..4bcb70e 100644
@@ -1849,6 +1849,7 @@ static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring,
  int intel_lr_context_deferred_create(struct intel_context *ctx,
  				     struct intel_engine_cs *ring)
  {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
  	const bool is_global_default_ctx = (ctx == ring->default_context);
  	struct drm_device *dev = ring->dev;
  	struct drm_i915_gem_object *ctx_obj;
@@ -1929,13 +1930,27 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
  		lrc_setup_hardware_status_page(ring, ctx_obj);
  	else if (ring->id == RCS && !ctx->rcs_initialized) {
  		if (ring->init_context) {
-			ret = ring->init_context(ring, ctx);
+			struct drm_i915_gem_request *req;
+
+			ret = dev_priv->gt.alloc_request(ring, ctx, &req);
+			if (ret)
+				return ret;
+
+			ret = ring->init_context(req->ring, ctx);
  			if (ret) {
  				DRM_ERROR("ring init context: %d\n", ret);
+				i915_gem_request_unreference(req);
  				ctx->engine[ring->id].ringbuf = NULL;
  				ctx->engine[ring->id].state = NULL;
  				goto error;
  			}

drivers/gpu/drm/i915/intel_lrc.c int intel_lr_context_deferred_create(struct intel_context *ctx, · line 1956

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +7 -0
+
+			ret = i915_add_request_no_flush(req->ring);
+			if (ret) {
+				DRM_ERROR("ring init context: %d\n", ret);
+				i915_gem_request_unreference(req);
+				goto error;
+			}
  		}
 
  		ctx->rcs_initialized = true;

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#165 lore raw

PATCH 25/53 drm/i915: Update init_context() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Now that everything above has been converted to use requests, it is possible to update init_context() to take a request pointer instead of a ring/context pair.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_context.c |    4 ++--
 drivers/gpu/drm/i915/intel_lrc.c        |    9 ++++-----
 drivers/gpu/drm/i915/intel_ringbuffer.c |    7 +++----
 drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
 4 files changed, 10 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +2 -2
index eedb994..938cd26 100644
@@ -412,7 +412,7 @@ int i915_gem_context_enable(struct drm_i915_gem_request *req)
 		if (ring->init_context == NULL)
 			return 0;
 
-		ret = ring->init_context(req->ring, ring->default_context);
+		ret = ring->init_context(req);
 	} else
 		ret = i915_switch_context(req);
 
@@ -678,7 +678,7 @@ done:
 
 	if (uninitialized) {
 		if (ring->init_context) {
-			ret = ring->init_context(req->ring, to);
+			ret = ring->init_context(req);
 			if (ret)
 				DRM_ERROR("ring init context: %d\n", ret);
 		}
drivers/gpu/drm/i915/intel_lrc.c +4 -5
index 4bcb70e..cbec056 100644
@@ -1376,16 +1376,15 @@ out:
 	return ret;
 }
 
-static int gen8_init_rcs_context(struct intel_engine_cs *ring,
-		       struct intel_context *ctx)
+static int gen8_init_rcs_context(struct drm_i915_gem_request *req)
 {
 	int ret;
 
-	ret = intel_logical_ring_workarounds_emit(ring, ctx);
+	ret = intel_logical_ring_workarounds_emit(req->ring, req->ctx);
 	if (ret)
 		return ret;
 
-	return intel_lr_context_render_state_init(ring, ctx);
+	return intel_lr_context_render_state_init(req->ring, req->ctx);
 }
 
 /**
@@ -1936,7 +1935,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
 			if (ret)
 				return ret;
 
-			ret = ring->init_context(req->ring, ctx);
+			ret = ring->init_context(req);
 			if (ret) {
 				DRM_ERROR("ring init context: %d\n", ret);
 				i915_gem_request_unreference(req);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -4
index 05a7e33..26964a2 100644
@@ -775,16 +775,15 @@ static int intel_ring_workarounds_emit(struct intel_engine_cs *ring,
 	return 0;
 }
 
-static int intel_rcs_ctx_init(struct intel_engine_cs *ring,
-			      struct intel_context *ctx)
+static int intel_rcs_ctx_init(struct drm_i915_gem_request *req)
 {
 	int ret;
 
-	ret = intel_ring_workarounds_emit(ring, ctx);
+	ret = intel_ring_workarounds_emit(req->ring, req->ctx);
 	if (ret != 0)
 		return ret;
 
-	ret = i915_gem_render_state_init(ring);
+	ret = i915_gem_render_state_init(req->ring);
 	if (ret)
 		DRM_ERROR("init render state: %d\n", ret);
 
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
index 4f8a14a..c32f5a1 100644
@@ -143,8 +143,7 @@ struct  intel_engine_cs {
 
 	int		(*init_hw)(struct intel_engine_cs *ring);
 
-	int		(*init_context)(struct intel_engine_cs *ring,
-					struct intel_context *ctx);
+	int		(*init_context)(struct drm_i915_gem_request *req);
 
 	void		(*write_tail)(struct intel_engine_cs *ring,
 				      u32 value);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 25/53
#166 lore raw

Re: [PATCH 25/53] drm/i915: Update init_context() to take a request structure

Quoted 99 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Now that everything above has been converted to use requests, it is possible to update init_context() to take a request pointer instead of a ring/context pair.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_context.c |    4 ++--
  drivers/gpu/drm/i915/intel_lrc.c        |    9 ++++-----
  drivers/gpu/drm/i915/intel_ringbuffer.c |    7 +++----
  drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
  4 files changed, 10 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +2 -2
index eedb994..938cd26 100644
@@ -412,7 +412,7 @@ int i915_gem_context_enable(struct drm_i915_gem_request *req)
  		if (ring->init_context == NULL)
  			return 0;
 
-		ret = ring->init_context(req->ring, ring->default_context);
+		ret = ring->init_context(req);
  	} else
  		ret = i915_switch_context(req);
 
@@ -678,7 +678,7 @@ done:
 
  	if (uninitialized) {
  		if (ring->init_context) {
-			ret = ring->init_context(req->ring, to);
+			ret = ring->init_context(req);
  			if (ret)
  				DRM_ERROR("ring init context: %d\n", ret);
  		}
drivers/gpu/drm/i915/intel_lrc.c +4 -5
index 4bcb70e..cbec056 100644
@@ -1376,16 +1376,15 @@ out:
  	return ret;
  }
 
-static int gen8_init_rcs_context(struct intel_engine_cs *ring,
-		       struct intel_context *ctx)
+static int gen8_init_rcs_context(struct drm_i915_gem_request *req)
  {
  	int ret;
 
-	ret = intel_logical_ring_workarounds_emit(ring, ctx);
+	ret = intel_logical_ring_workarounds_emit(req->ring, req->ctx);
  	if (ret)
  		return ret;
 
-	return intel_lr_context_render_state_init(ring, ctx);
+	return intel_lr_context_render_state_init(req->ring, req->ctx);
  }
 
  /**
@@ -1936,7 +1935,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
  			if (ret)
  				return ret;
 
-			ret = ring->init_context(req->ring, ctx);
+			ret = ring->init_context(req);
  			if (ret) {
  				DRM_ERROR("ring init context: %d\n", ret);
  				i915_gem_request_unreference(req);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -4
index 05a7e33..26964a2 100644
@@ -775,16 +775,15 @@ static int intel_ring_workarounds_emit(struct intel_engine_cs *ring,
  	return 0;
  }
 
-static int intel_rcs_ctx_init(struct intel_engine_cs *ring,
-			      struct intel_context *ctx)
+static int intel_rcs_ctx_init(struct drm_i915_gem_request *req)
  {
  	int ret;
 
-	ret = intel_ring_workarounds_emit(ring, ctx);
+	ret = intel_ring_workarounds_emit(req->ring, req->ctx);
  	if (ret != 0)
  		return ret;
 
-	ret = i915_gem_render_state_init(ring);
+	ret = i915_gem_render_state_init(req->ring);
  	if (ret)
  		DRM_ERROR("init render state: %d\n", ret);
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 4f8a14a..c32f5a1 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 149

Quoted 9 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
@@ -143,8 +143,7 @@ struct  intel_engine_cs {
 
  	int		(*init_hw)(struct intel_engine_cs *ring);
 
-	int		(*init_context)(struct intel_engine_cs *ring,
-					struct intel_context *ctx);
+	int		(*init_context)(struct drm_i915_gem_request *req);
 
  	void		(*write_tail)(struct intel_engine_cs *ring,
  				      u32 value);

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#167 lore raw

PATCH 26/53 drm/i915: Update render_state_init() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the two render_state_init() functions to take a request pointer instead of a ring. This removes their reliance on the OLR.

v2: Rebased to newer tree.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_render_state.c |   18 +++++++++---------
 drivers/gpu/drm/i915/i915_gem_render_state.h |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c             |   22 ++++++++++------------
 drivers/gpu/drm/i915/intel_ringbuffer.c      |    2 +-
 4 files changed, 21 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_gem_render_state.c +9 -9
index 989476e..85cc746 100644
@@ -152,29 +152,29 @@ int i915_gem_render_state_prepare(struct intel_engine_cs *ring,
 	return 0;
 }
 
-int i915_gem_render_state_init(struct intel_engine_cs *ring)
+int i915_gem_render_state_init(struct drm_i915_gem_request *req)
 {
 	struct render_state so;
 	int ret;
 
-	ret = i915_gem_render_state_prepare(ring, &so);
+	ret = i915_gem_render_state_prepare(req->ring, &so);
 	if (ret)
 		return ret;
 
 	if (so.rodata == NULL)
 		return 0;
 
-	ret = ring->dispatch_execbuffer(ring,
-					so.ggtt_offset,
-					so.rodata->batch_items * 4,
-					I915_DISPATCH_SECURE);
+	ret = req->ring->dispatch_execbuffer(req->ring,
+					     so.ggtt_offset,
+					     so.rodata->batch_items * 4,
+					     I915_DISPATCH_SECURE);
 	if (ret)
 		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
 
-	WARN_ON(ring->outstanding_lazy_request->batch_obj);
-	ring->outstanding_lazy_request->batch_obj = so.obj;
+	WARN_ON(req->batch_obj);
+	req->batch_obj = so.obj;
 	/* __i915_add_request moves object to inactive if it fails */
 out:
 	i915_gem_render_state_fini(&so);
drivers/gpu/drm/i915/i915_gem_render_state.h +1 -1
index c44961e..7aa7372 100644
@@ -39,7 +39,7 @@ struct render_state {
 	int gen;
 };
 
-int i915_gem_render_state_init(struct intel_engine_cs *ring);
+int i915_gem_render_state_init(struct drm_i915_gem_request *req);
 void i915_gem_render_state_fini(struct render_state *so);
 int i915_gem_render_state_prepare(struct intel_engine_cs *ring,
 				  struct render_state *so);
drivers/gpu/drm/i915/intel_lrc.c +10 -12
index cbec056..f0bb98a 100644
@@ -1345,31 +1345,29 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
 	return 0;
 }
 
-static int intel_lr_context_render_state_init(struct intel_engine_cs *ring,
-					      struct intel_context *ctx)
+static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req)
 {
-	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
 	struct render_state so;
 	int ret;
 
-	ret = i915_gem_render_state_prepare(ring, &so);
+	ret = i915_gem_render_state_prepare(req->ring, &so);
 	if (ret)
 		return ret;
 
 	if (so.rodata == NULL)
 		return 0;
 
-	ret = ring->emit_bb_start(ringbuf,
-			ctx,
-			so.ggtt_offset,
-			I915_DISPATCH_SECURE);
+	ret = req->ring->emit_bb_start(req->ringbuf,
+				       req->ctx,
+				       so.ggtt_offset,
+				       I915_DISPATCH_SECURE);
 	if (ret)
 		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
 
-	WARN_ON(ring->outstanding_lazy_request->batch_obj);
-	ring->outstanding_lazy_request->batch_obj = so.obj;
+	WARN_ON(req->batch_obj);
+	req->batch_obj = so.obj;
 	/* __i915_add_request moves object to inactive if it fails */
 out:
 	i915_gem_render_state_fini(&so);
@@ -1384,7 +1382,7 @@ static int gen8_init_rcs_context(struct drm_i915_gem_request *req)
 	if (ret)
 		return ret;
 
-	return intel_lr_context_render_state_init(req->ring, req->ctx);
+	return intel_lr_context_render_state_init(req);
 }
 
 /**
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index 26964a2..efb1729 100644
@@ -783,7 +783,7 @@ static int intel_rcs_ctx_init(struct drm_i915_gem_request *req)
 	if (ret != 0)
 		return ret;
 
-	ret = i915_gem_render_state_init(req->ring);
+	ret = i915_gem_render_state_init(req);
 	if (ret)
 		DRM_ERROR("init render state: %d\n", ret);
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 26/53
#168 lore raw

Re: [PATCH 26/53] drm/i915: Update render_state_init() to take a request structure

Quoted 132 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the two render_state_init() functions to take a request pointer instead of a ring. This removes their reliance on the OLR.

v2: Rebased to newer tree.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_render_state.c |   18 +++++++++---------
  drivers/gpu/drm/i915/i915_gem_render_state.h |    2 +-
  drivers/gpu/drm/i915/intel_lrc.c             |   22 ++++++++++------------
  drivers/gpu/drm/i915/intel_ringbuffer.c      |    2 +-
  4 files changed, 21 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_gem_render_state.c +9 -9
index 989476e..85cc746 100644
@@ -152,29 +152,29 @@ int i915_gem_render_state_prepare(struct intel_engine_cs *ring,
  	return 0;
  }
 
-int i915_gem_render_state_init(struct intel_engine_cs *ring)
+int i915_gem_render_state_init(struct drm_i915_gem_request *req)
  {
  	struct render_state so;
  	int ret;
 
-	ret = i915_gem_render_state_prepare(ring, &so);
+	ret = i915_gem_render_state_prepare(req->ring, &so);
  	if (ret)
  		return ret;
 
  	if (so.rodata == NULL)
  		return 0;
 
-	ret = ring->dispatch_execbuffer(ring,
-					so.ggtt_offset,
-					so.rodata->batch_items * 4,
-					I915_DISPATCH_SECURE);
+	ret = req->ring->dispatch_execbuffer(req->ring,
+					     so.ggtt_offset,
+					     so.rodata->batch_items * 4,
+					     I915_DISPATCH_SECURE);
  	if (ret)
  		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
 
-	WARN_ON(ring->outstanding_lazy_request->batch_obj);
-	ring->outstanding_lazy_request->batch_obj = so.obj;
+	WARN_ON(req->batch_obj);
+	req->batch_obj = so.obj;
  	/* __i915_add_request moves object to inactive if it fails */
  out:
  	i915_gem_render_state_fini(&so);
drivers/gpu/drm/i915/i915_gem_render_state.h +1 -1
index c44961e..7aa7372 100644
@@ -39,7 +39,7 @@ struct render_state {
  	int gen;
  };
 
-int i915_gem_render_state_init(struct intel_engine_cs *ring);
+int i915_gem_render_state_init(struct drm_i915_gem_request *req);
  void i915_gem_render_state_fini(struct render_state *so);
  int i915_gem_render_state_prepare(struct intel_engine_cs *ring,
  				  struct render_state *so);
drivers/gpu/drm/i915/intel_lrc.c +10 -12
index cbec056..f0bb98a 100644
@@ -1345,31 +1345,29 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
  	return 0;
  }
 
-static int intel_lr_context_render_state_init(struct intel_engine_cs *ring,
-					      struct intel_context *ctx)
+static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req)
  {
-	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
  	struct render_state so;
  	int ret;
 
-	ret = i915_gem_render_state_prepare(ring, &so);
+	ret = i915_gem_render_state_prepare(req->ring, &so);
  	if (ret)
  		return ret;
 
  	if (so.rodata == NULL)
  		return 0;
 
-	ret = ring->emit_bb_start(ringbuf,
-			ctx,
-			so.ggtt_offset,
-			I915_DISPATCH_SECURE);
+	ret = req->ring->emit_bb_start(req->ringbuf,
+				       req->ctx,
+				       so.ggtt_offset,
+				       I915_DISPATCH_SECURE);
  	if (ret)
  		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
 
-	WARN_ON(ring->outstanding_lazy_request->batch_obj);
-	ring->outstanding_lazy_request->batch_obj = so.obj;
+	WARN_ON(req->batch_obj);
+	req->batch_obj = so.obj;
  	/* __i915_add_request moves object to inactive if it fails */
  out:
  	i915_gem_render_state_fini(&so);
@@ -1384,7 +1382,7 @@ static int gen8_init_rcs_context(struct drm_i915_gem_request *req)
  	if (ret)
  		return ret;
 
-	return intel_lr_context_render_state_init(req->ring, req->ctx);
+	return intel_lr_context_render_state_init(req);
  }
 
  /**
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -0
index 26964a2..efb1729 100644

drivers/gpu/drm/i915/intel_ringbuffer.c static int intel_rcs_ctx_init(struct drm_i915_gem_request *req) · line 789

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
@@ -783,7 +783,7 @@ static int intel_rcs_ctx_init(struct drm_i915_gem_request *req)
  	if (ret != 0)
  		return ret;
 
-	ret = i915_gem_render_state_init(req->ring);
+	ret = i915_gem_render_state_init(req);
  	if (ret)
  		DRM_ERROR("init render state: %d\n", ret);
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#169 lore raw

PATCH 27/53 drm/i915: Update overlay code to do explicit request management

In reply to [email protected]

From: John Harrison <[email protected]>

The overlay update code path to do explicit request creation and submission rather than relying on the OLR to do the right thing.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_overlay.c |   64 +++++++++++++++++++++++++---------
 1 file changed, 48 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/intel_overlay.c +48 -16
index f93dfc1..dc209bf 100644
@@ -209,19 +209,19 @@ static void intel_overlay_unmap_regs(struct intel_overlay *overlay,
 }
 
 static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
+					 struct drm_i915_gem_request *req,
 					 void (*tail)(struct intel_overlay *))
 {
 	struct drm_device *dev = overlay->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	BUG_ON(overlay->last_flip_req);
-	i915_gem_request_assign(&overlay->last_flip_req,
-					     ring->outstanding_lazy_request);
-	ret = i915_add_request(ring);
-	if (ret)
+	i915_gem_request_assign(&overlay->last_flip_req, req);
+	ret = i915_add_request(req->ring);
+	if (ret) {
+		i915_gem_request_unreference(req);
 		return ret;
+	}
 
 	overlay->flip_tail = tail;
 	ret = i915_wait_request(overlay->last_flip_req);
@@ -239,6 +239,7 @@ static int intel_overlay_on(struct intel_overlay *overlay)
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req;
 	int ret;
 
 	BUG_ON(overlay->active);
@@ -246,17 +247,23 @@ static int intel_overlay_on(struct intel_overlay *overlay)
 
 	WARN_ON(IS_I830(dev) && !(dev_priv->quirks & QUIRK_PIPEA_FORCE));
 
-	ret = intel_ring_begin(ring, 4);
+	ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
 	if (ret)
 		return ret;
 
+	ret = intel_ring_begin(ring, 4);
+	if (ret) {
+		i915_gem_request_unreference(req);
+		return ret;
+	}
+
 	intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_ON);
 	intel_ring_emit(ring, overlay->flip_addr | OFC_UPDATE);
 	intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
 
-	return intel_overlay_do_wait_request(overlay, NULL);
+	return intel_overlay_do_wait_request(overlay, req, NULL);
 }
 
 /* overlay needs to be enabled in OCMD reg */
@@ -266,6 +273,7 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req;
 	u32 flip_addr = overlay->flip_addr;
 	u32 tmp;
 	int ret;
@@ -280,18 +288,27 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
 	if (tmp & (1 << 17))
 		DRM_DEBUG("overlay underrun, DOVSTA: %x\n", tmp);
 
-	ret = intel_ring_begin(ring, 2);
+	ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
 	if (ret)
 		return ret;
 
+	ret = intel_ring_begin(ring, 2);
+	if (ret) {
+		i915_gem_request_unreference(req);
+		return ret;
+	}
+
 	intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
 	intel_ring_emit(ring, flip_addr);
 	intel_ring_advance(ring);
 
 	WARN_ON(overlay->last_flip_req);
-	i915_gem_request_assign(&overlay->last_flip_req,
-					     ring->outstanding_lazy_request);
-	return i915_add_request(ring);
+	i915_gem_request_assign(&overlay->last_flip_req, req);
+	ret = i915_add_request(req->ring);
+	if (ret)
+		i915_gem_request_unreference(req);
+
+	return ret;
 }
 
 static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay)
@@ -326,6 +343,7 @@ static int intel_overlay_off(struct intel_overlay *overlay)
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req;
 	u32 flip_addr = overlay->flip_addr;
 	int ret;
 
@@ -337,10 +355,16 @@ static int intel_overlay_off(struct intel_overlay *overlay)
 	 * of the hw. Do it in both cases */
 	flip_addr |= OFC_UPDATE;
 
-	ret = intel_ring_begin(ring, 6);
+	ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
 	if (ret)
 		return ret;
 
+	ret = intel_ring_begin(ring, 6);
+	if (ret) {
+		i915_gem_request_unreference(req);
+		return ret;
+	}
+
 	/* wait for overlay to go idle */
 	intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
 	intel_ring_emit(ring, flip_addr);
@@ -359,7 +383,7 @@ static int intel_overlay_off(struct intel_overlay *overlay)
 	}
 	intel_ring_advance(ring);
 
-	return intel_overlay_do_wait_request(overlay, intel_overlay_off_tail);
+	return intel_overlay_do_wait_request(overlay, req, intel_overlay_off_tail);
 }
 
 /* recover from an interruption due to a signal
@@ -404,15 +428,23 @@ static int intel_overlay_release_old_vid(struct intel_overlay *overlay)
 
 	if (I915_READ(ISR) & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT) {
 		/* synchronous slowpath */
-		ret = intel_ring_begin(ring, 2);
+		struct drm_i915_gem_request *req;
+
+		ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
 		if (ret)
 			return ret;
 
+		ret = intel_ring_begin(ring, 2);
+		if (ret) {
+			i915_gem_request_unreference(req);
+			return ret;
+		}
+
 		intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
 		intel_ring_emit(ring, MI_NOOP);
 		intel_ring_advance(ring);
 
-		ret = intel_overlay_do_wait_request(overlay,
+		ret = intel_overlay_do_wait_request(overlay, req,
 						    intel_overlay_release_old_vid_tail);
 		if (ret)
 			return ret;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 27/53
#170 lore raw

Re: [PATCH 27/53] drm/i915: Update overlay code to do explicit request management

Quoted 167 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

The overlay update code path to do explicit request creation and submission rather than relying on the OLR to do the right thing.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_overlay.c |   64 +++++++++++++++++++++++++---------
  1 file changed, 48 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/intel_overlay.c +46 -15
index f93dfc1..dc209bf 100644
@@ -209,19 +209,19 @@ static void intel_overlay_unmap_regs(struct intel_overlay *overlay,
  }
 
  static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
+					 struct drm_i915_gem_request *req,
  					 void (*tail)(struct intel_overlay *))
  {
  	struct drm_device *dev = overlay->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
  	int ret;
 
  	BUG_ON(overlay->last_flip_req);
-	i915_gem_request_assign(&overlay->last_flip_req,
-					     ring->outstanding_lazy_request);
-	ret = i915_add_request(ring);
-	if (ret)
+	i915_gem_request_assign(&overlay->last_flip_req, req);
+	ret = i915_add_request(req->ring);
+	if (ret) {
+		i915_gem_request_unreference(req);
  		return ret;
+	}
 
  	overlay->flip_tail = tail;
  	ret = i915_wait_request(overlay->last_flip_req);
@@ -239,6 +239,7 @@ static int intel_overlay_on(struct intel_overlay *overlay)
  	struct drm_device *dev = overlay->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req;
  	int ret;
 
  	BUG_ON(overlay->active);
@@ -246,17 +247,23 @@ static int intel_overlay_on(struct intel_overlay *overlay)
 
  	WARN_ON(IS_I830(dev) && !(dev_priv->quirks & QUIRK_PIPEA_FORCE));
 
-	ret = intel_ring_begin(ring, 4);
+	ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
  	if (ret)
  		return ret;
 
+	ret = intel_ring_begin(ring, 4);
+	if (ret) {
+		i915_gem_request_unreference(req);
+		return ret;
+	}
+
  	intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_ON);
  	intel_ring_emit(ring, overlay->flip_addr | OFC_UPDATE);
  	intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
  	intel_ring_emit(ring, MI_NOOP);
  	intel_ring_advance(ring);
 
-	return intel_overlay_do_wait_request(overlay, NULL);
+	return intel_overlay_do_wait_request(overlay, req, NULL);
  }
 
  /* overlay needs to be enabled in OCMD reg */
@@ -266,6 +273,7 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
  	struct drm_device *dev = overlay->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req;
  	u32 flip_addr = overlay->flip_addr;
  	u32 tmp;
  	int ret;
@@ -280,18 +288,27 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
  	if (tmp & (1 << 17))
  		DRM_DEBUG("overlay underrun, DOVSTA: %x\n", tmp);
 
-	ret = intel_ring_begin(ring, 2);
+	ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
  	if (ret)
  		return ret;
 
+	ret = intel_ring_begin(ring, 2);
+	if (ret) {
+		i915_gem_request_unreference(req);
+		return ret;
+	}
+
  	intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
  	intel_ring_emit(ring, flip_addr);
  	intel_ring_advance(ring);
 
  	WARN_ON(overlay->last_flip_req);
-	i915_gem_request_assign(&overlay->last_flip_req,
-					     ring->outstanding_lazy_request);
-	return i915_add_request(ring);
+	i915_gem_request_assign(&overlay->last_flip_req, req);
+	ret = i915_add_request(req->ring);
+	if (ret)
+		i915_gem_request_unreference(req);
+
+	return ret;
  }
 
  static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay)
@@ -326,6 +343,7 @@ static int intel_overlay_off(struct intel_overlay *overlay)
  	struct drm_device *dev = overlay->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req;
  	u32 flip_addr = overlay->flip_addr;
  	int ret;
 
@@ -337,10 +355,16 @@ static int intel_overlay_off(struct intel_overlay *overlay)
  	 * of the hw. Do it in both cases */
  	flip_addr |= OFC_UPDATE;
 
-	ret = intel_ring_begin(ring, 6);
+	ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
  	if (ret)
  		return ret;
 
+	ret = intel_ring_begin(ring, 6);
+	if (ret) {
+		i915_gem_request_unreference(req);
+		return ret;
+	}
+
  	/* wait for overlay to go idle */
  	intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
  	intel_ring_emit(ring, flip_addr);
@@ -359,7 +383,7 @@ static int intel_overlay_off(struct intel_overlay *overlay)
  	}
  	intel_ring_advance(ring);
 
-	return intel_overlay_do_wait_request(overlay, intel_overlay_off_tail);
+	return intel_overlay_do_wait_request(overlay, req, intel_overlay_off_tail);
  }
 
  /* recover from an interruption due to a signal
@@ -404,15 +428,23 @@ static int intel_overlay_release_old_vid(struct intel_overlay *overlay)
 
  	if (I915_READ(ISR) & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT) {
  		/* synchronous slowpath */
-		ret = intel_ring_begin(ring, 2);
+		struct drm_i915_gem_request *req;
+
+		ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req)
  		if (ret)
  			return ret;
 
+		ret = intel_ring_begin(ring, 2);
+		if (ret) {
+			i915_gem_request_unreference(req);
+			return ret;
+		}

drivers/gpu/drm/i915/intel_overlay.c static int intel_overlay_release_old_vid(struct intel_overlay *overlay) · line 450

Quoted 10 lines
drivers/gpu/drm/i915/intel_overlay.c +2 -1
+
  		intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
  		intel_ring_emit(ring, MI_NOOP);
  		intel_ring_advance(ring);
 
-		ret = intel_overlay_do_wait_request(overlay,
+		ret = intel_overlay_do_wait_request(overlay, req,
  						    intel_overlay_release_old_vid_tail);
  		if (ret)
  			return ret;

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#171 lore raw

PATCH 28/53 drm/i915: Update queue_flip() to do explicit request management

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the display page flip code to do explicit request creation and submission rather than relying on the OLR and just hoping that the request actually gets submitted at some random point.

The sequence is now to create a request, queue the work to the ring, assign the known request to the flip queue work item then actually submit the work and post the request.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 +-
 drivers/gpu/drm/i915/intel_display.c    |   43 ++++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_ringbuffer.c |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.h |    1 -
 4 files changed, 30 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index e9cc343..34fd338 100644
@@ -560,7 +560,7 @@ struct drm_i915_display_funcs {
 	int (*queue_flip)(struct drm_device *dev, struct drm_crtc *crtc,
 			  struct drm_framebuffer *fb,
 			  struct drm_i915_gem_object *obj,
-			  struct intel_engine_cs *ring,
+			  struct drm_i915_gem_request *req,
 			  uint32_t flags);
 	void (*update_primary_plane)(struct drm_crtc *crtc,
 				     struct drm_framebuffer *fb,
drivers/gpu/drm/i915/intel_display.c +28 -15

140 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index efb1729..18d12a5 100644
@@ -81,7 +81,7 @@ bool intel_ring_stopped(struct intel_engine_cs *ring)
 	return dev_priv->gpu_error.stop_rings & intel_ring_flag(ring);
 }
 
-void __intel_ring_advance(struct intel_engine_cs *ring)
+static void __intel_ring_advance(struct intel_engine_cs *ring)
 {
 	struct intel_ringbuffer *ringbuf = ring->buffer;
 	ringbuf->tail &= ringbuf->size - 1;
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -1
index c32f5a1..25d5ede 100644
@@ -410,7 +410,6 @@ int __intel_ring_space(int head, int tail, int size);
 void intel_ring_update_space(struct intel_ringbuffer *ringbuf);
 int intel_ring_space(struct intel_ringbuffer *ringbuf);
 bool intel_ring_stopped(struct intel_engine_cs *ring);
-void __intel_ring_advance(struct intel_engine_cs *ring);
 
 int __must_check intel_ring_idle(struct intel_engine_cs *ring);
 void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#172 lore raw

Re: [PATCH 28/53] drm/i915: Update queue_flip() to do explicit request management

Quoted 209 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the display page flip code to do explicit request creation and submission rather than relying on the OLR and just hoping that the request actually gets submitted at some random point.

The sequence is now to create a request, queue the work to the ring, assign the known request to the flip queue work item then actually submit the work and post the request.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    2 +-
  drivers/gpu/drm/i915/intel_display.c    |   43 ++++++++++++++++++++-----------
  drivers/gpu/drm/i915/intel_ringbuffer.c |    2 +-
  drivers/gpu/drm/i915/intel_ringbuffer.h |    1 -
  4 files changed, 30 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index e9cc343..34fd338 100644
@@ -560,7 +560,7 @@ struct drm_i915_display_funcs {
  	int (*queue_flip)(struct drm_device *dev, struct drm_crtc *crtc,
  			  struct drm_framebuffer *fb,
  			  struct drm_i915_gem_object *obj,
-			  struct intel_engine_cs *ring,
+			  struct drm_i915_gem_request *req,
  			  uint32_t flags);
  	void (*update_primary_plane)(struct drm_crtc *crtc,
  				     struct drm_framebuffer *fb,
drivers/gpu/drm/i915/intel_display.c +28 -15
index 3b0fe9f..c32bc0c 100644
@@ -9251,9 +9251,10 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
  				 struct drm_crtc *crtc,
  				 struct drm_framebuffer *fb,
  				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
  				 uint32_t flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  	u32 flip_mask;
  	int ret;
@@ -9278,7 +9279,6 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
  	intel_ring_emit(ring, 0); /* aux display base address, unused */
 
  	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
  	return 0;
  }
 
@@ -9286,9 +9286,10 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
  				 struct drm_crtc *crtc,
  				 struct drm_framebuffer *fb,
  				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
  				 uint32_t flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  	u32 flip_mask;
  	int ret;
@@ -9310,7 +9311,6 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
  	intel_ring_emit(ring, MI_NOOP);
 
  	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
  	return 0;
  }
 
@@ -9318,9 +9318,10 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
  				 struct drm_crtc *crtc,
  				 struct drm_framebuffer *fb,
  				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
  				 uint32_t flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  	uint32_t pf, pipesrc;
@@ -9349,7 +9350,6 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
  	intel_ring_emit(ring, pf | pipesrc);
 
  	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
  	return 0;
  }
 
@@ -9357,9 +9357,10 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
  				 struct drm_crtc *crtc,
  				 struct drm_framebuffer *fb,
  				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
  				 uint32_t flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  	uint32_t pf, pipesrc;
@@ -9385,7 +9386,6 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
  	intel_ring_emit(ring, pf | pipesrc);
 
  	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
  	return 0;
  }
 
@@ -9393,9 +9393,10 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
  				 struct drm_crtc *crtc,
  				 struct drm_framebuffer *fb,
  				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
  				 uint32_t flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
  	uint32_t plane_bit = 0;
  	int len, ret;
@@ -9480,7 +9481,6 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
  	intel_ring_emit(ring, (MI_NOOP));
 
  	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
  	return 0;
  }
 
@@ -9636,7 +9636,7 @@ static int intel_default_queue_flip(struct drm_device *dev,
  				    struct drm_crtc *crtc,
  				    struct drm_framebuffer *fb,
  				    struct drm_i915_gem_object *obj,
-				    struct intel_engine_cs *ring,
+				    struct drm_i915_gem_request *req,
  				    uint32_t flags)
  {
  	return -ENODEV;
@@ -9715,6 +9715,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
  	enum pipe pipe = intel_crtc->pipe;
  	struct intel_unpin_work *work;
  	struct intel_engine_cs *ring;
+	struct drm_i915_gem_request *request;
  	int ret;
 
  	/*
@@ -9828,13 +9829,20 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
  		i915_gem_request_assign(&work->flip_queued_req,
  					obj->last_write_req);
  	} else {
-		ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, ring,
-						   page_flip_flags);
+		ret = dev_priv->gt.alloc_request(ring, ring->default_context, &request);
  		if (ret)
  			goto cleanup_unpin;
 
-		i915_gem_request_assign(&work->flip_queued_req,
-					intel_ring_get_request(ring));
+		ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, request,
+						   page_flip_flags);
+		if (ret)
+			goto cleanup_request;
+
+		i915_gem_request_assign(&work->flip_queued_req, request);
+
+		ret = i915_add_request_no_flush(request->ring);
+		if (ret)
+			goto cleanup_request_assign;
  	}
 
  	work->flip_queued_vblank = drm_vblank_count(dev, intel_crtc->pipe);
@@ -9851,6 +9859,11 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
  	return 0;
 
+cleanup_request_assign:
+	i915_gem_request_assign(&work->flip_queued_req, NULL);
+cleanup_request:
+	i915_gem_request_unreference(request);
+
  cleanup_unpin:
  	intel_unpin_fb_obj(obj);
  cleanup_pending:
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index efb1729..18d12a5 100644
@@ -81,7 +81,7 @@ bool intel_ring_stopped(struct intel_engine_cs *ring)
  	return dev_priv->gpu_error.stop_rings & intel_ring_flag(ring);
  }
 
-void __intel_ring_advance(struct intel_engine_cs *ring)
+static void __intel_ring_advance(struct intel_engine_cs *ring)
  {
  	struct intel_ringbuffer *ringbuf = ring->buffer;
  	ringbuf->tail &= ringbuf->size - 1;
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index c32f5a1..25d5ede 100644

drivers/gpu/drm/i915/intel_ringbuffer.h int __intel_ring_space(int head, int tail, int size); · line 415

Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -1
@@ -410,7 +410,6 @@ int __intel_ring_space(int head, int tail, int size);
  void intel_ring_update_space(struct intel_ringbuffer *ringbuf);
  int intel_ring_space(struct intel_ringbuffer *ringbuf);
  bool intel_ring_stopped(struct intel_engine_cs *ring);
-void __intel_ring_advance(struct intel_engine_cs *ring);
 
  int __must_check intel_ring_idle(struct intel_engine_cs *ring);
  void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);

Could you perhaps make a small note in the commit message to clarify why you remove __intel_ring_advance everywhere? After discussing it with you I understood that it's because we already do the corresponding operation in i915_add_request_no_flush that is added to intel_crtc_page_flip but since these pieces of code are so far from each other it's not entirely obvious from the start that they have something to do with each other.

Or am I the only one who thinks this is not trivial?

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#173 lore raw

Re: [PATCH 28/53] drm/i915: Update queue_flip() to do explicit request management

Quoted 225 lines · Tomas Elf
Quoted 209 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the display page flip code to do explicit request creation and submission rather than relying on the OLR and just hoping that the request actually gets submitted at some random point.

The sequence is now to create a request, queue the work to the ring, assign the known request to the flip queue work item then actually submit the work and post the request.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 +-
 drivers/gpu/drm/i915/intel_display.c    |   43 ++++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_ringbuffer.c |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.h |    1 -
 4 files changed, 30 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index e9cc343..34fd338 100644
@@ -560,7 +560,7 @@ struct drm_i915_display_funcs {
 	int (*queue_flip)(struct drm_device *dev, struct drm_crtc *crtc,
 			  struct drm_framebuffer *fb,
 			  struct drm_i915_gem_object *obj,
-			  struct intel_engine_cs *ring,
+			  struct drm_i915_gem_request *req,
 			  uint32_t flags);
 	void (*update_primary_plane)(struct drm_crtc *crtc,
 				     struct drm_framebuffer *fb,
drivers/gpu/drm/i915/intel_display.c +28 -15
index 3b0fe9f..c32bc0c 100644
@@ -9251,9 +9251,10 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
 				 struct drm_framebuffer *fb,
 				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
 				 uint32_t flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	u32 flip_mask;
 	int ret;
@@ -9278,7 +9279,6 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, 0); /* aux display base address, unused */
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
 	return 0;
 }
 
@@ -9286,9 +9286,10 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
 				 struct drm_framebuffer *fb,
 				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
 				 uint32_t flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	u32 flip_mask;
 	int ret;
@@ -9310,7 +9311,6 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, MI_NOOP);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
 	return 0;
 }
 
@@ -9318,9 +9318,10 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
 				 struct drm_framebuffer *fb,
 				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
 				 uint32_t flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	uint32_t pf, pipesrc;
@@ -9349,7 +9350,6 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, pf | pipesrc);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
 	return 0;
 }
 
@@ -9357,9 +9357,10 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
 				 struct drm_framebuffer *fb,
 				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
 				 uint32_t flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	uint32_t pf, pipesrc;
@@ -9385,7 +9386,6 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, pf | pipesrc);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
 	return 0;
 }
 
@@ -9393,9 +9393,10 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
 				 struct drm_framebuffer *fb,
 				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
+				 struct drm_i915_gem_request *req,
 				 uint32_t flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	uint32_t plane_bit = 0;
 	int len, ret;
@@ -9480,7 +9481,6 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, (MI_NOOP));
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
 	return 0;
 }
 
@@ -9636,7 +9636,7 @@ static int intel_default_queue_flip(struct drm_device *dev,
 				    struct drm_crtc *crtc,
 				    struct drm_framebuffer *fb,
 				    struct drm_i915_gem_object *obj,
-				    struct intel_engine_cs *ring,
+				    struct drm_i915_gem_request *req,
 				    uint32_t flags)
 {
 	return -ENODEV;
@@ -9715,6 +9715,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 	enum pipe pipe = intel_crtc->pipe;
 	struct intel_unpin_work *work;
 	struct intel_engine_cs *ring;
+	struct drm_i915_gem_request *request;
 	int ret;
 
 	/*
@@ -9828,13 +9829,20 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 		i915_gem_request_assign(&work->flip_queued_req,
 					obj->last_write_req);
 	} else {
-		ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, ring,
-						   page_flip_flags);
+		ret = dev_priv->gt.alloc_request(ring, ring->default_context, &request);
 		if (ret)
 			goto cleanup_unpin;
 
-		i915_gem_request_assign(&work->flip_queued_req,
-					intel_ring_get_request(ring));
+		ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, request,
+						   page_flip_flags);
+		if (ret)
+			goto cleanup_request;
+
+		i915_gem_request_assign(&work->flip_queued_req, request);
+
+		ret = i915_add_request_no_flush(request->ring);
+		if (ret)
+			goto cleanup_request_assign;
 	}
 
 	work->flip_queued_vblank = drm_vblank_count(dev, intel_crtc->pipe);
@@ -9851,6 +9859,11 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
 	return 0;
 
+cleanup_request_assign:
+	i915_gem_request_assign(&work->flip_queued_req, NULL);
+cleanup_request:
+	i915_gem_request_unreference(request);
+
 cleanup_unpin:
 	intel_unpin_fb_obj(obj);
 cleanup_pending:
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index efb1729..18d12a5 100644
@@ -81,7 +81,7 @@ bool intel_ring_stopped(struct intel_engine_cs *ring)
 	return dev_priv->gpu_error.stop_rings & intel_ring_flag(ring);
 }
 
-void __intel_ring_advance(struct intel_engine_cs *ring)
+static void __intel_ring_advance(struct intel_engine_cs *ring)
 {
 	struct intel_ringbuffer *ringbuf = ring->buffer;
 	ringbuf->tail &= ringbuf->size - 1;
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index c32f5a1..25d5ede 100644

drivers/gpu/drm/i915/intel_ringbuffer.h int __intel_ring_space(int head, int tail, int size); · line 415

Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -1
@@ -410,7 +410,6 @@ int __intel_ring_space(int head, int tail, int size);
 void intel_ring_update_space(struct intel_ringbuffer *ringbuf);
 int intel_ring_space(struct intel_ringbuffer *ringbuf);
 bool intel_ring_stopped(struct intel_engine_cs *ring);
-void __intel_ring_advance(struct intel_engine_cs *ring);
 
 int __must_check intel_ring_idle(struct intel_engine_cs *ring);
 void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);

Could you perhaps make a small note in the commit message to clarify why you remove __intel_ring_advance everywhere? After discussing it with you I understood that it's because we already do the corresponding operation in i915_add_request_no_flush that is added to intel_crtc_page_flip but since these pieces of code are so far from each other it's not entirely obvious from the start that they have something to do with each other.

Quoted 1 line

Or am I the only one who thinks this is not trivial?

I concur, the commit message should explain this.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#174 lore raw

PATCH 29/53 drm/i915: Update add_request() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Now that all callers of i915_add_request() have a request pointer to hand, it is possible to update the add request function to take a request pointer rather than pulling it out of the OLR.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |   10 +++++-----
 drivers/gpu/drm/i915/i915_gem.c            |   24 ++++++++++++------------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
 drivers/gpu/drm/i915/intel_display.c       |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
 drivers/gpu/drm/i915/intel_overlay.c       |    4 ++--
 drivers/gpu/drm/i915/intel_ringbuffer.c    |    3 ++-
 7 files changed, 24 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -5
index 34fd338..9206328 100644
@@ -2830,14 +2830,14 @@ void i915_gem_init_swizzling(struct drm_device *dev);
 void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
 int __must_check i915_gpu_idle(struct drm_device *dev);
 int __must_check i915_gem_suspend(struct drm_device *dev);
-int __i915_add_request(struct intel_engine_cs *ring,
+int __i915_add_request(struct drm_i915_gem_request *req,
 		       struct drm_file *file,
 		       struct drm_i915_gem_object *batch_obj,
 		       bool flush_caches);
-#define i915_add_request(ring) \
-	__i915_add_request(ring, NULL, NULL, true)
-#define i915_add_request_no_flush(ring) \
-	__i915_add_request(ring, NULL, NULL, false)
+#define i915_add_request(req) \
+	__i915_add_request(req, NULL, NULL, true)
+#define i915_add_request_no_flush(req) \
+	__i915_add_request(req, NULL, NULL, false)
 int __i915_wait_request(struct drm_i915_gem_request *req,
 			unsigned reset_counter,
 			bool interruptible,
drivers/gpu/drm/i915/i915_gem.c +12 -12
index 0c7e1bd..24fb7b9 100644
@@ -1162,7 +1162,7 @@ i915_gem_check_olr(struct drm_i915_gem_request *req)
 
 	ret = 0;
 	if (req == req->ring->outstanding_lazy_request)
-		ret = i915_add_request(req->ring);
+		ret = i915_add_request(req);
 
 	return ret;
 }
@@ -2407,25 +2407,25 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
 	return 0;
 }
 
-int __i915_add_request(struct intel_engine_cs *ring,
+int __i915_add_request(struct drm_i915_gem_request *request,
 		       struct drm_file *file,
 		       struct drm_i915_gem_object *obj,
 		       bool flush_caches)
 {
-	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct drm_i915_gem_request *request;
+	struct intel_engine_cs *ring;
+	struct drm_i915_private *dev_priv;
 	struct intel_ringbuffer *ringbuf;
 	u32 request_start;
 	int ret;
 
-	request = ring->outstanding_lazy_request;
 	if (WARN_ON(request == NULL))
 		return -ENOMEM;
 
-	if (i915.enable_execlists) {
-		ringbuf = request->ctx->engine[ring->id].ringbuf;
-	} else
-		ringbuf = ring->buffer;
+	ring = request->ring;
+	dev_priv = ring->dev->dev_private;
+	ringbuf = request->ringbuf;
+
+	WARN_ON(request != ring->outstanding_lazy_request);
 
 	request_start = intel_ring_get_tail(ringbuf);
 	/*
@@ -3118,7 +3118,7 @@ int i915_gpu_idle(struct drm_device *dev)
 				return ret;
 			}
 
-			ret = i915_add_request_no_flush(req->ring);
+			ret = i915_add_request_no_flush(req);
 			if (ret) {
 				i915_gem_request_unreference(req);
 				return ret;
@@ -3966,7 +3966,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 			if (ret)
 				return ret;
 
-			ret = i915_add_request_no_flush(req->ring);
+			ret = i915_add_request_no_flush(req);
 			if (ret)
 				return ret;
 		}
@@ -4884,7 +4884,7 @@ i915_gem_init_hw(struct drm_device *dev)
 			return ret;
 		}
 
-		ret = i915_add_request_no_flush(ring);
+		ret = i915_add_request_no_flush(req);
 		if (ret) {
 			DRM_ERROR("Add request ring #%d failed: %d\n", i, ret);
 			i915_gem_request_unreference(req);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 1e2fc80..15e33a9 100644
@@ -996,7 +996,7 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
 	params->ring->gpu_caches_dirty = true;
 
 	/* Add a breadcrumb for the completion of the batch buffer */
-	return __i915_add_request(params->ring, params->file,
+	return __i915_add_request(params->request, params->file,
 				  params->batch_obj, true);
 }
 
drivers/gpu/drm/i915/intel_display.c +1 -1
index c32bc0c..9cbfb93 100644
@@ -9840,7 +9840,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
 		i915_gem_request_assign(&work->flip_queued_req, request);
 
-		ret = i915_add_request_no_flush(request->ring);
+		ret = i915_add_request_no_flush(request);
 		if (ret)
 			goto cleanup_request_assign;
 	}
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index f0bb98a..3b4393c 100644
@@ -1942,7 +1942,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
 				goto error;
 			}
 
-			ret = i915_add_request_no_flush(req->ring);
+			ret = i915_add_request_no_flush(req);
 			if (ret) {
 				DRM_ERROR("ring init context: %d\n", ret);
 				i915_gem_request_unreference(req);
drivers/gpu/drm/i915/intel_overlay.c +2 -2
index dc209bf..228c9d1 100644
@@ -217,7 +217,7 @@ static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
 
 	BUG_ON(overlay->last_flip_req);
 	i915_gem_request_assign(&overlay->last_flip_req, req);
-	ret = i915_add_request(req->ring);
+	ret = i915_add_request(req);
 	if (ret) {
 		i915_gem_request_unreference(req);
 		return ret;
@@ -304,7 +304,7 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
 
 	WARN_ON(overlay->last_flip_req);
 	i915_gem_request_assign(&overlay->last_flip_req, req);
-	ret = i915_add_request(req->ring);
+	ret = i915_add_request(req);
 	if (ret)
 		i915_gem_request_unreference(req);
 
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -1
index 18d12a5..508d7d8 100644
@@ -2145,8 +2145,9 @@ int intel_ring_idle(struct intel_engine_cs *ring)
 	int ret;
 
 	/* We need to add any requests required to flush the objects and ring */
+	WARN_ON(ring->outstanding_lazy_request);
 	if (ring->outstanding_lazy_request) {
-		ret = i915_add_request(ring);
+		ret = i915_add_request(ring->outstanding_lazy_request);
 		if (ret)
 			return ret;
 	}
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 29/53
#175 lore raw

Re: [PATCH 29/53] drm/i915: Update add_request() to take a request structure

Quoted 183 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Now that all callers of i915_add_request() have a request pointer to hand, it is possible to update the add request function to take a request pointer rather than pulling it out of the OLR.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |   10 +++++-----
  drivers/gpu/drm/i915/i915_gem.c            |   24 ++++++++++++------------
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    2 +-
  drivers/gpu/drm/i915/intel_display.c       |    2 +-
  drivers/gpu/drm/i915/intel_lrc.c           |    2 +-
  drivers/gpu/drm/i915/intel_overlay.c       |    4 ++--
  drivers/gpu/drm/i915/intel_ringbuffer.c    |    3 ++-
  7 files changed, 24 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -5
index 34fd338..9206328 100644
@@ -2830,14 +2830,14 @@ void i915_gem_init_swizzling(struct drm_device *dev);
  void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
  int __must_check i915_gpu_idle(struct drm_device *dev);
  int __must_check i915_gem_suspend(struct drm_device *dev);
-int __i915_add_request(struct intel_engine_cs *ring,
+int __i915_add_request(struct drm_i915_gem_request *req,
  		       struct drm_file *file,
  		       struct drm_i915_gem_object *batch_obj,
  		       bool flush_caches);
-#define i915_add_request(ring) \
-	__i915_add_request(ring, NULL, NULL, true)
-#define i915_add_request_no_flush(ring) \
-	__i915_add_request(ring, NULL, NULL, false)
+#define i915_add_request(req) \
+	__i915_add_request(req, NULL, NULL, true)
+#define i915_add_request_no_flush(req) \
+	__i915_add_request(req, NULL, NULL, false)
  int __i915_wait_request(struct drm_i915_gem_request *req,
  			unsigned reset_counter,
  			bool interruptible,
drivers/gpu/drm/i915/i915_gem.c +12 -12
index 0c7e1bd..24fb7b9 100644
@@ -1162,7 +1162,7 @@ i915_gem_check_olr(struct drm_i915_gem_request *req)
 
  	ret = 0;
  	if (req == req->ring->outstanding_lazy_request)
-		ret = i915_add_request(req->ring);
+		ret = i915_add_request(req);
 
  	return ret;
  }
@@ -2407,25 +2407,25 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
  	return 0;
  }
 
-int __i915_add_request(struct intel_engine_cs *ring,
+int __i915_add_request(struct drm_i915_gem_request *request,
  		       struct drm_file *file,
  		       struct drm_i915_gem_object *obj,
  		       bool flush_caches)
  {
-	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct drm_i915_gem_request *request;
+	struct intel_engine_cs *ring;
+	struct drm_i915_private *dev_priv;
  	struct intel_ringbuffer *ringbuf;
  	u32 request_start;
  	int ret;
 
-	request = ring->outstanding_lazy_request;
  	if (WARN_ON(request == NULL))
  		return -ENOMEM;
 
-	if (i915.enable_execlists) {
-		ringbuf = request->ctx->engine[ring->id].ringbuf;
-	} else
-		ringbuf = ring->buffer;
+	ring = request->ring;
+	dev_priv = ring->dev->dev_private;
+	ringbuf = request->ringbuf;
+
+	WARN_ON(request != ring->outstanding_lazy_request);
 
  	request_start = intel_ring_get_tail(ringbuf);
  	/*
@@ -3118,7 +3118,7 @@ int i915_gpu_idle(struct drm_device *dev)
  				return ret;
  			}
 
-			ret = i915_add_request_no_flush(req->ring);
+			ret = i915_add_request_no_flush(req);
  			if (ret) {
  				i915_gem_request_unreference(req);
  				return ret;
@@ -3966,7 +3966,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
  			if (ret)
  				return ret;
 
-			ret = i915_add_request_no_flush(req->ring);
+			ret = i915_add_request_no_flush(req);
  			if (ret)
  				return ret;
  		}
@@ -4884,7 +4884,7 @@ i915_gem_init_hw(struct drm_device *dev)
  			return ret;
  		}
 
-		ret = i915_add_request_no_flush(ring);
+		ret = i915_add_request_no_flush(req);
  		if (ret) {
  			DRM_ERROR("Add request ring #%d failed: %d\n", i, ret);
  			i915_gem_request_unreference(req);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 1e2fc80..15e33a9 100644
@@ -996,7 +996,7 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
  	params->ring->gpu_caches_dirty = true;
 
  	/* Add a breadcrumb for the completion of the batch buffer */
-	return __i915_add_request(params->ring, params->file,
+	return __i915_add_request(params->request, params->file,
  				  params->batch_obj, true);
  }
 
drivers/gpu/drm/i915/intel_display.c +1 -1
index c32bc0c..9cbfb93 100644
@@ -9840,7 +9840,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
  		i915_gem_request_assign(&work->flip_queued_req, request);
 
-		ret = i915_add_request_no_flush(request->ring);
+		ret = i915_add_request_no_flush(request);
  		if (ret)
  			goto cleanup_request_assign;
  	}
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index f0bb98a..3b4393c 100644
@@ -1942,7 +1942,7 @@ int intel_lr_context_deferred_create(struct intel_context *ctx,
  				goto error;
  			}
 
-			ret = i915_add_request_no_flush(req->ring);
+			ret = i915_add_request_no_flush(req);
  			if (ret) {
  				DRM_ERROR("ring init context: %d\n", ret);
  				i915_gem_request_unreference(req);
drivers/gpu/drm/i915/intel_overlay.c +2 -2
index dc209bf..228c9d1 100644
@@ -217,7 +217,7 @@ static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
 
  	BUG_ON(overlay->last_flip_req);
  	i915_gem_request_assign(&overlay->last_flip_req, req);
-	ret = i915_add_request(req->ring);
+	ret = i915_add_request(req);
  	if (ret) {
  		i915_gem_request_unreference(req);
  		return ret;
@@ -304,7 +304,7 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
 
  	WARN_ON(overlay->last_flip_req);
  	i915_gem_request_assign(&overlay->last_flip_req, req);
-	ret = i915_add_request(req->ring);
+	ret = i915_add_request(req);
  	if (ret)
  		i915_gem_request_unreference(req);
 
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -0
index 18d12a5..508d7d8 100644

drivers/gpu/drm/i915/intel_ringbuffer.c int intel_ring_idle(struct intel_engine_cs *ring) · line 2153

Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -1
@@ -2145,8 +2145,9 @@ int intel_ring_idle(struct intel_engine_cs *ring)
  	int ret;
 
  	/* We need to add any requests required to flush the objects and ring */
+	WARN_ON(ring->outstanding_lazy_request);
  	if (ring->outstanding_lazy_request) {
-		ret = i915_add_request(ring);
+		ret = i915_add_request(ring->outstanding_lazy_request);
  		if (ret)
  			return ret;
  	}

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#176 lore raw

PATCH 30/53 drm/i915: Update [vma|object]_move_to_active() to take request structures

In reply to [email protected]

From: John Harrison <[email protected]>

Now that everything above has been converted to use request structures, it is possible to update the lower level move_to_active() functions to be request based as well.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h              |    2 +-
 drivers/gpu/drm/i915/i915_gem.c              |   17 ++++++++---------
 drivers/gpu/drm/i915/i915_gem_context.c      |    2 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   |    2 +-
 drivers/gpu/drm/i915/i915_gem_render_state.c |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c             |    2 +-
 6 files changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 9206328..e9fef4c 100644
@@ -2747,7 +2747,7 @@ int __must_check i915_mutex_lock_interruptible(struct drm_device *dev);
 int i915_gem_object_sync(struct drm_i915_gem_object *obj,
 			 struct drm_i915_gem_request *to_req);
 void i915_vma_move_to_active(struct i915_vma *vma,
-			     struct intel_engine_cs *ring);
+			     struct drm_i915_gem_request *req);
 int i915_gem_dumb_create(struct drm_file *file_priv,
 			 struct drm_device *dev,
 			 struct drm_mode_create_dumb *args);
drivers/gpu/drm/i915/i915_gem.c +8 -9
index 24fb7b9..0ae9be2 100644
@@ -2265,17 +2265,16 @@ i915_gem_object_get_pages(struct drm_i915_gem_object *obj)
 
 static void
 i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
-			       struct intel_engine_cs *ring)
+			       struct drm_i915_gem_request *req)
 {
-	struct drm_i915_gem_request *req;
-	struct intel_engine_cs *old_ring;
+	struct intel_engine_cs *new_ring, *old_ring;
 
-	BUG_ON(ring == NULL);
+	BUG_ON(req == NULL);
 
-	req = intel_ring_get_request(ring);
+	new_ring = i915_gem_request_get_ring(req);
 	old_ring = i915_gem_request_get_ring(obj->last_read_req);
 
-	if (old_ring != ring && obj->last_write_req) {
+	if (old_ring != new_ring && obj->last_write_req) {
 		/* Keep the request relative to the current ring */
 		i915_gem_request_assign(&obj->last_write_req, req);
 	}
@@ -2286,16 +2285,16 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
 		obj->active = 1;
 	}
 
-	list_move_tail(&obj->ring_list, &ring->active_list);
+	list_move_tail(&obj->ring_list, &new_ring->active_list);
 
 	i915_gem_request_assign(&obj->last_read_req, req);
 }
 
 void i915_vma_move_to_active(struct i915_vma *vma,
-			     struct intel_engine_cs *ring)
+			     struct drm_i915_gem_request *req)
 {
 	list_move_tail(&vma->mm_list, &vma->vm->active_list);
-	return i915_gem_object_move_to_active(vma->obj, ring);
+	return i915_gem_object_move_to_active(vma->obj, req);
 }
 
 static void
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 938cd26..e4d75be 100644
@@ -652,7 +652,7 @@ static int do_switch(struct drm_i915_gem_request *req)
 	 */
 	if (from != NULL) {
 		from->legacy_hw_ctx.rcs_state->base.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
-		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), req->ring);
+		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), req);
 		/* As long as MI_SET_CONTEXT is serializing, ie. it flushes the
 		 * whole damn pipeline, we don't need to explicitly mark the
 		 * object dirty. The only exception is that the context must be
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 15e33a9..dc13751 100644
@@ -966,7 +966,7 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
 			obj->base.pending_read_domains |= obj->base.read_domains;
 		obj->base.read_domains = obj->base.pending_read_domains;
 
-		i915_vma_move_to_active(vma, ring);
+		i915_vma_move_to_active(vma, req);
 		if (obj->base.write_domain) {
 			obj->dirty = 1;
 			i915_gem_request_assign(&obj->last_write_req, req);
drivers/gpu/drm/i915/i915_gem_render_state.c +1 -1
index 85cc746..866274c 100644
@@ -171,7 +171,7 @@ int i915_gem_render_state_init(struct drm_i915_gem_request *req)
 	if (ret)
 		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req);
 
 	WARN_ON(req->batch_obj);
 	req->batch_obj = so.obj;
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index 3b4393c..479365e 100644
@@ -1364,7 +1364,7 @@ static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req)
 	if (ret)
 		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req);
 
 	WARN_ON(req->batch_obj);
 	req->batch_obj = so.obj;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 30/53
#177 lore raw

Re: [PATCH 30/53] drm/i915: Update [vma|object]_move_to_active() to take request structures

Quoted 122 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Now that everything above has been converted to use request structures, it is possible to update the lower level move_to_active() functions to be request based as well.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h              |    2 +-
  drivers/gpu/drm/i915/i915_gem.c              |   17 ++++++++---------
  drivers/gpu/drm/i915/i915_gem_context.c      |    2 +-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c   |    2 +-
  drivers/gpu/drm/i915/i915_gem_render_state.c |    2 +-
  drivers/gpu/drm/i915/intel_lrc.c             |    2 +-
  6 files changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 9206328..e9fef4c 100644
@@ -2747,7 +2747,7 @@ int __must_check i915_mutex_lock_interruptible(struct drm_device *dev);
  int i915_gem_object_sync(struct drm_i915_gem_object *obj,
  			 struct drm_i915_gem_request *to_req);
  void i915_vma_move_to_active(struct i915_vma *vma,
-			     struct intel_engine_cs *ring);
+			     struct drm_i915_gem_request *req);
  int i915_gem_dumb_create(struct drm_file *file_priv,
  			 struct drm_device *dev,
  			 struct drm_mode_create_dumb *args);
drivers/gpu/drm/i915/i915_gem.c +8 -9
index 24fb7b9..0ae9be2 100644
@@ -2265,17 +2265,16 @@ i915_gem_object_get_pages(struct drm_i915_gem_object *obj)
 
  static void
  i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
-			       struct intel_engine_cs *ring)
+			       struct drm_i915_gem_request *req)
  {
-	struct drm_i915_gem_request *req;
-	struct intel_engine_cs *old_ring;
+	struct intel_engine_cs *new_ring, *old_ring;
 
-	BUG_ON(ring == NULL);
+	BUG_ON(req == NULL);
 
-	req = intel_ring_get_request(ring);
+	new_ring = i915_gem_request_get_ring(req);
  	old_ring = i915_gem_request_get_ring(obj->last_read_req);
 
-	if (old_ring != ring && obj->last_write_req) {
+	if (old_ring != new_ring && obj->last_write_req) {
  		/* Keep the request relative to the current ring */
  		i915_gem_request_assign(&obj->last_write_req, req);
  	}
@@ -2286,16 +2285,16 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
  		obj->active = 1;
  	}
 
-	list_move_tail(&obj->ring_list, &ring->active_list);
+	list_move_tail(&obj->ring_list, &new_ring->active_list);
 
  	i915_gem_request_assign(&obj->last_read_req, req);
  }
 
  void i915_vma_move_to_active(struct i915_vma *vma,
-			     struct intel_engine_cs *ring)
+			     struct drm_i915_gem_request *req)
  {
  	list_move_tail(&vma->mm_list, &vma->vm->active_list);
-	return i915_gem_object_move_to_active(vma->obj, ring);
+	return i915_gem_object_move_to_active(vma->obj, req);
  }
 
  static void
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 938cd26..e4d75be 100644
@@ -652,7 +652,7 @@ static int do_switch(struct drm_i915_gem_request *req)
  	 */
  	if (from != NULL) {
  		from->legacy_hw_ctx.rcs_state->base.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
-		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), req->ring);
+		i915_vma_move_to_active(i915_gem_obj_to_ggtt(from->legacy_hw_ctx.rcs_state), req);
  		/* As long as MI_SET_CONTEXT is serializing, ie. it flushes the
  		 * whole damn pipeline, we don't need to explicitly mark the
  		 * object dirty. The only exception is that the context must be
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index 15e33a9..dc13751 100644
@@ -966,7 +966,7 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
  			obj->base.pending_read_domains |= obj->base.read_domains;
  		obj->base.read_domains = obj->base.pending_read_domains;
 
-		i915_vma_move_to_active(vma, ring);
+		i915_vma_move_to_active(vma, req);
  		if (obj->base.write_domain) {
  			obj->dirty = 1;
  			i915_gem_request_assign(&obj->last_write_req, req);
drivers/gpu/drm/i915/i915_gem_render_state.c +1 -1
index 85cc746..866274c 100644
@@ -171,7 +171,7 @@ int i915_gem_render_state_init(struct drm_i915_gem_request *req)
  	if (ret)
  		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req);
 
  	WARN_ON(req->batch_obj);
  	req->batch_obj = so.obj;
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index 3b4393c..479365e 100644

drivers/gpu/drm/i915/intel_lrc.c static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req) · line 1370

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -1364,7 +1364,7 @@ static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req)
  	if (ret)
  		goto out;
 
-	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req->ring);
+	i915_vma_move_to_active(i915_gem_obj_to_ggtt(so.obj), req);
 
  	WARN_ON(req->batch_obj);
  	req->batch_obj = so.obj;

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#178 lore raw

PATCH 31/53 drm/i915: Update l3_remap to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Converted i915_gem_l3_remap() to take a request structure instead of a ring.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h         |    2 +-
 drivers/gpu/drm/i915/i915_gem.c         |    5 +++--
 drivers/gpu/drm/i915/i915_gem_context.c |    2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index e9fef4c..3955bef 100644
@@ -2825,7 +2825,7 @@ int __must_check i915_gem_object_finish_gpu(struct drm_i915_gem_object *obj);
 int __must_check i915_gem_init(struct drm_device *dev);
 int i915_gem_init_rings(struct drm_device *dev);
 int __must_check i915_gem_init_hw(struct drm_device *dev);
-int i915_gem_l3_remap(struct intel_engine_cs *ring, int slice);
+int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice);
 void i915_gem_init_swizzling(struct drm_device *dev);
 void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
 int __must_check i915_gpu_idle(struct drm_device *dev);
drivers/gpu/drm/i915/i915_gem.c +3 -2
index 0ae9be2..043933b 100644
@@ -4644,8 +4644,9 @@ err:
 	return ret;
 }
 
-int i915_gem_l3_remap(struct intel_engine_cs *ring, int slice)
+int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	u32 reg_base = GEN7_L3LOG_BASE + (slice * 0x200);
@@ -4864,7 +4865,7 @@ i915_gem_init_hw(struct drm_device *dev)
 
 		if (ring->id == RCS) {
 			for (i = 0; i < NUM_L3_SLICES(dev); i++)
-				i915_gem_l3_remap(ring, i);
+				i915_gem_l3_remap(req, i);
 		}
 
 		ret = i915_ppgtt_init_ring(req);
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index e4d75be..475d1fd 100644
@@ -636,7 +636,7 @@ static int do_switch(struct drm_i915_gem_request *req)
 		if (!(to->remap_slice & (1<<i)))
 			continue;
 
-		ret = i915_gem_l3_remap(req->ring, i);
+		ret = i915_gem_l3_remap(req, i);
 		/* If it failed, try again next round */
 		if (ret)
 			DRM_DEBUG_DRIVER("L3 remapping failed\n");
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 31/53
#179 lore raw

Re: [PATCH 31/53] drm/i915: Update l3_remap to take a request structure

Quoted 55 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Converted i915_gem_l3_remap() to take a request structure instead of a ring.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h         |    2 +-
  drivers/gpu/drm/i915/i915_gem.c         |    5 +++--
  drivers/gpu/drm/i915/i915_gem_context.c |    2 +-
  3 files changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index e9fef4c..3955bef 100644
@@ -2825,7 +2825,7 @@ int __must_check i915_gem_object_finish_gpu(struct drm_i915_gem_object *obj);
  int __must_check i915_gem_init(struct drm_device *dev);
  int i915_gem_init_rings(struct drm_device *dev);
  int __must_check i915_gem_init_hw(struct drm_device *dev);
-int i915_gem_l3_remap(struct intel_engine_cs *ring, int slice);
+int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice);
  void i915_gem_init_swizzling(struct drm_device *dev);
  void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
  int __must_check i915_gpu_idle(struct drm_device *dev);
drivers/gpu/drm/i915/i915_gem.c +3 -2
index 0ae9be2..043933b 100644
@@ -4644,8 +4644,9 @@ err:
  	return ret;
  }
 
-int i915_gem_l3_remap(struct intel_engine_cs *ring, int slice)
+int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_device *dev = ring->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	u32 reg_base = GEN7_L3LOG_BASE + (slice * 0x200);
@@ -4864,7 +4865,7 @@ i915_gem_init_hw(struct drm_device *dev)
 
  		if (ring->id == RCS) {
  			for (i = 0; i < NUM_L3_SLICES(dev); i++)
-				i915_gem_l3_remap(ring, i);
+				i915_gem_l3_remap(req, i);
  		}
 
  		ret = i915_ppgtt_init_ring(req);
drivers/gpu/drm/i915/i915_gem_context.c +0 -0
index e4d75be..475d1fd 100644

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct drm_i915_gem_request *req) · line 642

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
@@ -636,7 +636,7 @@ static int do_switch(struct drm_i915_gem_request *req)
  		if (!(to->remap_slice & (1<<i)))
  			continue;
 
-		ret = i915_gem_l3_remap(req->ring, i);
+		ret = i915_gem_l3_remap(req, i);
  		/* If it failed, try again next round */
  		if (ret)
  			DRM_DEBUG_DRIVER("L3 remapping failed\n");

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#180 lore raw

PATCH 32/53 drm/i915: Update mi_set_context() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated mi_set_context() to take a request structure instead of a ring and context pair.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_context.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +4 -5
index 475d1fd..9e66fac 100644
@@ -472,10 +472,9 @@ i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)
 }
 
 static inline int
-mi_set_context(struct intel_engine_cs *ring,
-	       struct intel_context *new_context,
-	       u32 hw_flags)
+mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 flags = hw_flags | MI_MM_SPACE_GTT;
 	const int num_rings =
 		/* Use an extended w/a on ivb+ if signalling from other rings */
@@ -527,7 +526,7 @@ mi_set_context(struct intel_engine_cs *ring,
 
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_emit(ring, MI_SET_CONTEXT);
-	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(new_context->legacy_hw_ctx.rcs_state) |
+	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(req->ctx->legacy_hw_ctx.rcs_state) |
 			flags);
 	/*
 	 * w/a: MI_SET_CONTEXT must always be followed by MI_NOOP
@@ -628,7 +627,7 @@ static int do_switch(struct drm_i915_gem_request *req)
 	if (!to->legacy_hw_ctx.initialized || i915_gem_context_is_default(to))
 		hw_flags |= MI_RESTORE_INHIBIT;
 
-	ret = mi_set_context(req->ring, to, hw_flags);
+	ret = mi_set_context(req, hw_flags);
 	if (ret)
 		goto unpin_out;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 32/53
#181 lore raw

Re: [PATCH 32/53] drm/i915: Update mi_set_context() to take a request structure

Quoted 39 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated mi_set_context() to take a request structure instead of a ring and context pair.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_context.c |    9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +3 -4
index 475d1fd..9e66fac 100644
@@ -472,10 +472,9 @@ i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)
  }
 
  static inline int
-mi_set_context(struct intel_engine_cs *ring,
-	       struct intel_context *new_context,
-	       u32 hw_flags)
+mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 flags = hw_flags | MI_MM_SPACE_GTT;
  	const int num_rings =
  		/* Use an extended w/a on ivb+ if signalling from other rings */
@@ -527,7 +526,7 @@ mi_set_context(struct intel_engine_cs *ring,
 
  	intel_ring_emit(ring, MI_NOOP);
  	intel_ring_emit(ring, MI_SET_CONTEXT);
-	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(new_context->legacy_hw_ctx.rcs_state) |
+	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(req->ctx->legacy_hw_ctx.rcs_state) |
  			flags);
  	/*
  	 * w/a: MI_SET_CONTEXT must always be followed by MI_NOOP

drivers/gpu/drm/i915/i915_gem_context.c static int do_switch(struct drm_i915_gem_request *req) · line 633

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
@@ -628,7 +627,7 @@ static int do_switch(struct drm_i915_gem_request *req)
  	if (!to->legacy_hw_ctx.initialized || i915_gem_context_is_default(to))
  		hw_flags |= MI_RESTORE_INHIBIT;
 
-	ret = mi_set_context(req->ring, to, hw_flags);
+	ret = mi_set_context(req, hw_flags);
  	if (ret)
  		goto unpin_out;
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#182 lore raw

PATCH 33/53 drm/i915: Update a bunch of execbuffer heplers to take request structures

In reply to [email protected]

From: John Harrison <[email protected]>

Updated *_ring_invalidate_all_caches(), i915_reset_gen7_sol_offsets() and i915_emit_box() to take request structures instead of ring or ringbuf/context pairs.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   12 +++++++-----
 drivers/gpu/drm/i915/intel_lrc.c           |    9 ++++-----
 drivers/gpu/drm/i915/intel_ringbuffer.c    |    3 ++-
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    2 +-
 4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -5
index dc13751..a79c893 100644
@@ -857,7 +857,7 @@ i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req,
 	/* Unconditionally invalidate gpu caches and ensure that we do flush
 	 * any residual writes from the previous batch.
 	 */
-	return intel_ring_invalidate_all_caches(req->ring);
+	return intel_ring_invalidate_all_caches(req);
 }
 
 static bool
@@ -1002,8 +1002,9 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
 
 static int
 i915_reset_gen7_sol_offsets(struct drm_device *dev,
-			    struct intel_engine_cs *ring)
+			    struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret, i;
 
@@ -1028,10 +1029,11 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
 }
 
 static int
-i915_emit_box(struct intel_engine_cs *ring,
+i915_emit_box(struct drm_i915_gem_request *req,
 	      struct drm_clip_rect *box,
 	      int DR1, int DR4)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	if (box->y2 <= box->y1 || box->x2 <= box->x1 ||
@@ -1247,7 +1249,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 	}
 
 	if (args->flags & I915_EXEC_GEN7_SOL_RESET) {
-		ret = i915_reset_gen7_sol_offsets(params->dev, ring);
+		ret = i915_reset_gen7_sol_offsets(params->dev, params->request);
 		if (ret)
 			goto error;
 	}
@@ -1258,7 +1260,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 
 	if (cliprects) {
 		for (i = 0; i < args->num_cliprects; i++) {
-			ret = i915_emit_box(ring, &cliprects[i],
+			ret = i915_emit_box(params->request, &cliprects[i],
 					    args->DR1, args->DR4);
 			if (ret)
 				goto error;
drivers/gpu/drm/i915/intel_lrc.c +4 -5
index 479365e..fab9269 100644
@@ -558,10 +558,9 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
 	return 0;
 }
 
-static int logical_ring_invalidate_all_caches(struct intel_ringbuffer *ringbuf,
-					      struct intel_context *ctx)
+static int logical_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
 {
-	struct intel_engine_cs *ring = ringbuf->ring;
+	struct intel_engine_cs *ring = req->ring;
 	uint32_t flush_domains;
 	int ret;
 
@@ -569,7 +568,7 @@ static int logical_ring_invalidate_all_caches(struct intel_ringbuffer *ringbuf,
 	if (ring->gpu_caches_dirty)
 		flush_domains = I915_GEM_GPU_DOMAINS;
 
-	ret = ring->emit_flush(ringbuf, ctx,
+	ret = ring->emit_flush(req->ringbuf, req->ctx,
 			       I915_GEM_GPU_DOMAINS, flush_domains);
 	if (ret)
 		return ret;
@@ -605,7 +604,7 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req,
 	/* Unconditionally invalidate gpu caches and ensure that we do flush
 	 * any residual writes from the previous batch.
 	 */
-	return logical_ring_invalidate_all_caches(req->ringbuf, req->ctx);
+	return logical_ring_invalidate_all_caches(req);
 }
 
 /**
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -1
index 508d7d8..efa44db 100644
@@ -2864,8 +2864,9 @@ intel_ring_flush_all_caches(struct intel_engine_cs *ring)
 }
 
 int
-intel_ring_invalidate_all_caches(struct intel_engine_cs *ring)
+intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	uint32_t flush_domains;
 	int ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index 25d5ede..b817725 100644
@@ -414,7 +414,7 @@ bool intel_ring_stopped(struct intel_engine_cs *ring);
 int __must_check intel_ring_idle(struct intel_engine_cs *ring);
 void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);
 int intel_ring_flush_all_caches(struct intel_engine_cs *ring);
-int intel_ring_invalidate_all_caches(struct intel_engine_cs *ring);
+int intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req);
 
 void intel_fini_pipe_control(struct intel_engine_cs *ring);
 int intel_init_pipe_control(struct intel_engine_cs *ring);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 33/53
#183 lore raw

Re: [PATCH 33/53] drm/i915: Update a bunch of execbuffer heplers to take request structures

Quoted 126 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated *_ring_invalidate_all_caches(), i915_reset_gen7_sol_offsets() and i915_emit_box() to take request structures instead of ring or ringbuf/context pairs.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   12 +++++++-----
  drivers/gpu/drm/i915/intel_lrc.c           |    9 ++++-----
  drivers/gpu/drm/i915/intel_ringbuffer.c    |    3 ++-
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    2 +-
  4 files changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -5
index dc13751..a79c893 100644
@@ -857,7 +857,7 @@ i915_gem_execbuffer_move_to_gpu(struct drm_i915_gem_request *req,
  	/* Unconditionally invalidate gpu caches and ensure that we do flush
  	 * any residual writes from the previous batch.
  	 */
-	return intel_ring_invalidate_all_caches(req->ring);
+	return intel_ring_invalidate_all_caches(req);
  }
 
  static bool
@@ -1002,8 +1002,9 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
 
  static int
  i915_reset_gen7_sol_offsets(struct drm_device *dev,
-			    struct intel_engine_cs *ring)
+			    struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	int ret, i;
 
@@ -1028,10 +1029,11 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
  }
 
  static int
-i915_emit_box(struct intel_engine_cs *ring,
+i915_emit_box(struct drm_i915_gem_request *req,
  	      struct drm_clip_rect *box,
  	      int DR1, int DR4)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	if (box->y2 <= box->y1 || box->x2 <= box->x1 ||
@@ -1247,7 +1249,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  	}
 
  	if (args->flags & I915_EXEC_GEN7_SOL_RESET) {
-		ret = i915_reset_gen7_sol_offsets(params->dev, ring);
+		ret = i915_reset_gen7_sol_offsets(params->dev, params->request);
  		if (ret)
  			goto error;
  	}
@@ -1258,7 +1260,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 
  	if (cliprects) {
  		for (i = 0; i < args->num_cliprects; i++) {
-			ret = i915_emit_box(ring, &cliprects[i],
+			ret = i915_emit_box(params->request, &cliprects[i],
  					    args->DR1, args->DR4);
  			if (ret)
  				goto error;
drivers/gpu/drm/i915/intel_lrc.c +4 -5
index 479365e..fab9269 100644
@@ -558,10 +558,9 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
  	return 0;
  }
 
-static int logical_ring_invalidate_all_caches(struct intel_ringbuffer *ringbuf,
-					      struct intel_context *ctx)
+static int logical_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
  {
-	struct intel_engine_cs *ring = ringbuf->ring;
+	struct intel_engine_cs *ring = req->ring;
  	uint32_t flush_domains;
  	int ret;
 
@@ -569,7 +568,7 @@ static int logical_ring_invalidate_all_caches(struct intel_ringbuffer *ringbuf,
  	if (ring->gpu_caches_dirty)
  		flush_domains = I915_GEM_GPU_DOMAINS;
 
-	ret = ring->emit_flush(ringbuf, ctx,
+	ret = ring->emit_flush(req->ringbuf, req->ctx,
  			       I915_GEM_GPU_DOMAINS, flush_domains);
  	if (ret)
  		return ret;
@@ -605,7 +604,7 @@ static int execlists_move_to_gpu(struct drm_i915_gem_request *req,
  	/* Unconditionally invalidate gpu caches and ensure that we do flush
  	 * any residual writes from the previous batch.
  	 */
-	return logical_ring_invalidate_all_caches(req->ringbuf, req->ctx);
+	return logical_ring_invalidate_all_caches(req);
  }
 
  /**
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -1
index 508d7d8..efa44db 100644
@@ -2864,8 +2864,9 @@ intel_ring_flush_all_caches(struct intel_engine_cs *ring)
  }
 
  int
-intel_ring_invalidate_all_caches(struct intel_engine_cs *ring)
+intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	uint32_t flush_domains;
  	int ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 25d5ede..b817725 100644

drivers/gpu/drm/i915/intel_ringbuffer.h bool intel_ring_stopped(struct intel_engine_cs *ring); · line 420

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -414,7 +414,7 @@ bool intel_ring_stopped(struct intel_engine_cs *ring);
  int __must_check intel_ring_idle(struct intel_engine_cs *ring);
  void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);
  int intel_ring_flush_all_caches(struct intel_engine_cs *ring);
-int intel_ring_invalidate_all_caches(struct intel_engine_cs *ring);
+int intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req);
 
  void intel_fini_pipe_control(struct intel_engine_cs *ring);
  int intel_init_pipe_control(struct intel_engine_cs *ring);

Nitpick: "Update a bunch of execbuffer >>> heplers <<< "

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#184 lore raw

PATCH 34/53 drm/i915: Update workarounds_emit() to take request structures

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the *_ring_workarounds_emit() functions to take requests instead of ring/context pairs.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c        |   14 +++++++-------
 drivers/gpu/drm/i915/intel_ringbuffer.c |    6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +7 -7
index fab9269..08ed800 100644
@@ -1076,11 +1076,11 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
 	return 0;
 }
 
-static int intel_logical_ring_workarounds_emit(struct intel_engine_cs *ring,
-					       struct intel_context *ctx)
+static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
 {
 	int ret, i;
-	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
+	struct intel_engine_cs *ring = req->ring;
+	struct intel_ringbuffer *ringbuf = req->ringbuf;
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_workarounds *w = &dev_priv->workarounds;
@@ -1089,11 +1089,11 @@ static int intel_logical_ring_workarounds_emit(struct intel_engine_cs *ring,
 		return 0;
 
 	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, ctx);
+	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
 	if (ret)
 		return ret;
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, w->count * 2 + 2);
+	ret = intel_logical_ring_begin(ringbuf, req->ctx, w->count * 2 + 2);
 	if (ret)
 		return ret;
 
@@ -1107,7 +1107,7 @@ static int intel_logical_ring_workarounds_emit(struct intel_engine_cs *ring,
 	intel_logical_ring_advance(ringbuf);
 
 	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, ctx);
+	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
 	if (ret)
 		return ret;
 
@@ -1377,7 +1377,7 @@ static int gen8_init_rcs_context(struct drm_i915_gem_request *req)
 {
 	int ret;
 
-	ret = intel_logical_ring_workarounds_emit(req->ring, req->ctx);
+	ret = intel_logical_ring_workarounds_emit(req);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
index efa44db..d147ffa 100644
@@ -736,10 +736,10 @@ err:
 	return ret;
 }
 
-static int intel_ring_workarounds_emit(struct intel_engine_cs *ring,
-				       struct intel_context *ctx)
+static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)
 {
 	int ret, i;
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_workarounds *w = &dev_priv->workarounds;
@@ -779,7 +779,7 @@ static int intel_rcs_ctx_init(struct drm_i915_gem_request *req)
 {
 	int ret;
 
-	ret = intel_ring_workarounds_emit(req->ring, req->ctx);
+	ret = intel_ring_workarounds_emit(req);
 	if (ret != 0)
 		return ret;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 34/53
#185 lore raw

Re: [PATCH 34/53] drm/i915: Update workarounds_emit() to take request structures

Quoted 82 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the *_ring_workarounds_emit() functions to take requests instead of ring/context pairs.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_lrc.c        |   14 +++++++-------
  drivers/gpu/drm/i915/intel_ringbuffer.c |    6 +++---
  2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +7 -7
index fab9269..08ed800 100644
@@ -1076,11 +1076,11 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
  	return 0;
  }
 
-static int intel_logical_ring_workarounds_emit(struct intel_engine_cs *ring,
-					       struct intel_context *ctx)
+static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
  {
  	int ret, i;
-	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
+	struct intel_engine_cs *ring = req->ring;
+	struct intel_ringbuffer *ringbuf = req->ringbuf;
  	struct drm_device *dev = ring->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct i915_workarounds *w = &dev_priv->workarounds;
@@ -1089,11 +1089,11 @@ static int intel_logical_ring_workarounds_emit(struct intel_engine_cs *ring,
  		return 0;
 
  	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, ctx);
+	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
  	if (ret)
  		return ret;
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, w->count * 2 + 2);
+	ret = intel_logical_ring_begin(ringbuf, req->ctx, w->count * 2 + 2);
  	if (ret)
  		return ret;
 
@@ -1107,7 +1107,7 @@ static int intel_logical_ring_workarounds_emit(struct intel_engine_cs *ring,
  	intel_logical_ring_advance(ringbuf);
 
  	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, ctx);
+	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
  	if (ret)
  		return ret;
 
@@ -1377,7 +1377,7 @@ static int gen8_init_rcs_context(struct drm_i915_gem_request *req)
  {
  	int ret;
 
-	ret = intel_logical_ring_workarounds_emit(req->ring, req->ctx);
+	ret = intel_logical_ring_workarounds_emit(req);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -2
index efa44db..d147ffa 100644
@@ -736,10 +736,10 @@ err:
  	return ret;
  }
 
-static int intel_ring_workarounds_emit(struct intel_engine_cs *ring,
-				       struct intel_context *ctx)
+static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)
  {
  	int ret, i;
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_device *dev = ring->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct i915_workarounds *w = &dev_priv->workarounds;

drivers/gpu/drm/i915/intel_ringbuffer.c static int intel_rcs_ctx_init(struct drm_i915_gem_request *req) · line 785

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
@@ -779,7 +779,7 @@ static int intel_rcs_ctx_init(struct drm_i915_gem_request *req)
  {
  	int ret;
 
-	ret = intel_ring_workarounds_emit(req->ring, req->ctx);
+	ret = intel_ring_workarounds_emit(req);
  	if (ret != 0)
  		return ret;
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#186 lore raw

PATCH 35/53 drm/i915: Update flush_all_caches() to take request structures

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the *_ring_flush_all_caches() functions to take requests instead of rings or ringbuf/context pairs.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c         |    4 ++--
 drivers/gpu/drm/i915/intel_lrc.c        |   11 +++++------
 drivers/gpu/drm/i915/intel_lrc.h        |    3 +--
 drivers/gpu/drm/i915/intel_ringbuffer.c |    7 ++++---
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
 5 files changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -2
index 043933b..e8577d7 100644
@@ -2436,9 +2436,9 @@ int __i915_add_request(struct drm_i915_gem_request *request,
 	 */
 	if (flush_caches) {
 		if (i915.enable_execlists)
-			ret = logical_ring_flush_all_caches(ringbuf, request->ctx);
+			ret = logical_ring_flush_all_caches(request);
 		else
-			ret = intel_ring_flush_all_caches(ring);
+			ret = intel_ring_flush_all_caches(request);
 		if (ret)
 			return ret;
 	}
drivers/gpu/drm/i915/intel_lrc.c +5 -6
index 08ed800..d8084a1 100644
@@ -768,16 +768,15 @@ void intel_logical_ring_stop(struct intel_engine_cs *ring)
 	I915_WRITE_MODE(ring, _MASKED_BIT_DISABLE(STOP_RING));
 }
 
-int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf,
-				  struct intel_context *ctx)
+int logical_ring_flush_all_caches(struct drm_i915_gem_request *req)
 {
-	struct intel_engine_cs *ring = ringbuf->ring;
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	if (!ring->gpu_caches_dirty)
 		return 0;
 
-	ret = ring->emit_flush(ringbuf, ctx, 0, I915_GEM_GPU_DOMAINS);
+	ret = ring->emit_flush(req->ringbuf, req->ctx, 0, I915_GEM_GPU_DOMAINS);
 	if (ret)
 		return ret;
 
@@ -1089,7 +1088,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
 		return 0;
 
 	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
+	ret = logical_ring_flush_all_caches(req);
 	if (ret)
 		return ret;
 
@@ -1107,7 +1106,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
 	intel_logical_ring_advance(ringbuf);
 
 	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
+	ret = logical_ring_flush_all_caches(req);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +1 -2
index 77de8ac..40848b0 100644
@@ -43,8 +43,7 @@ void intel_logical_ring_stop(struct intel_engine_cs *ring);
 void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
 int intel_logical_rings_init(struct drm_device *dev);
 
-int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf,
-				  struct intel_context *ctx);
+int logical_ring_flush_all_caches(struct drm_i915_gem_request *req);
 /**
  * intel_logical_ring_advance() - advance the ringbuffer tail
  * @ringbuf: Ringbuffer to advance.
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -3
index d147ffa..91a9131 100644
@@ -748,7 +748,7 @@ static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)
 		return 0;
 
 	ring->gpu_caches_dirty = true;
-	ret = intel_ring_flush_all_caches(ring);
+	ret = intel_ring_flush_all_caches(req);
 	if (ret)
 		return ret;
 
@@ -766,7 +766,7 @@ static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)
 	intel_ring_advance(ring);
 
 	ring->gpu_caches_dirty = true;
-	ret = intel_ring_flush_all_caches(ring);
+	ret = intel_ring_flush_all_caches(req);
 	if (ret)
 		return ret;
 
@@ -2846,8 +2846,9 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev)
 }
 
 int
-intel_ring_flush_all_caches(struct intel_engine_cs *ring)
+intel_ring_flush_all_caches(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	if (!ring->gpu_caches_dirty)
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index b817725..0ef29fb 100644
@@ -413,7 +413,7 @@ bool intel_ring_stopped(struct intel_engine_cs *ring);
 
 int __must_check intel_ring_idle(struct intel_engine_cs *ring);
 void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);
-int intel_ring_flush_all_caches(struct intel_engine_cs *ring);
+int intel_ring_flush_all_caches(struct drm_i915_gem_request *req);
 int intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req);
 
 void intel_fini_pipe_control(struct intel_engine_cs *ring);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 35/53
#187 lore raw

Re: [PATCH 35/53] drm/i915: Update flush_all_caches() to take request structures

Quoted 126 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the *_ring_flush_all_caches() functions to take requests instead of rings or ringbuf/context pairs.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c         |    4 ++--
  drivers/gpu/drm/i915/intel_lrc.c        |   11 +++++------
  drivers/gpu/drm/i915/intel_lrc.h        |    3 +--
  drivers/gpu/drm/i915/intel_ringbuffer.c |    7 ++++---
  drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
  5 files changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -2
index 043933b..e8577d7 100644
@@ -2436,9 +2436,9 @@ int __i915_add_request(struct drm_i915_gem_request *request,
  	 */
  	if (flush_caches) {
  		if (i915.enable_execlists)
-			ret = logical_ring_flush_all_caches(ringbuf, request->ctx);
+			ret = logical_ring_flush_all_caches(request);
  		else
-			ret = intel_ring_flush_all_caches(ring);
+			ret = intel_ring_flush_all_caches(request);
  		if (ret)
  			return ret;
  	}
drivers/gpu/drm/i915/intel_lrc.c +5 -6
index 08ed800..d8084a1 100644
@@ -768,16 +768,15 @@ void intel_logical_ring_stop(struct intel_engine_cs *ring)
  	I915_WRITE_MODE(ring, _MASKED_BIT_DISABLE(STOP_RING));
  }
 
-int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf,
-				  struct intel_context *ctx)
+int logical_ring_flush_all_caches(struct drm_i915_gem_request *req)
  {
-	struct intel_engine_cs *ring = ringbuf->ring;
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	if (!ring->gpu_caches_dirty)
  		return 0;
 
-	ret = ring->emit_flush(ringbuf, ctx, 0, I915_GEM_GPU_DOMAINS);
+	ret = ring->emit_flush(req->ringbuf, req->ctx, 0, I915_GEM_GPU_DOMAINS);
  	if (ret)
  		return ret;
 
@@ -1089,7 +1088,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
  		return 0;
 
  	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
+	ret = logical_ring_flush_all_caches(req);
  	if (ret)
  		return ret;
 
@@ -1107,7 +1106,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
  	intel_logical_ring_advance(ringbuf);
 
  	ring->gpu_caches_dirty = true;
-	ret = logical_ring_flush_all_caches(ringbuf, req->ctx);
+	ret = logical_ring_flush_all_caches(req);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +1 -2
index 77de8ac..40848b0 100644
@@ -43,8 +43,7 @@ void intel_logical_ring_stop(struct intel_engine_cs *ring);
  void intel_logical_ring_cleanup(struct intel_engine_cs *ring);
  int intel_logical_rings_init(struct drm_device *dev);
 
-int logical_ring_flush_all_caches(struct intel_ringbuffer *ringbuf,
-				  struct intel_context *ctx);
+int logical_ring_flush_all_caches(struct drm_i915_gem_request *req);
  /**
   * intel_logical_ring_advance() - advance the ringbuffer tail
   * @ringbuf: Ringbuffer to advance.
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -3
index d147ffa..91a9131 100644
@@ -748,7 +748,7 @@ static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)
  		return 0;
 
  	ring->gpu_caches_dirty = true;
-	ret = intel_ring_flush_all_caches(ring);
+	ret = intel_ring_flush_all_caches(req);
  	if (ret)
  		return ret;
 
@@ -766,7 +766,7 @@ static int intel_ring_workarounds_emit(struct drm_i915_gem_request *req)
  	intel_ring_advance(ring);
 
  	ring->gpu_caches_dirty = true;
-	ret = intel_ring_flush_all_caches(ring);
+	ret = intel_ring_flush_all_caches(req);
  	if (ret)
  		return ret;
 
@@ -2846,8 +2846,9 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev)
  }
 
  int
-intel_ring_flush_all_caches(struct intel_engine_cs *ring)
+intel_ring_flush_all_caches(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	if (!ring->gpu_caches_dirty)
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index b817725..0ef29fb 100644

drivers/gpu/drm/i915/intel_ringbuffer.h bool intel_ring_stopped(struct intel_engine_cs *ring); · line 419

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -413,7 +413,7 @@ bool intel_ring_stopped(struct intel_engine_cs *ring);
 
  int __must_check intel_ring_idle(struct intel_engine_cs *ring);
  void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno);
-int intel_ring_flush_all_caches(struct intel_engine_cs *ring);
+int intel_ring_flush_all_caches(struct drm_i915_gem_request *req);
  int intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req);
 
  void intel_fini_pipe_control(struct intel_engine_cs *ring);

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#188 lore raw

PATCH 36/53 drm/i915: Update switch_mm() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the switch_mm() code paths to take a request instead of a ring.

v2: Rebased to newer tree.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_context.c |    2 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c     |   23 ++++++++++++++---------
 drivers/gpu/drm/i915/i915_gem_gtt.h     |    2 +-
 3 files changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 9e66fac..816a442 100644
@@ -591,7 +591,7 @@ static int do_switch(struct drm_i915_gem_request *req)
 
 	if (to->ppgtt) {
 		trace_switch_mm(ring, to);
-		ret = to->ppgtt->switch_mm(to->ppgtt, req->ring);
+		ret = to->ppgtt->switch_mm(to->ppgtt, req);
 		if (ret)
 			goto unpin_out;
 	}
drivers/gpu/drm/i915/i915_gem_gtt.c +14 -9
index cd00080..c3408f2 100644
@@ -280,9 +280,10 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr,
 }
 
 /* Broadwell Page Directory Pointer Descriptors */
-static int gen8_write_pdp(struct intel_engine_cs *ring, unsigned entry,
-			   uint64_t val)
+static int gen8_write_pdp(struct drm_i915_gem_request *req, unsigned entry,
+			  uint64_t val)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	BUG_ON(entry >= 4);
@@ -303,7 +304,7 @@ static int gen8_write_pdp(struct intel_engine_cs *ring, unsigned entry,
 }
 
 static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
 {
 	int i, ret;
 
@@ -312,7 +313,7 @@ static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt,
 
 	for (i = used_pd - 1; i >= 0; i--) {
 		dma_addr_t addr = ppgtt->pd_dma_addr[i];
-		ret = gen8_write_pdp(ring, i, addr);
+		ret = gen8_write_pdp(req, i, addr);
 		if (ret)
 			return ret;
 	}
@@ -777,8 +778,9 @@ static uint32_t get_pd_offset(struct i915_hw_ppgtt *ppgtt)
 }
 
 static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_engine_cs *ring)
+			 struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	/* NB: TLBs must be flushed and invalidated before a switch */
@@ -802,8 +804,9 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static int vgpu_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_i915_private *dev_priv = to_i915(ppgtt->base.dev);
 
 	I915_WRITE(RING_PP_DIR_DCLV(ring), PP_DIR_DCLV_2G);
@@ -812,8 +815,9 @@ static int vgpu_mm_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	/* NB: TLBs must be flushed and invalidated before a switch */
@@ -844,8 +848,9 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static int gen6_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_device *dev = ppgtt->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
@@ -1235,7 +1240,7 @@ int i915_ppgtt_init_ring(struct drm_i915_gem_request *req)
 	if (!ppgtt)
 		return 0;
 
-	return ppgtt->switch_mm(ppgtt, req->ring);
+	return ppgtt->switch_mm(ppgtt, req);
 }
 
 struct i915_hw_ppgtt *
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
index e7e202f..073be7f 100644
@@ -289,7 +289,7 @@ struct i915_hw_ppgtt {
 
 	int (*enable)(struct i915_hw_ppgtt *ppgtt);
 	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_engine_cs *ring);
+			 struct drm_i915_gem_request *req);
 	void (*debug_dump)(struct i915_hw_ppgtt *ppgtt, struct seq_file *m);
 };
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#189 lore raw

Re: [PATCH 36/53] drm/i915: Update switch_mm() to take a request structure

Quoted 4 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the switch_mm() code paths to take a request instead of a ring.

This commit message could be slightly clearer by saying specifically what you changed rather than using the blanket expression "paths". You could e.g. say that you changed the mm_switch virtual function implementations and the gen8_write_pdp helper function to take requests rather than rings.

Quoted 117 lines

v2: Rebased to newer tree.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_context.c |    2 +-
  drivers/gpu/drm/i915/i915_gem_gtt.c     |   23 ++++++++++++++---------
  drivers/gpu/drm/i915/i915_gem_gtt.h     |    2 +-
  3 files changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 9e66fac..816a442 100644
@@ -591,7 +591,7 @@ static int do_switch(struct drm_i915_gem_request *req)
 
  	if (to->ppgtt) {
  		trace_switch_mm(ring, to);
-		ret = to->ppgtt->switch_mm(to->ppgtt, req->ring);
+		ret = to->ppgtt->switch_mm(to->ppgtt, req);
  		if (ret)
  			goto unpin_out;
  	}
drivers/gpu/drm/i915/i915_gem_gtt.c +14 -9
index cd00080..c3408f2 100644
@@ -280,9 +280,10 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr,
  }
 
  /* Broadwell Page Directory Pointer Descriptors */
-static int gen8_write_pdp(struct intel_engine_cs *ring, unsigned entry,
-			   uint64_t val)
+static int gen8_write_pdp(struct drm_i915_gem_request *req, unsigned entry,
+			  uint64_t val)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	BUG_ON(entry >= 4);
@@ -303,7 +304,7 @@ static int gen8_write_pdp(struct intel_engine_cs *ring, unsigned entry,
  }
 
  static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
  {
  	int i, ret;
 
@@ -312,7 +313,7 @@ static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt,
 
  	for (i = used_pd - 1; i >= 0; i--) {
  		dma_addr_t addr = ppgtt->pd_dma_addr[i];
-		ret = gen8_write_pdp(ring, i, addr);
+		ret = gen8_write_pdp(req, i, addr);
  		if (ret)
  			return ret;
  	}
@@ -777,8 +778,9 @@ static uint32_t get_pd_offset(struct i915_hw_ppgtt *ppgtt)
  }
 
  static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_engine_cs *ring)
+			 struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	/* NB: TLBs must be flushed and invalidated before a switch */
@@ -802,8 +804,9 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
  }
 
  static int vgpu_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_i915_private *dev_priv = to_i915(ppgtt->base.dev);
 
  	I915_WRITE(RING_PP_DIR_DCLV(ring), PP_DIR_DCLV_2G);
@@ -812,8 +815,9 @@ static int vgpu_mm_switch(struct i915_hw_ppgtt *ppgtt,
  }
 
  static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	/* NB: TLBs must be flushed and invalidated before a switch */
@@ -844,8 +848,9 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
  }
 
  static int gen6_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_engine_cs *ring)
+			  struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_device *dev = ppgtt->base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
 
@@ -1235,7 +1240,7 @@ int i915_ppgtt_init_ring(struct drm_i915_gem_request *req)
  	if (!ppgtt)
  		return 0;
 
-	return ppgtt->switch_mm(ppgtt, req->ring);
+	return ppgtt->switch_mm(ppgtt, req);
  }
 
  struct i915_hw_ppgtt *
drivers/gpu/drm/i915/i915_gem_gtt.h +0 -0
index e7e202f..073be7f 100644

drivers/gpu/drm/i915/i915_gem_gtt.h struct i915_hw_ppgtt { · line 295

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
@@ -289,7 +289,7 @@ struct i915_hw_ppgtt {
 
  	int (*enable)(struct i915_hw_ppgtt *ppgtt);
  	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_engine_cs *ring);
+			 struct drm_i915_gem_request *req);
  	void (*debug_dump)(struct i915_hw_ppgtt *ppgtt, struct seq_file *m);
  };
 

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#190 lore raw

PATCH 37/53 drm/i915: Update ring->flush() to take a requests structure

In reply to [email protected]

From: John Harrison <[email protected]>

Udpated the various ring->flush() functions to take a request instead of a ring.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_context.c |    2 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c     |    6 +++---
 drivers/gpu/drm/i915/intel_ringbuffer.c |   30 +++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
 4 files changed, 24 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 816a442..384f481 100644
@@ -489,7 +489,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
 	 * itlb_before_ctx_switch.
 	 */
 	if (IS_GEN6(ring->dev)) {
-		ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, 0);
+		ret = ring->flush(req, I915_GEM_GPU_DOMAINS, 0);
 		if (ret)
 			return ret;
 	}
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -3
index c3408f2..a1af644 100644
@@ -784,7 +784,7 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
 	int ret;
 
 	/* NB: TLBs must be flushed and invalidated before a switch */
-	ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
+	ret = ring->flush(req, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
 	if (ret)
 		return ret;
 
@@ -821,7 +821,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 	int ret;
 
 	/* NB: TLBs must be flushed and invalidated before a switch */
-	ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
+	ret = ring->flush(req, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
 	if (ret)
 		return ret;
 
@@ -839,7 +839,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 
 	/* XXX: RCS is the only one to auto invalidate the TLBs? */
 	if (ring->id != RCS) {
-		ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
+		ret = ring->flush(req, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
 		if (ret)
 			return ret;
 	}
drivers/gpu/drm/i915/intel_ringbuffer.c +19 -11
index 91a9131..ca8f039 100644
@@ -91,10 +91,11 @@ static void __intel_ring_advance(struct intel_engine_cs *ring)
 }
 
 static int
-gen2_render_ring_flush(struct intel_engine_cs *ring,
+gen2_render_ring_flush(struct drm_i915_gem_request *req,
 		       u32	invalidate_domains,
 		       u32	flush_domains)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 cmd;
 	int ret;
 
@@ -117,10 +118,11 @@ gen2_render_ring_flush(struct intel_engine_cs *ring,
 }
 
 static int
-gen4_render_ring_flush(struct intel_engine_cs *ring,
+gen4_render_ring_flush(struct drm_i915_gem_request *req,
 		       u32	invalidate_domains,
 		       u32	flush_domains)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_device *dev = ring->dev;
 	u32 cmd;
 	int ret;
@@ -247,9 +249,10 @@ intel_emit_post_sync_nonzero_flush(struct intel_engine_cs *ring)
 }
 
 static int
-gen6_render_ring_flush(struct intel_engine_cs *ring,
-                         u32 invalidate_domains, u32 flush_domains)
+gen6_render_ring_flush(struct drm_i915_gem_request *req,
+		       u32 invalidate_domains, u32 flush_domains)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 flags = 0;
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
@@ -341,9 +344,10 @@ static int gen7_ring_fbc_flush(struct intel_engine_cs *ring, u32 value)
 }
 
 static int
-gen7_render_ring_flush(struct intel_engine_cs *ring,
+gen7_render_ring_flush(struct drm_i915_gem_request *req,
 		       u32 invalidate_domains, u32 flush_domains)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 flags = 0;
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
@@ -426,9 +430,10 @@ gen8_emit_pipe_control(struct intel_engine_cs *ring,
 }
 
 static int
-gen8_render_ring_flush(struct intel_engine_cs *ring,
+gen8_render_ring_flush(struct drm_i915_gem_request *req,
 		       u32 invalidate_domains, u32 flush_domains)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 flags = 0;
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
@@ -1527,10 +1532,11 @@ i8xx_ring_put_irq(struct intel_engine_cs *ring)
 }
 
 static int
-bsd_ring_flush(struct intel_engine_cs *ring,
+bsd_ring_flush(struct drm_i915_gem_request *req,
 	       u32     invalidate_domains,
 	       u32     flush_domains)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 2);
@@ -2318,9 +2324,10 @@ static void gen6_bsd_ring_write_tail(struct intel_engine_cs *ring,
 		   _MASKED_BIT_DISABLE(GEN6_BSD_SLEEP_MSG_DISABLE));
 }
 
-static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
+static int gen6_bsd_ring_flush(struct drm_i915_gem_request *req,
 			       u32 invalidate, u32 flush)
 {
+	struct intel_engine_cs *ring = req->ring;
 	uint32_t cmd;
 	int ret;
 
@@ -2430,9 +2437,10 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 /* Blitter support (SandyBridge+) */
 
-static int gen6_ring_flush(struct intel_engine_cs *ring,
+static int gen6_ring_flush(struct drm_i915_gem_request *req,
 			   u32 invalidate, u32 flush)
 {
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	uint32_t cmd;
@@ -2854,7 +2862,7 @@ intel_ring_flush_all_caches(struct drm_i915_gem_request *req)
 	if (!ring->gpu_caches_dirty)
 		return 0;
 
-	ret = ring->flush(ring, 0, I915_GEM_GPU_DOMAINS);
+	ret = ring->flush(req, 0, I915_GEM_GPU_DOMAINS);
 	if (ret)
 		return ret;
 
@@ -2875,7 +2883,7 @@ intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
 	if (ring->gpu_caches_dirty)
 		flush_domains = I915_GEM_GPU_DOMAINS;
 
-	ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, flush_domains);
+	ret = ring->flush(req, I915_GEM_GPU_DOMAINS, flush_domains);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index 0ef29fb..c08e2dc 100644
@@ -147,7 +147,7 @@ struct  intel_engine_cs {
 
 	void		(*write_tail)(struct intel_engine_cs *ring,
 				      u32 value);
-	int __must_check (*flush)(struct intel_engine_cs *ring,
+	int __must_check (*flush)(struct drm_i915_gem_request *req,
 				  u32	invalidate_domains,
 				  u32	flush_domains);
 	int		(*add_request)(struct intel_engine_cs *ring);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#191 lore raw

Re: [PATCH 37/53] drm/i915: Update ring->flush() to take a requests structure

Quoted 185 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Udpated the various ring->flush() functions to take a request instead of a ring.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_context.c |    2 +-
  drivers/gpu/drm/i915/i915_gem_gtt.c     |    6 +++---
  drivers/gpu/drm/i915/intel_ringbuffer.c |   30 +++++++++++++++++++-----------
  drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
  4 files changed, 24 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 816a442..384f481 100644
@@ -489,7 +489,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
  	 * itlb_before_ctx_switch.
  	 */
  	if (IS_GEN6(ring->dev)) {
-		ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, 0);
+		ret = ring->flush(req, I915_GEM_GPU_DOMAINS, 0);
  		if (ret)
  			return ret;
  	}
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -3
index c3408f2..a1af644 100644
@@ -784,7 +784,7 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
  	int ret;
 
  	/* NB: TLBs must be flushed and invalidated before a switch */
-	ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
+	ret = ring->flush(req, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
  	if (ret)
  		return ret;
 
@@ -821,7 +821,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
  	int ret;
 
  	/* NB: TLBs must be flushed and invalidated before a switch */
-	ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
+	ret = ring->flush(req, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
  	if (ret)
  		return ret;
 
@@ -839,7 +839,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 
  	/* XXX: RCS is the only one to auto invalidate the TLBs? */
  	if (ring->id != RCS) {
-		ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
+		ret = ring->flush(req, I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
  		if (ret)
  			return ret;
  	}
drivers/gpu/drm/i915/intel_ringbuffer.c +19 -11
index 91a9131..ca8f039 100644
@@ -91,10 +91,11 @@ static void __intel_ring_advance(struct intel_engine_cs *ring)
  }
 
  static int
-gen2_render_ring_flush(struct intel_engine_cs *ring,
+gen2_render_ring_flush(struct drm_i915_gem_request *req,
  		       u32	invalidate_domains,
  		       u32	flush_domains)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 cmd;
  	int ret;
 
@@ -117,10 +118,11 @@ gen2_render_ring_flush(struct intel_engine_cs *ring,
  }
 
  static int
-gen4_render_ring_flush(struct intel_engine_cs *ring,
+gen4_render_ring_flush(struct drm_i915_gem_request *req,
  		       u32	invalidate_domains,
  		       u32	flush_domains)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_device *dev = ring->dev;
  	u32 cmd;
  	int ret;
@@ -247,9 +249,10 @@ intel_emit_post_sync_nonzero_flush(struct intel_engine_cs *ring)
  }
 
  static int
-gen6_render_ring_flush(struct intel_engine_cs *ring,
-                         u32 invalidate_domains, u32 flush_domains)
+gen6_render_ring_flush(struct drm_i915_gem_request *req,
+		       u32 invalidate_domains, u32 flush_domains)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 flags = 0;
  	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
  	int ret;
@@ -341,9 +344,10 @@ static int gen7_ring_fbc_flush(struct intel_engine_cs *ring, u32 value)
  }
 
  static int
-gen7_render_ring_flush(struct intel_engine_cs *ring,
+gen7_render_ring_flush(struct drm_i915_gem_request *req,
  		       u32 invalidate_domains, u32 flush_domains)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 flags = 0;
  	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
  	int ret;
@@ -426,9 +430,10 @@ gen8_emit_pipe_control(struct intel_engine_cs *ring,
  }
 
  static int
-gen8_render_ring_flush(struct intel_engine_cs *ring,
+gen8_render_ring_flush(struct drm_i915_gem_request *req,
  		       u32 invalidate_domains, u32 flush_domains)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 flags = 0;
  	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
  	int ret;
@@ -1527,10 +1532,11 @@ i8xx_ring_put_irq(struct intel_engine_cs *ring)
  }
 
  static int
-bsd_ring_flush(struct intel_engine_cs *ring,
+bsd_ring_flush(struct drm_i915_gem_request *req,
  	       u32     invalidate_domains,
  	       u32     flush_domains)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 2);
@@ -2318,9 +2324,10 @@ static void gen6_bsd_ring_write_tail(struct intel_engine_cs *ring,
  		   _MASKED_BIT_DISABLE(GEN6_BSD_SLEEP_MSG_DISABLE));
  }
 
-static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
+static int gen6_bsd_ring_flush(struct drm_i915_gem_request *req,
  			       u32 invalidate, u32 flush)
  {
+	struct intel_engine_cs *ring = req->ring;
  	uint32_t cmd;
  	int ret;
 
@@ -2430,9 +2437,10 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
  /* Blitter support (SandyBridge+) */
 
-static int gen6_ring_flush(struct intel_engine_cs *ring,
+static int gen6_ring_flush(struct drm_i915_gem_request *req,
  			   u32 invalidate, u32 flush)
  {
+	struct intel_engine_cs *ring = req->ring;
  	struct drm_device *dev = ring->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	uint32_t cmd;
@@ -2854,7 +2862,7 @@ intel_ring_flush_all_caches(struct drm_i915_gem_request *req)
  	if (!ring->gpu_caches_dirty)
  		return 0;
 
-	ret = ring->flush(ring, 0, I915_GEM_GPU_DOMAINS);
+	ret = ring->flush(req, 0, I915_GEM_GPU_DOMAINS);
  	if (ret)
  		return ret;
 
@@ -2875,7 +2883,7 @@ intel_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
  	if (ring->gpu_caches_dirty)
  		flush_domains = I915_GEM_GPU_DOMAINS;
 
-	ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, flush_domains);
+	ret = ring->flush(req, I915_GEM_GPU_DOMAINS, flush_domains);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 0ef29fb..c08e2dc 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 153

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -147,7 +147,7 @@ struct  intel_engine_cs {
 
  	void		(*write_tail)(struct intel_engine_cs *ring,
  				      u32 value);
-	int __must_check (*flush)(struct intel_engine_cs *ring,
+	int __must_check (*flush)(struct drm_i915_gem_request *req,
  				  u32	invalidate_domains,
  				  u32	flush_domains);
  	int		(*add_request)(struct intel_engine_cs *ring);

trace_i915_gem_ring_flush still takes a ring as input argument. Do you feel like updating it to reflect your changes?

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#192 lore raw

PATCH 38/53 drm/i915: Update some flush helpers to take request structures

In reply to [email protected]

From: John Harrison <[email protected]>

Updated intel_emit_post_sync_nonzero_flush(), gen7_render_ring_cs_stall_wa(), gen7_ring_fbc_flush() and gen8_emit_pipe_control() to take requests instead of rings.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_ringbuffer.c |   29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +16 -13
index ca8f039..470fa93 100644
@@ -214,8 +214,9 @@ gen4_render_ring_flush(struct drm_i915_gem_request *req,
  * really our business.  That leaves only stall at scoreboard.
  */
 static int
-intel_emit_post_sync_nonzero_flush(struct intel_engine_cs *ring)
+intel_emit_post_sync_nonzero_flush(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
 
@@ -258,7 +259,7 @@ gen6_render_ring_flush(struct drm_i915_gem_request *req,
 	int ret;
 
 	/* Force SNB workarounds for PIPE_CONTROL flushes */
-	ret = intel_emit_post_sync_nonzero_flush(ring);
+	ret = intel_emit_post_sync_nonzero_flush(req);
 	if (ret)
 		return ret;
 
@@ -302,8 +303,9 @@ gen6_render_ring_flush(struct drm_i915_gem_request *req,
 }
 
 static int
-gen7_render_ring_cs_stall_wa(struct intel_engine_cs *ring)
+gen7_render_ring_cs_stall_wa(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 4);
@@ -320,8 +322,9 @@ gen7_render_ring_cs_stall_wa(struct intel_engine_cs *ring)
 	return 0;
 }
 
-static int gen7_ring_fbc_flush(struct intel_engine_cs *ring, u32 value)
+static int gen7_ring_fbc_flush(struct drm_i915_gem_request *req, u32 value)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	if (!ring->fbc_dirty)
@@ -389,7 +392,7 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req,
 		/* Workaround: we must issue a pipe_control with CS-stall bit
 		 * set before a pipe_control command that has the state cache
 		 * invalidate bit set. */
-		gen7_render_ring_cs_stall_wa(ring);
+		gen7_render_ring_cs_stall_wa(req);
 	}
 
 	ret = intel_ring_begin(ring, 4);
@@ -403,15 +406,16 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req,
 	intel_ring_advance(ring);
 
 	if (!invalidate_domains && flush_domains)
-		return gen7_ring_fbc_flush(ring, FBC_REND_NUKE);
+		return gen7_ring_fbc_flush(req, FBC_REND_NUKE);
 
 	return 0;
 }
 
 static int
-gen8_emit_pipe_control(struct intel_engine_cs *ring,
+gen8_emit_pipe_control(struct drm_i915_gem_request *req,
 		       u32 flags, u32 scratch_addr)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 6);
@@ -433,9 +437,8 @@ static int
 gen8_render_ring_flush(struct drm_i915_gem_request *req,
 		       u32 invalidate_domains, u32 flush_domains)
 {
-	struct intel_engine_cs *ring = req->ring;
 	u32 flags = 0;
-	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
+	u32 scratch_addr = req->ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
 
 	flags |= PIPE_CONTROL_CS_STALL;
@@ -455,7 +458,7 @@ gen8_render_ring_flush(struct drm_i915_gem_request *req,
 		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
 
 		/* WaCsStallBeforeStateCacheInvalidate:bdw,chv */
-		ret = gen8_emit_pipe_control(ring,
+		ret = gen8_emit_pipe_control(req,
 					     PIPE_CONTROL_CS_STALL |
 					     PIPE_CONTROL_STALL_AT_SCOREBOARD,
 					     0);
@@ -463,12 +466,12 @@ gen8_render_ring_flush(struct drm_i915_gem_request *req,
 			return ret;
 	}
 
-	ret = gen8_emit_pipe_control(ring, flags, scratch_addr);
+	ret = gen8_emit_pipe_control(req, flags, scratch_addr);
 	if (ret)
 		return ret;
 
 	if (!invalidate_domains && flush_domains)
-		return gen7_ring_fbc_flush(ring, FBC_REND_NUKE);
+		return gen7_ring_fbc_flush(req, FBC_REND_NUKE);
 
 	return 0;
 }
@@ -2482,7 +2485,7 @@ static int gen6_ring_flush(struct drm_i915_gem_request *req,
 
 	if (!invalidate && flush) {
 		if (IS_GEN7(dev))
-			return gen7_ring_fbc_flush(ring, FBC_REND_CACHE_CLEAN);
+			return gen7_ring_fbc_flush(req, FBC_REND_CACHE_CLEAN);
 		else if (IS_BROADWELL(dev))
 			dev_priv->fbc.need_sw_cache_clean = true;
 	}
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 38/53
#193 lore raw

Re: [PATCH 38/53] drm/i915: Update some flush helpers to take request structures

Quoted 123 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated intel_emit_post_sync_nonzero_flush(), gen7_render_ring_cs_stall_wa(), gen7_ring_fbc_flush() and gen8_emit_pipe_control() to take requests instead of rings.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_ringbuffer.c |   29 ++++++++++++++++-------------
  1 file changed, 16 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +15 -12
index ca8f039..470fa93 100644
@@ -214,8 +214,9 @@ gen4_render_ring_flush(struct drm_i915_gem_request *req,
   * really our business.  That leaves only stall at scoreboard.
   */
  static int
-intel_emit_post_sync_nonzero_flush(struct intel_engine_cs *ring)
+intel_emit_post_sync_nonzero_flush(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
  	int ret;
 
@@ -258,7 +259,7 @@ gen6_render_ring_flush(struct drm_i915_gem_request *req,
  	int ret;
 
  	/* Force SNB workarounds for PIPE_CONTROL flushes */
-	ret = intel_emit_post_sync_nonzero_flush(ring);
+	ret = intel_emit_post_sync_nonzero_flush(req);
  	if (ret)
  		return ret;
 
@@ -302,8 +303,9 @@ gen6_render_ring_flush(struct drm_i915_gem_request *req,
  }
 
  static int
-gen7_render_ring_cs_stall_wa(struct intel_engine_cs *ring)
+gen7_render_ring_cs_stall_wa(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 4);
@@ -320,8 +322,9 @@ gen7_render_ring_cs_stall_wa(struct intel_engine_cs *ring)
  	return 0;
  }
 
-static int gen7_ring_fbc_flush(struct intel_engine_cs *ring, u32 value)
+static int gen7_ring_fbc_flush(struct drm_i915_gem_request *req, u32 value)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	if (!ring->fbc_dirty)
@@ -389,7 +392,7 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req,
  		/* Workaround: we must issue a pipe_control with CS-stall bit
  		 * set before a pipe_control command that has the state cache
  		 * invalidate bit set. */
-		gen7_render_ring_cs_stall_wa(ring);
+		gen7_render_ring_cs_stall_wa(req);
  	}
 
  	ret = intel_ring_begin(ring, 4);
@@ -403,15 +406,16 @@ gen7_render_ring_flush(struct drm_i915_gem_request *req,
  	intel_ring_advance(ring);
 
  	if (!invalidate_domains && flush_domains)
-		return gen7_ring_fbc_flush(ring, FBC_REND_NUKE);
+		return gen7_ring_fbc_flush(req, FBC_REND_NUKE);
 
  	return 0;
  }
 
  static int
-gen8_emit_pipe_control(struct intel_engine_cs *ring,
+gen8_emit_pipe_control(struct drm_i915_gem_request *req,
  		       u32 flags, u32 scratch_addr)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 6);
@@ -433,9 +437,8 @@ static int
  gen8_render_ring_flush(struct drm_i915_gem_request *req,
  		       u32 invalidate_domains, u32 flush_domains)
  {
-	struct intel_engine_cs *ring = req->ring;
  	u32 flags = 0;
-	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
+	u32 scratch_addr = req->ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
  	int ret;
 
  	flags |= PIPE_CONTROL_CS_STALL;
@@ -455,7 +458,7 @@ gen8_render_ring_flush(struct drm_i915_gem_request *req,
  		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
 
  		/* WaCsStallBeforeStateCacheInvalidate:bdw,chv */
-		ret = gen8_emit_pipe_control(ring,
+		ret = gen8_emit_pipe_control(req,
  					     PIPE_CONTROL_CS_STALL |
  					     PIPE_CONTROL_STALL_AT_SCOREBOARD,
  					     0);
@@ -463,12 +466,12 @@ gen8_render_ring_flush(struct drm_i915_gem_request *req,
  			return ret;
  	}
 
-	ret = gen8_emit_pipe_control(ring, flags, scratch_addr);
+	ret = gen8_emit_pipe_control(req, flags, scratch_addr);
  	if (ret)
  		return ret;
 
  	if (!invalidate_domains && flush_domains)
-		return gen7_ring_fbc_flush(ring, FBC_REND_NUKE);
+		return gen7_ring_fbc_flush(req, FBC_REND_NUKE);
 
  	return 0;
  }

drivers/gpu/drm/i915/intel_ringbuffer.c static int gen6_ring_flush(struct drm_i915_gem_request *req, · line 2491

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
@@ -2482,7 +2485,7 @@ static int gen6_ring_flush(struct drm_i915_gem_request *req,
 
  	if (!invalidate && flush) {
  		if (IS_GEN7(dev))
-			return gen7_ring_fbc_flush(ring, FBC_REND_CACHE_CLEAN);
+			return gen7_ring_fbc_flush(req, FBC_REND_CACHE_CLEAN);
  		else if (IS_BROADWELL(dev))
  			dev_priv->fbc.need_sw_cache_clean = true;
  	}

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#194 lore raw

PATCH 39/53 drm/i915: Update ring->emit_flush() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the various ring->emit_flush() implementations to take a request instead of a ringbuf/context pair.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c        |   17 ++++++++---------
 drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
 2 files changed, 9 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +8 -9
index d8084a1..f3bf2cc 100644
@@ -568,8 +568,7 @@ static int logical_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
 	if (ring->gpu_caches_dirty)
 		flush_domains = I915_GEM_GPU_DOMAINS;
 
-	ret = ring->emit_flush(req->ringbuf, req->ctx,
-			       I915_GEM_GPU_DOMAINS, flush_domains);
+	ret = ring->emit_flush(req, I915_GEM_GPU_DOMAINS, flush_domains);
 	if (ret)
 		return ret;
 
@@ -776,7 +775,7 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req)
 	if (!ring->gpu_caches_dirty)
 		return 0;
 
-	ret = ring->emit_flush(req->ringbuf, req->ctx, 0, I915_GEM_GPU_DOMAINS);
+	ret = ring->emit_flush(req, 0, I915_GEM_GPU_DOMAINS);
 	if (ret)
 		return ret;
 
@@ -1221,18 +1220,18 @@ static void gen8_logical_ring_put_irq(struct intel_engine_cs *ring)
 	spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
 }
 
-static int gen8_emit_flush(struct intel_ringbuffer *ringbuf,
-			   struct intel_context *ctx,
+static int gen8_emit_flush(struct drm_i915_gem_request *request,
 			   u32 invalidate_domains,
 			   u32 unused)
 {
+	struct intel_ringbuffer *ringbuf = request->ringbuf;
 	struct intel_engine_cs *ring = ringbuf->ring;
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	uint32_t cmd;
 	int ret;
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
+	ret = intel_logical_ring_begin(ringbuf, request->ctx, 4);
 	if (ret)
 		return ret;
 
@@ -1262,11 +1261,11 @@ static int gen8_emit_flush(struct intel_ringbuffer *ringbuf,
 	return 0;
 }
 
-static int gen8_emit_flush_render(struct intel_ringbuffer *ringbuf,
-				  struct intel_context *ctx,
+static int gen8_emit_flush_render(struct drm_i915_gem_request *request,
 				  u32 invalidate_domains,
 				  u32 flush_domains)
 {
+	struct intel_ringbuffer *ringbuf = request->ringbuf;
 	struct intel_engine_cs *ring = ringbuf->ring;
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	u32 flags = 0;
@@ -1290,7 +1289,7 @@ static int gen8_emit_flush_render(struct intel_ringbuffer *ringbuf,
 		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
 	}
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, 6);
+	ret = intel_logical_ring_begin(ringbuf, request->ctx, 6);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
index c08e2dc..6f7c79c 100644
@@ -235,8 +235,7 @@ struct  intel_engine_cs {
 	u32             irq_keep_mask; /* bitmask for interrupts that should not be masked */
 	int		(*emit_request)(struct intel_ringbuffer *ringbuf,
 					struct drm_i915_gem_request *request);
-	int		(*emit_flush)(struct intel_ringbuffer *ringbuf,
-				      struct intel_context *ctx,
+	int		(*emit_flush)(struct drm_i915_gem_request *request,
 				      u32 invalidate_domains,
 				      u32 flush_domains);
 	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 39/53
#195 lore raw

Re: [PATCH 39/53] drm/i915: Update ring->emit_flush() to take a request structure

Quoted 86 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the various ring->emit_flush() implementations to take a request instead of a ringbuf/context pair.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_lrc.c        |   17 ++++++++---------
  drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
  2 files changed, 9 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +8 -9
index d8084a1..f3bf2cc 100644
@@ -568,8 +568,7 @@ static int logical_ring_invalidate_all_caches(struct drm_i915_gem_request *req)
  	if (ring->gpu_caches_dirty)
  		flush_domains = I915_GEM_GPU_DOMAINS;
 
-	ret = ring->emit_flush(req->ringbuf, req->ctx,
-			       I915_GEM_GPU_DOMAINS, flush_domains);
+	ret = ring->emit_flush(req, I915_GEM_GPU_DOMAINS, flush_domains);
  	if (ret)
  		return ret;
 
@@ -776,7 +775,7 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req)
  	if (!ring->gpu_caches_dirty)
  		return 0;
 
-	ret = ring->emit_flush(req->ringbuf, req->ctx, 0, I915_GEM_GPU_DOMAINS);
+	ret = ring->emit_flush(req, 0, I915_GEM_GPU_DOMAINS);
  	if (ret)
  		return ret;
 
@@ -1221,18 +1220,18 @@ static void gen8_logical_ring_put_irq(struct intel_engine_cs *ring)
  	spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
  }
 
-static int gen8_emit_flush(struct intel_ringbuffer *ringbuf,
-			   struct intel_context *ctx,
+static int gen8_emit_flush(struct drm_i915_gem_request *request,
  			   u32 invalidate_domains,
  			   u32 unused)
  {
+	struct intel_ringbuffer *ringbuf = request->ringbuf;
  	struct intel_engine_cs *ring = ringbuf->ring;
  	struct drm_device *dev = ring->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	uint32_t cmd;
  	int ret;
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
+	ret = intel_logical_ring_begin(ringbuf, request->ctx, 4);
  	if (ret)
  		return ret;
 
@@ -1262,11 +1261,11 @@ static int gen8_emit_flush(struct intel_ringbuffer *ringbuf,
  	return 0;
  }
 
-static int gen8_emit_flush_render(struct intel_ringbuffer *ringbuf,
-				  struct intel_context *ctx,
+static int gen8_emit_flush_render(struct drm_i915_gem_request *request,
  				  u32 invalidate_domains,
  				  u32 flush_domains)
  {
+	struct intel_ringbuffer *ringbuf = request->ringbuf;
  	struct intel_engine_cs *ring = ringbuf->ring;
  	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
  	u32 flags = 0;
@@ -1290,7 +1289,7 @@ static int gen8_emit_flush_render(struct intel_ringbuffer *ringbuf,
  		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
  	}
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, 6);
+	ret = intel_logical_ring_begin(ringbuf, request->ctx, 6);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index c08e2dc..6f7c79c 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 241

Quoted 9 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
@@ -235,8 +235,7 @@ struct  intel_engine_cs {
  	u32             irq_keep_mask; /* bitmask for interrupts that should not be masked */
  	int		(*emit_request)(struct intel_ringbuffer *ringbuf,
  					struct drm_i915_gem_request *request);
-	int		(*emit_flush)(struct intel_ringbuffer *ringbuf,
-				      struct intel_context *ctx,
+	int		(*emit_flush)(struct drm_i915_gem_request *request,
  				      u32 invalidate_domains,
  				      u32 flush_domains);
  	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#196 lore raw

PATCH 40/53 drm/i915: Update ring->add_request() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the various ring->add_request() implementations to take a request instead of a ring. This removes their reliance on the OLR to obtain the seqno value that the request should be tagged with.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c         |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |   26 ++++++++++++--------------
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
 3 files changed, 14 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index e8577d7..4357cd3 100644
@@ -2453,7 +2453,7 @@ int __i915_add_request(struct drm_i915_gem_request *request,
 	if (i915.enable_execlists)
 		ret = ring->emit_request(ringbuf, request);
 	else
-		ret = ring->add_request(ring);
+		ret = ring->add_request(request);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +12 -14
index 470fa93..99f0dd1 100644
@@ -1222,16 +1222,16 @@ static int gen6_signal(struct intel_engine_cs *signaller,
 
 /**
  * gen6_add_request - Update the semaphore mailbox registers
- * 
- * @ring - ring that is adding a request
- * @seqno - return seqno stuck into the ring
+ *
+ * @request - request to write to the ring
  *
  * Update the mailbox registers in the *other* rings with the current seqno.
  * This acts like a signal in the canonical semaphore.
  */
 static int
-gen6_add_request(struct intel_engine_cs *ring)
+gen6_add_request(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	if (ring->semaphore.signal)
@@ -1244,8 +1244,7 @@ gen6_add_request(struct intel_engine_cs *ring)
 
 	intel_ring_emit(ring, MI_STORE_DWORD_INDEX);
 	intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
 	intel_ring_emit(ring, MI_USER_INTERRUPT);
 	__intel_ring_advance(ring);
 
@@ -1342,8 +1341,9 @@ do {									\
 } while (0)
 
 static int
-pc_render_add_request(struct intel_engine_cs *ring)
+pc_render_add_request(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
 
@@ -1363,8 +1363,7 @@ pc_render_add_request(struct intel_engine_cs *ring)
 			PIPE_CONTROL_WRITE_FLUSH |
 			PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE);
 	intel_ring_emit(ring, ring->scratch.gtt_offset | PIPE_CONTROL_GLOBAL_GTT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
 	intel_ring_emit(ring, 0);
 	PIPE_CONTROL_FLUSH(ring, scratch_addr);
 	scratch_addr += 2 * CACHELINE_BYTES; /* write to separate cachelines */
@@ -1383,8 +1382,7 @@ pc_render_add_request(struct intel_engine_cs *ring)
 			PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
 			PIPE_CONTROL_NOTIFY);
 	intel_ring_emit(ring, ring->scratch.gtt_offset | PIPE_CONTROL_GLOBAL_GTT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
 	intel_ring_emit(ring, 0);
 	__intel_ring_advance(ring);
 
@@ -1553,8 +1551,9 @@ bsd_ring_flush(struct drm_i915_gem_request *req,
 }
 
 static int
-i9xx_add_request(struct intel_engine_cs *ring)
+i9xx_add_request(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 4);
@@ -1563,8 +1562,7 @@ i9xx_add_request(struct intel_engine_cs *ring)
 
 	intel_ring_emit(ring, MI_STORE_DWORD_INDEX);
 	intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
 	intel_ring_emit(ring, MI_USER_INTERRUPT);
 	__intel_ring_advance(ring);
 
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index 6f7c79c..d2391a9 100644
@@ -150,7 +150,7 @@ struct  intel_engine_cs {
 	int __must_check (*flush)(struct drm_i915_gem_request *req,
 				  u32	invalidate_domains,
 				  u32	flush_domains);
-	int		(*add_request)(struct intel_engine_cs *ring);
+	int		(*add_request)(struct drm_i915_gem_request *req);
 	/* Some chipsets are not quite as coherent as advertised and need
 	 * an expensive kick to force a true read of the up-to-date seqno.
 	 * However, the up-to-date seqno is not always required and the last
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 40/53
#197 lore raw

Re: [PATCH 40/53] drm/i915: Update ring->add_request() to take a request structure

Quoted 120 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the various ring->add_request() implementations to take a request instead of a ring. This removes their reliance on the OLR to obtain the seqno value that the request should be tagged with.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c         |    2 +-
  drivers/gpu/drm/i915/intel_ringbuffer.c |   26 ++++++++++++--------------
  drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
  3 files changed, 14 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index e8577d7..4357cd3 100644
@@ -2453,7 +2453,7 @@ int __i915_add_request(struct drm_i915_gem_request *request,
  	if (i915.enable_execlists)
  		ret = ring->emit_request(ringbuf, request);
  	else
-		ret = ring->add_request(ring);
+		ret = ring->add_request(request);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +12 -14
index 470fa93..99f0dd1 100644
@@ -1222,16 +1222,16 @@ static int gen6_signal(struct intel_engine_cs *signaller,
 
  /**
   * gen6_add_request - Update the semaphore mailbox registers
- *
- * @ring - ring that is adding a request
- * @seqno - return seqno stuck into the ring
+ *
+ * @request - request to write to the ring
   *
   * Update the mailbox registers in the *other* rings with the current seqno.
   * This acts like a signal in the canonical semaphore.
   */
  static int
-gen6_add_request(struct intel_engine_cs *ring)
+gen6_add_request(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	if (ring->semaphore.signal)
@@ -1244,8 +1244,7 @@ gen6_add_request(struct intel_engine_cs *ring)
 
  	intel_ring_emit(ring, MI_STORE_DWORD_INDEX);
  	intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
  	intel_ring_emit(ring, MI_USER_INTERRUPT);
  	__intel_ring_advance(ring);
 
@@ -1342,8 +1341,9 @@ do {									\
  } while (0)
 
  static int
-pc_render_add_request(struct intel_engine_cs *ring)
+pc_render_add_request(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
  	int ret;
 
@@ -1363,8 +1363,7 @@ pc_render_add_request(struct intel_engine_cs *ring)
  			PIPE_CONTROL_WRITE_FLUSH |
  			PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE);
  	intel_ring_emit(ring, ring->scratch.gtt_offset | PIPE_CONTROL_GLOBAL_GTT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
  	intel_ring_emit(ring, 0);
  	PIPE_CONTROL_FLUSH(ring, scratch_addr);
  	scratch_addr += 2 * CACHELINE_BYTES; /* write to separate cachelines */
@@ -1383,8 +1382,7 @@ pc_render_add_request(struct intel_engine_cs *ring)
  			PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE |
  			PIPE_CONTROL_NOTIFY);
  	intel_ring_emit(ring, ring->scratch.gtt_offset | PIPE_CONTROL_GLOBAL_GTT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
  	intel_ring_emit(ring, 0);
  	__intel_ring_advance(ring);
 
@@ -1553,8 +1551,9 @@ bsd_ring_flush(struct drm_i915_gem_request *req,
  }
 
  static int
-i9xx_add_request(struct intel_engine_cs *ring)
+i9xx_add_request(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 4);
@@ -1563,8 +1562,7 @@ i9xx_add_request(struct intel_engine_cs *ring)
 
  	intel_ring_emit(ring, MI_STORE_DWORD_INDEX);
  	intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
-	intel_ring_emit(ring,
-		    i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_ring_emit(ring, i915_gem_request_get_seqno(req));
  	intel_ring_emit(ring, MI_USER_INTERRUPT);
  	__intel_ring_advance(ring);
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 6f7c79c..d2391a9 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 156

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -150,7 +150,7 @@ struct  intel_engine_cs {
  	int __must_check (*flush)(struct drm_i915_gem_request *req,
  				  u32	invalidate_domains,
  				  u32	flush_domains);
-	int		(*add_request)(struct intel_engine_cs *ring);
+	int		(*add_request)(struct drm_i915_gem_request *req);
  	/* Some chipsets are not quite as coherent as advertised and need
  	 * an expensive kick to force a true read of the up-to-date seqno.
  	 * However, the up-to-date seqno is not always required and the last

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#198 lore raw

PATCH 41/53 drm/i915: Update ring->emit_request() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the ring->emit_request() implementation to take a request instead of a ringbuf/request pair. Also removed it's use of the OLR for obtaining the request's seqno.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c         |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c        |    7 +++----
 drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 4357cd3..4f6e9ad 100644
@@ -2451,7 +2451,7 @@ int __i915_add_request(struct drm_i915_gem_request *request,
 	request->postfix = intel_ring_get_tail(ringbuf);
 
 	if (i915.enable_execlists)
-		ret = ring->emit_request(ringbuf, request);
+		ret = ring->emit_request(request);
 	else
 		ret = ring->add_request(request);
 	if (ret)
drivers/gpu/drm/i915/intel_lrc.c +3 -4
index f3bf2cc..f4661ec 100644
@@ -1314,9 +1314,9 @@ static void gen8_set_seqno(struct intel_engine_cs *ring, u32 seqno)
 	intel_write_status_page(ring, I915_GEM_HWS_INDEX, seqno);
 }
 
-static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
-			     struct drm_i915_gem_request *request)
+static int gen8_emit_request(struct drm_i915_gem_request *request)
 {
+	struct intel_ringbuffer *ringbuf = request->ringbuf;
 	struct intel_engine_cs *ring = ringbuf->ring;
 	u32 cmd;
 	int ret;
@@ -1333,8 +1333,7 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
 				(ring->status_page.gfx_addr +
 				(I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT)));
 	intel_logical_ring_emit(ringbuf, 0);
-	intel_logical_ring_emit(ringbuf,
-		i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_logical_ring_emit(ringbuf, i915_gem_request_get_seqno(request));
 	intel_logical_ring_emit(ringbuf, MI_USER_INTERRUPT);
 	intel_logical_ring_emit(ringbuf, MI_NOOP);
 	intel_logical_ring_advance_and_submit(ringbuf, request->ctx, request);
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
index d2391a9..d8300f2 100644
@@ -233,8 +233,7 @@ struct  intel_engine_cs {
 	struct list_head execlist_retired_req_list;
 	u8 next_context_status_buffer;
 	u32             irq_keep_mask; /* bitmask for interrupts that should not be masked */
-	int		(*emit_request)(struct intel_ringbuffer *ringbuf,
-					struct drm_i915_gem_request *request);
+	int		(*emit_request)(struct drm_i915_gem_request *request);
 	int		(*emit_flush)(struct drm_i915_gem_request *request,
 				      u32 invalidate_domains,
 				      u32 flush_domains);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 41/53
#199 lore raw

Re: [PATCH 41/53] drm/i915: Update ring->emit_request() to take a request structure

Quoted 59 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the ring->emit_request() implementation to take a request instead of a ringbuf/request pair. Also removed it's use of the OLR for obtaining the request's seqno.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c         |    2 +-
  drivers/gpu/drm/i915/intel_lrc.c        |    7 +++----
  drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
  3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 4357cd3..4f6e9ad 100644
@@ -2451,7 +2451,7 @@ int __i915_add_request(struct drm_i915_gem_request *request,
  	request->postfix = intel_ring_get_tail(ringbuf);
 
  	if (i915.enable_execlists)
-		ret = ring->emit_request(ringbuf, request);
+		ret = ring->emit_request(request);
  	else
  		ret = ring->add_request(request);
  	if (ret)
drivers/gpu/drm/i915/intel_lrc.c +3 -4
index f3bf2cc..f4661ec 100644
@@ -1314,9 +1314,9 @@ static void gen8_set_seqno(struct intel_engine_cs *ring, u32 seqno)
  	intel_write_status_page(ring, I915_GEM_HWS_INDEX, seqno);
  }
 
-static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
-			     struct drm_i915_gem_request *request)
+static int gen8_emit_request(struct drm_i915_gem_request *request)
  {
+	struct intel_ringbuffer *ringbuf = request->ringbuf;
  	struct intel_engine_cs *ring = ringbuf->ring;
  	u32 cmd;
  	int ret;
@@ -1333,8 +1333,7 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
  				(ring->status_page.gfx_addr +
  				(I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT)));
  	intel_logical_ring_emit(ringbuf, 0);
-	intel_logical_ring_emit(ringbuf,
-		i915_gem_request_get_seqno(ring->outstanding_lazy_request));
+	intel_logical_ring_emit(ringbuf, i915_gem_request_get_seqno(request));
  	intel_logical_ring_emit(ringbuf, MI_USER_INTERRUPT);
  	intel_logical_ring_emit(ringbuf, MI_NOOP);
  	intel_logical_ring_advance_and_submit(ringbuf, request->ctx, request);
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index d2391a9..d8300f2 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 239

Quoted 9 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
@@ -233,8 +233,7 @@ struct  intel_engine_cs {
  	struct list_head execlist_retired_req_list;
  	u8 next_context_status_buffer;
  	u32             irq_keep_mask; /* bitmask for interrupts that should not be masked */
-	int		(*emit_request)(struct intel_ringbuffer *ringbuf,
-					struct drm_i915_gem_request *request);
+	int		(*emit_request)(struct drm_i915_gem_request *request);
  	int		(*emit_flush)(struct drm_i915_gem_request *request,
  				      u32 invalidate_domains,
  				      u32 flush_domains);

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#200 lore raw

PATCH 42/53 drm/i915: Update ring->dispatch_execbuffer() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the various ring->dispatch_execbuffer() implementations to take a request instead of a ring.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   |    4 ++--
 drivers/gpu/drm/i915/i915_gem_render_state.c |    3 +--
 drivers/gpu/drm/i915/intel_ringbuffer.c      |   18 ++++++++++++------
 drivers/gpu/drm/i915/intel_ringbuffer.h      |    2 +-
 4 files changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -2
index a79c893..8b4f8a9 100644
@@ -1265,14 +1265,14 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 			if (ret)
 				goto error;
 
-			ret = ring->dispatch_execbuffer(ring,
+			ret = ring->dispatch_execbuffer(params->request,
 							exec_start, exec_len,
 							params->dispatch_flags);
 			if (ret)
 				goto error;
 		}
 	} else {
-		ret = ring->dispatch_execbuffer(ring,
+		ret = ring->dispatch_execbuffer(params->request,
 						exec_start, exec_len,
 						params->dispatch_flags);
 		if (ret)
drivers/gpu/drm/i915/i915_gem_render_state.c +1 -2
index 866274c..cdf2fee 100644
@@ -164,8 +164,7 @@ int i915_gem_render_state_init(struct drm_i915_gem_request *req)
 	if (so.rodata == NULL)
 		return 0;
 
-	ret = req->ring->dispatch_execbuffer(req->ring,
-					     so.ggtt_offset,
+	ret = req->ring->dispatch_execbuffer(req, so.ggtt_offset,
 					     so.rodata->batch_items * 4,
 					     I915_DISPATCH_SECURE);
 	if (ret)
drivers/gpu/drm/i915/intel_ringbuffer.c +12 -6
index 99f0dd1..87612f1 100644
@@ -1694,10 +1694,11 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
 }
 
 static int
-i965_dispatch_execbuffer(struct intel_engine_cs *ring,
+i965_dispatch_execbuffer(struct drm_i915_gem_request *req,
 			 u64 offset, u32 length,
 			 unsigned dispatch_flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 2);
@@ -1720,10 +1721,11 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 #define I830_TLB_ENTRIES (2)
 #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
 static int
-i830_dispatch_execbuffer(struct intel_engine_cs *ring,
+i830_dispatch_execbuffer(struct drm_i915_gem_request *req,
 			 u64 offset, u32 len,
 			 unsigned dispatch_flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	u32 cs_offset = ring->scratch.gtt_offset;
 	int ret;
 
@@ -1782,10 +1784,11 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 }
 
 static int
-i915_dispatch_execbuffer(struct intel_engine_cs *ring,
+i915_dispatch_execbuffer(struct drm_i915_gem_request *req,
 			 u64 offset, u32 len,
 			 unsigned dispatch_flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 2);
@@ -2370,10 +2373,11 @@ static int gen6_bsd_ring_flush(struct drm_i915_gem_request *req,
 }
 
 static int
-gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
+gen8_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,
 			      u64 offset, u32 len,
 			      unsigned dispatch_flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	bool ppgtt = USES_PPGTT(ring->dev) &&
 			!(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
@@ -2393,10 +2397,11 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 }
 
 static int
-hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
+hsw_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,
 			     u64 offset, u32 len,
 			     unsigned dispatch_flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 2);
@@ -2415,10 +2420,11 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 }
 
 static int
-gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
+gen6_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,
 			      u64 offset, u32 len,
 			      unsigned dispatch_flags)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int ret;
 
 	ret = intel_ring_begin(ring, 2);
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index d8300f2..0b03b3a 100644
@@ -161,7 +161,7 @@ struct  intel_engine_cs {
 				     bool lazy_coherency);
 	void		(*set_seqno)(struct intel_engine_cs *ring,
 				     u32 seqno);
-	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
+	int		(*dispatch_execbuffer)(struct drm_i915_gem_request *req,
 					       u64 offset, u32 length,
 					       unsigned dispatch_flags);
 #define I915_DISPATCH_SECURE 0x1
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 42/53
#201 lore raw

Re: [PATCH 42/53] drm/i915: Update ring->dispatch_execbuffer() to take a request structure

Quoted 137 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the various ring->dispatch_execbuffer() implementations to take a request instead of a ring.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c   |    4 ++--
  drivers/gpu/drm/i915/i915_gem_render_state.c |    3 +--
  drivers/gpu/drm/i915/intel_ringbuffer.c      |   18 ++++++++++++------
  drivers/gpu/drm/i915/intel_ringbuffer.h      |    2 +-
  4 files changed, 16 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -2
index a79c893..8b4f8a9 100644
@@ -1265,14 +1265,14 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
  			if (ret)
  				goto error;
 
-			ret = ring->dispatch_execbuffer(ring,
+			ret = ring->dispatch_execbuffer(params->request,
  							exec_start, exec_len,
  							params->dispatch_flags);
  			if (ret)
  				goto error;
  		}
  	} else {
-		ret = ring->dispatch_execbuffer(ring,
+		ret = ring->dispatch_execbuffer(params->request,
  						exec_start, exec_len,
  						params->dispatch_flags);
  		if (ret)
drivers/gpu/drm/i915/i915_gem_render_state.c +1 -2
index 866274c..cdf2fee 100644
@@ -164,8 +164,7 @@ int i915_gem_render_state_init(struct drm_i915_gem_request *req)
  	if (so.rodata == NULL)
  		return 0;
 
-	ret = req->ring->dispatch_execbuffer(req->ring,
-					     so.ggtt_offset,
+	ret = req->ring->dispatch_execbuffer(req, so.ggtt_offset,
  					     so.rodata->batch_items * 4,
  					     I915_DISPATCH_SECURE);
  	if (ret)
drivers/gpu/drm/i915/intel_ringbuffer.c +12 -6
index 99f0dd1..87612f1 100644
@@ -1694,10 +1694,11 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
  }
 
  static int
-i965_dispatch_execbuffer(struct intel_engine_cs *ring,
+i965_dispatch_execbuffer(struct drm_i915_gem_request *req,
  			 u64 offset, u32 length,
  			 unsigned dispatch_flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 2);
@@ -1720,10 +1721,11 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
  #define I830_TLB_ENTRIES (2)
  #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
  static int
-i830_dispatch_execbuffer(struct intel_engine_cs *ring,
+i830_dispatch_execbuffer(struct drm_i915_gem_request *req,
  			 u64 offset, u32 len,
  			 unsigned dispatch_flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	u32 cs_offset = ring->scratch.gtt_offset;
  	int ret;
 
@@ -1782,10 +1784,11 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
  }
 
  static int
-i915_dispatch_execbuffer(struct intel_engine_cs *ring,
+i915_dispatch_execbuffer(struct drm_i915_gem_request *req,
  			 u64 offset, u32 len,
  			 unsigned dispatch_flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 2);
@@ -2370,10 +2373,11 @@ static int gen6_bsd_ring_flush(struct drm_i915_gem_request *req,
  }
 
  static int
-gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
+gen8_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,
  			      u64 offset, u32 len,
  			      unsigned dispatch_flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	bool ppgtt = USES_PPGTT(ring->dev) &&
  			!(dispatch_flags & I915_DISPATCH_SECURE);
  	int ret;
@@ -2393,10 +2397,11 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  }
 
  static int
-hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
+hsw_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,
  			     u64 offset, u32 len,
  			     unsigned dispatch_flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 2);
@@ -2415,10 +2420,11 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  }
 
  static int
-gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
+gen6_ring_dispatch_execbuffer(struct drm_i915_gem_request *req,
  			      u64 offset, u32 len,
  			      unsigned dispatch_flags)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int ret;
 
  	ret = intel_ring_begin(ring, 2);
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index d8300f2..0b03b3a 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 167

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -161,7 +161,7 @@ struct  intel_engine_cs {
  				     bool lazy_coherency);
  	void		(*set_seqno)(struct intel_engine_cs *ring,
  				     u32 seqno);
-	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
+	int		(*dispatch_execbuffer)(struct drm_i915_gem_request *req,
  					       u64 offset, u32 length,
  					       unsigned dispatch_flags);
  #define I915_DISPATCH_SECURE 0x1

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#202 lore raw

PATCH 43/53 drm/i915: Update ring->emit_bb_start() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the ring->emit_bb_start() implementation to take a request instead of a ringbuf/context pair.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c        |   12 +++++-------
 drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +5 -7
index f4661ec..5212b54 100644
@@ -704,7 +704,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 	exec_start = params->batch_obj_vm_offset +
 		     args->batch_start_offset;
 
-	ret = ring->emit_bb_start(ringbuf, params->ctx, exec_start, params->dispatch_flags);
+	ret = ring->emit_bb_start(params->request, exec_start, params->dispatch_flags);
 	if (ret)
 		return ret;
 
@@ -1166,14 +1166,14 @@ static int gen9_init_render_ring(struct intel_engine_cs *ring)
 	return init_workarounds_ring(ring);
 }
 
-static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
-			      struct intel_context *ctx,
+static int gen8_emit_bb_start(struct drm_i915_gem_request *req,
 			      u64 offset, unsigned dispatch_flags)
 {
+	struct intel_ringbuffer *ringbuf = req->ringbuf;
 	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
+	ret = intel_logical_ring_begin(ringbuf, req->ctx, 4);
 	if (ret)
 		return ret;
 
@@ -1353,9 +1353,7 @@ static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req)
 	if (so.rodata == NULL)
 		return 0;
 
-	ret = req->ring->emit_bb_start(req->ringbuf,
-				       req->ctx,
-				       so.ggtt_offset,
+	ret = req->ring->emit_bb_start(req, so.ggtt_offset,
 				       I915_DISPATCH_SECURE);
 	if (ret)
 		goto out;
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
index 0b03b3a..1ff0ad1 100644
@@ -237,8 +237,7 @@ struct  intel_engine_cs {
 	int		(*emit_flush)(struct drm_i915_gem_request *request,
 				      u32 invalidate_domains,
 				      u32 flush_domains);
-	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
-					 struct intel_context *ctx,
+	int		(*emit_bb_start)(struct drm_i915_gem_request *req,
 					 u64 offset, unsigned dispatch_flags);
 
 	/**
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 43/53
#203 lore raw

Re: [PATCH 43/53] drm/i915: Update ring->emit_bb_start() to take a request structure

Quoted 60 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the ring->emit_bb_start() implementation to take a request instead of a ringbuf/context pair.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_lrc.c        |   12 +++++-------
  drivers/gpu/drm/i915/intel_ringbuffer.h |    3 +--
  2 files changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +5 -7
index f4661ec..5212b54 100644
@@ -704,7 +704,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
  	exec_start = params->batch_obj_vm_offset +
  		     args->batch_start_offset;
 
-	ret = ring->emit_bb_start(ringbuf, params->ctx, exec_start, params->dispatch_flags);
+	ret = ring->emit_bb_start(params->request, exec_start, params->dispatch_flags);
  	if (ret)
  		return ret;
 
@@ -1166,14 +1166,14 @@ static int gen9_init_render_ring(struct intel_engine_cs *ring)
  	return init_workarounds_ring(ring);
  }
 
-static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
-			      struct intel_context *ctx,
+static int gen8_emit_bb_start(struct drm_i915_gem_request *req,
  			      u64 offset, unsigned dispatch_flags)
  {
+	struct intel_ringbuffer *ringbuf = req->ringbuf;
  	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
  	int ret;
 
-	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
+	ret = intel_logical_ring_begin(ringbuf, req->ctx, 4);
  	if (ret)
  		return ret;
 
@@ -1353,9 +1353,7 @@ static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req)
  	if (so.rodata == NULL)
  		return 0;
 
-	ret = req->ring->emit_bb_start(req->ringbuf,
-				       req->ctx,
-				       so.ggtt_offset,
+	ret = req->ring->emit_bb_start(req, so.ggtt_offset,
  				       I915_DISPATCH_SECURE);
  	if (ret)
  		goto out;
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 0b03b3a..1ff0ad1 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 243

Quoted 9 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -2
@@ -237,8 +237,7 @@ struct  intel_engine_cs {
  	int		(*emit_flush)(struct drm_i915_gem_request *request,
  				      u32 invalidate_domains,
  				      u32 flush_domains);
-	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
-					 struct intel_context *ctx,
+	int		(*emit_bb_start)(struct drm_i915_gem_request *req,
  					 u64 offset, unsigned dispatch_flags);
 
  	/**

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#204 lore raw

PATCH 44/53 drm/i915: Update ring->sync_to() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the ring->sync_to() implementations to take a request instead of a ring.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c         |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |    6 ++++--
 drivers/gpu/drm/i915/intel_ringbuffer.h |    4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 4f6e9ad..b5613ff 100644
@@ -2985,7 +2985,7 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj,
 		return ret;
 
 	trace_i915_gem_ring_sync_to(from, to, obj->last_read_req);
-	ret = to->semaphore.sync_to(to, from, seqno);
+	ret = to->semaphore.sync_to(to_req, from, seqno);
 	if (!ret)
 		/* We use last_read_req because sync_to()
 		 * might have just caused seqno wrap under
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -2
index 87612f1..767bab1 100644
@@ -1267,10 +1267,11 @@ static inline bool i915_gem_has_seqno_wrapped(struct drm_device *dev,
  */
 
 static int
-gen8_ring_sync(struct intel_engine_cs *waiter,
+gen8_ring_sync(struct drm_i915_gem_request *waiter_req,
 	       struct intel_engine_cs *signaller,
 	       u32 seqno)
 {
+	struct intel_engine_cs *waiter = waiter_req->ring;
 	struct drm_i915_private *dev_priv = waiter->dev->dev_private;
 	int ret;
 
@@ -1292,10 +1293,11 @@ gen8_ring_sync(struct intel_engine_cs *waiter,
 }
 
 static int
-gen6_ring_sync(struct intel_engine_cs *waiter,
+gen6_ring_sync(struct drm_i915_gem_request *waiter_req,
 	       struct intel_engine_cs *signaller,
 	       u32 seqno)
 {
+	struct intel_engine_cs *waiter = waiter_req->ring;
 	u32 dw1 = MI_SEMAPHORE_MBOX |
 		  MI_SEMAPHORE_COMPARE |
 		  MI_SEMAPHORE_REGISTER;
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index 1ff0ad1..65fe151 100644
@@ -219,8 +219,8 @@ struct  intel_engine_cs {
 		};
 
 		/* AKA wait() */
-		int	(*sync_to)(struct intel_engine_cs *ring,
-				   struct intel_engine_cs *to,
+		int	(*sync_to)(struct drm_i915_gem_request *to_req,
+				   struct intel_engine_cs *from,
 				   u32 seqno);
 		int	(*signal)(struct intel_engine_cs *signaller,
 				  /* num_dwords needed by caller */
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#205 lore raw

Re: [PATCH 44/53] drm/i915: Update ring->sync_to() to take a request structure

Quoted 17 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the ring->sync_to() implementations to take a request instead of a ring.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c         |    2 +-
  drivers/gpu/drm/i915/intel_ringbuffer.c |    6 ++++--
  drivers/gpu/drm/i915/intel_ringbuffer.h |    4 ++--
  3 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 4f6e9ad..b5613ff 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_object_sync(struct drm_i915_gem_object *obj, · line 2987

Quoted 3 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
@@ -2985,7 +2985,7 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj,
  		return ret;
 
  	trace_i915_gem_ring_sync_to(from, to, obj->last_read_req);

trace_i915_gem_ring_sync_to() still takes a ring as argument instead of a request. Do you want to change the trace function to reflect your changes?

Thanks,
Tomas

Quoted 41 lines
drivers/gpu/drm/i915/i915_gem.c +1 -1
-	ret = to->semaphore.sync_to(to, from, seqno);
+	ret = to->semaphore.sync_to(to_req, from, seqno);
  	if (!ret)
  		/* We use last_read_req because sync_to()
  		 * might have just caused seqno wrap under
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -2
index 87612f1..767bab1 100644
@@ -1267,10 +1267,11 @@ static inline bool i915_gem_has_seqno_wrapped(struct drm_device *dev,
   */
 
  static int
-gen8_ring_sync(struct intel_engine_cs *waiter,
+gen8_ring_sync(struct drm_i915_gem_request *waiter_req,
  	       struct intel_engine_cs *signaller,
  	       u32 seqno)
  {
+	struct intel_engine_cs *waiter = waiter_req->ring;
  	struct drm_i915_private *dev_priv = waiter->dev->dev_private;
  	int ret;
 
@@ -1292,10 +1293,11 @@ gen8_ring_sync(struct intel_engine_cs *waiter,
  }
 
  static int
-gen6_ring_sync(struct intel_engine_cs *waiter,
+gen6_ring_sync(struct drm_i915_gem_request *waiter_req,
  	       struct intel_engine_cs *signaller,
  	       u32 seqno)
  {
+	struct intel_engine_cs *waiter = waiter_req->ring;
  	u32 dw1 = MI_SEMAPHORE_MBOX |
  		  MI_SEMAPHORE_COMPARE |
  		  MI_SEMAPHORE_REGISTER;
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 1ff0ad1..65fe151 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 226

Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
@@ -219,8 +219,8 @@ struct  intel_engine_cs {
  		};
 
  		/* AKA wait() */
-		int	(*sync_to)(struct intel_engine_cs *ring,
-				   struct intel_engine_cs *to,
+		int	(*sync_to)(struct drm_i915_gem_request *to_req,
+				   struct intel_engine_cs *from,
  				   u32 seqno);
  		int	(*signal)(struct intel_engine_cs *signaller,
  				  /* num_dwords needed by caller */

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#206 lore raw

PATCH 45/53 drm/i915: Update ring->signal() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated the various ring->signal() implementations to take a request instead of a ring. This removes their reliance on the OLR to obtain the seqno value that should be used for the signal.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_ringbuffer.c |   20 ++++++++++----------
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +10 -10
index 767bab1..440356d 100644
@@ -1105,10 +1105,11 @@ static void render_ring_cleanup(struct intel_engine_cs *ring)
 	intel_fini_pipe_control(ring);
 }
 
-static int gen8_rcs_signal(struct intel_engine_cs *signaller,
+static int gen8_rcs_signal(struct drm_i915_gem_request *signaller_req,
 			   unsigned int num_dwords)
 {
 #define MBOX_UPDATE_DWORDS 8
+	struct intel_engine_cs *signaller = signaller_req->ring;
 	struct drm_device *dev = signaller->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *waiter;
@@ -1128,8 +1129,7 @@ static int gen8_rcs_signal(struct intel_engine_cs *signaller,
 		if (gtt_offset == MI_SEMAPHORE_SYNC_INVALID)
 			continue;
 
-		seqno = i915_gem_request_get_seqno(
-					   signaller->outstanding_lazy_request);
+		seqno = i915_gem_request_get_seqno(signaller_req);
 		intel_ring_emit(signaller, GFX_OP_PIPE_CONTROL(6));
 		intel_ring_emit(signaller, PIPE_CONTROL_GLOBAL_GTT_IVB |
 					   PIPE_CONTROL_QW_WRITE |
@@ -1146,10 +1146,11 @@ static int gen8_rcs_signal(struct intel_engine_cs *signaller,
 	return 0;
 }
 
-static int gen8_xcs_signal(struct intel_engine_cs *signaller,
+static int gen8_xcs_signal(struct drm_i915_gem_request *signaller_req,
 			   unsigned int num_dwords)
 {
 #define MBOX_UPDATE_DWORDS 6
+	struct intel_engine_cs *signaller = signaller_req->ring;
 	struct drm_device *dev = signaller->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *waiter;
@@ -1169,8 +1170,7 @@ static int gen8_xcs_signal(struct intel_engine_cs *signaller,
 		if (gtt_offset == MI_SEMAPHORE_SYNC_INVALID)
 			continue;
 
-		seqno = i915_gem_request_get_seqno(
-					   signaller->outstanding_lazy_request);
+		seqno = i915_gem_request_get_seqno(signaller_req);
 		intel_ring_emit(signaller, (MI_FLUSH_DW + 1) |
 					   MI_FLUSH_DW_OP_STOREDW);
 		intel_ring_emit(signaller, lower_32_bits(gtt_offset) |
@@ -1185,9 +1185,10 @@ static int gen8_xcs_signal(struct intel_engine_cs *signaller,
 	return 0;
 }
 
-static int gen6_signal(struct intel_engine_cs *signaller,
+static int gen6_signal(struct drm_i915_gem_request *signaller_req,
 		       unsigned int num_dwords)
 {
+	struct intel_engine_cs *signaller = signaller_req->ring;
 	struct drm_device *dev = signaller->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *useless;
@@ -1205,8 +1206,7 @@ static int gen6_signal(struct intel_engine_cs *signaller,
 	for_each_ring(useless, dev_priv, i) {
 		u32 mbox_reg = signaller->semaphore.mbox.signal[i];
 		if (mbox_reg != GEN6_NOSYNC) {
-			u32 seqno = i915_gem_request_get_seqno(
-					   signaller->outstanding_lazy_request);
+			u32 seqno = i915_gem_request_get_seqno(signaller_req);
 			intel_ring_emit(signaller, MI_LOAD_REGISTER_IMM(1));
 			intel_ring_emit(signaller, mbox_reg);
 			intel_ring_emit(signaller, seqno);
@@ -1235,7 +1235,7 @@ gen6_add_request(struct drm_i915_gem_request *req)
 	int ret;
 
 	if (ring->semaphore.signal)
-		ret = ring->semaphore.signal(ring, 4);
+		ret = ring->semaphore.signal(req, 4);
 	else
 		ret = intel_ring_begin(ring, 4);
 
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index 65fe151..7c1e0f5 100644
@@ -222,7 +222,7 @@ struct  intel_engine_cs {
 		int	(*sync_to)(struct drm_i915_gem_request *to_req,
 				   struct intel_engine_cs *from,
 				   u32 seqno);
-		int	(*signal)(struct intel_engine_cs *signaller,
+		int	(*signal)(struct drm_i915_gem_request *signaller_req,
 				  /* num_dwords needed by caller */
 				  unsigned int num_dwords);
 	} semaphore;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 45/53
#207 lore raw

Re: [PATCH 45/53] drm/i915: Update ring->signal() to take a request structure

Quoted 100 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated the various ring->signal() implementations to take a request instead of a ring. This removes their reliance on the OLR to obtain the seqno value that should be used for the signal.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_ringbuffer.c |   20 ++++++++++----------
  drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
  2 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +10 -10
index 767bab1..440356d 100644
@@ -1105,10 +1105,11 @@ static void render_ring_cleanup(struct intel_engine_cs *ring)
  	intel_fini_pipe_control(ring);
  }
 
-static int gen8_rcs_signal(struct intel_engine_cs *signaller,
+static int gen8_rcs_signal(struct drm_i915_gem_request *signaller_req,
  			   unsigned int num_dwords)
  {
  #define MBOX_UPDATE_DWORDS 8
+	struct intel_engine_cs *signaller = signaller_req->ring;
  	struct drm_device *dev = signaller->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_engine_cs *waiter;
@@ -1128,8 +1129,7 @@ static int gen8_rcs_signal(struct intel_engine_cs *signaller,
  		if (gtt_offset == MI_SEMAPHORE_SYNC_INVALID)
  			continue;
 
-		seqno = i915_gem_request_get_seqno(
-					   signaller->outstanding_lazy_request);
+		seqno = i915_gem_request_get_seqno(signaller_req);
  		intel_ring_emit(signaller, GFX_OP_PIPE_CONTROL(6));
  		intel_ring_emit(signaller, PIPE_CONTROL_GLOBAL_GTT_IVB |
  					   PIPE_CONTROL_QW_WRITE |
@@ -1146,10 +1146,11 @@ static int gen8_rcs_signal(struct intel_engine_cs *signaller,
  	return 0;
  }
 
-static int gen8_xcs_signal(struct intel_engine_cs *signaller,
+static int gen8_xcs_signal(struct drm_i915_gem_request *signaller_req,
  			   unsigned int num_dwords)
  {
  #define MBOX_UPDATE_DWORDS 6
+	struct intel_engine_cs *signaller = signaller_req->ring;
  	struct drm_device *dev = signaller->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_engine_cs *waiter;
@@ -1169,8 +1170,7 @@ static int gen8_xcs_signal(struct intel_engine_cs *signaller,
  		if (gtt_offset == MI_SEMAPHORE_SYNC_INVALID)
  			continue;
 
-		seqno = i915_gem_request_get_seqno(
-					   signaller->outstanding_lazy_request);
+		seqno = i915_gem_request_get_seqno(signaller_req);
  		intel_ring_emit(signaller, (MI_FLUSH_DW + 1) |
  					   MI_FLUSH_DW_OP_STOREDW);
  		intel_ring_emit(signaller, lower_32_bits(gtt_offset) |
@@ -1185,9 +1185,10 @@ static int gen8_xcs_signal(struct intel_engine_cs *signaller,
  	return 0;
  }
 
-static int gen6_signal(struct intel_engine_cs *signaller,
+static int gen6_signal(struct drm_i915_gem_request *signaller_req,
  		       unsigned int num_dwords)
  {
+	struct intel_engine_cs *signaller = signaller_req->ring;
  	struct drm_device *dev = signaller->dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_engine_cs *useless;
@@ -1205,8 +1206,7 @@ static int gen6_signal(struct intel_engine_cs *signaller,
  	for_each_ring(useless, dev_priv, i) {
  		u32 mbox_reg = signaller->semaphore.mbox.signal[i];
  		if (mbox_reg != GEN6_NOSYNC) {
-			u32 seqno = i915_gem_request_get_seqno(
-					   signaller->outstanding_lazy_request);
+			u32 seqno = i915_gem_request_get_seqno(signaller_req);
  			intel_ring_emit(signaller, MI_LOAD_REGISTER_IMM(1));
  			intel_ring_emit(signaller, mbox_reg);
  			intel_ring_emit(signaller, seqno);
@@ -1235,7 +1235,7 @@ gen6_add_request(struct drm_i915_gem_request *req)
  	int ret;
 
  	if (ring->semaphore.signal)
-		ret = ring->semaphore.signal(ring, 4);
+		ret = ring->semaphore.signal(req, 4);
  	else
  		ret = intel_ring_begin(ring, 4);
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 65fe151..7c1e0f5 100644

drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_engine_cs { · line 228

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -222,7 +222,7 @@ struct  intel_engine_cs {
  		int	(*sync_to)(struct drm_i915_gem_request *to_req,
  				   struct intel_engine_cs *from,
  				   u32 seqno);
-		int	(*signal)(struct intel_engine_cs *signaller,
+		int	(*signal)(struct drm_i915_gem_request *signaller_req,
  				  /* num_dwords needed by caller */
  				  unsigned int num_dwords);
  	} semaphore;

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#208 lore raw

PATCH 46/53 drm/i915: Update cacheline_align() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Updated intel_ring_cacheline_align() to take a request instead of a ring.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_display.c    |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |    3 ++-
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 9cbfb93..7962946 100644
@@ -9438,7 +9438,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 	 * then do the cacheline alignment, and finally emit the
 	 * MI_DISPLAY_FLIP.
 	 */
-	ret = intel_ring_cacheline_align(ring);
+	ret = intel_ring_cacheline_align(req);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -1
index 440356d..109f283 100644
@@ -2258,8 +2258,9 @@ int intel_ring_begin(struct intel_engine_cs *ring,
 }
 
 /* Align the ring tail to a cacheline boundary */
-int intel_ring_cacheline_align(struct intel_engine_cs *ring)
+int intel_ring_cacheline_align(struct drm_i915_gem_request *req)
 {
+	struct intel_engine_cs *ring = req->ring;
 	int num_dwords = (ring->buffer->tail & (CACHELINE_BYTES - 1)) / sizeof(uint32_t);
 	int ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index 7c1e0f5..80eb399 100644
@@ -387,7 +387,7 @@ void intel_stop_ring_buffer(struct intel_engine_cs *ring);
 void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
 
 int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
-int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
+int __must_check intel_ring_cacheline_align(struct drm_i915_gem_request *req);
 int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
 					  struct intel_context *ctx,
 					  struct drm_i915_gem_request **req_out);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 46/53
#209 lore raw

Re: [PATCH 46/53] drm/i915: Update cacheline_align() to take a request structure

Quoted 46 lines · On 19/02/2015 17:17, [email protected] wrote:

From: John Harrison <[email protected]>

Updated intel_ring_cacheline_align() to take a request instead of a ring.

For: VIZ-5115

---
  drivers/gpu/drm/i915/intel_display.c    |    2 +-
  drivers/gpu/drm/i915/intel_ringbuffer.c |    3 ++-
  drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
  3 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -1
index 9cbfb93..7962946 100644
@@ -9438,7 +9438,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
  	 * then do the cacheline alignment, and finally emit the
  	 * MI_DISPLAY_FLIP.
  	 */
-	ret = intel_ring_cacheline_align(ring);
+	ret = intel_ring_cacheline_align(req);
  	if (ret)
  		return ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -1
index 440356d..109f283 100644
@@ -2258,8 +2258,9 @@ int intel_ring_begin(struct intel_engine_cs *ring,
  }
 
  /* Align the ring tail to a cacheline boundary */
-int intel_ring_cacheline_align(struct intel_engine_cs *ring)
+int intel_ring_cacheline_align(struct drm_i915_gem_request *req)
  {
+	struct intel_engine_cs *ring = req->ring;
  	int num_dwords = (ring->buffer->tail & (CACHELINE_BYTES - 1)) / sizeof(uint32_t);
  	int ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
index 7c1e0f5..80eb399 100644

drivers/gpu/drm/i915/intel_ringbuffer.h void intel_stop_ring_buffer(struct intel_engine_cs *ring); · line 393

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -387,7 +387,7 @@ void intel_stop_ring_buffer(struct intel_engine_cs *ring);
  void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
 
  int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
-int __must_check intel_ring_cacheline_align(struct intel_engine_cs *ring);
+int __must_check intel_ring_cacheline_align(struct drm_i915_gem_request *req);
  int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
  					  struct intel_context *ctx,
  					  struct drm_i915_gem_request **req_out);

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#210 lore raw

PATCH 47/53 drm/i915: Update ironlake_enable_rc6() to do explicit request management

In reply to [email protected]

From: John Harrison <[email protected]>

Updated ironlake_enable_rc6() to do explicit request creation and submission.

v2: Fixed null context bug.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_pm.c |   31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +21 -10
index f7c9938..6594a52 100644
@@ -4985,6 +4985,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring = &dev_priv->ring[RCS];
+	struct drm_i915_gem_request *req = NULL;
 	bool was_interruptible;
 	int ret;
 
@@ -5003,16 +5004,17 @@ static void ironlake_enable_rc6(struct drm_device *dev)
 	was_interruptible = dev_priv->mm.interruptible;
 	dev_priv->mm.interruptible = false;
 
+	ret = dev_priv->gt.alloc_request(ring, ring->default_context, &req);
+	if (ret)
+		goto err;
+
 	/*
 	 * GPU can automatically power down the render unit if given a page
 	 * to save state.
 	 */
 	ret = intel_ring_begin(ring, 6);
-	if (ret) {
-		ironlake_teardown_rc6(dev);
-		dev_priv->mm.interruptible = was_interruptible;
-		return;
-	}
+	if (ret)
+		goto err;
 
 	intel_ring_emit(ring, MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
 	intel_ring_emit(ring, MI_SET_CONTEXT);
@@ -5026,6 +5028,11 @@ static void ironlake_enable_rc6(struct drm_device *dev)
 	intel_ring_emit(ring, MI_FLUSH);
 	intel_ring_advance(ring);
 
+	ret = i915_add_request_no_flush(req);
+	if (ret)
+		goto err;
+	req = NULL;
+
 	/*
 	 * Wait for the command parser to advance past MI_SET_CONTEXT. The HW
 	 * does an implicit flush, combined with MI_FLUSH above, it should be
@@ -5033,16 +5040,20 @@ static void ironlake_enable_rc6(struct drm_device *dev)
 	 */
 	ret = intel_ring_idle(ring);
 	dev_priv->mm.interruptible = was_interruptible;
-	if (ret) {
-		DRM_ERROR("failed to enable ironlake power savings\n");
-		ironlake_teardown_rc6(dev);
-		return;
-	}
+	if (ret)
+		goto err;
 
 	I915_WRITE(PWRCTXA, i915_gem_obj_ggtt_offset(dev_priv->ips.pwrctx) | PWRCTX_EN);
 	I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
 
 	intel_print_rc6_info(dev, GEN6_RC_CTL_RC6_ENABLE);
+
+err:
+	DRM_ERROR("failed to enable ironlake power savings\n");
+	ironlake_teardown_rc6(dev);
+	dev_priv->mm.interruptible = was_interruptible;
+	if (req)
+		i915_gem_request_unreference(req);
 }
 
 static unsigned long intel_pxfreq(u32 vidfreq)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#211 lore raw

PATCH 48/53 drm/i915: Update intel_ring_begin() to take a request structure

In reply to [email protected]

From: John Harrison <[email protected]>

Now that everything above has been converted to use requests, intel_ring_begin() can be updated to take a request instead of a ring. This also means that it no longer needs to lazily allocate a request if no-one happens to have done it earlier.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c            |    2 +-
 drivers/gpu/drm/i915/i915_gem_context.c    |    2 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    8 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.c        |    6 +--
 drivers/gpu/drm/i915/intel_display.c       |   10 ++--
 drivers/gpu/drm/i915/intel_overlay.c       |    8 ++--
 drivers/gpu/drm/i915/intel_pm.c            |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   72 +++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    2 +-
 9 files changed, 54 insertions(+), 58 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index b5613ff..60f6671 100644
@@ -4656,7 +4656,7 @@ int i915_gem_l3_remap(struct drm_i915_gem_request *req, int slice)
 	if (!HAS_L3_DPF(dev) || !remap_info)
 		return 0;
 
-	ret = intel_ring_begin(ring, GEN7_L3LOG_SIZE / 4 * 3);
+	ret = intel_ring_begin(req, GEN7_L3LOG_SIZE / 4 * 3);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 384f481..e348424 100644
@@ -503,7 +503,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
 	if (INTEL_INFO(ring->dev)->gen >= 7)
 		len += 2 + (num_rings ? 4*num_rings + 2 : 0);
 
-	ret = intel_ring_begin(ring, len);
+	ret = intel_ring_begin(req, len);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/i915_gem_execbuffer.c +4 -4
index 8b4f8a9..6a703e6 100644
@@ -1013,7 +1013,7 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	ret = intel_ring_begin(ring, 4 * 3);
+	ret = intel_ring_begin(req, 4 * 3);
 	if (ret)
 		return ret;
 
@@ -1044,7 +1044,7 @@ i915_emit_box(struct drm_i915_gem_request *req,
 	}
 
 	if (INTEL_INFO(ring->dev)->gen >= 4) {
-		ret = intel_ring_begin(ring, 4);
+		ret = intel_ring_begin(req, 4);
 		if (ret)
 			return ret;
 
@@ -1053,7 +1053,7 @@ i915_emit_box(struct drm_i915_gem_request *req,
 		intel_ring_emit(ring, ((box->x2 - 1) & 0xffff) | (box->y2 - 1) << 16);
 		intel_ring_emit(ring, DR4);
 	} else {
-		ret = intel_ring_begin(ring, 6);
+		ret = intel_ring_begin(req, 6);
 		if (ret)
 			return ret;
 
@@ -1235,7 +1235,7 @@ i915_gem_ringbuffer_submission(struct i915_execbuffer_params *params,
 
 	if (ring == &dev_priv->ring[RCS] &&
 			instp_mode != dev_priv->relative_constants_mode) {
-		ret = intel_ring_begin(ring, 4);
+		ret = intel_ring_begin(params->request, 4);
 		if (ret)
 			goto error;
 
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -3
index a1af644..0445278 100644
@@ -288,7 +288,7 @@ static int gen8_write_pdp(struct drm_i915_gem_request *req, unsigned entry,
 
 	BUG_ON(entry >= 4);
 
-	ret = intel_ring_begin(ring, 6);
+	ret = intel_ring_begin(req, 6);
 	if (ret)
 		return ret;
 
@@ -788,7 +788,7 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
 	if (ret)
 		return ret;
 
-	ret = intel_ring_begin(ring, 6);
+	ret = intel_ring_begin(req, 6);
 	if (ret)
 		return ret;
 
@@ -825,7 +825,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 	if (ret)
 		return ret;
 
-	ret = intel_ring_begin(ring, 6);
+	ret = intel_ring_begin(req, 6);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_display.c +5 -5
index 7962946..6901e9a 100644
@@ -9259,7 +9259,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
 	u32 flip_mask;
 	int ret;
 
-	ret = intel_ring_begin(ring, 6);
+	ret = intel_ring_begin(req, 6);
 	if (ret)
 		return ret;
 
@@ -9294,7 +9294,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
 	u32 flip_mask;
 	int ret;
 
-	ret = intel_ring_begin(ring, 6);
+	ret = intel_ring_begin(req, 6);
 	if (ret)
 		return ret;
 
@@ -9327,7 +9327,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
 	uint32_t pf, pipesrc;
 	int ret;
 
-	ret = intel_ring_begin(ring, 4);
+	ret = intel_ring_begin(req, 4);
 	if (ret)
 		return ret;
 
@@ -9366,7 +9366,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
 	uint32_t pf, pipesrc;
 	int ret;
 
-	ret = intel_ring_begin(ring, 4);
+	ret = intel_ring_begin(req, 4);
 	if (ret)
 		return ret;
 
@@ -9442,7 +9442,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	ret = intel_ring_begin(ring, len);
+	ret = intel_ring_begin(req, len);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_overlay.c +4 -4
index 228c9d1..1fb7653 100644
@@ -251,7 +251,7 @@ static int intel_overlay_on(struct intel_overlay *overlay)
 	if (ret)
 		return ret;
 
-	ret = intel_ring_begin(ring, 4);
+	ret = intel_ring_begin(req, 4);
 	if (ret) {
 		i915_gem_request_unreference(req);
 		return ret;
@@ -292,7 +292,7 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
 	if (ret)
 		return ret;
 
-	ret = intel_ring_begin(ring, 2);
+	ret = intel_ring_begin(req, 2);
 	if (ret) {
 		i915_gem_request_unreference(req);
 		return ret;
@@ -359,7 +359,7 @@ static int intel_overlay_off(struct intel_overlay *overlay)
 	if (ret)
 		return ret;
 
-	ret = intel_ring_begin(ring, 6);
+	ret = intel_ring_begin(req, 6);
 	if (ret) {
 		i915_gem_request_unreference(req);
 		return ret;
@@ -434,7 +434,7 @@ static int intel_overlay_release_old_vid(struct intel_overlay *overlay)
 		if (ret)
 			return ret;
 
-		ret = intel_ring_begin(ring, 2);
+		ret = intel_ring_begin(req, 2);
 		if (ret) {
 			i915_gem_request_unreference(req);
 			return ret;
drivers/gpu/drm/i915/intel_pm.c +1 -1
index 6594a52..cc22536 100644
@@ -5012,7 +5012,7 @@ static void ironlake_enable_rc6(struct drm_device *dev)
 	 * GPU can automatically power down the render unit if given a page
 	 * to save state.
 	 */
-	ret = intel_ring_begin(ring, 6);
+	ret = intel_ring_begin(req, 6);
 	if (ret)
 		goto err;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +34 -38

269 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index 80eb399..e83fbbb 100644
@@ -386,7 +386,7 @@ int intel_alloc_ringbuffer_obj(struct drm_device *dev,
 void intel_stop_ring_buffer(struct intel_engine_cs *ring);
 void intel_cleanup_ring_buffer(struct intel_engine_cs *ring);
 
-int __must_check intel_ring_begin(struct intel_engine_cs *ring, int n);
+int __must_check intel_ring_begin(struct drm_i915_gem_request *req, int n);
 int __must_check intel_ring_cacheline_align(struct drm_i915_gem_request *req);
 int __must_check intel_ring_alloc_request(struct intel_engine_cs *ring,
 					  struct intel_context *ctx,
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx