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 1 of 3

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

cover Remove the outstanding_lazy_request

From: John Harrison <[email protected]>

The driver tracks GPU work using request structures. Unfortunately, this tracking is not currently explicit but is done by means of a catch-all request that floats around in the background hoovering up work until it gets submitted. This background request (ring->outstanding_lazy_request or OLR) is created at the point of actually writing to the ring rather than when a particular piece of GPU work is started. This scheme sort of hangs together but causes a number of issues. It can mean that multiple pieces of independent work are lumped together in the same request or that work is not officially submitted until much later than it was created.

This patch series completely removes the OLR and explicitly tracks each piece of work with it's own personal request structure from start to submission.

The patch set seems to fix the "'gem_ringfill --r render' + ctrl-c straight after boot" issue logged as BZ:40112. I haven't done any analysis of that particular issue but the descriptions I've seen appear to blame an inconsistent or mangled OLR.

Note also that by the end of this series, a number of differences between the legacy and execlist code paths have been removed. For example add_request() and emit_request() now have the same signature thus could be merged back to a single function pointer. Merging some of these together would also allow the removal of a bunch of 'if(execlists)' tests where the difference is simply to call the legacy function or the execlist one.

[Patches against drm-intel-nightly tree fetched 03/02/2015]

John Harrison (51):
drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading drm/i915: Add missing trace point to LRC execbuff code path drm/i915: Cache ringbuf pointer in request structure
drm/i915: Merged the many do_execbuf() parameters into a structure drm/i915: Add return code check to i915_gem_execbuffer_retire_commands() drm/i915: Wrap request allocation with a function pointer drm/i915: Early alloc request in execbuff
drm/i915: Update alloc_request to return the allocated request drm/i915: Add request to execbuf params and add explicit cleanup drm/i915: Update the dispatch tracepoint to use params->request drm/i915: Update move_to_gpu() to take a request structure drm/i915: Update execbuffer_move_to_active() to take a request structure drm/i915: Add flag to i915_add_request() to skip the cache flush drm/i915: Update pin_to_display_plane() to do explicit request management drm/i915: Update i915_gem_object_sync() to take a request structure drm/i915: Update i915_gpu_idle() to manage its own request drm/i915: Split i915_ppgtt_init_hw() in half - generic and per ring drm/i915: Moved the for_each_ring loop outside of i915_gem_context_enable() drm/i915: Add explicit request management to i915_gem_init_hw() drm/i915: Update ppgtt_init_ring() & context_enable() to take requests drm/i915: Set context in request from creation even in legacy mode drm/i915: Update i915_switch_context() to take a request structure drm/i915: Update do_switch() to take a request structure drm/i915: Update deferred context creation to do explicit request management drm/i915: Update init_context() to take a request structure drm/i915: Update render_state_init() to take a request structure drm/i915: Update overlay code to do explicit request management drm/i915: Update queue_flip() to do explicit request management drm/i915: Update add_request() to take a request structure drm/i915: Update [vma|object]_move_to_active() to take request structures drm/i915: Update l3_remap to take a request structure
drm/i915: Update mi_set_context() to take a request structure drm/i915: Update a bunch of execbuffer heplers to take request structures drm/i915: Update workarounds_emit() to take request structures drm/i915: Update flush_all_caches() to take request structures drm/i915: Update switch_mm() to take a request structure drm/i915: Update ring->flush() to take a requests structure drm/i915: Update some flush helpers to take request structures drm/i915: Update ring->emit_flush() to take a request structure drm/i915: Update ring->add_request() to take a request structure drm/i915: Update ring->emit_request() to take a request structure drm/i915: Update ring->dispatch_execbuffer() to take a request structure drm/i915: Update ring->emit_bb_start() to take a request structure drm/i915: Update ring->sync_to() to take a request structure drm/i915: Update ring->signal() to take a request structure drm/i915: Update cacheline_align() to take a request structure drm/i915: Update ironlake_enable_rc6() to do explicit request management drm/i915: Update intel_ring_begin() to take a request structure drm/i915: Update intel_logical_ring_begin() to take a request structure drm/i915: Remove the now obsolete intel_ring_get_request() drm/i915: Remove the now obsolete 'outstanding_lazy_request'

 drivers/gpu/drm/i915/i915_drv.h              |   68 +++---
 drivers/gpu/drm/i915/i915_gem.c              |  207 +++++++++++--------
 drivers/gpu/drm/i915/i915_gem_context.c      |   76 +++----
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   |  138 ++++++++-----
 drivers/gpu/drm/i915/i915_gem_gtt.c          |   55 ++---
 drivers/gpu/drm/i915/i915_gem_gtt.h          |    3 +-
 drivers/gpu/drm/i915/i915_gem_render_state.c |   16 +-
 drivers/gpu/drm/i915/i915_gem_render_state.h |    2 +-
 drivers/gpu/drm/i915/intel_display.c         |   61 +++---
 drivers/gpu/drm/i915/intel_lrc.c             |  186 +++++++++--------
 drivers/gpu/drm/i915/intel_lrc.h             |   20 +-
 drivers/gpu/drm/i915/intel_overlay.c         |   64 ++++--
 drivers/gpu/drm/i915/intel_pm.c              |   33 ++-
 drivers/gpu/drm/i915/intel_ringbuffer.c      |  287 ++++++++++++++------------
 drivers/gpu/drm/i915/intel_ringbuffer.h      |   51 ++---
 15 files changed, 697 insertions(+), 570 deletions(-)
Signature · 6 lines
1.7.9.5

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

PATCH 1/51 drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading

From: John Harrison <[email protected]>

There is a flags word that is passed through the execbuffer code path all the way from initial decoding of the user parameters down to the very final dispatch buffer call. It is simply called 'flags'. Unfortuantely, there are many other flags words floating around in the same blocks of code. Even more once the GPU scheduler arrives.

This patch makes it more obvious exactly which flags word is which by renaming 'flags' to 'dispatch_flags'. Note that the bit definitions for this flags word already have an 'I915_DISPATCH_' prefix on them and so are not quite so ambiguous.

For: VIZ-1587

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   25 ++++++++++----------
 drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++----
 drivers/gpu/drm/i915/intel_lrc.h           |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   35 ++++++++++++++++------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ++--
 5 files changed, 41 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +13 -12
index b773368..ec9ea45 100644
@@ -1138,7 +1138,7 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_clip_rect *cliprects = NULL;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1266,19 +1266,19 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 
 			ret = ring->dispatch_execbuffer(ring,
 							exec_start, exec_len,
-							flags);
+							dispatch_flags);
 			if (ret)
 				goto error;
 		}
 	} else {
 		ret = ring->dispatch_execbuffer(ring,
 						exec_start, exec_len,
-						flags);
+						dispatch_flags);
 		if (ret)
 			return ret;
 	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), flags);
+	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);
@@ -1353,7 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct i915_address_space *vm;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
 	u64 exec_start = args->batch_start_offset;
-	u32 flags;
+	u32 dispatch_flags;
 	int ret;
 	bool need_relocs;
 
@@ -1364,15 +1364,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	flags = 0;
+	dispatch_flags = 0;
 	if (args->flags & I915_EXEC_SECURE) {
 		if (!file->is_master || !capable(CAP_SYS_ADMIN))
 		    return -EPERM;
 
-		flags |= I915_DISPATCH_SECURE;
+		dispatch_flags |= I915_DISPATCH_SECURE;
 	}
 	if (args->flags & I915_EXEC_IS_PINNED)
-		flags |= I915_DISPATCH_PINNED;
+		dispatch_flags |= I915_DISPATCH_PINNED;
 
 	if ((args->flags & I915_EXEC_RING_MASK) > LAST_USER_RING) {
 		DRM_DEBUG("execbuf with unknown ring: %d\n",
@@ -1495,7 +1495,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 						      args->batch_start_offset,
 						      args->batch_len,
 						      file->is_master,
-						      &flags);
+						      &dispatch_flags);
 		if (IS_ERR(batch_obj)) {
 			ret = PTR_ERR(batch_obj);
 			goto err;
@@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	/* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
 	 * batch" bit. Hence we need to pin secure batches into the global gtt.
 	 * hsw should have this fixed, but bdw mucks it up again. */
-	if (flags & I915_DISPATCH_SECURE) {
+	if (dispatch_flags & I915_DISPATCH_SECURE) {
 		/*
 		 * So on first glance it looks freaky that we pin the batch here
 		 * outside of the reservation loop. But:
@@ -1527,7 +1527,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		exec_start += i915_gem_obj_offset(batch_obj, vm);
 
 	ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-				      &eb->vmas, batch_obj, exec_start, flags);
+				      &eb->vmas, batch_obj, exec_start,
+				      dispatch_flags);
 
 	/*
 	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
@@ -1535,7 +1536,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	 * needs to be adjusted to also track the ggtt batch vma properly as
 	 * active.
 	 */
-	if (flags & I915_DISPATCH_SECURE)
+	if (dispatch_flags & I915_DISPATCH_SECURE)
 		i915_gem_object_ggtt_unpin(batch_obj);
 err:
 	/* the request owns the ref now */
drivers/gpu/drm/i915/intel_lrc.c +5 -5
index a94346f..0376285 100644
@@ -611,7 +611,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  * @vmas: list of vmas.
  * @batch_obj: the batchbuffer to submit.
  * @exec_start: batchbuffer start virtual address pointer.
- * @flags: translated execbuffer call flags.
+ * @dispatch_flags: translated execbuffer call flags.
  *
  * This is the evil twin version of i915_gem_ringbuffer_submission. It abstracts
  * away the submission details of the execbuffer ioctl call.
@@ -624,7 +624,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
@@ -697,7 +697,7 @@ 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, flags);
+	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
 	if (ret)
 		return ret;
 
@@ -1142,9 +1142,9 @@ static int gen8_init_render_ring(struct intel_engine_cs *ring)
 
 static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
 			      struct intel_context *ctx,
-			      u64 offset, unsigned flags)
+			      u64 offset, unsigned dispatch_flags)
 {
-	bool ppgtt = !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
 	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
drivers/gpu/drm/i915/intel_lrc.h +1 -1
index 6f2d7da..3093836 100644
@@ -86,7 +86,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags);
+			       u64 exec_start, u32 dispatch_flags);
 u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
 void intel_lrc_irq_handler(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -15
index 0bd3976..d611608 100644
@@ -1611,7 +1611,7 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
 static int
 i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 length,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
 
@@ -1622,7 +1622,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
 			MI_BATCH_GTT |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
 
@@ -1635,8 +1636,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
 static int
 i830_dispatch_execbuffer(struct intel_engine_cs *ring,
-				u64 offset, u32 len,
-				unsigned flags)
+			 u64 offset, u32 len,
+			 unsigned dispatch_flags)
 {
 	u32 cs_offset = ring->scratch.gtt_offset;
 	int ret;
@@ -1654,7 +1655,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
 
-	if ((flags & I915_DISPATCH_PINNED) == 0) {
+	if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) {
 		if (len > I830_BATCH_LIMIT)
 			return -ENOSPC;
 
@@ -1686,7 +1687,8 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 
 	intel_ring_emit(ring, MI_BATCH_BUFFER);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_emit(ring, offset + len - 8);
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
@@ -1697,7 +1699,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 len,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
 
@@ -1706,7 +1708,8 @@ i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 
 	intel_ring_emit(ring, MI_BATCH_BUFFER_START | MI_BATCH_GTT);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_advance(ring);
 
 	return 0;
@@ -2265,9 +2268,10 @@ static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
 static int
 gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
-	bool ppgtt = USES_PPGTT(ring->dev) && !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = USES_PPGTT(ring->dev) &&
+			!(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
 	ret = intel_ring_begin(ring, 4);
@@ -2286,8 +2290,8 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 static int
 hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
-			      u64 offset, u32 len,
-			      unsigned flags)
+			     u64 offset, u32 len,
+			     unsigned dispatch_flags)
 {
 	int ret;
 
@@ -2297,7 +2301,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ?
+			(dispatch_flags & I915_DISPATCH_SECURE ?
 			 0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
@@ -2309,7 +2313,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
 	int ret;
 
@@ -2319,7 +2323,8 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index 714f3fd..26e5774 100644
@@ -164,7 +164,7 @@ struct  intel_engine_cs {
 				     u32 seqno);
 	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
 					       u64 offset, u32 length,
-					       unsigned flags);
+					       unsigned dispatch_flags);
 #define I915_DISPATCH_SECURE 0x1
 #define I915_DISPATCH_PINNED 0x2
 	void		(*cleanup)(struct intel_engine_cs *ring);
@@ -242,7 +242,7 @@ struct  intel_engine_cs {
 				      u32 flush_domains);
 	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
 					 struct intel_context *ctx,
-					 u64 offset, unsigned flags);
+					 u64 offset, unsigned dispatch_flags);
 
 	/**
 	 * List of objects currently involved in rendering from the
Signature · 6 lines
1.7.9.5

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

Re: [PATCH 01/51] drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading

Quoted 8 lines · On Fri, Feb 13, 2015 at 11:48:10AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

There is a flags word that is passed through the execbuffer code path all the way from initial decoding of the user parameters down to the very final dispatch buffer call. It is simply called 'flags'. Unfortuantely, there are many other flags words floating around in the same blocks of code. Even more once the GPU scheduler arrives.

Quoted 6 lines

This patch makes it more obvious exactly which flags word is which by renaming 'flags' to 'dispatch_flags'. Note that the bit definitions for this flags word already have an 'I915_DISPATCH_' prefix on them and so are not quite so ambiguous.

For: VIZ-1587

I've thought we've decided that the tag is OTC-Jira or similar. For:
certainly looks a bit too generic, and a prefix helps in namespacing if you want to scan with automated tools for this.

Quoted 1 line

Anyway looks like a good idea, queued for -next, thanks for the patch. -Daniel

Quoted 318 lines
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   25 ++++++++++----------
 drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++----
 drivers/gpu/drm/i915/intel_lrc.h           |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   35 ++++++++++++++++------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ++--
 5 files changed, 41 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +13 -12
index b773368..ec9ea45 100644
@@ -1138,7 +1138,7 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_clip_rect *cliprects = NULL;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1266,19 +1266,19 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 
 			ret = ring->dispatch_execbuffer(ring,
 							exec_start, exec_len,
-							flags);
+							dispatch_flags);
 			if (ret)
 				goto error;
 		}
 	} else {
 		ret = ring->dispatch_execbuffer(ring,
 						exec_start, exec_len,
-						flags);
+						dispatch_flags);
 		if (ret)
 			return ret;
 	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), flags);
+	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);
@@ -1353,7 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct i915_address_space *vm;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
 	u64 exec_start = args->batch_start_offset;
-	u32 flags;
+	u32 dispatch_flags;
 	int ret;
 	bool need_relocs;
 
@@ -1364,15 +1364,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	flags = 0;
+	dispatch_flags = 0;
 	if (args->flags & I915_EXEC_SECURE) {
 		if (!file->is_master || !capable(CAP_SYS_ADMIN))
 		    return -EPERM;
 
-		flags |= I915_DISPATCH_SECURE;
+		dispatch_flags |= I915_DISPATCH_SECURE;
 	}
 	if (args->flags & I915_EXEC_IS_PINNED)
-		flags |= I915_DISPATCH_PINNED;
+		dispatch_flags |= I915_DISPATCH_PINNED;
 
 	if ((args->flags & I915_EXEC_RING_MASK) > LAST_USER_RING) {
 		DRM_DEBUG("execbuf with unknown ring: %d\n",
@@ -1495,7 +1495,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 						      args->batch_start_offset,
 						      args->batch_len,
 						      file->is_master,
-						      &flags);
+						      &dispatch_flags);
 		if (IS_ERR(batch_obj)) {
 			ret = PTR_ERR(batch_obj);
 			goto err;
@@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	/* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
 	 * batch" bit. Hence we need to pin secure batches into the global gtt.
 	 * hsw should have this fixed, but bdw mucks it up again. */
-	if (flags & I915_DISPATCH_SECURE) {
+	if (dispatch_flags & I915_DISPATCH_SECURE) {
 		/*
 		 * So on first glance it looks freaky that we pin the batch here
 		 * outside of the reservation loop. But:
@@ -1527,7 +1527,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		exec_start += i915_gem_obj_offset(batch_obj, vm);
 
 	ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-				      &eb->vmas, batch_obj, exec_start, flags);
+				      &eb->vmas, batch_obj, exec_start,
+				      dispatch_flags);
 
 	/*
 	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
@@ -1535,7 +1536,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	 * needs to be adjusted to also track the ggtt batch vma properly as
 	 * active.
 	 */
-	if (flags & I915_DISPATCH_SECURE)
+	if (dispatch_flags & I915_DISPATCH_SECURE)
 		i915_gem_object_ggtt_unpin(batch_obj);
 err:
 	/* the request owns the ref now */
drivers/gpu/drm/i915/intel_lrc.c +5 -5
index a94346f..0376285 100644
@@ -611,7 +611,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  * @vmas: list of vmas.
  * @batch_obj: the batchbuffer to submit.
  * @exec_start: batchbuffer start virtual address pointer.
- * @flags: translated execbuffer call flags.
+ * @dispatch_flags: translated execbuffer call flags.
  *
  * This is the evil twin version of i915_gem_ringbuffer_submission. It abstracts
  * away the submission details of the execbuffer ioctl call.
@@ -624,7 +624,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
@@ -697,7 +697,7 @@ 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, flags);
+	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
 	if (ret)
 		return ret;
 
@@ -1142,9 +1142,9 @@ static int gen8_init_render_ring(struct intel_engine_cs *ring)
 
 static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
 			      struct intel_context *ctx,
-			      u64 offset, unsigned flags)
+			      u64 offset, unsigned dispatch_flags)
 {
-	bool ppgtt = !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
 	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
drivers/gpu/drm/i915/intel_lrc.h +1 -1
index 6f2d7da..3093836 100644
@@ -86,7 +86,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags);
+			       u64 exec_start, u32 dispatch_flags);
 u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
 void intel_lrc_irq_handler(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -15
index 0bd3976..d611608 100644
@@ -1611,7 +1611,7 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
 static int
 i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 length,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
 
@@ -1622,7 +1622,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
 			MI_BATCH_GTT |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
 
@@ -1635,8 +1636,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
 static int
 i830_dispatch_execbuffer(struct intel_engine_cs *ring,
-				u64 offset, u32 len,
-				unsigned flags)
+			 u64 offset, u32 len,
+			 unsigned dispatch_flags)
 {
 	u32 cs_offset = ring->scratch.gtt_offset;
 	int ret;
@@ -1654,7 +1655,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
 
-	if ((flags & I915_DISPATCH_PINNED) == 0) {
+	if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) {
 		if (len > I830_BATCH_LIMIT)
 			return -ENOSPC;
 
@@ -1686,7 +1687,8 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 
 	intel_ring_emit(ring, MI_BATCH_BUFFER);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_emit(ring, offset + len - 8);
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
@@ -1697,7 +1699,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 len,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
 
@@ -1706,7 +1708,8 @@ i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 
 	intel_ring_emit(ring, MI_BATCH_BUFFER_START | MI_BATCH_GTT);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_advance(ring);
 
 	return 0;
@@ -2265,9 +2268,10 @@ static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
 static int
 gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
-	bool ppgtt = USES_PPGTT(ring->dev) && !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = USES_PPGTT(ring->dev) &&
+			!(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
 	ret = intel_ring_begin(ring, 4);
@@ -2286,8 +2290,8 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 static int
 hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
-			      u64 offset, u32 len,
-			      unsigned flags)
+			     u64 offset, u32 len,
+			     unsigned dispatch_flags)
 {
 	int ret;
 
@@ -2297,7 +2301,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ?
+			(dispatch_flags & I915_DISPATCH_SECURE ?
 			 0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
@@ -2309,7 +2313,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
 	int ret;
 
@@ -2319,7 +2323,8 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index 714f3fd..26e5774 100644
@@ -164,7 +164,7 @@ struct  intel_engine_cs {
 				     u32 seqno);
 	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
 					       u64 offset, u32 length,
-					       unsigned flags);
+					       unsigned dispatch_flags);
 #define I915_DISPATCH_SECURE 0x1
 #define I915_DISPATCH_PINNED 0x2
 	void		(*cleanup)(struct intel_engine_cs *ring);
@@ -242,7 +242,7 @@ struct  intel_engine_cs {
 				      u32 flush_domains);
 	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
 					 struct intel_context *ctx,
-					 u64 offset, unsigned flags);
+					 u64 offset, unsigned dispatch_flags);
 
 	/**
 	 * List of objects currently involved in rendering from the
Signature · 6 lines
1.7.9.5

_______________________________________________
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
#3 lore raw

Re: [PATCH 01/51] drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading

Quoted 14 lines · Daniel Vetter
Quoted 13 lines · On Fri, Feb 13, 2015 at 11:48:10AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

There is a flags word that is passed through the execbuffer code path all the way from initial decoding of the user parameters down to the very final dispatch buffer call. It is simply called 'flags'. Unfortuantely, there are many other flags words floating around in the same blocks of code. Even more once the GPU scheduler arrives.

This patch makes it more obvious exactly which flags word is which by renaming 'flags' to 'dispatch_flags'. Note that the bit definitions for this flags word already have an 'I915_DISPATCH_' prefix on them and so are not quite so ambiguous.

Quoted 4 lines
Quoted 1 line

For: VIZ-1587

I've thought we've decided that the tag is OTC-Jira or similar. For:
certainly looks a bit too generic, and a prefix helps in namespacing if you want to scan with automated tools for this.

The wiki page about GMIN tagging (which comes from the OTC) very clearly says to use 'For:' in the case of multi-patch series or 'Issue:' for single patches and talks about automated tools using these tags to update and/or close bugs. It also says the tags should be used for linux kernel upstreaming as well.

Quoted 318 lines
Quoted 2 lines

Anyway looks like a good idea, queued for -next, thanks for the patch. -Daniel

Quoted 314 lines
---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   25 ++++++++++----------
  drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    2 +-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   35 ++++++++++++++++------------
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ++--
  5 files changed, 41 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +13 -12
index b773368..ec9ea45 100644
@@ -1138,7 +1138,7 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
  			       struct drm_i915_gem_execbuffer2 *args,
  			       struct list_head *vmas,
  			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
  {
  	struct drm_clip_rect *cliprects = NULL;
  	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1266,19 +1266,19 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 
  			ret = ring->dispatch_execbuffer(ring,
  							exec_start, exec_len,
-							flags);
+							dispatch_flags);
  			if (ret)
  				goto error;
  		}
  	} else {
  		ret = ring->dispatch_execbuffer(ring,
  						exec_start, exec_len,
-						flags);
+						dispatch_flags);
  		if (ret)
  			return ret;
  	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), flags);
+	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);
@@ -1353,7 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	struct i915_address_space *vm;
  	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
  	u64 exec_start = args->batch_start_offset;
-	u32 flags;
+	u32 dispatch_flags;
  	int ret;
  	bool need_relocs;
 
@@ -1364,15 +1364,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	if (ret)
  		return ret;
 
-	flags = 0;
+	dispatch_flags = 0;
  	if (args->flags & I915_EXEC_SECURE) {
  		if (!file->is_master || !capable(CAP_SYS_ADMIN))
  		    return -EPERM;
 
-		flags |= I915_DISPATCH_SECURE;
+		dispatch_flags |= I915_DISPATCH_SECURE;
  	}
  	if (args->flags & I915_EXEC_IS_PINNED)
-		flags |= I915_DISPATCH_PINNED;
+		dispatch_flags |= I915_DISPATCH_PINNED;
 
  	if ((args->flags & I915_EXEC_RING_MASK) > LAST_USER_RING) {
  		DRM_DEBUG("execbuf with unknown ring: %d\n",
@@ -1495,7 +1495,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  						      args->batch_start_offset,
  						      args->batch_len,
  						      file->is_master,
-						      &flags);
+						      &dispatch_flags);
  		if (IS_ERR(batch_obj)) {
  			ret = PTR_ERR(batch_obj);
  			goto err;
@@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	/* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
  	 * batch" bit. Hence we need to pin secure batches into the global gtt.
  	 * hsw should have this fixed, but bdw mucks it up again. */
-	if (flags & I915_DISPATCH_SECURE) {
+	if (dispatch_flags & I915_DISPATCH_SECURE) {
  		/*
  		 * So on first glance it looks freaky that we pin the batch here
  		 * outside of the reservation loop. But:
@@ -1527,7 +1527,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  		exec_start += i915_gem_obj_offset(batch_obj, vm);
 
  	ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-				      &eb->vmas, batch_obj, exec_start, flags);
+				      &eb->vmas, batch_obj, exec_start,
+				      dispatch_flags);
 
  	/*
  	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
@@ -1535,7 +1536,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	 * needs to be adjusted to also track the ggtt batch vma properly as
  	 * active.
  	 */
-	if (flags & I915_DISPATCH_SECURE)
+	if (dispatch_flags & I915_DISPATCH_SECURE)
  		i915_gem_object_ggtt_unpin(batch_obj);
  err:
  	/* the request owns the ref now */
drivers/gpu/drm/i915/intel_lrc.c +5 -5
index a94346f..0376285 100644
@@ -611,7 +611,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
   * @vmas: list of vmas.
   * @batch_obj: the batchbuffer to submit.
   * @exec_start: batchbuffer start virtual address pointer.
- * @flags: translated execbuffer call flags.
+ * @dispatch_flags: translated execbuffer call flags.
   *
   * This is the evil twin version of i915_gem_ringbuffer_submission. It abstracts
   * away the submission details of the execbuffer ioctl call.
@@ -624,7 +624,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
  			       struct drm_i915_gem_execbuffer2 *args,
  			       struct list_head *vmas,
  			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
  {
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
@@ -697,7 +697,7 @@ 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, flags);
+	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
  	if (ret)
  		return ret;
 
@@ -1142,9 +1142,9 @@ static int gen8_init_render_ring(struct intel_engine_cs *ring)
 
  static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
  			      struct intel_context *ctx,
-			      u64 offset, unsigned flags)
+			      u64 offset, unsigned dispatch_flags)
  {
-	bool ppgtt = !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
  	int ret;
 
  	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
drivers/gpu/drm/i915/intel_lrc.h +1 -1
index 6f2d7da..3093836 100644
@@ -86,7 +86,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
  			       struct drm_i915_gem_execbuffer2 *args,
  			       struct list_head *vmas,
  			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags);
+			       u64 exec_start, u32 dispatch_flags);
  u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
  void intel_lrc_irq_handler(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -15
index 0bd3976..d611608 100644
@@ -1611,7 +1611,7 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
  static int
  i965_dispatch_execbuffer(struct intel_engine_cs *ring,
  			 u64 offset, u32 length,
-			 unsigned flags)
+			 unsigned dispatch_flags)
  {
  	int ret;
 
@@ -1622,7 +1622,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
  	intel_ring_emit(ring,
  			MI_BATCH_BUFFER_START |
  			MI_BATCH_GTT |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
  	intel_ring_emit(ring, offset);
  	intel_ring_advance(ring);
 
@@ -1635,8 +1636,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
  #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
  static int
  i830_dispatch_execbuffer(struct intel_engine_cs *ring,
-				u64 offset, u32 len,
-				unsigned flags)
+			 u64 offset, u32 len,
+			 unsigned dispatch_flags)
  {
  	u32 cs_offset = ring->scratch.gtt_offset;
  	int ret;
@@ -1654,7 +1655,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
  	intel_ring_emit(ring, MI_NOOP);
  	intel_ring_advance(ring);
 
-	if ((flags & I915_DISPATCH_PINNED) == 0) {
+	if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) {
  		if (len > I830_BATCH_LIMIT)
  			return -ENOSPC;
 
@@ -1686,7 +1687,8 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
  		return ret;
 
  	intel_ring_emit(ring, MI_BATCH_BUFFER);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
  	intel_ring_emit(ring, offset + len - 8);
  	intel_ring_emit(ring, MI_NOOP);
  	intel_ring_advance(ring);
@@ -1697,7 +1699,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
  static int
  i915_dispatch_execbuffer(struct intel_engine_cs *ring,
  			 u64 offset, u32 len,
-			 unsigned flags)
+			 unsigned dispatch_flags)
  {
  	int ret;
 
@@ -1706,7 +1708,8 @@ i915_dispatch_execbuffer(struct intel_engine_cs *ring,
  		return ret;
 
  	intel_ring_emit(ring, MI_BATCH_BUFFER_START | MI_BATCH_GTT);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
  	intel_ring_advance(ring);
 
  	return 0;
@@ -2265,9 +2268,10 @@ static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
  static int
  gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
  {
-	bool ppgtt = USES_PPGTT(ring->dev) && !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = USES_PPGTT(ring->dev) &&
+			!(dispatch_flags & I915_DISPATCH_SECURE);
  	int ret;
 
  	ret = intel_ring_begin(ring, 4);
@@ -2286,8 +2290,8 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
  static int
  hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
-			      u64 offset, u32 len,
-			      unsigned flags)
+			     u64 offset, u32 len,
+			     unsigned dispatch_flags)
  {
  	int ret;
 
@@ -2297,7 +2301,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
  	intel_ring_emit(ring,
  			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ?
+			(dispatch_flags & I915_DISPATCH_SECURE ?
  			 0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW));
  	/* bit0-7 is the length on GEN6+ */
  	intel_ring_emit(ring, offset);
@@ -2309,7 +2313,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  static int
  gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
  {
  	int ret;
 
@@ -2319,7 +2323,8 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
  	intel_ring_emit(ring,
  			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
  	/* bit0-7 is the length on GEN6+ */
  	intel_ring_emit(ring, offset);
  	intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index 714f3fd..26e5774 100644
@@ -164,7 +164,7 @@ struct  intel_engine_cs {
  				     u32 seqno);
  	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
  					       u64 offset, u32 length,
-					       unsigned flags);
+					       unsigned dispatch_flags);
  #define I915_DISPATCH_SECURE 0x1
  #define I915_DISPATCH_PINNED 0x2
  	void		(*cleanup)(struct intel_engine_cs *ring);
@@ -242,7 +242,7 @@ struct  intel_engine_cs {
  				      u32 flush_domains);
  	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
  					 struct intel_context *ctx,
-					 u64 offset, unsigned flags);
+					 u64 offset, unsigned dispatch_flags);
 
  	/**
  	 * List of objects currently involved in rendering from the
Signature · 1 line
1.7.9.5
Quoted 4 lines
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

#4 lore raw

Re: [PATCH 01/51] drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading

Quoted 20 lines · John Harrison
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · On Fri, Feb 13, 2015 at 11:48:10AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

There is a flags word that is passed through the execbuffer code path all the way from initial decoding of the user parameters down to the very final dispatch buffer call. It is simply called 'flags'. Unfortuantely, there are many other flags words floating around in the same blocks of code. Even more once the GPU scheduler arrives.

This patch makes it more obvious exactly which flags word is which by renaming 'flags' to 'dispatch_flags'. Note that the bit definitions for this flags word already have an 'I915_DISPATCH_' prefix on them and so are not quite so ambiguous.

Quoted 4 lines
Quoted 1 line

For: VIZ-1587

I've thought we've decided that the tag is OTC-Jira or similar. For:
certainly looks a bit too generic, and a prefix helps in namespacing if you want to scan with automated tools for this.

Quoted 5 lines

The wiki page about GMIN tagging (which comes from the OTC) very clearly says to use 'For:' in the case of multi-patch series or 'Issue:' for single patches and talks about automated tools using these tags to update and/or close bugs. It also says the tags should be used for linux kernel upstreaming as well.

Well I guess that wasn't a very nice decision to make without the namespacing ... Whom do I need to send a mail to to make a fuzz about this? I really don't think For: and Issue: are really great ideas for tags to internal tracking when we're supposed to add them to the public git repo.

Maybe just add them all to cc on this thread.
-Daniel

Quoted 296 lines
Quoted 295 lines
Quoted 4 lines

Anyway looks like a good idea, queued for -next, thanks for the patch. -Daniel

Quoted 289 lines
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   25 ++++++++++----------
 drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++----
 drivers/gpu/drm/i915/intel_lrc.h           |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   35 ++++++++++++++++------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ++--
 5 files changed, 41 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +13 -12
index b773368..ec9ea45 100644
@@ -1138,7 +1138,7 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_clip_rect *cliprects = NULL;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1266,19 +1266,19 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 			ret = ring->dispatch_execbuffer(ring,
 							exec_start, exec_len,
-							flags);
+							dispatch_flags);
 			if (ret)
 				goto error;
 		}
 	} else {
 		ret = ring->dispatch_execbuffer(ring,
 						exec_start, exec_len,
-						flags);
+						dispatch_flags);
 		if (ret)
 			return ret;
 	}
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), flags);
+	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);
@@ -1353,7 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct i915_address_space *vm;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
 	u64 exec_start = args->batch_start_offset;
-	u32 flags;
+	u32 dispatch_flags;
 	int ret;
 	bool need_relocs;
@@ -1364,15 +1364,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
-	flags = 0;
+	dispatch_flags = 0;
 	if (args->flags & I915_EXEC_SECURE) {
 		if (!file->is_master || !capable(CAP_SYS_ADMIN))
 		    return -EPERM;
-		flags |= I915_DISPATCH_SECURE;
+		dispatch_flags |= I915_DISPATCH_SECURE;
 	}
 	if (args->flags & I915_EXEC_IS_PINNED)
-		flags |= I915_DISPATCH_PINNED;
+		dispatch_flags |= I915_DISPATCH_PINNED;
 	if ((args->flags & I915_EXEC_RING_MASK) > LAST_USER_RING) {
 		DRM_DEBUG("execbuf with unknown ring: %d\n",
@@ -1495,7 +1495,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 						      args->batch_start_offset,
 						      args->batch_len,
 						      file->is_master,
-						      &flags);
+						      &dispatch_flags);
 		if (IS_ERR(batch_obj)) {
 			ret = PTR_ERR(batch_obj);
 			goto err;
@@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	/* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
 	 * batch" bit. Hence we need to pin secure batches into the global gtt.
 	 * hsw should have this fixed, but bdw mucks it up again. */
-	if (flags & I915_DISPATCH_SECURE) {
+	if (dispatch_flags & I915_DISPATCH_SECURE) {
 		/*
 		 * So on first glance it looks freaky that we pin the batch here
 		 * outside of the reservation loop. But:
@@ -1527,7 +1527,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		exec_start += i915_gem_obj_offset(batch_obj, vm);
 	ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-				      &eb->vmas, batch_obj, exec_start, flags);
+				      &eb->vmas, batch_obj, exec_start,
+				      dispatch_flags);
 	/*
 	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
@@ -1535,7 +1536,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	 * needs to be adjusted to also track the ggtt batch vma properly as
 	 * active.
 	 */
-	if (flags & I915_DISPATCH_SECURE)
+	if (dispatch_flags & I915_DISPATCH_SECURE)
 		i915_gem_object_ggtt_unpin(batch_obj);
 err:
 	/* the request owns the ref now */
drivers/gpu/drm/i915/intel_lrc.c +5 -5
index a94346f..0376285 100644
@@ -611,7 +611,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  * @vmas: list of vmas.
  * @batch_obj: the batchbuffer to submit.
  * @exec_start: batchbuffer start virtual address pointer.
- * @flags: translated execbuffer call flags.
+ * @dispatch_flags: translated execbuffer call flags.
  *
  * This is the evil twin version of i915_gem_ringbuffer_submission. It abstracts
  * away the submission details of the execbuffer ioctl call.
@@ -624,7 +624,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
@@ -697,7 +697,7 @@ 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, flags);
+	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
 	if (ret)
 		return ret;
@@ -1142,9 +1142,9 @@ static int gen8_init_render_ring(struct intel_engine_cs *ring)
 static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
 			      struct intel_context *ctx,
-			      u64 offset, unsigned flags)
+			      u64 offset, unsigned dispatch_flags)
 {
-	bool ppgtt = !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
drivers/gpu/drm/i915/intel_lrc.h +1 -1
index 6f2d7da..3093836 100644
@@ -86,7 +86,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags);
+			       u64 exec_start, u32 dispatch_flags);
 u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 void intel_lrc_irq_handler(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -15
index 0bd3976..d611608 100644
@@ -1611,7 +1611,7 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
 static int
 i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 length,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
@@ -1622,7 +1622,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
 			MI_BATCH_GTT |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
@@ -1635,8 +1636,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
 static int
 i830_dispatch_execbuffer(struct intel_engine_cs *ring,
-				u64 offset, u32 len,
-				unsigned flags)
+			 u64 offset, u32 len,
+			 unsigned dispatch_flags)
 {
 	u32 cs_offset = ring->scratch.gtt_offset;
 	int ret;
@@ -1654,7 +1655,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
-	if ((flags & I915_DISPATCH_PINNED) == 0) {
+	if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) {
 		if (len > I830_BATCH_LIMIT)
 			return -ENOSPC;
@@ -1686,7 +1687,8 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 	intel_ring_emit(ring, MI_BATCH_BUFFER);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_emit(ring, offset + len - 8);
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
@@ -1697,7 +1699,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 len,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
@@ -1706,7 +1708,8 @@ i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 	intel_ring_emit(ring, MI_BATCH_BUFFER_START | MI_BATCH_GTT);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_advance(ring);
 	return 0;
@@ -2265,9 +2268,10 @@ static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
 static int
 gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
-	bool ppgtt = USES_PPGTT(ring->dev) && !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = USES_PPGTT(ring->dev) &&
+			!(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 	ret = intel_ring_begin(ring, 4);
@@ -2286,8 +2290,8 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
-			      u64 offset, u32 len,
-			      unsigned flags)
+			     u64 offset, u32 len,
+			     unsigned dispatch_flags)
 {
 	int ret;
@@ -2297,7 +2301,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ?
+			(dispatch_flags & I915_DISPATCH_SECURE ?
 			 0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
@@ -2309,7 +2313,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
 	int ret;
@@ -2319,7 +2323,8 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index 714f3fd..26e5774 100644
@@ -164,7 +164,7 @@ struct  intel_engine_cs {
 				     u32 seqno);
 	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
 					       u64 offset, u32 length,
-					       unsigned flags);
+					       unsigned dispatch_flags);
 #define I915_DISPATCH_SECURE 0x1
 #define I915_DISPATCH_PINNED 0x2
 	void		(*cleanup)(struct intel_engine_cs *ring);
@@ -242,7 +242,7 @@ struct  intel_engine_cs {
 				      u32 flush_domains);
 	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
 					 struct intel_context *ctx,
-					 u64 offset, unsigned flags);
+					 u64 offset, unsigned dispatch_flags);
 	/**
 	 * List of objects currently involved in rendering from the
Signature · 6 lines
1.7.9.5

_______________________________________________
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
#5 lore raw

PATCH 2/51 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 0376285..73c1861 100644
@@ -701,6 +701,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
#6 lore raw

PATCH 3/51 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 f2a825e..e90b786 100644
@@ -2137,8 +2137,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 c26d36c..2ebe914 100644
@@ -2758,7 +2758,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,
@@ -2769,23 +2768,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 73c1861..762136b 100644
@@ -878,12 +878,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 d611608..ca9e7e6 100644
@@ -2100,6 +2100,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
#7 lore raw

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

Quoted 15 lines · On Fri, Feb 13, 2015 at 11:48:12AM +0000, [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 1 line

Caching the pointer means the calculation is done one at request creation time

s/one/once/ I guess?

Quoted 68 lines

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 f2a825e..e90b786 100644
@@ -2137,8 +2137,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 c26d36c..2ebe914 100644
@@ -2758,7 +2758,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,
@@ -2769,23 +2768,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 +0 -0
index 73c1861..762136b 100644

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

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -2
@@ -878,12 +878,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.
 	 */

Imo this comment is a bit too obvious so I just deleted it ;-) -Daniel

Quoted 25 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
 	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 d611608..ca9e7e6 100644
@@ -2100,6 +2100,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
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
#8 lore raw

PATCH 4/51 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 e90b786..e6d616b 100644
@@ -1640,6 +1640,16 @@ struct i915_workarounds {
 	u32 count;
 };
 
+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;
@@ -1891,13 +1901,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);
@@ -2622,14 +2628,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 762136b..ca29290 100644
@@ -618,16 +618,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;
@@ -678,13 +677,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;
 
@@ -697,14 +696,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 3093836..ae2f3ed 100644
@@ -80,13 +80,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
#9 lore raw

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

Quoted 36 lines · On Fri, Feb 13, 2015 at 11:48:13AM +0000, [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. 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 +0 -0
index e90b786..e6d616b 100644
@@ -1640,6 +1640,16 @@ struct i915_workarounds {
 	u32 count;
 };

drivers/gpu/drm/i915/i915_drv.h struct i915_workarounds { · line 1651

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +9 -0
 
+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;
+};

tbh I'm not a fan of parameter objects in C. C is verbose and explicit.

If we add the request then we can remove ring and ctx, which already improves things. We also have the eb structure we use to pass around a pile of things, which we could somewhat reuse here. What else do you plan to add? Just want to figure out whether this is really required ... -Daniel

Quoted 261 lines
drivers/gpu/drm/i915/i915_drv.h +5 -13
+
 struct drm_i915_private {
 	struct drm_device *dev;
 	struct kmem_cache *slab;
@@ -1891,13 +1901,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);
@@ -2622,14 +2628,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
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);
@@ -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 */
+	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 762136b..ca29290 100644
@@ -618,16 +618,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;
@@ -678,13 +677,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;
 
@@ -697,14 +696,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 3093836..ae2f3ed 100644
@@ -80,13 +80,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
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
#10 lore raw

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

Quoted 49 lines · Daniel Vetter
Quoted 36 lines · On Fri, Feb 13, 2015 at 11:48:13AM +0000, [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. 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 +0 -0
index e90b786..e6d616b 100644
@@ -1640,6 +1640,16 @@ struct i915_workarounds {
  	u32 count;
  };

drivers/gpu/drm/i915/i915_drv.h struct i915_workarounds { · line 1651

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +9 -0
 
+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;
+};

tbh I'm not a fan of parameter objects in C. C is verbose and explicit.

Quoted 5 lines

If we add the request then we can remove ring and ctx, which already improves things. We also have the eb structure we use to pass around a pile of things, which we could somewhat reuse here. What else do you plan to add? Just want to figure out whether this is really required ... -Daniel

The major advantage of this is when the GPU scheduler arrives. It splits the execbuffer code path in half - front half is all the software state verification and management, back half is the actual hardware writes to post the buffer. This structure is used to bridge the two. It contains all the state created by the front half that is later used by the back half. It is saved away with the request/scheduler node until such a time as the back half is called. Hence some kind of structure is required and it does not really make sense to add all this information to the generic request structure. Also, with the full pre-emptive scheduler, the structure grows to about twenty entries and passing that quantity of individual parameters to a function is just unwieldly!

Quoted 253 lines
Quoted 253 lines
drivers/gpu/drm/i915/i915_drv.h +5 -13
+
  struct drm_i915_private {
  	struct drm_device *dev;
  	struct kmem_cache *slab;
@@ -1891,13 +1901,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);
@@ -2622,14 +2628,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
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);
@@ -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 */
+	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 762136b..ca29290 100644
@@ -618,16 +618,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;
@@ -678,13 +677,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;
 
@@ -697,14 +696,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 3093836..ae2f3ed 100644
@@ -80,13 +80,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);
 
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.h +0 -0
  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

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

#11 lore raw

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

Quoted 55 lines · John Harrison
Quoted 48 lines · Daniel Vetter
Quoted 35 lines · On Fri, Feb 13, 2015 at 11:48:13AM +0000, [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. 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 +0 -0
index e90b786..e6d616b 100644
@@ -1640,6 +1640,16 @@ struct i915_workarounds {
 	u32 count;

drivers/gpu/drm/i915/i915_drv.h struct i915_workarounds { · line 1650

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +9 -0
 };
+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;
+};

tbh I'm not a fan of parameter objects in C. C is verbose and explicit.

Quoted 5 lines

If we add the request then we can remove ring and ctx, which already improves things. We also have the eb structure we use to pass around a pile of things, which we could somewhat reuse here. What else do you plan to add? Just want to figure out whether this is really required ... -Daniel

Quoted 11 lines

The major advantage of this is when the GPU scheduler arrives. It splits the execbuffer code path in half - front half is all the software state verification and management, back half is the actual hardware writes to post the buffer. This structure is used to bridge the two. It contains all the state created by the front half that is later used by the back half. It is saved away with the request/scheduler node until such a time as the back half is called. Hence some kind of structure is required and it does not really make sense to add all this information to the generic request structure. Also, with the full pre-emptive scheduler, the structure grows to about twenty entries and passing that quantity of individual parameters to a function is just unwieldly!

Well we already have an execbuf tracking structure with eb_vmas. And then there's requests. So if this is more than just a parameter object I wonder whether we shouldn't reuse either of these. Adding them all to requests is imo totally ok.

Oh and a bikeshed aside: imo the ->do_exebuf name is really confusing, since it clashes with the the various do_execbuf functions we have which are at a higher level. Also the implementations all have a _submission postfix. Imo better names would be do_submission or engine_submit or something simlar. The only caveat is that we need to make sure the lifetime rules for any pointers are ok. E.g. before we return from the ioctl we need to clear out drm_i915_gem_execbuffer2 *args pointers if we store them in the request structure.

Can you please pick a name and insert that rename patch somewhere convenient (for you) in your series?

Thanks, Daniel

Quoted 241 lines
Quoted 240 lines
Quoted 240 lines
drivers/gpu/drm/i915/i915_drv.h +5 -13
+
 struct drm_i915_private {
 	struct drm_device *dev;
 	struct kmem_cache *slab;
@@ -1891,13 +1901,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);
@@ -2622,14 +2628,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
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);
@@ -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 */
+	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 762136b..ca29290 100644
@@ -618,16 +618,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;
@@ -678,13 +677,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;
@@ -697,14 +696,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 3093836..ae2f3ed 100644
@@ -80,13 +80,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
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
#12 lore raw

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

Quoted 71 lines · Daniel Vetter
Quoted 54 lines · John Harrison
Quoted 48 lines · Daniel Vetter
Quoted 35 lines · On Fri, Feb 13, 2015 at 11:48:13AM +0000, [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. 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 +0 -0
index e90b786..e6d616b 100644
@@ -1640,6 +1640,16 @@ struct i915_workarounds {
  	u32 count;

drivers/gpu/drm/i915/i915_drv.h struct i915_workarounds { · line 1650

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +9 -0
  };
+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;
+};

tbh I'm not a fan of parameter objects in C. C is verbose and explicit.

Quoted 5 lines

If we add the request then we can remove ring and ctx, which already improves things. We also have the eb structure we use to pass around a pile of things, which we could somewhat reuse here. What else do you plan to add? Just want to figure out whether this is really required ... -Daniel

Quoted 11 lines

The major advantage of this is when the GPU scheduler arrives. It splits the execbuffer code path in half - front half is all the software state verification and management, back half is the actual hardware writes to post the buffer. This structure is used to bridge the two. It contains all the state created by the front half that is later used by the back half. It is saved away with the request/scheduler node until such a time as the back half is called. Hence some kind of structure is required and it does not really make sense to add all this information to the generic request structure. Also, with the full pre-emptive scheduler, the structure grows to about twenty entries and passing that quantity of individual parameters to a function is just unwieldly!

Well we already have an execbuf tracking structure with eb_vmas. And then there's requests. So if this is more than just a parameter object I wonder whether we shouldn't reuse either of these. Adding them all to requests is imo totally ok.

Quoted 8 lines

Oh and a bikeshed aside: imo the ->do_exebuf name is really confusing, since it clashes with the the various do_execbuf functions we have which are at a higher level. Also the implementations all have a _submission postfix. Imo better names would be do_submission or engine_submit or something simlar. The only caveat is that we need to make sure the lifetime rules for any pointers are ok. E.g. before we return from the ioctl we need to clear out drm_i915_gem_execbuffer2 *args pointers if we store them in the request structure.

The lifetime issues is part of the reason for having a dedicated execbuf params structure. Some of the contents of the args block are copied out and saved away for future reference and they are only relevant to the execbuf code. IMHO, keeping all of these things in one place is much more neat and tidy (and thus easier to read and easier to maintain) than overloading other structures with large amounts of stuff that isn't relevant. The eb_vma structure is freed at the end of the front half and not kept around for that back half. Requests are used for stuff that isn't an execbuffer call.

Quoted 2 lines

Can you please pick a name and insert that rename patch somewhere convenient (for you) in your series?

Can do.

Quoted 236 lines

Thanks, Daniel

Quoted 235 lines
Quoted 235 lines
Quoted 235 lines
drivers/gpu/drm/i915/i915_drv.h +5 -13
+
  struct drm_i915_private {
  	struct drm_device *dev;
  	struct kmem_cache *slab;
@@ -1891,13 +1901,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);
@@ -2622,14 +2628,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
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);
@@ -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 */
+	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 762136b..ca29290 100644
@@ -618,16 +618,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;
@@ -678,13 +677,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;
@@ -697,14 +696,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 3093836..ae2f3ed 100644
@@ -80,13 +80,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 · 1 line
1.7.9.5
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
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

#13 lore raw

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

Quoted 81 lines · John Harrison
Quoted 71 lines · Daniel Vetter
Quoted 54 lines · John Harrison
Quoted 48 lines · Daniel Vetter
Quoted 35 lines · On Fri, Feb 13, 2015 at 11:48:13AM +0000, [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. 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 +0 -0
index e90b786..e6d616b 100644
@@ -1640,6 +1640,16 @@ struct i915_workarounds {
 	u32 count;

drivers/gpu/drm/i915/i915_drv.h struct i915_workarounds { · line 1650

Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +9 -0
 };
+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;
+};

tbh I'm not a fan of parameter objects in C. C is verbose and explicit.

Quoted 5 lines

If we add the request then we can remove ring and ctx, which already improves things. We also have the eb structure we use to pass around a pile of things, which we could somewhat reuse here. What else do you plan to add? Just want to figure out whether this is really required ... -Daniel

Quoted 11 lines

The major advantage of this is when the GPU scheduler arrives. It splits the execbuffer code path in half - front half is all the software state verification and management, back half is the actual hardware writes to post the buffer. This structure is used to bridge the two. It contains all the state created by the front half that is later used by the back half. It is saved away with the request/scheduler node until such a time as the back half is called. Hence some kind of structure is required and it does not really make sense to add all this information to the generic request structure. Also, with the full pre-emptive scheduler, the structure grows to about twenty entries and passing that quantity of individual parameters to a function is just unwieldly!

Well we already have an execbuf tracking structure with eb_vmas. And then there's requests. So if this is more than just a parameter object I wonder whether we shouldn't reuse either of these. Adding them all to requests is imo totally ok.

Quoted 8 lines

Oh and a bikeshed aside: imo the ->do_exebuf name is really confusing, since it clashes with the the various do_execbuf functions we have which are at a higher level. Also the implementations all have a _submission postfix. Imo better names would be do_submission or engine_submit or something simlar. The only caveat is that we need to make sure the lifetime rules for any pointers are ok. E.g. before we return from the ioctl we need to clear out drm_i915_gem_execbuffer2 *args pointers if we store them in the request structure.

Quoted 8 lines

The lifetime issues is part of the reason for having a dedicated execbuf params structure. Some of the contents of the args block are copied out and saved away for future reference and they are only relevant to the execbuf code. IMHO, keeping all of these things in one place is much more neat and tidy (and thus easier to read and easier to maintain) than overloading other structures with large amounts of stuff that isn't relevant. The eb_vma structure is freed at the end of the front half and not kept around for that back half. Requests are used for stuff that isn't an execbuffer call.

Hm I still think just putting all that stuff into requests makes more sense. Requests' primary reason for existence is to track execbufs after all.
-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
#14 lore raw

PATCH 5/51 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 e6d616b..143bc63 100644
@@ -2624,10 +2624,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 ca29290..90400d0d 100644
@@ -706,9 +706,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
#15 lore raw

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

Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:14AM +0000, [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.

I was so convinced we've had a commit somewhere explaining this, but apparently not.

The deal is that after the dispatch call we have the batch commit and there's no going back any more, which also means we can't return an error code from the ioctl. So if you return -EIO or -ENOMEM that's a pretty bad lie and you really have to ignore that error code.

Again I've tried to dig up the commit for that but that was lost in the maze of the past 5 years of changes. We've had piles of older approaches to deal with this issue:
- Don't even emit a request, just mark objects as gpu dirty. Only when waiting did we emit flushes and requests, which again again gave us a context to return the error. This resulted in horrible latency since flushes where wait too late and also all that book-keeping was not worth it at all. Don't ask ;-)
- Emit flushes right away, but if we fail to alloc the request set the outstanding lazy request bit. The job of the check_olr function used in waits was to notice that and retry the allocation.
- Preallocate the request, but that still leaves the possibility that the gpu dies. But since we've committed hangcheck will clean this up and we can just ignore the -EIO.

Given all that backstory: Why does add_request/retire_commands suddenly need to fail?

Cheers, Daniel

Quoted 87 lines

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 e6d616b..143bc63 100644
@@ -2624,10 +2624,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 ca29290..90400d0d 100644
@@ -706,9 +706,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
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
#16 lore raw

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

Quoted 16 lines · Daniel Vetter
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:14AM +0000, [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.

I was so convinced we've had a commit somewhere explaining this, but apparently not.

The deal is that after the dispatch call we have the batch commit and there's no going back any more, which also means we can't return an error code from the ioctl. So if you return -EIO or -ENOMEM that's a pretty bad lie and you really have to ignore that error code.

Quoted 14 lines

Again I've tried to dig up the commit for that but that was lost in the maze of the past 5 years of changes. We've had piles of older approaches to deal with this issue:
- Don't even emit a request, just mark objects as gpu dirty. Only when waiting did we emit flushes and requests, which again again gave us a context to return the error. This resulted in horrible latency since flushes where wait too late and also all that book-keeping was not worth it at all. Don't ask ;-)
- Emit flushes right away, but if we fail to alloc the request set the outstanding lazy request bit. The job of the check_olr function used in waits was to notice that and retry the allocation.
- Preallocate the request, but that still leaves the possibility that the gpu dies. But since we've committed hangcheck will clean this up and we can just ignore the -EIO.

It's actually worse since it's not just -EIO but also -EINTR, returned by intel_ring_begin when we're thrashing the gpu a bit too badly with requests. Which means we really need to guarantee that the request is completed properly, eventually since it's not just for fatal gpu hangs.

Atm that's done by only clearing outstanding_lazy_request after we've really emitted the request fully. That guarantees that even when parts of the request emission to the ringbuf fails we'll retry on the next wait if needed.

A possible fix to make this infallible would be to reserve some fixed amount of ringbuf credit at request creation time and then consume it here. Of course we'd need checks to make sure we never use more ringspace than what we reserve. To avoid massive churn we could convert I915_RING_FREE_SPACE into a variable and increase it enough when allocating the request. And then reduce it again at the start of add_request.
-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
#17 lore raw

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

Quoted 31 lines · Daniel Vetter
Quoted 30 lines · Daniel Vetter
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:14AM +0000, [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.

I was so convinced we've had a commit somewhere explaining this, but apparently not.

The deal is that after the dispatch call we have the batch commit and there's no going back any more, which also means we can't return an error code from the ioctl. So if you return -EIO or -ENOMEM that's a pretty bad lie and you really have to ignore that error code.

Again I've tried to dig up the commit for that but that was lost in the maze of the past 5 years of changes. We've had piles of older approaches to deal with this issue:
- Don't even emit a request, just mark objects as gpu dirty. Only when waiting did we emit flushes and requests, which again again gave us a context to return the error. This resulted in horrible latency since flushes where wait too late and also all that book-keeping was not worth it at all. Don't ask ;-)
- Emit flushes right away, but if we fail to alloc the request set the outstanding lazy request bit. The job of the check_olr function used in waits was to notice that and retry the allocation.
- Preallocate the request, but that still leaves the possibility that the gpu dies. But since we've committed hangcheck will clean this up and we can just ignore the -EIO.

Quoted 2 lines
Quoted 2 lines

Given all that backstory: Why does add_request/retire_commands suddenly need to fail?

The problem is that if add_request() fails and the request is not added to ring->request_list then it will be lost. As soon as the execbuff code returns, there is no longer a request pointer floating around so it can can't have add_request() called on it later. Thus the request will never be retired, the objects, context, etc never dereferenced, and basically lots of stuff will be leaked. Without the OLR to hoover up the failures, the add_request() call really must not be allowed to give up.

Quoted 10 lines

It's actually worse since it's not just -EIO but also -EINTR, returned by intel_ring_begin when we're thrashing the gpu a bit too badly with requests. Which means we really need to guarantee that the request is completed properly, eventually since it's not just for fatal gpu hangs.

Atm that's done by only clearing outstanding_lazy_request after we've really emitted the request fully. That guarantees that even when parts of the request emission to the ringbuf fails we'll retry on the next wait if needed.

Quoted 8 lines

A possible fix to make this infallible would be to reserve some fixed amount of ringbuf credit at request creation time and then consume it here. Of course we'd need checks to make sure we never use more ringspace than what we reserve. To avoid massive churn we could convert I915_RING_FREE_SPACE into a variable and increase it enough when allocating the request. And then reduce it again at the start of add_request.
-Daniel

I don't think you can guarantee to reserve enough space at request creation time. You have no idea how much space will be required by what ever piece of code is wanting the request. It could be a few words or it might be reams and reams of workaround goo. One of the scheduler patches does improve this and do a 'large enough' ring_begin() at the start of the execbuffer submission path in order to prevent out of space issues and other such problems half way through that could lead to a partial submission. However, even that is not absoluetely guaranteed 100% failure proof.

How about changing add_request() so that it can't fail. As in, the cache flush call and the emit request call can still failure due to running out of ring space, but add_request() just ignores that and keeps going anyway. That way the request is still correctly tracked and will be retired eventually. The only issues are unflushed caches and no seqno interrupt being generated. However, if the assumption is that another request will be submitted shortly (which is extremely likely if the system is busy enough to cause a failure during add_request!) then this will be fine. The following request will flush the caches and write the next seqno along to the ringbuffer. When that pops out, both the broken request and the new one will be considered complete and can be retired. The only issue is if the broken request is that last one to be submitted and is then waited on. In that case, you will get a timeout/hang as the request will never complete. Although that could be worked around by setting a 'failed request' flag in the ring and having the wait code (or even the currently redundant check_olr function) look at that and attempt a brand new (but empty) request submission.

Or maybe a simpler solution is to just keep a 'last failed request' pointer in the ring. Sort of a not-quite-OLR. If add_request() fails, it saves the request pointer here instead of adding it to the request list. A subsequent request allocation call starts by checking the 'last failed' value and retries the add_request() call if present. At that point it is allowed to fail. I guess it still needs to be done by check_olr as well to prevent a wait from stalling if no other requests are submitted.

John.

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

#18 lore raw

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

Quoted 34 lines · John Harrison
Quoted 31 lines · Daniel Vetter
Quoted 30 lines · Daniel Vetter
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:14AM +0000, [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.

I was so convinced we've had a commit somewhere explaining this, but apparently not.

The deal is that after the dispatch call we have the batch commit and there's no going back any more, which also means we can't return an error code from the ioctl. So if you return -EIO or -ENOMEM that's a pretty bad lie and you really have to ignore that error code.

Again I've tried to dig up the commit for that but that was lost in the maze of the past 5 years of changes. We've had piles of older approaches to deal with this issue:
- Don't even emit a request, just mark objects as gpu dirty. Only when waiting did we emit flushes and requests, which again again gave us a context to return the error. This resulted in horrible latency since flushes where wait too late and also all that book-keeping was not worth it at all. Don't ask ;-)
- Emit flushes right away, but if we fail to alloc the request set the outstanding lazy request bit. The job of the check_olr function used in waits was to notice that and retry the allocation.
- Preallocate the request, but that still leaves the possibility that the gpu dies. But since we've committed hangcheck will clean this up and we can just ignore the -EIO.

Quoted 2 lines
Quoted 2 lines

Given all that backstory: Why does add_request/retire_commands suddenly need to fail?

Quoted 7 lines

The problem is that if add_request() fails and the request is not added to ring->request_list then it will be lost. As soon as the execbuff code returns, there is no longer a request pointer floating around so it can can't have add_request() called on it later. Thus the request will never be retired, the objects, context, etc never dereferenced, and basically lots of stuff will be leaked. Without the OLR to hoover up the failures, the add_request() call really must not be allowed to give up.

That's exactly what I mean, add_request can't fail. The other issue is that you can't fail execbuf at the point you call add_request either any more since we've already (at least potentially) started executing the batch.

Quoted 45 lines
Quoted 10 lines

It's actually worse since it's not just -EIO but also -EINTR, returned by intel_ring_begin when we're thrashing the gpu a bit too badly with requests. Which means we really need to guarantee that the request is completed properly, eventually since it's not just for fatal gpu hangs.

Atm that's done by only clearing outstanding_lazy_request after we've really emitted the request fully. That guarantees that even when parts of the request emission to the ringbuf fails we'll retry on the next wait if needed.

Quoted 8 lines

A possible fix to make this infallible would be to reserve some fixed amount of ringbuf credit at request creation time and then consume it here. Of course we'd need checks to make sure we never use more ringspace than what we reserve. To avoid massive churn we could convert I915_RING_FREE_SPACE into a variable and increase it enough when allocating the request. And then reduce it again at the start of add_request.
-Daniel

I don't think you can guarantee to reserve enough space at request creation time. You have no idea how much space will be required by what ever piece of code is wanting the request. It could be a few words or it might be reams and reams of workaround goo. One of the scheduler patches does improve this and do a 'large enough' ring_begin() at the start of the execbuffer submission path in order to prevent out of space issues and other such problems half way through that could lead to a partial submission. However, even that is not absoluetely guaranteed 100% failure proof.

How about changing add_request() so that it can't fail. As in, the cache flush call and the emit request call can still failure due to running out of ring space, but add_request() just ignores that and keeps going anyway. That way the request is still correctly tracked and will be retired eventually. The only issues are unflushed caches and no seqno interrupt being generated. However, if the assumption is that another request will be submitted shortly (which is extremely likely if the system is busy enough to cause a failure during add_request!) then this will be fine. The following request will flush the caches and write the next seqno along to the ringbuffer. When that pops out, both the broken request and the new one will be considered complete and can be retired. The only issue is if the broken request is that last one to be submitted and is then waited on. In that case, you will get a timeout/hang as the request will never complete. Although that could be worked around by setting a 'failed request' flag in the ring and having the wait code (or even the currently redundant check_olr function) look at that and attempt a brand new (but empty) request submission.

Quoted 7 lines

Or maybe a simpler solution is to just keep a 'last failed request' pointer in the ring. Sort of a not-quite-OLR. If add_request() fails, it saves the request pointer here instead of adding it to the request list. A subsequent request allocation call starts by checking the 'last failed' value and retries the add_request() call if present. At that point it is allowed to fail. I guess it still needs to be done by check_olr as well to prevent a wait from stalling if no other requests are submitted.

Imo reserving a bit of ring space for each add_request should be solid. Userspace uses the exact same reservation logic for adding end-of-batch workarounds. The only thing needed to make this solid is to WARN if add_request ends up using more ring space than what we've reserved (not just when it actually runs out, that obviously doesn't happen often enough for testing).

Everything else just readds olr through the backdoor, which is kinda what we wanted to avoid from an accounting pov. Because then you have again some random request outstanding which scoops up everything it encounters.

For the ringbuf interface itself I think we only need 3 pieces:
- ringbuf_reserve(space): Ensures there's @space available in the ring and then sets that as ring->reserved_space. ring_free_space needs to subtract that ofc. This would be in the alloc_request function.

- rinbuf_use_reserve(): sets ring->reserve_space to 0 so that intel_ring_begin can start eating into reserves. This would be at the top of add_request.

- ringbuf_check_reserve(): This would be called at the end of add_request and WARNs if we've used more ring space than what we've promised. Obviously needs some boo-keeping between use and check but that's just a detail. If you go with a flag instead of clearing ->reserve_space you can even enforce that these three functions are always called in this order and don't end up being nested wrongly.

Cheers, 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
#19 lore raw

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

Quoted 98 lines · Daniel Vetter
Quoted 34 lines · John Harrison
Quoted 31 lines · Daniel Vetter
Quoted 30 lines · Daniel Vetter
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:14AM +0000, [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.

I was so convinced we've had a commit somewhere explaining this, but apparently not.

The deal is that after the dispatch call we have the batch commit and there's no going back any more, which also means we can't return an error code from the ioctl. So if you return -EIO or -ENOMEM that's a pretty bad lie and you really have to ignore that error code.

Again I've tried to dig up the commit for that but that was lost in the maze of the past 5 years of changes. We've had piles of older approaches to deal with this issue:
- Don't even emit a request, just mark objects as gpu dirty. Only when waiting did we emit flushes and requests, which again again gave us a context to return the error. This resulted in horrible latency since flushes where wait too late and also all that book-keeping was not worth it at all. Don't ask ;-)
- Emit flushes right away, but if we fail to alloc the request set the outstanding lazy request bit. The job of the check_olr function used in waits was to notice that and retry the allocation.
- Preallocate the request, but that still leaves the possibility that the gpu dies. But since we've committed hangcheck will clean this up and we can just ignore the -EIO.

Quoted 2 lines
Quoted 2 lines

Given all that backstory: Why does add_request/retire_commands suddenly need to fail?

Quoted 7 lines

The problem is that if add_request() fails and the request is not added to ring->request_list then it will be lost. As soon as the execbuff code returns, there is no longer a request pointer floating around so it can can't have add_request() called on it later. Thus the request will never be retired, the objects, context, etc never dereferenced, and basically lots of stuff will be leaked. Without the OLR to hoover up the failures, the add_request() call really must not be allowed to give up.

That's exactly what I mean, add_request can't fail. The other issue is that you can't fail execbuf at the point you call add_request either any more since we've already (at least potentially) started executing the batch.

Quoted 44 lines
Quoted 10 lines

It's actually worse since it's not just -EIO but also -EINTR, returned by intel_ring_begin when we're thrashing the gpu a bit too badly with requests. Which means we really need to guarantee that the request is completed properly, eventually since it's not just for fatal gpu hangs.

Atm that's done by only clearing outstanding_lazy_request after we've really emitted the request fully. That guarantees that even when parts of the request emission to the ringbuf fails we'll retry on the next wait if needed.

Quoted 8 lines

A possible fix to make this infallible would be to reserve some fixed amount of ringbuf credit at request creation time and then consume it here. Of course we'd need checks to make sure we never use more ringspace than what we reserve. To avoid massive churn we could convert I915_RING_FREE_SPACE into a variable and increase it enough when allocating the request. And then reduce it again at the start of add_request.
-Daniel

I don't think you can guarantee to reserve enough space at request creation time. You have no idea how much space will be required by what ever piece of code is wanting the request. It could be a few words or it might be reams and reams of workaround goo. One of the scheduler patches does improve this and do a 'large enough' ring_begin() at the start of the execbuffer submission path in order to prevent out of space issues and other such problems half way through that could lead to a partial submission. However, even that is not absoluetely guaranteed 100% failure proof.

How about changing add_request() so that it can't fail. As in, the cache flush call and the emit request call can still failure due to running out of ring space, but add_request() just ignores that and keeps going anyway. That way the request is still correctly tracked and will be retired eventually. The only issues are unflushed caches and no seqno interrupt being generated. However, if the assumption is that another request will be submitted shortly (which is extremely likely if the system is busy enough to cause a failure during add_request!) then this will be fine. The following request will flush the caches and write the next seqno along to the ringbuffer. When that pops out, both the broken request and the new one will be considered complete and can be retired. The only issue is if the broken request is that last one to be submitted and is then waited on. In that case, you will get a timeout/hang as the request will never complete. Although that could be worked around by setting a 'failed request' flag in the ring and having the wait code (or even the currently redundant check_olr function) look at that and attempt a brand new (but empty) request submission.

Quoted 7 lines

Or maybe a simpler solution is to just keep a 'last failed request' pointer in the ring. Sort of a not-quite-OLR. If add_request() fails, it saves the request pointer here instead of adding it to the request list. A subsequent request allocation call starts by checking the 'last failed' value and retries the add_request() call if present. At that point it is allowed to fail. I guess it still needs to be done by check_olr as well to prevent a wait from stalling if no other requests are submitted.

Quoted 6 lines

Imo reserving a bit of ring space for each add_request should be solid. Userspace uses the exact same reservation logic for adding end-of-batch workarounds. The only thing needed to make this solid is to WARN if add_request ends up using more ring space than what we've reserved (not just when it actually runs out, that obviously doesn't happen often enough for testing).

The problem is that there could be multiple requests being processed in parallel. This is especially true with the scheduler. Userland could submit a whole stream of batches that all get queued up in the scheduler. Only later do they get submitted to the hardware. The request must be allocated up front because there is no other means of tracking them. But reserving space at that point won't work because you either end up reserving massive amounts of space if the reserve is cumulative, or not enough if only one slot is reserved.

Quoted 3 lines

Everything else just readds olr through the backdoor, which is kinda what we wanted to avoid from an accounting pov. Because then you have again some random request outstanding which scoops up everything it encounters.

Not quite. The difference is that with something like an outstanding failed request rather than a lazy one, there is still the segregation of work. The failed request will be posted and added to the request list in its entirety before a new request is allocated and used for the new work.

Quoted 9 lines

For the ringbuf interface itself I think we only need 3 pieces:
- ringbuf_reserve(space): Ensures there's @space available in the ring and then sets that as ring->reserved_space. ring_free_space needs to subtract that ofc. This would be in the alloc_request function.

- rinbuf_use_reserve(): sets ring->reserve_space to 0 so that intel_ring_begin can start eating into reserves. This would be at the top of add_request.

Quoted 8 lines

- ringbuf_check_reserve(): This would be called at the end of add_request and WARNs if we've used more ring space than what we've promised. Obviously needs some boo-keeping between use and check but that's just a detail. If you go with a flag instead of clearing ->reserve_space you can even enforce that these three functions are always called in this order and don't end up being nested wrongly.

Cheers, Daniel

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

#20 lore raw

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

Quoted 7 lines · John Harrison
Quoted 6 lines · Daniel Vetter

Imo reserving a bit of ring space for each add_request should be solid. Userspace uses the exact same reservation logic for adding end-of-batch workarounds. The only thing needed to make this solid is to WARN if add_request ends up using more ring space than what we've reserved (not just when it actually runs out, that obviously doesn't happen often enough for testing).

Quoted 8 lines

The problem is that there could be multiple requests being processed in parallel. This is especially true with the scheduler. Userland could submit a whole stream of batches that all get queued up in the scheduler. Only later do they get submitted to the hardware. The request must be allocated up front because there is no other means of tracking them. But reserving space at that point won't work because you either end up reserving massive amounts of space if the reserve is cumulative, or not enough if only one slot is reserved.

At least with execlist we don't have that problem really since writing the ringbuffer is done synchronously and directly.

For the legacy scheduler I expect that we won't do any of the ringbuf writes directly and instead that's all done by the scheduler asynchronously.

So this should just be an issue while we are converting to the scheduler or on platforms that will never have one. And imo the request ringbuf reservation is the solution with the simplest impact on the design.

Quoted 7 lines
Quoted 3 lines

Everything else just readds olr through the backdoor, which is kinda what we wanted to avoid from an accounting pov. Because then you have again some random request outstanding which scoops up everything it encounters.

Not quite. The difference is that with something like an outstanding failed request rather than a lazy one, there is still the segregation of work. The failed request will be posted and added to the request list in its entirety before a new request is allocated and used for the new work.

Well history lesson, but that's exactly how olr started out. Then the hydra grew heads to no end. That's why I don't want to go down this road again, since I've been on that trip the past 3 years ;-) And since your motivation for olr light is exactly the one I provided 3 years ago to get my patch in I think history repeating is likely.
-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
#21 lore raw

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

Quoted 19 lines · Daniel Vetter
Quoted 7 lines · John Harrison
Quoted 6 lines · Daniel Vetter

Imo reserving a bit of ring space for each add_request should be solid. Userspace uses the exact same reservation logic for adding end-of-batch workarounds. The only thing needed to make this solid is to WARN if add_request ends up using more ring space than what we've reserved (not just when it actually runs out, that obviously doesn't happen often enough for testing).

Quoted 8 lines

The problem is that there could be multiple requests being processed in parallel. This is especially true with the scheduler. Userland could submit a whole stream of batches that all get queued up in the scheduler. Only later do they get submitted to the hardware. The request must be allocated up front because there is no other means of tracking them. But reserving space at that point won't work because you either end up reserving massive amounts of space if the reserve is cumulative, or not enough if only one slot is reserved.

At least with execlist we don't have that problem really since writing the ringbuffer is done synchronously and directly.

Quoted 7 lines

For the legacy scheduler I expect that we won't do any of the ringbuf writes directly and instead that's all done by the scheduler asynchronously.

So this should just be an issue while we are converting to the scheduler or on platforms that will never have one. And imo the request ringbuf reservation is the solution with the simplest impact on the design.

I don't understand what you mean here. The scheduler decouples the submission of a batch buffer to the driver with the submission of that batch buffer to the hardware. The submission code path itself is identical. The scheduler does not do any hardware writes - it merely adds an extra layer between the user interface code and the hardware access code. The request creation must be done at driver submission time. The hardware submission could be an arbitrary amount of time later. In the intervening time, any number of new batch buffers may be submitted to the driver and thus new requests be created. This is true for both legacy and execlist mode.

The space reserve would have to be done at the start of the hardware submission process not at driver submission time. I.e. it would need to be a separate and new i915_gem_request_reserve_space() call at the start of the back half of the exec buffer code. It could not be done during request creation.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

Everything else just readds olr through the backdoor, which is kinda what we wanted to avoid from an accounting pov. Because then you have again some random request outstanding which scoops up everything it encounters.

Not quite. The difference is that with something like an outstanding failed request rather than a lazy one, there is still the segregation of work. The failed request will be posted and added to the request list in its entirety before a new request is allocated and used for the new work.

Quoted 6 lines

Well history lesson, but that's exactly how olr started out. Then the hydra grew heads to no end. That's why I don't want to go down this road again, since I've been on that trip the past 3 years ;-) And since your motivation for olr light is exactly the one I provided 3 years ago to get my patch in I think history repeating is likely.
-Daniel

Fair enough. Let's stay away from the evil hydra.

John.

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

#22 lore raw

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

Quoted 37 lines · John Harrison
Quoted 19 lines · Daniel Vetter
Quoted 7 lines · John Harrison
Quoted 6 lines · Daniel Vetter

Imo reserving a bit of ring space for each add_request should be solid. Userspace uses the exact same reservation logic for adding end-of-batch workarounds. The only thing needed to make this solid is to WARN if add_request ends up using more ring space than what we've reserved (not just when it actually runs out, that obviously doesn't happen often enough for testing).

Quoted 8 lines

The problem is that there could be multiple requests being processed in parallel. This is especially true with the scheduler. Userland could submit a whole stream of batches that all get queued up in the scheduler. Only later do they get submitted to the hardware. The request must be allocated up front because there is no other means of tracking them. But reserving space at that point won't work because you either end up reserving massive amounts of space if the reserve is cumulative, or not enough if only one slot is reserved.

At least with execlist we don't have that problem really since writing the ringbuffer is done synchronously and directly.

Quoted 7 lines

For the legacy scheduler I expect that we won't do any of the ringbuf writes directly and instead that's all done by the scheduler asynchronously.

So this should just be an issue while we are converting to the scheduler or on platforms that will never have one. And imo the request ringbuf reservation is the solution with the simplest impact on the design.

I don't understand what you mean here. The scheduler decouples the submission of a batch buffer to the driver with the submission of that batch buffer to the hardware. The submission code path itself is identical. The scheduler does not do any hardware writes - it merely adds an extra layer between the user interface code and the hardware access code. The request creation must be done at driver submission time. The hardware submission could be an arbitrary amount of time later. In the intervening time, any number of new batch buffers may be submitted to the driver and thus new requests be created. This is true for both legacy and execlist mode.

Quoted 5 lines

The space reserve would have to be done at the start of the hardware submission process not at driver submission time. I.e. it would need to be a separate and new i915_gem_request_reserve_space() call at the start of the back half of the exec buffer code. It could not be done during request creation.

Yeah with the scheduler we need to take out the reservation again since it doesn't make a lot of sense - the scheduler is the safety net that guarantees execution (barring gpu death ofc as always) when the execbuf ioctl returns 0. Maybe in the end we need a special alloc_request function for execbuf to only reserve when the scheduler isn't around.

That additional work is just part of the prize we have to pay to never break things while refactoring code. And since we'll get the execlist scheduler in first that reservation code will probably stick around for a while (or maybe forever even if we decide against upstreaming the gen7 scheduler).

Does this make sense?

Thanks, 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
#23 lore raw

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

Quoted 56 lines · Daniel Vetter
Quoted 37 lines · John Harrison
Quoted 19 lines · Daniel Vetter
Quoted 7 lines · John Harrison
Quoted 6 lines · Daniel Vetter

Imo reserving a bit of ring space for each add_request should be solid. Userspace uses the exact same reservation logic for adding end-of-batch workarounds. The only thing needed to make this solid is to WARN if add_request ends up using more ring space than what we've reserved (not just when it actually runs out, that obviously doesn't happen often enough for testing).

Quoted 8 lines

The problem is that there could be multiple requests being processed in parallel. This is especially true with the scheduler. Userland could submit a whole stream of batches that all get queued up in the scheduler. Only later do they get submitted to the hardware. The request must be allocated up front because there is no other means of tracking them. But reserving space at that point won't work because you either end up reserving massive amounts of space if the reserve is cumulative, or not enough if only one slot is reserved.

At least with execlist we don't have that problem really since writing the ringbuffer is done synchronously and directly.

Quoted 7 lines

For the legacy scheduler I expect that we won't do any of the ringbuf writes directly and instead that's all done by the scheduler asynchronously.

So this should just be an issue while we are converting to the scheduler or on platforms that will never have one. And imo the request ringbuf reservation is the solution with the simplest impact on the design.

I don't understand what you mean here. The scheduler decouples the submission of a batch buffer to the driver with the submission of that batch buffer to the hardware. The submission code path itself is identical. The scheduler does not do any hardware writes - it merely adds an extra layer between the user interface code and the hardware access code. The request creation must be done at driver submission time. The hardware submission could be an arbitrary amount of time later. In the intervening time, any number of new batch buffers may be submitted to the driver and thus new requests be created. This is true for both legacy and execlist mode.

Quoted 5 lines

The space reserve would have to be done at the start of the hardware submission process not at driver submission time. I.e. it would need to be a separate and new i915_gem_request_reserve_space() call at the start of the back half of the exec buffer code. It could not be done during request creation.

Yeah with the scheduler we need to take out the reservation again since it doesn't make a lot of sense - the scheduler is the safety net that guarantees execution (barring gpu death ofc as always) when the execbuf ioctl returns 0. Maybe in the end we need a special alloc_request function for execbuf to only reserve when the scheduler isn't around.

That additional work is just part of the prize we have to pay to never break things while refactoring code. And since we'll get the execlist scheduler in first that reservation code will probably stick around for a while (or maybe forever even if we decide against upstreaming the gen7 scheduler).

Quoted 3 lines

Does this make sense?

Thanks, Daniel

I already put a pre-reservation in the preemptive version of the scheduler. It won't start to write anything in the ringbuffer unless it's guaranteed there's enough space to write the whole set of commands to run a batch, from preamble to finalisation. That means that none of the ring_begin() commands can fail, and we won't leave a partial set of commands in the ring to confuse any subsequent (successful) submissions.

And yes, I added warnings if the commands emitted to the ring overran the amount of reserved space, so that developers would know if they'd increased the total ringspace requirement.

If there are any other failure modes while writing to the ring, we should simply back up to the start of the sequence (i.e. rewind the software copy of TAIL to where it was after we checked for space -- easy because we haven't updated h/w TAIL yet), and we can leave the request queued for subsequent retry (or fail it as though it had been submitted and then killed by TDR, if the failure mode suggests it's not retryable).

[aside] One version of this was posted as
http://lists.freedesktop.org/archives/intel-gfx/2014-December/057247.html but that re-used intel_ring_begin() as a reserve-space call, whereas another version has a separate nonblocking function intel_ring_test_space() for prechecking available space [/aside]

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

#24 lore raw

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

Quoted 72 lines · Dave Gordon
Quoted 56 lines · Daniel Vetter
Quoted 37 lines · John Harrison
Quoted 19 lines · Daniel Vetter
Quoted 7 lines · John Harrison
Quoted 6 lines · Daniel Vetter

Imo reserving a bit of ring space for each add_request should be solid. Userspace uses the exact same reservation logic for adding end-of-batch workarounds. The only thing needed to make this solid is to WARN if add_request ends up using more ring space than what we've reserved (not just when it actually runs out, that obviously doesn't happen often enough for testing).

Quoted 8 lines

The problem is that there could be multiple requests being processed in parallel. This is especially true with the scheduler. Userland could submit a whole stream of batches that all get queued up in the scheduler. Only later do they get submitted to the hardware. The request must be allocated up front because there is no other means of tracking them. But reserving space at that point won't work because you either end up reserving massive amounts of space if the reserve is cumulative, or not enough if only one slot is reserved.

At least with execlist we don't have that problem really since writing the ringbuffer is done synchronously and directly.

Quoted 7 lines

For the legacy scheduler I expect that we won't do any of the ringbuf writes directly and instead that's all done by the scheduler asynchronously.

So this should just be an issue while we are converting to the scheduler or on platforms that will never have one. And imo the request ringbuf reservation is the solution with the simplest impact on the design.

I don't understand what you mean here. The scheduler decouples the submission of a batch buffer to the driver with the submission of that batch buffer to the hardware. The submission code path itself is identical. The scheduler does not do any hardware writes - it merely adds an extra layer between the user interface code and the hardware access code. The request creation must be done at driver submission time. The hardware submission could be an arbitrary amount of time later. In the intervening time, any number of new batch buffers may be submitted to the driver and thus new requests be created. This is true for both legacy and execlist mode.

Quoted 5 lines

The space reserve would have to be done at the start of the hardware submission process not at driver submission time. I.e. it would need to be a separate and new i915_gem_request_reserve_space() call at the start of the back half of the exec buffer code. It could not be done during request creation.

Yeah with the scheduler we need to take out the reservation again since it doesn't make a lot of sense - the scheduler is the safety net that guarantees execution (barring gpu death ofc as always) when the execbuf ioctl returns 0. Maybe in the end we need a special alloc_request function for execbuf to only reserve when the scheduler isn't around.

That additional work is just part of the prize we have to pay to never break things while refactoring code. And since we'll get the execlist scheduler in first that reservation code will probably stick around for a while (or maybe forever even if we decide against upstreaming the gen7 scheduler).

Quoted 3 lines

Does this make sense?

Thanks, Daniel

I already put a pre-reservation in the preemptive version of the scheduler. It won't start to write anything in the ringbuffer unless it's guaranteed there's enough space to write the whole set of commands to run a batch, from preamble to finalisation. That means that none of the ring_begin() commands can fail, and we won't leave a partial set of commands in the ring to confuse any subsequent (successful) submissions.

And yes, I added warnings if the commands emitted to the ring overran the amount of reserved space, so that developers would know if they'd increased the total ringspace requirement.

Quoted 6 lines

If there are any other failure modes while writing to the ring, we should simply back up to the start of the sequence (i.e. rewind the software copy of TAIL to where it was after we checked for space -- easy because we haven't updated h/w TAIL yet), and we can leave the request queued for subsequent retry (or fail it as though it had been submitted and then killed by TDR, if the failure mode suggests it's not retryable).

Sounds good.

Quoted 5 lines

[aside] One version of this was posted as
http://lists.freedesktop.org/archives/intel-gfx/2014-December/057247.html but that re-used intel_ring_begin() as a reserve-space call, whereas another version has a separate nonblocking function intel_ring_test_space() for prechecking available space [/aside]

I prefer the explicit reservation over allowing nesting. Allowing nesting gives us a lot more rope than we need I think, so much room for "creative abuse" (i.e. really hard to understand bugs).
-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
#25 lore raw

PATCH 6/51 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 143bc63..7959dfa 100644
@@ -1901,6 +1901,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 2ebe914..9546992 100644
@@ -4855,11 +4855,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 90400d0d..2f906a2 100644
@@ -846,8 +846,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;
@@ -1056,7 +1056,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 ae2f3ed..2b1bf83 100644
@@ -34,6 +34,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 ca9e7e6..c80e20d 100644
@@ -2084,8 +2084,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;
@@ -2150,7 +2150,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 26e5774..74df0fc 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
#26 lore raw

PATCH 7/51 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
#27 lore raw

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

Quoted 57 lines · On Fri, Feb 13, 2015 at 11:48:16AM +0000, [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);

This hunk here looks wrong, or maybe the context changed sufficiently already (but I can't find that in previous patches). Why do we need to change the pinning for the ggtt batch pin hack when allocating the request earlier?
-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
#28 lore raw

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

Quoted 65 lines · Daniel Vetter
Quoted 64 lines · On Fri, Feb 13, 2015 at 11:48:16AM +0000, [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 +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:
+
Quoted 8 lines

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

Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
  	/* the request owns the ref now */
  	i915_gem_context_unreference(ctx);
  	eb_destroy(eb);

This hunk here looks wrong, or maybe the context changed sufficiently already (but I can't find that in previous patches). Why do we need to change the pinning for the ggtt batch pin hack when allocating the request earlier?
-Daniel

It doesn't change the behaviour. It is just coping with the extra error path. If the alloc request call fails, we need to jump past the do_execbuf() call but not past the batch unpin. Hence the 'err:' tag is moved upwards. That means it is now possible to get to the batch unpin test from an error that occurred before the pin call actually happened. Hence it is no longer safe to just test the dispatch flag. Instead an explicit 'did this get pinned yet' boolean is required.

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

#29 lore raw

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

Quoted 70 lines · John Harrison
Quoted 60 lines · Daniel Vetter
Quoted 59 lines · On Fri, Feb 13, 2015 at 11:48:16AM +0000, [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 +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:
+
Quoted 8 lines

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

Quoted 3 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
 	/* the request owns the ref now */
 	i915_gem_context_unreference(ctx);
 	eb_destroy(eb);

This hunk here looks wrong, or maybe the context changed sufficiently already (but I can't find that in previous patches). Why do we need to change the pinning for the ggtt batch pin hack when allocating the request earlier?
-Daniel

Quoted 7 lines

It doesn't change the behaviour. It is just coping with the extra error path. If the alloc request call fails, we need to jump past the do_execbuf() call but not past the batch unpin. Hence the 'err:' tag is moved upwards. That means it is now possible to get to the batch unpin test from an error that occurred before the pin call actually happened. Hence it is no longer safe to just test the dispatch flag. Instead an explicit 'did this get pinned yet' boolean is required.

Ah I see what's going on. The usual pattern is to just duplicate goto targets, i.e. here:

err_batch_unpin:
/*
* 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)
i915_gem_object_ggtt_unpin(batch_obj);
err:

/* the request owns the ref now */
i915_gem_context_unreference(ctx);
eb_destroy(eb);

Then you can let gcc deal with how to best structure the control flow for you. It means a bit larger diff since you need to change a pile of goto err; to goto err_batch_unpin, but imo that also makes it easier for reviewers to double-check there's no error case with funky requirements now broken.

Cheers, 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
#30 lore raw

PATCH 8/51 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 7959dfa..92c183f 100644
@@ -1902,7 +1902,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 2f906a2..325ef2c 100644
@@ -847,13 +847,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);
@@ -888,7 +892,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;
 }
 
@@ -1041,6 +1045,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;
@@ -1056,7 +1061,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 2b1bf83..b4620b9 100644
@@ -35,7 +35,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 c80e20d..40b5d83 100644
@@ -2085,13 +2085,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);
@@ -2109,7 +2114,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;
 }
 
@@ -2137,6 +2142,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;
 
@@ -2150,7 +2156,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 74df0fc..fdeaa66 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
#31 lore raw

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

Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:17AM +0000, [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.

Why do we have different functions in the first place? -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#32 lore raw

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

Quoted 9 lines · Chris Wilson
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:17AM +0000, [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.

Why do we have different functions in the first place?

There seems to be a bit a layer fumble going on with the lrc alloc request also pinning the lrc context. We could pull that out and then share the function again since there's indeed no reason no to. At least afaics.

Also we should probably assign the ctx (if there is any) right in the request alloc function so that these two bits are always tied together. -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
#33 lore raw

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

Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Chris Wilson
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:17AM +0000, [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.

Quoted 8 lines
Quoted 1 line

Why do we have different functions in the first place?

There seems to be a bit a layer fumble going on with the lrc alloc request also pinning the lrc context. We could pull that out and then share the function again since there's indeed no reason no to. At least afaics.

Also we should probably assign the ctx (if there is any) right in the request alloc function so that these two bits are always tied together. -Daniel

See later patch 'set context in request creation...'. That moves the ctx assignment out of _i915_add_request() and into alloc_request() for the legacy code path. Thus bringing the legacy and lrc versions back into alignment. As for the pinning, I am leaving that exactly as is as I don't really know the ins and outs of it. One of the execlist experts might be able to comment as to whether that is the right place for it or not.

Also, I am currently working on the conversion to struct fence. As part of that, the request allocation changes quite a bit. Rather than have two clones of the code that have to be independently maintained, I have a patch to unify the common portion. We then have i915_gem_request_alloc() that all the driver calls instead of the indirected function pointer. That then does all the common work and chains on to the legacy/execlist specific helper at the end (which currently only sets the ringbuffer field for legacy mode and also does the LRC pinning for execlist mode).

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

#34 lore raw

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

Quoted 25 lines · John Harrison
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Chris Wilson
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:17AM +0000, [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.

Quoted 8 lines
Quoted 1 line

Why do we have different functions in the first place?

There seems to be a bit a layer fumble going on with the lrc alloc request also pinning the lrc context. We could pull that out and then share the function again since there's indeed no reason no to. At least afaics.

Also we should probably assign the ctx (if there is any) right in the request alloc function so that these two bits are always tied together. -Daniel

See later patch 'set context in request creation...'. That moves the ctx assignment out of _i915_add_request() and into alloc_request() for the legacy code path. Thus bringing the legacy and lrc versions back into alignment. As for the pinning, I am leaving that exactly as is as I don't really know the ins and outs of it. One of the execlist experts might be able to comment as to whether that is the right place for it or not.

Quoted 8 lines

Also, I am currently working on the conversion to struct fence. As part of that, the request allocation changes quite a bit. Rather than have two clones of the code that have to be independently maintained, I have a patch to unify the common portion. We then have i915_gem_request_alloc() that all the driver calls instead of the indirected function pointer. That then does all the common work and chains on to the legacy/execlist specific helper at the end (which currently only sets the ringbuffer field for legacy mode and also does the LRC pinning for execlist mode).

That sounds exactly like what I'd want to see here. So no need for additional frobbing in the mean time imo.
-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
#35 lore raw

PATCH 9/51 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 92c183f..df9b5d7 100644
@@ -1648,6 +1648,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
#36 lore raw

PATCH 10/51 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 325ef2c..2ab6922 100644
@@ -703,7 +703,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
#37 lore raw

PATCH 11/51 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 2ab6922..1dbf4b1 100644
@@ -569,11 +569,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;
@@ -582,7 +580,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;
 
@@ -598,7 +596,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);
 }
 
 /**
@@ -677,7 +675,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
#38 lore raw

PATCH 12/51 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 df9b5d7..21a2b35 100644
@@ -2627,7 +2627,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 1dbf4b1..450eed4 100644
@@ -703,7 +703,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
#39 lore raw

PATCH 13/51 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 21a2b35..5c87876 100644
@@ -2815,9 +2815,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 9546992..96f9155 100644
@@ -2408,7 +2408,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;
@@ -2433,12 +2434,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;
 	}
@@ -2450,15 +2450,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 450eed4..318500c 100644
@@ -1612,7 +1612,7 @@ 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
#40 lore raw

PATCH 14/51 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.

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 96f9155..ef561e5 100644
@@ -3938,9 +3938,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) {
+			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
#41 lore raw

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

Quoted 32 lines · On Fri, Feb 13, 2015 at 11:48:23AM +0000, [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.

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 +8 -3
index 96f9155..ef561e5 100644
@@ -3938,9 +3938,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) {
+			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)

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

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

Wrong layer. The only place using pin_and_fence (the caller of this function) with non-NULL ring is the pageflip code, which also throws other stuff onto the ring.
-Daniel

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
 	}
 
 	/* 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
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
#42 lore raw

PATCH 15/51 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 5c87876..1bfb8d3 100644
@@ -2728,7 +2728,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 ef561e5..00a031b 100644
@@ -2951,7 +2951,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
@@ -2961,8 +2961,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;
@@ -3948,7 +3949,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 318500c..cb12eea 100644
@@ -580,7 +580,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
#43 lore raw

PATCH 16/51 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 00a031b..8923ecd 100644
@@ -3109,11 +3109,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
#44 lore raw

PATCH 17/51 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 |   28 ++++++++++++++++------------
 drivers/gpu/drm/i915/i915_gem_gtt.h |    1 +
 3 files changed, 36 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +19 -6
index 8923ecd..e298119 100644
@@ -4839,19 +4839,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 +16 -12
index 746f77f..1528e77 100644
@@ -1186,11 +1186,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. */
@@ -1209,16 +1204,25 @@ 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;
+}
+
+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;
+	int ret = 0;
+
+	if (!ppgtt)
+		return 0;
+
+	ret = ppgtt->switch_mm(ppgtt, ring);
+	if (ret != 0)
+		return ret;
 
 	return ret;
 }
+
 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 e377c7d..78a107e 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
#45 lore raw

PATCH 18/51 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 1bfb8d3..099a3ee 100644
@@ -2973,7 +2973,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 e298119..1c711c0 100644
@@ -4839,6 +4839,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);
@@ -4854,6 +4856,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);
@@ -4865,17 +4869,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
#46 lore raw

PATCH 19/51 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_gtt.c          |    7 +------
 drivers/gpu/drm/i915/i915_gem_render_state.c |    3 ++-
 drivers/gpu/drm/i915/intel_lrc.c             |    8 +++-----
 5 files changed, 26 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 099a3ee..2229238 100644
@@ -2151,7 +2151,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 1c711c0..5f24ce1 100644
@@ -2466,6 +2466,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) {
@@ -4856,8 +4857,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);
@@ -4866,6 +4875,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;
 		}
@@ -4873,8 +4883,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_gtt.c +1 -6
index 1528e77..6048ed9 100644
@@ -1211,16 +1211,11 @@ 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;
-	int ret = 0;
 
 	if (!ppgtt)
 		return 0;
 
-	ret = ppgtt->switch_mm(ppgtt, ring);
-	if (ret != 0)
-		return ret;
-
-	return ret;
+	return ppgtt->switch_mm(ppgtt, ring);
 }
 
 struct i915_hw_ppgtt *
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 cb12eea..de01cae 100644
@@ -1592,8 +1592,6 @@ 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);
@@ -1612,9 +1610,9 @@ 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
#47 lore raw

PATCH 20/51 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 2229238..2eab9f4 100644
@@ -2974,7 +2974,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 5f24ce1..e34672e 100644
@@ -4872,7 +4872,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);
@@ -4880,7 +4880,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 6048ed9..e7c9137 100644
@@ -1207,15 +1207,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 78a107e..0804bbc 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
#48 lore raw

PATCH 21/51 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 e34672e..02b921b 100644
@@ -2469,14 +2469,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 40b5d83..84a1e22 100644
@@ -2107,6 +2107,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
#49 lore raw

PATCH 22/51 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 2eab9f4..e5132d3 100644
@@ -2976,8 +2976,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 02b921b..5f17ade 100644
@@ -2469,8 +2469,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;
@@ -3109,7 +3107,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
#50 lore raw

PATCH 23/51 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
#51 lore raw

PATCH 24/51 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 de01cae..2882d3f 100644
@@ -1822,6 +1822,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;
@@ -1902,13 +1903,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
#52 lore raw

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

Quoted 5 lines · On Fri, Feb 13, 2015 at 11:48:33AM +0000, [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.

That's not correct. There are no more contexts in execlists than legacy. There are more ringbuffers, or rather the contexts have an extra state object associated with them.

Quoted 8 lines

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.

This is upside down though. The request should be referencing the context (thus instantiating it on demand) and nothing in the context allocation requires the request. The initialisation here should be during i915_request_switch_context(), since it can be entirely shared with legacy.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#53 lore raw

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

Quoted 9 lines · Chris Wilson
Quoted 5 lines · On Fri, Feb 13, 2015 at 11:48:33AM +0000, [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.

That's not correct. There are no more contexts in execlists than legacy. There are more ringbuffers, or rather the contexts have an extra state object associated with them.

Okay, I should have said sub-contexts. Or context state objects. Or something.

Quoted 8 lines
Quoted 8 lines

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.

Quoted 6 lines

This is upside down though. The request should be referencing the context (thus instantiating it on demand) and nothing in the context allocation requires the request. The initialisation here should be during i915_request_switch_context(), since it can be entirely shared with legacy.
-Chris

The request does reference the context - the alloc_reques() function takes a context object as a parameter. Thus it is impossible for the request to be used/supplied/required during context creation. The issue here is the lazy initialisation of the per ring context state which requires sending commands to the ring on first usage of the given context object on the given ring.

One problem is that the initialisation request and the batch buffer request cannot be merged at the moment. They both use request->batch_obj for tracking the command object. Thus this patch only works due to the deferred intialisation occurring during the i915_gem_validate_context() call very early on in execbuffer() rather than as part of the context switch within the batch buffer execution which is much later.

I'm not sure what you mean by i915_request_switch_context(). The existing i915_switch_context() does now take just a request structure rather than a ring/ringbuf/context mixture. However, it is not really a good idea to do the context switch automatically as part of creating the request. The request creation and request execution could be quite separated in time, especially with a scheduler.

It should be possible to move the deferred initialisation within the context switch if the object tracking can be resolved. Thus they could share the same request and there would not be effectively two separate execution calls at the hardware level. Again, that's potentially work that could be done as a follow up task of improving the context management independent of the current task of removing the OLR.

John.

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

#54 lore raw

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

Quoted 4 lines · John Harrison
Quoted 3 lines · Chris Wilson
Quoted 2 lines · On Fri, Feb 13, 2015 at 11:48:33AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

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.

That's not correct. There are no more contexts in execlists than legacy. There are more ringbuffers, or rather the contexts have an extra state object associated with them.

Okay, I should have said sub-contexts. Or context state objects. Or something.

per-engine ctx state? Naming stuff is hard ;-)

Quoted 21 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

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.

Quoted 6 lines

This is upside down though. The request should be referencing the context (thus instantiating it on demand) and nothing in the context allocation requires the request. The initialisation here should be during i915_request_switch_context(), since it can be entirely shared with legacy.
-Chris

The request does reference the context - the alloc_reques() function takes a context object as a parameter. Thus it is impossible for the request to be used/supplied/required during context creation. The issue here is the lazy initialisation of the per ring context state which requires sending commands to the ring on first usage of the given context object on the given ring.

Quoted 6 lines

One problem is that the initialisation request and the batch buffer request cannot be merged at the moment. They both use request->batch_obj for tracking the command object. Thus this patch only works due to the deferred intialisation occurring during the i915_gem_validate_context() call very early on in execbuffer() rather than as part of the context switch within the batch buffer execution which is much later.

My request struct doesn't have a batch_obj pointer. Where is that from and why do we need it? Atm just chasing Chris' comments, haven't read the full series yet.

Quoted 7 lines

I'm not sure what you mean by i915_request_switch_context(). The existing i915_switch_context() does now take just a request structure rather than a ring/ringbuf/context mixture. However, it is not really a good idea to do the context switch automatically as part of creating the request. The request creation and request execution could be quite separated in time, especially with a scheduler.

Quoted 6 lines

It should be possible to move the deferred initialisation within the context switch if the object tracking can be resolved. Thus they could share the same request and there would not be effectively two separate execution calls at the hardware level. Again, that's potentially work that could be done as a follow up task of improving the context management independent of the current task of removing the OLR.

I think the biggest risk with adding a separate request for the lrc deferred init is in accidentally nesting request when someone moves around the lrc validation. Atm it's at the top of execbuf but we tend to shuffle things around a lot.

Is there some simple WARN_ON we could smash into the alloc function to make sure this never happens? ring->olr would be it, but since we want to kill that that's not great. Or do I see risks which aren't really there? -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
#55 lore raw

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

Quoted 41 lines · Daniel Vetter
Quoted 4 lines · John Harrison
Quoted 3 lines · Chris Wilson
Quoted 2 lines · On Fri, Feb 13, 2015 at 11:48:33AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

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.

That's not correct. There are no more contexts in execlists than legacy. There are more ringbuffers, or rather the contexts have an extra state object associated with them.

Okay, I should have said sub-contexts. Or context state objects. Or something.

per-engine ctx state? Naming stuff is hard ;-)

Quoted 20 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

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.

Quoted 6 lines

This is upside down though. The request should be referencing the context (thus instantiating it on demand) and nothing in the context allocation requires the request. The initialisation here should be during i915_request_switch_context(), since it can be entirely shared with legacy.
-Chris

The request does reference the context - the alloc_reques() function takes a context object as a parameter. Thus it is impossible for the request to be used/supplied/required during context creation. The issue here is the lazy initialisation of the per ring context state which requires sending commands to the ring on first usage of the given context object on the given ring.

Quoted 6 lines

One problem is that the initialisation request and the batch buffer request cannot be merged at the moment. They both use request->batch_obj for tracking the command object. Thus this patch only works due to the deferred intialisation occurring during the i915_gem_validate_context() call very early on in execbuffer() rather than as part of the context switch within the batch buffer execution which is much later.

Quoted 3 lines

My request struct doesn't have a batch_obj pointer. Where is that from and why do we need it? Atm just chasing Chris' comments, haven't read the full series yet.

It should do! It was added way back in June 2013 by Mika in 'drm/i915: add batch bo to i915_add_request()'. So unless someone has removed it again since I last fetched a tree, you should definitely have it.

Quoted 18 lines
Quoted 7 lines

I'm not sure what you mean by i915_request_switch_context(). The existing i915_switch_context() does now take just a request structure rather than a ring/ringbuf/context mixture. However, it is not really a good idea to do the context switch automatically as part of creating the request. The request creation and request execution could be quite separated in time, especially with a scheduler.

Quoted 6 lines

It should be possible to move the deferred initialisation within the context switch if the object tracking can be resolved. Thus they could share the same request and there would not be effectively two separate execution calls at the hardware level. Again, that's potentially work that could be done as a follow up task of improving the context management independent of the current task of removing the OLR.

I think the biggest risk with adding a separate request for the lrc deferred init is in accidentally nesting request when someone moves around the lrc validation. Atm it's at the top of execbuf but we tend to shuffle things around a lot.

Quoted 4 lines

Is there some simple WARN_ON we could smash into the alloc function to make sure this never happens? ring->olr would be it, but since we want to kill that that's not great. Or do I see risks which aren't really there? -Daniel

There is a WARN_ON that the batch object in the request structure does not get overwritten. Although, that could only happen if the lazy setup and the batch buffer execution were sharing the same request. Nesting multiple requests shouldn't really be a problem. Without the OLR, there is no globally shared state. Having multiple requests being created in parallel is fine. The lazy context setup must be completed before the execbuffer is executed otherwise Bad Things are going to happen irrespective of request usage. So even if the execbuffer request is created first, the lazy setup will still happen at the right time without breaking the execbuffer's request.

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

#56 lore raw

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

Quoted 42 lines · John Harrison
Quoted 41 lines · Daniel Vetter
Quoted 4 lines · John Harrison
Quoted 3 lines · Chris Wilson
Quoted 2 lines · On Fri, Feb 13, 2015 at 11:48:33AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

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.

That's not correct. There are no more contexts in execlists than legacy. There are more ringbuffers, or rather the contexts have an extra state object associated with them.

Okay, I should have said sub-contexts. Or context state objects. Or something.

per-engine ctx state? Naming stuff is hard ;-)

Quoted 26 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line

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.

Quoted 6 lines

This is upside down though. The request should be referencing the context (thus instantiating it on demand) and nothing in the context allocation requires the request. The initialisation here should be during i915_request_switch_context(), since it can be entirely shared with legacy.
-Chris

The request does reference the context - the alloc_reques() function takes a context object as a parameter. Thus it is impossible for the request to be used/supplied/required during context creation. The issue here is the lazy initialisation of the per ring context state which requires sending commands to the ring on first usage of the given context object on the given ring.

One problem is that the initialisation request and the batch buffer request cannot be merged at the moment. They both use request->batch_obj for tracking the command object. Thus this patch only works due to the deferred intialisation occurring during the i915_gem_validate_context() call very early on in execbuffer() rather than as part of the context switch within the batch buffer execution which is much later.

Quoted 6 lines
Quoted 3 lines

My request struct doesn't have a batch_obj pointer. Where is that from and why do we need it? Atm just chasing Chris' comments, haven't read the full series yet.

It should do! It was added way back in June 2013 by Mika in 'drm/i915: add batch bo to i915_add_request()'. So unless someone has removed it again since I last fetched a tree, you should definitely have it.

I must have been blind. Now I've found both the batch_obj and how it's used in the renderstate. And that usage looks wrong since request->batch_obj is used to assign blame to userspace batches for arb_robustness gpu hang stats. The render state init batch is created by the kernel, per definition userspace can't be responsible for hangs in there.

Imo we should replace the batch obj argument in i915_gem_render_state_init with NULL.

Would this allow you to resolve the inversion Chris brought up? Or is there something else which would prevent us from putting the deferred render ring init into the same request as the first execbuf?

Quoted 23 lines
Quoted 18 lines
Quoted 7 lines

I'm not sure what you mean by i915_request_switch_context(). The existing i915_switch_context() does now take just a request structure rather than a ring/ringbuf/context mixture. However, it is not really a good idea to do the context switch automatically as part of creating the request. The request creation and request execution could be quite separated in time, especially with a scheduler.

Quoted 6 lines

It should be possible to move the deferred initialisation within the context switch if the object tracking can be resolved. Thus they could share the same request and there would not be effectively two separate execution calls at the hardware level. Again, that's potentially work that could be done as a follow up task of improving the context management independent of the current task of removing the OLR.

I think the biggest risk with adding a separate request for the lrc deferred init is in accidentally nesting request when someone moves around the lrc validation. Atm it's at the top of execbuf but we tend to shuffle things around a lot.

Quoted 4 lines

Is there some simple WARN_ON we could smash into the alloc function to make sure this never happens? ring->olr would be it, but since we want to kill that that's not great. Or do I see risks which aren't really there? -Daniel

Quoted 10 lines

There is a WARN_ON that the batch object in the request structure does not get overwritten. Although, that could only happen if the lazy setup and the batch buffer execution were sharing the same request. Nesting multiple requests shouldn't really be a problem. Without the OLR, there is no globally shared state. Having multiple requests being created in parallel is fine. The lazy context setup must be completed before the execbuffer is executed otherwise Bad Things are going to happen irrespective of request usage. So even if the execbuffer request is created first, the lazy setup will still happen at the right time without breaking the execbuffer's request.

Ok, sounds like we'd be covered. I just wanted to make sure we're not ignoring potential issues here, but if requests are free-standing already as-is (well after this series) we're hopefully fine.
-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
#57 lore raw

PATCH 25/51 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 2882d3f..4689853 100644
@@ -1322,16 +1322,15 @@ static int gen8_emit_request(struct intel_ringbuffer *ringbuf,
 	return 0;
 }
 
-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);
 }
 
 /**
@@ -1909,7 +1908,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 84a1e22..a0a9d71 100644
@@ -713,16 +713,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 fdeaa66..36631e2 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
#58 lore raw

PATCH 26/51 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.

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             |   23 +++++++++++------------
 drivers/gpu/drm/i915/intel_lrc.h             |    2 --
 drivers/gpu/drm/i915/intel_ringbuffer.c      |    2 +-
 5 files changed, 22 insertions(+), 25 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 +11 -12
index 4689853..ad13cc7 100644
@@ -203,6 +203,7 @@ enum {
 };
 #define GEN8_CTX_ID_SHIFT 32
 
+static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req);
 static int intel_lr_context_pin(struct intel_engine_cs *ring,
 		struct intel_context *ctx);
 
@@ -1330,7 +1331,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);
 }
 
 /**
@@ -1586,31 +1587,29 @@ cleanup_render_ring:
 	return ret;
 }
 
-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);
drivers/gpu/drm/i915/intel_lrc.h +0 -2
index b4620b9..975effb 100644
@@ -73,8 +73,6 @@ int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
 			     int num_dwords);
 
 /* Logical Ring Contexts */
-int intel_lr_context_render_state_init(struct intel_engine_cs *ring,
-				       struct intel_context *ctx);
 void intel_lr_context_free(struct intel_context *ctx);
 int intel_lr_context_deferred_create(struct intel_context *ctx,
 				     struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index a0a9d71..c7a9192 100644
@@ -721,7 +721,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
#59 lore raw

PATCH 27/51 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
#60 lore raw

PATCH 28/51 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    |   47 ++++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_ringbuffer.c |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.h |    1 -
 4 files changed, 32 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index e5132d3..4b82b2e 100644
@@ -559,7 +559,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 +30 -17

158 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index c7a9192..9a0e944 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 36631e2..582b0ec 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
#61 lore raw

PATCH 29/51 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 4b82b2e..b7c01e2 100644
@@ -2814,14 +2814,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 5f17ade..8b0bfbd 100644
@@ -1161,7 +1161,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;
 }
@@ -2406,25 +2406,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);
 	/*
@@ -3113,7 +3113,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;
@@ -3961,7 +3961,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;
 		}
@@ -4879,7 +4879,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 f23f28e..4aaa190 100644
@@ -9859,7 +9859,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 ad13cc7..56151c3 100644
@@ -1916,7 +1916,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 9a0e944..178bf49 100644
@@ -2066,8 +2066,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
#62 lore raw

PATCH 30/51 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 b7c01e2..be1e143 100644
@@ -2731,7 +2731,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 8b0bfbd..e8257dd 100644
@@ -2264,17 +2264,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);
 	}
@@ -2285,16 +2284,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 56151c3..245a5da 100644
@@ -1606,7 +1606,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
#63 lore raw

PATCH 31/51 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 be1e143..8f20c37 100644
@@ -2809,7 +2809,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 e8257dd..ab31cb0 100644
@@ -4639,8 +4639,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);
@@ -4859,7 +4860,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
#64 lore raw

PATCH 32/51 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
#65 lore raw

PATCH 33/51 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 245a5da..0c1a8e5 100644
@@ -550,10 +550,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;
 
@@ -561,7 +560,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;
@@ -597,7 +596,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 178bf49..fc5bc48 100644
@@ -2776,8 +2776,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 582b0ec..411cd76 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
#66 lore raw

PATCH 34/51 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 0c1a8e5..ee1f062 100644
@@ -1067,11 +1067,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;
@@ -1080,11 +1080,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;
 
@@ -1098,7 +1098,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;
 
@@ -1326,7 +1326,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 fc5bc48..32cae54 100644
@@ -674,10 +674,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;
@@ -717,7 +717,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
#67 lore raw

PATCH 35/51 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 ab31cb0..a728f91 100644
@@ -2435,9 +2435,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 ee1f062..a31cc33 100644
@@ -760,16 +760,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;
 
@@ -1080,7 +1079,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;
 
@@ -1098,7 +1097,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 975effb..474597e 100644
@@ -41,8 +41,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);
 void intel_logical_ring_advance_and_submit(
 				struct intel_ringbuffer *ringbuf,
 				struct intel_context *ctx,
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -3
index 32cae54..6a53bfc 100644
@@ -686,7 +686,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;
 
@@ -704,7 +704,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;
 
@@ -2758,8 +2758,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 411cd76..8a672b1 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
#68 lore raw

PATCH 36/51 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.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem_context.c |    2 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c     |   20 ++++++++++++--------
 drivers/gpu/drm/i915/i915_gem_gtt.h     |    2 +-
 3 files changed, 14 insertions(+), 10 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 +12 -8
index e7c9137..89bbc2c 100644
@@ -276,9 +276,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);
@@ -299,7 +300,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;
 
@@ -308,7 +309,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;
 	}
@@ -773,8 +774,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 */
@@ -798,8 +800,9 @@ static int hsw_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 */
@@ -830,8 +833,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;
 
@@ -1215,7 +1219,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 0804bbc..96a58d4 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
#69 lore raw

PATCH 37/51 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 89bbc2c..e3a65c3 100644
@@ -780,7 +780,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;
 
@@ -806,7 +806,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;
 
@@ -824,7 +824,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 6a53bfc..bc3c0e6 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;
@@ -1448,10 +1453,11 @@ void intel_ring_setup_status_page(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);
@@ -2239,9 +2245,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;
 
@@ -2343,9 +2350,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;
@@ -2766,7 +2774,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;
 
@@ -2787,7 +2795,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 8a672b1..824c71b 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
#70 lore raw

PATCH 38/51 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 bc3c0e6..2f9ba79 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;
 }
@@ -2388,7 +2391,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
#71 lore raw

PATCH 39/51 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 a31cc33..21bda2d 100644
@@ -560,8 +560,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;
 
@@ -768,7 +767,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;
 
@@ -1201,18 +1200,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;
 
@@ -1240,11 +1239,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;
@@ -1268,7 +1267,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 824c71b..373ebf3 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
#72 lore raw

PATCH 40/51 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 a728f91..616b34a 100644
@@ -2452,7 +2452,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 2f9ba79..ce1dab4 100644
@@ -1081,16 +1081,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)
@@ -1103,8 +1103,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);
 
@@ -1201,8 +1200,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;
 
@@ -1222,8 +1222,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 */
@@ -1242,8 +1241,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);
 
@@ -1474,8 +1472,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);
@@ -1484,8 +1483,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 373ebf3..e33e010 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
#73 lore raw

PATCH 41/51 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 616b34a..38f8a3b 100644
@@ -2450,7 +2450,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 21bda2d..02769f8 100644
@@ -1292,9 +1292,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;
@@ -1311,8 +1311,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 e33e010..ef20c49 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
#74 lore raw

PATCH 42/51 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 ce1dab4..cf23767 100644
@@ -1615,10 +1615,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);
@@ -1641,10 +1642,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;
 
@@ -1703,10 +1705,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);
@@ -2283,10 +2286,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;
@@ -2306,10 +2310,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);
@@ -2328,10 +2333,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 ef20c49..545b867 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
#75 lore raw

PATCH 43/51 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 02769f8..54e6a25 100644
@@ -696,7 +696,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;
 
@@ -1146,14 +1146,14 @@ static int gen8_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;
 
@@ -1595,9 +1595,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 545b867..514ddcb 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
#76 lore raw

PATCH 44/51 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 38f8a3b..e60ea05 100644
@@ -2980,7 +2980,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 cf23767..aa521c7 100644
@@ -1126,10 +1126,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;
 
@@ -1151,10 +1152,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 514ddcb..4b4fd2d 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
#77 lore raw

PATCH 45/51 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 aa521c7..e04e881 100644
@@ -964,10 +964,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;
@@ -987,8 +988,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 |
@@ -1005,10 +1005,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;
@@ -1028,8 +1029,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) |
@@ -1044,9 +1044,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;
@@ -1064,8 +1065,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);
@@ -1094,7 +1094,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 4b4fd2d..70f3f5d 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
#78 lore raw

PATCH 46/51 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 4aaa190..30fa5e1 100644
@@ -9388,7 +9388,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 e04e881..b3aca4a 100644
@@ -2179,8 +2179,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 70f3f5d..ba7213f 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
#79 lore raw

PATCH 47/51 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.

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 6ece663..0844166 100644
@@ -4959,6 +4959,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;
 
@@ -4977,16 +4978,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, NULL, &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);
@@ -5000,6 +5002,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
@@ -5007,16 +5014,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
#80 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#81 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

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

#82 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 9 lines · John Harrison
Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Quoted 5 lines

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

I did and tested extensively.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#83 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 10 lines · Chris Wilson
Quoted 9 lines · John Harrison
Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Quoted 7 lines
Quoted 5 lines

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

I did and tested extensively.
-Chris

Do you have a patch that just does the move of this from PM code to context switch code? Something that I can drop into this series would be great. If not, exactly where about in the context switch code should it go? Should it be in the start of day initialisation, in the per context intialisation, every context switch, only the first switch after a resume, ...?

Tracing back to where/when this code is currently executed seems to be quite complicated. The _enable_rc6() function is called during ring reset but only for Gen6+ because Ironlake is broken according to the comment. It is also called by a system power management callback but it is unclear when that would occur. Finally, it is also called from the display code in intel_modeset_init_hw().

Thanks,
John.

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

#84 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 25 lines · John Harrison
Quoted 10 lines · Chris Wilson
Quoted 9 lines · John Harrison
Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Quoted 7 lines
Quoted 5 lines

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

I did and tested extensively.
-Chris

Do you have a patch that just does the move of this from PM code to context switch code? Something that I can drop into this series would be great. If not, exactly where about in the context switch code should it go? Should it be in the start of day initialisation, in the per context intialisation, every context switch, only the first switch after a resume, ...?

Quoted 6 lines

Tracing back to where/when this code is currently executed seems to be quite complicated. The _enable_rc6() function is called during ring reset but only for Gen6+ because Ironlake is broken according to the comment. It is also called by a system power management callback but it is unclear when that would occur. Finally, it is also called from the display code in intel_modeset_init_hw().

ilk rc6 is disabled by default because it crashes machines hard and doesn't seem to be all that useful really. Compared to gen6+ rc6 which has a massive impact on idle power consumption, more with each generation.

I've also never heard of anyone managing to make this work reliably. We could also just rip the entire code out I think, at least I wouldn't be surprised if it has bitrot completely by now.
-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
#85 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 31 lines · Daniel Vetter
Quoted 24 lines · John Harrison
Quoted 10 lines · Chris Wilson
Quoted 9 lines · John Harrison
Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Quoted 7 lines
Quoted 5 lines

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

I did and tested extensively.
-Chris

Do you have a patch that just does the move of this from PM code to context switch code? Something that I can drop into this series would be great. If not, exactly where about in the context switch code should it go? Should it be in the start of day initialisation, in the per context intialisation, every context switch, only the first switch after a resume, ...?

Quoted 6 lines

Tracing back to where/when this code is currently executed seems to be quite complicated. The _enable_rc6() function is called during ring reset but only for Gen6+ because Ironlake is broken according to the comment. It is also called by a system power management callback but it is unclear when that would occur. Finally, it is also called from the display code in intel_modeset_init_hw().

Quoted 8 lines

ilk rc6 is disabled by default because it crashes machines hard and doesn't seem to be all that useful really. Compared to gen6+ rc6 which has a massive impact on idle power consumption, more with each generation.

I've also never heard of anyone managing to make this work reliably. We could also just rip the entire code out I think, at least I wouldn't be surprised if it has bitrot completely by now.
-Daniel

So just remove the ironlake_enable_rc6() function completely? Or keep it as a stub that just says '/* this has never worked so has been removed */'.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#86 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 36 lines · John Harrison
Quoted 35 lines · Daniel Vetter
Quoted 24 lines · John Harrison
Quoted 10 lines · Chris Wilson
Quoted 9 lines · John Harrison
Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Quoted 7 lines
Quoted 5 lines

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

I did and tested extensively.
-Chris

Do you have a patch that just does the move of this from PM code to context switch code? Something that I can drop into this series would be great. If not, exactly where about in the context switch code should it go? Should it be in the start of day initialisation, in the per context intialisation, every context switch, only the first switch after a resume, ...?

Quoted 6 lines

Tracing back to where/when this code is currently executed seems to be quite complicated. The _enable_rc6() function is called during ring reset but only for Gen6+ because Ironlake is broken according to the comment. It is also called by a system power management callback but it is unclear when that would occur. Finally, it is also called from the display code in intel_modeset_init_hw().

ilk rc6 is disabled by default because it crashes machines hard and doesn't seem to be all that useful really. Compared to gen6+ rc6 which has a massive impact on idle power consumption, more with each generation.

Quoted 7 lines
Quoted 4 lines

I've also never heard of anyone managing to make this work reliably. We could also just rip the entire code out I think, at least I wouldn't be surprised if it has bitrot completely by now.
-Daniel

So just remove the ironlake_enable_rc6() function completely? Or keep it as a stub that just says '/* this has never worked so has been removed */'.

Just remove it entirely, together with all the other ironlake rc6 stuff plus functions only called by it. All the ironlake_*_rc6 stuff essentially. ironlake_*_drps is the turbo support, that part needs to stay.
-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
#87 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

In reply to Daniel Vetter
Quoted 33 lines · Daniel Vetter
Quoted 25 lines · John Harrison
Quoted 10 lines · Chris Wilson
Quoted 9 lines · John Harrison
Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Quoted 7 lines
Quoted 5 lines

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

I did and tested extensively.
-Chris

Do you have a patch that just does the move of this from PM code to context switch code? Something that I can drop into this series would be great. If not, exactly where about in the context switch code should it go? Should it be in the start of day initialisation, in the per context intialisation, every context switch, only the first switch after a resume, ...?

Quoted 6 lines

Tracing back to where/when this code is currently executed seems to be quite complicated. The _enable_rc6() function is called during ring reset but only for Gen6+ because Ironlake is broken according to the comment. It is also called by a system power management callback but it is unclear when that would occur. Finally, it is also called from the display code in intel_modeset_init_hw().

Quoted 7 lines

ilk rc6 is disabled by default because it crashes machines hard and doesn't seem to be all that useful really. Compared to gen6+ rc6 which has a massive impact on idle power consumption, more with each generation.

I've also never heard of anyone managing to make this work reliably. We could also just rip the entire code out I think, at least I wouldn't be surprised if it has bitrot completely by now.

I was running with it when Ben had those ILK context+rc6 patches flying around. But I admit that was some time ago.

Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#88 lore raw

Re: [PATCH 47/51] drm/i915: Update ironlake_enable_rc6() to do explicit request management

Quoted 38 lines · Ville Syrjälä
Quoted 37 lines · Daniel Vetter
Quoted 25 lines · John Harrison
Quoted 10 lines · Chris Wilson
Quoted 9 lines · John Harrison
Quoted 8 lines · Chris Wilson
Quoted 3 lines · On Fri, Feb 13, 2015 at 11:48:56AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

If you merged the context here with the common context switching code, we don't even need to touch the ring here.
-Chris

Quoted 7 lines
Quoted 5 lines

It would certainly be preferable to not have any ring commands written from deep within the power management code. However, I didn't want to change anything I didn't really need to, especially in code that I'm not at all sure about. Plus I don't have an ironlake to test any significant change on.

I did and tested extensively.
-Chris

Do you have a patch that just does the move of this from PM code to context switch code? Something that I can drop into this series would be great. If not, exactly where about in the context switch code should it go? Should it be in the start of day initialisation, in the per context intialisation, every context switch, only the first switch after a resume, ...?

Quoted 6 lines

Tracing back to where/when this code is currently executed seems to be quite complicated. The _enable_rc6() function is called during ring reset but only for Gen6+ because Ironlake is broken according to the comment. It is also called by a system power management callback but it is unclear when that would occur. Finally, it is also called from the display code in intel_modeset_init_hw().

ilk rc6 is disabled by default because it crashes machines hard and doesn't seem to be all that useful really. Compared to gen6+ rc6 which has a massive impact on idle power consumption, more with each generation.

Quoted 6 lines
Quoted 3 lines

I've also never heard of anyone managing to make this work reliably. We could also just rip the entire code out I think, at least I wouldn't be surprised if it has bitrot completely by now.

I was running with it when Ben had those ILK context+rc6 patches flying around. But I admit that was some time ago.

Iirc we've enabled it for a bit with those, it fell to pieces too. And it seems to be rare enough that testing on a developers machine doesn't cut it (tried myself to enable it a few times and had to revert again). -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
#89 lore raw

PATCH 48/51 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       |   12 ++---
 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, 55 insertions(+), 59 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index e60ea05..4777eb2 100644
@@ -4651,7 +4651,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 e3a65c3..417a89e 100644
@@ -284,7 +284,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;
 
@@ -784,7 +784,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;
 
@@ -810,7 +810,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 +6 -6
index 30fa5e1..ef53839 100644
@@ -9209,7 +9209,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;
 
@@ -9244,7 +9244,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;
 
@@ -9277,7 +9277,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;
 
@@ -9316,7 +9316,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;
 
@@ -9392,7 +9392,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;
 
@@ -9621,7 +9621,7 @@ static int intel_gen9_queue_flip(struct drm_device *dev,
 		return -ENODEV;
 	}
 
-	ret = intel_ring_begin(ring, 10);
+	ret = intel_ring_begin(req, 10);
 	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 0844166..4ac7206 100644
@@ -4986,7 +4986,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 ba7213f..35799dc 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
#90 lore raw

Re: [PATCH 48/51] drm/i915: Update intel_ring_begin() to take a request structure

Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:57AM +0000, [email protected] wrote:

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.

Hmm, you missed out on returning @ring@ from intel_ring_begin() to make it explicit that accessing @ring@ through any other means is verboten. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#91 lore raw

Re: [PATCH 48/51] drm/i915: Update intel_ring_begin() to take a request structure

Quoted 10 lines · Chris Wilson
Quoted 6 lines · On Fri, Feb 13, 2015 at 11:48:57AM +0000, [email protected] wrote:

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.

Hmm, you missed out on returning @ring@ from intel_ring_begin() to make it explicit that accessing @ring@ through any other means is verboten. -Chris

Not sure what you mean here. The ring is used and necessary (at the moment) in quite a lot of places. The ringbuf object could maybe be returned by intel_ring_begin(). Although there places like _add_request() and _retire_requests() do access the ringbuf to do tail tracking. So some alternative access method or tracking scheme would be required for those uses.

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

#92 lore raw

PATCH 49/51 drm/i915: Update intel_logical_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_logical_ring_begin() can be updated to take a request instead of a ringbuf/context pair. This also means that it no longer needs to lazily allocate a request if no-one happens to have done it earlier.

Note that this change makes the execlist signature the same as the legacy version. Thus the two functions could be merged into a ring->begin() wrapper if required.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c |   35 +++++++++++++++++------------------
 drivers/gpu/drm/i915/intel_lrc.h |    3 ---
 2 files changed, 17 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +17 -18
index 54e6a25..c5408bc 100644
@@ -203,6 +203,8 @@ enum {
 };
 #define GEN8_CTX_ID_SHIFT 32
 
+static int intel_logical_ring_begin(struct drm_i915_gem_request *req,
+				    int num_dwords);
 static int intel_lr_context_render_state_init(struct drm_i915_gem_request *req);
 static int intel_lr_context_pin(struct intel_engine_cs *ring,
 		struct intel_context *ctx);
@@ -680,7 +682,7 @@ int intel_execlists_submission(struct i915_execbuffer_params *params,
 
 	if (ring == &dev_priv->ring[RCS] &&
 	    instp_mode != dev_priv->relative_constants_mode) {
-		ret = intel_logical_ring_begin(ringbuf, params->ctx, 4);
+		ret = intel_logical_ring_begin(params->request, 4);
 		if (ret)
 			return ret;
 
@@ -1028,7 +1030,7 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,
 /**
  * intel_logical_ring_begin() - prepare the logical ringbuffer to accept some commands
  *
- * @ringbuf: Logical ringbuffer.
+ * @request: The request to start some new work for
  * @num_dwords: number of DWORDs that we plan to write to the ringbuffer.
  *
  * The ringbuffer might not be ready to accept the commands right away (maybe it needs to
@@ -1038,30 +1040,27 @@ static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,
  *
  * Return: non-zero if the ringbuffer is not ready to be written to.
  */
-int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
-			     struct intel_context *ctx, int num_dwords)
+static int intel_logical_ring_begin(struct drm_i915_gem_request *req,
+				    int num_dwords)
 {
-	struct drm_i915_gem_request *req;
-	struct intel_engine_cs *ring = ringbuf->ring;
+	struct intel_engine_cs *ring = req->ring;
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret;
 
+	WARN_ON(req == NULL);
+
 	ret = i915_gem_check_wedge(&dev_priv->gpu_error,
 				   dev_priv->mm.interruptible);
 	if (ret)
 		return ret;
 
-	ret = logical_ring_prepare(ringbuf, ctx, num_dwords * sizeof(uint32_t));
-	if (ret)
-		return ret;
-
-	/* Preallocate the olr before touching the ring */
-	ret = intel_logical_ring_alloc_request(ring, ctx, &req);
+	ret = logical_ring_prepare(req->ringbuf, req->ctx,
+				   num_dwords * sizeof(uint32_t));
 	if (ret)
 		return ret;
 
-	ringbuf->space -= num_dwords * sizeof(uint32_t);
+	req->ringbuf->space -= num_dwords * sizeof(uint32_t);
 	return 0;
 }
 
@@ -1082,7 +1081,7 @@ static int intel_logical_ring_workarounds_emit(struct drm_i915_gem_request *req)
 	if (ret)
 		return ret;
 
-	ret = intel_logical_ring_begin(ringbuf, req->ctx, w->count * 2 + 2);
+	ret = intel_logical_ring_begin(req, w->count * 2 + 2);
 	if (ret)
 		return ret;
 
@@ -1153,7 +1152,7 @@ static int gen8_emit_bb_start(struct drm_i915_gem_request *req,
 	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
-	ret = intel_logical_ring_begin(ringbuf, req->ctx, 4);
+	ret = intel_logical_ring_begin(req, 4);
 	if (ret)
 		return ret;
 
@@ -1211,7 +1210,7 @@ static int gen8_emit_flush(struct drm_i915_gem_request *request,
 	uint32_t cmd;
 	int ret;
 
-	ret = intel_logical_ring_begin(ringbuf, request->ctx, 4);
+	ret = intel_logical_ring_begin(request, 4);
 	if (ret)
 		return ret;
 
@@ -1267,7 +1266,7 @@ static int gen8_emit_flush_render(struct drm_i915_gem_request *request,
 		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
 	}
 
-	ret = intel_logical_ring_begin(ringbuf, request->ctx, 6);
+	ret = intel_logical_ring_begin(request, 6);
 	if (ret)
 		return ret;
 
@@ -1299,7 +1298,7 @@ static int gen8_emit_request(struct drm_i915_gem_request *request)
 	u32 cmd;
 	int ret;
 
-	ret = intel_logical_ring_begin(ringbuf, request->ctx, 6);
+	ret = intel_logical_ring_begin(request, 6);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/intel_lrc.h +0 -3
index 474597e..42088c1 100644
@@ -67,9 +67,6 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,
 	iowrite32(data, ringbuf->virtual_start + ringbuf->tail);
 	ringbuf->tail += 4;
 }
-int intel_logical_ring_begin(struct intel_ringbuffer *ringbuf,
-			     struct intel_context *ctx,
-			     int num_dwords);
 
 /* Logical Ring Contexts */
 void intel_lr_context_free(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
#93 lore raw

Re: [PATCH 49/51] drm/i915: Update intel_logical_ring_begin() to take a request structure

Quoted 10 lines · On Fri, Feb 13, 2015 at 11:48:58AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

Note that this change makes the execlist signature the same as the legacy version. Thus the two functions could be merged into a ring->begin() wrapper if required.

It should be noted that you don't even need to virtualise the function... Please kill all the duplicated code. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#94 lore raw

Re: [PATCH 49/51] drm/i915: Update intel_logical_ring_begin() to take a request structure

Quoted 8 lines · Chris Wilson
Quoted 7 lines · On Fri, Feb 13, 2015 at 11:48:58AM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

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

Quoted 7 lines
Quoted 3 lines

Note that this change makes the execlist signature the same as the legacy version. Thus the two functions could be merged into a ring->begin() wrapper if required.

It should be noted that you don't even need to virtualise the function... Please kill all the duplicated code. -Chris

As noted in the cover letter, quite a lot of the execlist vs legacy duplication could be resolved back to a single code path. However, that was quite a large war discussion first time around. So I would rather leave that for another patch series once people actually decide what the best direction really is.

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

#95 lore raw

PATCH 50/51 drm/i915: Remove the now obsolete intel_ring_get_request()

In reply to [email protected]

From: John Harrison <[email protected]>

Much of the driver has now been converted to passing requests around instead of rings/ringbufs/contexts. Thus the function for retreiving the request from a ring (i.e. the OLR) is no longer used and can be removed.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_ringbuffer.h |    7 -------
 1 file changed, 7 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -7
index 35799dc..e20ba9e 100644
@@ -432,11 +432,4 @@ static inline u32 intel_ring_get_tail(struct intel_ringbuffer *ringbuf)
 	return ringbuf->tail;
 }
 
-static inline struct drm_i915_gem_request *
-intel_ring_get_request(struct intel_engine_cs *ring)
-{
-	BUG_ON(ring->outstanding_lazy_request == NULL);
-	return ring->outstanding_lazy_request;
-}
-
 #endif /* _INTEL_RINGBUFFER_H_ */
Signature · 6 lines
1.7.9.5

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

PATCH 51/51 drm/i915: Remove the now obsolete 'outstanding_lazy_request'

In reply to [email protected]

From: John Harrison <[email protected]>

The outstanding_lazy_request is no longer used anywhere in the driver. Everything that was looking at it now has a request explicitly passed in from on high. Everything that was relying upon behind the scenes is now explicitly creating/passing/submitting it's own private request. Thus the OLR can be removed.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c            |   16 +---------------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    4 +---
 drivers/gpu/drm/i915/intel_lrc.c           |    6 ++----
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   17 ++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ----
 5 files changed, 6 insertions(+), 41 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +1 -15
index 4777eb2..8febd58 100644
@@ -1155,15 +1155,9 @@ i915_gem_check_wedge(struct i915_gpu_error *error,
 int
 i915_gem_check_olr(struct drm_i915_gem_request *req)
 {
-	int ret;
-
 	WARN_ON(!mutex_is_locked(&req->ring->dev->struct_mutex));
 
-	ret = 0;
-	if (req == req->ring->outstanding_lazy_request)
-		ret = i915_add_request(req);
-
-	return ret;
+	return 0;
 }
 
 static void fake_irq(unsigned long data)
@@ -2423,8 +2417,6 @@ int __i915_add_request(struct drm_i915_gem_request *request,
 	dev_priv = ring->dev->dev_private;
 	ringbuf = request->ringbuf;
 
-	WARN_ON(request != ring->outstanding_lazy_request);
-
 	request_start = intel_ring_get_tail(ringbuf);
 	/*
 	 * Emit any outstanding flushes - execbuf can fail to emit the flush
@@ -2483,7 +2475,6 @@ int __i915_add_request(struct drm_i915_gem_request *request,
 	}
 
 	trace_i915_gem_request_add(request);
-	ring->outstanding_lazy_request = NULL;
 
 	i915_queue_hangcheck(ring->dev);
 
@@ -2667,9 +2658,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
 
 		i915_gem_free_request(request);
 	}
-
-	/* This may not have been flushed before the reset, so clean it now */
-	i915_gem_request_assign(&ring->outstanding_lazy_request, NULL);
 }
 
 void i915_gem_restore_fences(struct drm_device *dev)
@@ -3119,8 +3107,6 @@ int i915_gpu_idle(struct drm_device *dev)
 			}
 		}
 
-		WARN_ON(ring->outstanding_lazy_request);
-
 		ret = intel_ring_idle(ring);
 		if (ret)
 			return ret;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -3
index 6a703e6..0eae592 100644
@@ -1571,10 +1571,8 @@ err:
 	 * 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) {
+	if (ret && params->request)
 		i915_gem_request_unreference(params->request);
-		ring->outstanding_lazy_request = NULL;
-	}
 
 	mutex_unlock(&dev->struct_mutex);
 
drivers/gpu/drm/i915/intel_lrc.c +2 -4
index c5408bc..1e23702 100644
@@ -855,8 +855,7 @@ int intel_logical_ring_alloc_request(struct intel_engine_cs *ring,
 	if (!req_out)
 		return -EINVAL;
 
-	if ((*req_out = ring->outstanding_lazy_request) != NULL)
-		return 0;
+	*req_out = NULL;
 
 	request = kzalloc(sizeof(*request), GFP_KERNEL);
 	if (request == NULL)
@@ -890,7 +889,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;
 
-	*req_out = ring->outstanding_lazy_request = request;
+	*req_out = request;
 	return 0;
 }
 
@@ -1346,7 +1345,6 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)
 
 	intel_logical_ring_stop(ring);
 	WARN_ON((I915_READ_MODE(ring) & MODE_IDLE) == 0);
-	i915_gem_request_assign(&ring->outstanding_lazy_request, NULL);
 
 	if (ring->cleanup)
 		ring->cleanup(ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -15
index 9b4cf99..1cbde62 100644
@@ -1955,7 +1955,6 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)
 
 	intel_unpin_ringbuffer_obj(ringbuf);
 	intel_destroy_ringbuffer_obj(ringbuf);
-	i915_gem_request_assign(&ring->outstanding_lazy_request, NULL);
 
 	if (ring->cleanup)
 		ring->cleanup(ring);
@@ -2074,15 +2073,6 @@ static int intel_wrap_ring_buffer(struct intel_engine_cs *ring)
 int intel_ring_idle(struct intel_engine_cs *ring)
 {
 	struct drm_i915_gem_request *req;
-	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->outstanding_lazy_request);
-		if (ret)
-			return ret;
-	}
 
 	/* Wait upon the last request to be completed */
 	if (list_empty(&ring->request_list))
@@ -2107,8 +2097,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,
 	if (!req_out)
 		return -EINVAL;
 
-	if ((*req_out = ring->outstanding_lazy_request) != NULL)
-		return 0;
+	*req_out = NULL;
 
 	request = kzalloc(sizeof(*request), GFP_KERNEL);
 	if (request == NULL)
@@ -2127,7 +2116,7 @@ intel_ring_alloc_request(struct intel_engine_cs *ring,
 		return ret;
 	}
 
-	*req_out = ring->outstanding_lazy_request = request;
+	*req_out = request;
 	return 0;
 }
 
@@ -2202,8 +2191,6 @@ void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno)
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	BUG_ON(ring->outstanding_lazy_request);
-
 	if (INTEL_INFO(dev)->gen == 6 || INTEL_INFO(dev)->gen == 7) {
 		I915_WRITE(RING_SYNC_0(ring->mmio_base), 0);
 		I915_WRITE(RING_SYNC_1(ring->mmio_base), 0);
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -4
index e20ba9e..6af5e5e 100644
@@ -258,10 +258,6 @@ struct  intel_engine_cs {
 	 */
 	struct list_head request_list;
 
-	/**
-	 * Do we have some not yet emitted requests outstanding?
-	 */
-	struct drm_i915_gem_request *outstanding_lazy_request;
 	bool gpu_caches_dirty;
 	bool fbc_dirty;
 
Signature · 6 lines
1.7.9.5

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

cover Remove the outstanding_lazy_request

In reply to [email protected]

From: John Harrison <[email protected]>

The driver tracks GPU work using request structures. Unfortunately, this tracking is not currently explicit but is done by means of a catch-all request that floats around in the background hoovering up work until it gets submitted. This background request (ring->outstanding_lazy_request or OLR) is created at the point of actually writing to the ring rather than when a particular piece of GPU work is started. This scheme sort of hangs together but causes a number of issues. It can mean that multiple pieces of independent work are lumped together in the same request or that work is not officially submitted until much later than it was created.

This patch series completely removes the OLR and explicitly tracks each piece of work with it's own personal request structure from start to submission.

The patch set seems to fix the "'gem_ringfill --r render' + ctrl-c straight after boot" issue logged as BZ:40112. I haven't done any analysis of that particular issue but the descriptions I've seen appear to blame an inconsistent or mangled OLR.

Note also that by the end of this series, a number of differences between the legacy and execlist code paths have been removed. For example add_request() and emit_request() now have the same signature thus could be merged back to a single function pointer. Merging some of these together would also allow the removal of a bunch of 'if(execlists)' tests where the difference is simply to call the legacy function or the execlist one.

v2: Rebased to newer nightly tree, fixed up a few minor issues, added two extra patches - one to move the LRC ring begin around in the vein of other recent reshuffles, the other to clean up some issues with i915_add_request().

[Patches against drm-intel-nightly tree fetched 13/02/2015]

John Harrison (53):
drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading drm/i915: Add missing trace point to LRC execbuff code path drm/i915: Cache ringbuf pointer in request structure
drm/i915: Merged the many do_execbuf() parameters into a structure drm/i915: Add return code check to i915_gem_execbuffer_retire_commands() drm/i915: Wrap request allocation with a function pointer drm/i915: Early alloc request in execbuff
drm/i915: Update alloc_request to return the allocated request drm/i915: Add request to execbuf params and add explicit cleanup drm/i915: Update the dispatch tracepoint to use params->request drm/i915: Update move_to_gpu() to take a request structure drm/i915: Update execbuffer_move_to_active() to take a request structure drm/i915: Add flag to i915_add_request() to skip the cache flush drm/i915: Update pin_to_display_plane() to do explicit request management drm/i915: Update i915_gem_object_sync() to take a request structure drm/i915: Update i915_gpu_idle() to manage its own request drm/i915: Split i915_ppgtt_init_hw() in half - generic and per ring drm/i915: Moved the for_each_ring loop outside of i915_gem_context_enable() drm/i915: Add explicit request management to i915_gem_init_hw() drm/i915: Update ppgtt_init_ring() & context_enable() to take requests drm/i915: Set context in request from creation even in legacy mode drm/i915: Update i915_switch_context() to take a request structure drm/i915: Update do_switch() to take a request structure drm/i915: Update deferred context creation to do explicit request management drm/i915: Update init_context() to take a request structure drm/i915: Update render_state_init() to take a request structure drm/i915: Update overlay code to do explicit request management drm/i915: Update queue_flip() to do explicit request management drm/i915: Update add_request() to take a request structure drm/i915: Update [vma|object]_move_to_active() to take request structures drm/i915: Update l3_remap to take a request structure
drm/i915: Update mi_set_context() to take a request structure drm/i915: Update a bunch of execbuffer heplers to take request structures drm/i915: Update workarounds_emit() to take request structures drm/i915: Update flush_all_caches() to take request structures drm/i915: Update switch_mm() to take a request structure drm/i915: Update ring->flush() to take a requests structure drm/i915: Update some flush helpers to take request structures drm/i915: Update ring->emit_flush() to take a request structure drm/i915: Update ring->add_request() to take a request structure drm/i915: Update ring->emit_request() to take a request structure drm/i915: Update ring->dispatch_execbuffer() to take a request structure drm/i915: Update ring->emit_bb_start() to take a request structure drm/i915: Update ring->sync_to() to take a request structure drm/i915: Update ring->signal() to take a request structure drm/i915: Update cacheline_align() to take a request structure drm/i915: Update ironlake_enable_rc6() to do explicit request management drm/i915: Update intel_ring_begin() to take a request structure drm/i915: Make intel_logical_ring_begin() static
drm/i915: Update intel_logical_ring_begin() to take a request structure drm/i915: Remove the now obsolete intel_ring_get_request() drm/i915: Remove the now obsolete 'outstanding_lazy_request' drm/i915: Move the request/file and request/pid association to creation time

 drivers/gpu/drm/i915/i915_drv.h              |   72 ++--
 drivers/gpu/drm/i915/i915_gem.c              |  256 +++++++-----
 drivers/gpu/drm/i915/i915_gem_context.c      |   76 ++--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   |  141 ++++---
 drivers/gpu/drm/i915/i915_gem_gtt.c          |   58 +--
 drivers/gpu/drm/i915/i915_gem_gtt.h          |    3 +-
 drivers/gpu/drm/i915/i915_gem_render_state.c |   16 +-
 drivers/gpu/drm/i915/i915_gem_render_state.h |    2 +-
 drivers/gpu/drm/i915/intel_display.c         |   55 ++-
 drivers/gpu/drm/i915/intel_lrc.c             |  553 +++++++++++++-------------
 drivers/gpu/drm/i915/intel_lrc.h             |   18 +-
 drivers/gpu/drm/i915/intel_overlay.c         |   64 ++-
 drivers/gpu/drm/i915/intel_pm.c              |   33 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c      |  287 ++++++-------
 drivers/gpu/drm/i915/intel_ringbuffer.h      |   51 +--
 15 files changed, 918 insertions(+), 767 deletions(-)
Signature · 6 lines
1.7.9.5

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

PATCH 1/53 drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading

From: John Harrison <[email protected]>

There is a flags word that is passed through the execbuffer code path all the way from initial decoding of the user parameters down to the very final dispatch buffer call. It is simply called 'flags'. Unfortuantely, there are many other flags words floating around in the same blocks of code. Even more once the GPU scheduler arrives.

This patch makes it more obvious exactly which flags word is which by renaming 'flags' to 'dispatch_flags'. Note that the bit definitions for this flags word already have an 'I915_DISPATCH_' prefix on them and so are not quite so ambiguous.

For: VIZ-1587

---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   25 ++++++++++----------
 drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++----
 drivers/gpu/drm/i915/intel_lrc.h           |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    |   35 ++++++++++++++++------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ++--
 5 files changed, 41 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +13 -12
index b773368..ec9ea45 100644
@@ -1138,7 +1138,7 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_clip_rect *cliprects = NULL;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1266,19 +1266,19 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 
 			ret = ring->dispatch_execbuffer(ring,
 							exec_start, exec_len,
-							flags);
+							dispatch_flags);
 			if (ret)
 				goto error;
 		}
 	} else {
 		ret = ring->dispatch_execbuffer(ring,
 						exec_start, exec_len,
-						flags);
+						dispatch_flags);
 		if (ret)
 			return ret;
 	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), flags);
+	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);
@@ -1353,7 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct i915_address_space *vm;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
 	u64 exec_start = args->batch_start_offset;
-	u32 flags;
+	u32 dispatch_flags;
 	int ret;
 	bool need_relocs;
 
@@ -1364,15 +1364,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	flags = 0;
+	dispatch_flags = 0;
 	if (args->flags & I915_EXEC_SECURE) {
 		if (!file->is_master || !capable(CAP_SYS_ADMIN))
 		    return -EPERM;
 
-		flags |= I915_DISPATCH_SECURE;
+		dispatch_flags |= I915_DISPATCH_SECURE;
 	}
 	if (args->flags & I915_EXEC_IS_PINNED)
-		flags |= I915_DISPATCH_PINNED;
+		dispatch_flags |= I915_DISPATCH_PINNED;
 
 	if ((args->flags & I915_EXEC_RING_MASK) > LAST_USER_RING) {
 		DRM_DEBUG("execbuf with unknown ring: %d\n",
@@ -1495,7 +1495,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 						      args->batch_start_offset,
 						      args->batch_len,
 						      file->is_master,
-						      &flags);
+						      &dispatch_flags);
 		if (IS_ERR(batch_obj)) {
 			ret = PTR_ERR(batch_obj);
 			goto err;
@@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	/* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
 	 * batch" bit. Hence we need to pin secure batches into the global gtt.
 	 * hsw should have this fixed, but bdw mucks it up again. */
-	if (flags & I915_DISPATCH_SECURE) {
+	if (dispatch_flags & I915_DISPATCH_SECURE) {
 		/*
 		 * So on first glance it looks freaky that we pin the batch here
 		 * outside of the reservation loop. But:
@@ -1527,7 +1527,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		exec_start += i915_gem_obj_offset(batch_obj, vm);
 
 	ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-				      &eb->vmas, batch_obj, exec_start, flags);
+				      &eb->vmas, batch_obj, exec_start,
+				      dispatch_flags);
 
 	/*
 	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
@@ -1535,7 +1536,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	 * needs to be adjusted to also track the ggtt batch vma properly as
 	 * active.
 	 */
-	if (flags & I915_DISPATCH_SECURE)
+	if (dispatch_flags & I915_DISPATCH_SECURE)
 		i915_gem_object_ggtt_unpin(batch_obj);
 err:
 	/* the request owns the ref now */
drivers/gpu/drm/i915/intel_lrc.c +5 -5
index aafcef3..f30a8e3 100644
@@ -620,7 +620,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
  * @vmas: list of vmas.
  * @batch_obj: the batchbuffer to submit.
  * @exec_start: batchbuffer start virtual address pointer.
- * @flags: translated execbuffer call flags.
+ * @dispatch_flags: translated execbuffer call flags.
  *
  * This is the evil twin version of i915_gem_ringbuffer_submission. It abstracts
  * away the submission details of the execbuffer ioctl call.
@@ -633,7 +633,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
@@ -706,7 +706,7 @@ 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, flags);
+	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
 	if (ret)
 		return ret;
 
@@ -1163,9 +1163,9 @@ static int gen9_init_render_ring(struct intel_engine_cs *ring)
 
 static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
 			      struct intel_context *ctx,
-			      u64 offset, unsigned flags)
+			      u64 offset, unsigned dispatch_flags)
 {
-	bool ppgtt = !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
 	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
drivers/gpu/drm/i915/intel_lrc.h +1 -1
index f635735..b66fc4d 100644
@@ -82,7 +82,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
 			       struct drm_i915_gem_execbuffer2 *args,
 			       struct list_head *vmas,
 			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags);
+			       u64 exec_start, u32 dispatch_flags);
 u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
 void intel_lrc_irq_handler(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -15
index d17e76d..ca7de3d 100644
@@ -1690,7 +1690,7 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
 static int
 i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 length,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
 
@@ -1701,7 +1701,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
 			MI_BATCH_GTT |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
 
@@ -1714,8 +1715,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
 #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
 static int
 i830_dispatch_execbuffer(struct intel_engine_cs *ring,
-				u64 offset, u32 len,
-				unsigned flags)
+			 u64 offset, u32 len,
+			 unsigned dispatch_flags)
 {
 	u32 cs_offset = ring->scratch.gtt_offset;
 	int ret;
@@ -1733,7 +1734,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
 
-	if ((flags & I915_DISPATCH_PINNED) == 0) {
+	if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) {
 		if (len > I830_BATCH_LIMIT)
 			return -ENOSPC;
 
@@ -1765,7 +1766,8 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 
 	intel_ring_emit(ring, MI_BATCH_BUFFER);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_emit(ring, offset + len - 8);
 	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
@@ -1776,7 +1778,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 			 u64 offset, u32 len,
-			 unsigned flags)
+			 unsigned dispatch_flags)
 {
 	int ret;
 
@@ -1785,7 +1787,8 @@ i915_dispatch_execbuffer(struct intel_engine_cs *ring,
 		return ret;
 
 	intel_ring_emit(ring, MI_BATCH_BUFFER_START | MI_BATCH_GTT);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
 	intel_ring_advance(ring);
 
 	return 0;
@@ -2352,9 +2355,10 @@ static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
 static int
 gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
-	bool ppgtt = USES_PPGTT(ring->dev) && !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = USES_PPGTT(ring->dev) &&
+			!(dispatch_flags & I915_DISPATCH_SECURE);
 	int ret;
 
 	ret = intel_ring_begin(ring, 4);
@@ -2373,8 +2377,8 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 static int
 hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
-			      u64 offset, u32 len,
-			      unsigned flags)
+			     u64 offset, u32 len,
+			     unsigned dispatch_flags)
 {
 	int ret;
 
@@ -2384,7 +2388,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ?
+			(dispatch_flags & I915_DISPATCH_SECURE ?
 			 0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
@@ -2396,7 +2400,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 static int
 gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
 {
 	int ret;
 
@@ -2406,7 +2410,8 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
 	intel_ring_emit(ring,
 			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
 	/* bit0-7 is the length on GEN6+ */
 	intel_ring_emit(ring, offset);
 	intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index b6c484f..ffa3724 100644
@@ -164,7 +164,7 @@ struct  intel_engine_cs {
 				     u32 seqno);
 	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
 					       u64 offset, u32 length,
-					       unsigned flags);
+					       unsigned dispatch_flags);
 #define I915_DISPATCH_SECURE 0x1
 #define I915_DISPATCH_PINNED 0x2
 	void		(*cleanup)(struct intel_engine_cs *ring);
@@ -242,7 +242,7 @@ struct  intel_engine_cs {
 				      u32 flush_domains);
 	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
 					 struct intel_context *ctx,
-					 u64 offset, unsigned flags);
+					 u64 offset, unsigned dispatch_flags);
 
 	/**
 	 * List of objects currently involved in rendering from the
Signature · 6 lines
1.7.9.5

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

Re: [PATCH 01/53] drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading

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

From: John Harrison <[email protected]>

There is a flags word that is passed through the execbuffer code path all the way from initial decoding of the user parameters down to the very final dispatch buffer call. It is simply called 'flags'. Unfortuantely, there are many other flags words floating around in the same blocks of code. Even more once the GPU scheduler arrives.

This patch makes it more obvious exactly which flags word is which by renaming 'flags' to 'dispatch_flags'. Note that the bit definitions for this flags word already have an 'I915_DISPATCH_' prefix on them and so are not quite so ambiguous.

For: VIZ-1587

---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   25 ++++++++++----------
  drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    2 +-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   35 ++++++++++++++++------------
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ++--
  5 files changed, 41 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
index b773368..ec9ea45 100644

drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file, · line 1141

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1138,7 +1138,7 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
  			       struct drm_i915_gem_execbuffer2 *args,
  			       struct list_head *vmas,
  			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)

You didn't change the parameter name in the prototype declaration in i915_drv.h .

Thanks,
Tomas

Quoted 286 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +12 -11
  {
  	struct drm_clip_rect *cliprects = NULL;
  	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1266,19 +1266,19 @@ i915_gem_ringbuffer_submission(struct drm_device *dev, struct drm_file *file,
 
  			ret = ring->dispatch_execbuffer(ring,
  							exec_start, exec_len,
-							flags);
+							dispatch_flags);
  			if (ret)
  				goto error;
  		}
  	} else {
  		ret = ring->dispatch_execbuffer(ring,
  						exec_start, exec_len,
-						flags);
+						dispatch_flags);
  		if (ret)
  			return ret;
  	}
 
-	trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), flags);
+	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);
@@ -1353,7 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	struct i915_address_space *vm;
  	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
  	u64 exec_start = args->batch_start_offset;
-	u32 flags;
+	u32 dispatch_flags;
  	int ret;
  	bool need_relocs;
 
@@ -1364,15 +1364,15 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	if (ret)
  		return ret;
 
-	flags = 0;
+	dispatch_flags = 0;
  	if (args->flags & I915_EXEC_SECURE) {
  		if (!file->is_master || !capable(CAP_SYS_ADMIN))
  		    return -EPERM;
 
-		flags |= I915_DISPATCH_SECURE;
+		dispatch_flags |= I915_DISPATCH_SECURE;
  	}
  	if (args->flags & I915_EXEC_IS_PINNED)
-		flags |= I915_DISPATCH_PINNED;
+		dispatch_flags |= I915_DISPATCH_PINNED;
 
  	if ((args->flags & I915_EXEC_RING_MASK) > LAST_USER_RING) {
  		DRM_DEBUG("execbuf with unknown ring: %d\n",
@@ -1495,7 +1495,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  						      args->batch_start_offset,
  						      args->batch_len,
  						      file->is_master,
-						      &flags);
+						      &dispatch_flags);
  		if (IS_ERR(batch_obj)) {
  			ret = PTR_ERR(batch_obj);
  			goto err;
@@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	/* snb/ivb/vlv conflate the "batch in ppgtt" bit with the "non-secure
  	 * batch" bit. Hence we need to pin secure batches into the global gtt.
  	 * hsw should have this fixed, but bdw mucks it up again. */
-	if (flags & I915_DISPATCH_SECURE) {
+	if (dispatch_flags & I915_DISPATCH_SECURE) {
  		/*
  		 * So on first glance it looks freaky that we pin the batch here
  		 * outside of the reservation loop. But:
@@ -1527,7 +1527,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  		exec_start += i915_gem_obj_offset(batch_obj, vm);
 
  	ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-				      &eb->vmas, batch_obj, exec_start, flags);
+				      &eb->vmas, batch_obj, exec_start,
+				      dispatch_flags);
 
  	/*
  	 * FIXME: We crucially rely upon the active tracking for the (ppgtt)
@@ -1535,7 +1536,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	 * needs to be adjusted to also track the ggtt batch vma properly as
  	 * active.
  	 */
-	if (flags & I915_DISPATCH_SECURE)
+	if (dispatch_flags & I915_DISPATCH_SECURE)
  		i915_gem_object_ggtt_unpin(batch_obj);
  err:
  	/* the request owns the ref now */
drivers/gpu/drm/i915/intel_lrc.c +5 -5
index aafcef3..f30a8e3 100644
@@ -620,7 +620,7 @@ static int execlists_move_to_gpu(struct intel_ringbuffer *ringbuf,
   * @vmas: list of vmas.
   * @batch_obj: the batchbuffer to submit.
   * @exec_start: batchbuffer start virtual address pointer.
- * @flags: translated execbuffer call flags.
+ * @dispatch_flags: translated execbuffer call flags.
   *
   * This is the evil twin version of i915_gem_ringbuffer_submission. It abstracts
   * away the submission details of the execbuffer ioctl call.
@@ -633,7 +633,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
  			       struct drm_i915_gem_execbuffer2 *args,
  			       struct list_head *vmas,
  			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags)
+			       u64 exec_start, u32 dispatch_flags)
  {
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
@@ -706,7 +706,7 @@ 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, flags);
+	ret = ring->emit_bb_start(ringbuf, ctx, exec_start, dispatch_flags);
  	if (ret)
  		return ret;
 
@@ -1163,9 +1163,9 @@ static int gen9_init_render_ring(struct intel_engine_cs *ring)
 
  static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
  			      struct intel_context *ctx,
-			      u64 offset, unsigned flags)
+			      u64 offset, unsigned dispatch_flags)
  {
-	bool ppgtt = !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
  	int ret;
 
  	ret = intel_logical_ring_begin(ringbuf, ctx, 4);
drivers/gpu/drm/i915/intel_lrc.h +1 -1
index f635735..b66fc4d 100644
@@ -82,7 +82,7 @@ int intel_execlists_submission(struct drm_device *dev, struct drm_file *file,
  			       struct drm_i915_gem_execbuffer2 *args,
  			       struct list_head *vmas,
  			       struct drm_i915_gem_object *batch_obj,
-			       u64 exec_start, u32 flags);
+			       u64 exec_start, u32 dispatch_flags);
  u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
  void intel_lrc_irq_handler(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -15
index d17e76d..ca7de3d 100644
@@ -1690,7 +1690,7 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
  static int
  i965_dispatch_execbuffer(struct intel_engine_cs *ring,
  			 u64 offset, u32 length,
-			 unsigned flags)
+			 unsigned dispatch_flags)
  {
  	int ret;
 
@@ -1701,7 +1701,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
  	intel_ring_emit(ring,
  			MI_BATCH_BUFFER_START |
  			MI_BATCH_GTT |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
  	intel_ring_emit(ring, offset);
  	intel_ring_advance(ring);
 
@@ -1714,8 +1715,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs *ring,
  #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
  static int
  i830_dispatch_execbuffer(struct intel_engine_cs *ring,
-				u64 offset, u32 len,
-				unsigned flags)
+			 u64 offset, u32 len,
+			 unsigned dispatch_flags)
  {
  	u32 cs_offset = ring->scratch.gtt_offset;
  	int ret;
@@ -1733,7 +1734,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
  	intel_ring_emit(ring, MI_NOOP);
  	intel_ring_advance(ring);
 
-	if ((flags & I915_DISPATCH_PINNED) == 0) {
+	if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) {
  		if (len > I830_BATCH_LIMIT)
  			return -ENOSPC;
 
@@ -1765,7 +1766,8 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
  		return ret;
 
  	intel_ring_emit(ring, MI_BATCH_BUFFER);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
  	intel_ring_emit(ring, offset + len - 8);
  	intel_ring_emit(ring, MI_NOOP);
  	intel_ring_advance(ring);
@@ -1776,7 +1778,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs *ring,
  static int
  i915_dispatch_execbuffer(struct intel_engine_cs *ring,
  			 u64 offset, u32 len,
-			 unsigned flags)
+			 unsigned dispatch_flags)
  {
  	int ret;
 
@@ -1785,7 +1787,8 @@ i915_dispatch_execbuffer(struct intel_engine_cs *ring,
  		return ret;
 
  	intel_ring_emit(ring, MI_BATCH_BUFFER_START | MI_BATCH_GTT);
-	intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE));
+	intel_ring_emit(ring, offset | (dispatch_flags & I915_DISPATCH_SECURE ?
+					0 : MI_BATCH_NON_SECURE));
  	intel_ring_advance(ring);
 
  	return 0;
@@ -2352,9 +2355,10 @@ static int gen6_bsd_ring_flush(struct intel_engine_cs *ring,
  static int
  gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
  {
-	bool ppgtt = USES_PPGTT(ring->dev) && !(flags & I915_DISPATCH_SECURE);
+	bool ppgtt = USES_PPGTT(ring->dev) &&
+			!(dispatch_flags & I915_DISPATCH_SECURE);
  	int ret;
 
  	ret = intel_ring_begin(ring, 4);
@@ -2373,8 +2377,8 @@ gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
  static int
  hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
-			      u64 offset, u32 len,
-			      unsigned flags)
+			     u64 offset, u32 len,
+			     unsigned dispatch_flags)
  {
  	int ret;
 
@@ -2384,7 +2388,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
  	intel_ring_emit(ring,
  			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ?
+			(dispatch_flags & I915_DISPATCH_SECURE ?
  			 0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW));
  	/* bit0-7 is the length on GEN6+ */
  	intel_ring_emit(ring, offset);
@@ -2396,7 +2400,7 @@ hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  static int
  gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
  			      u64 offset, u32 len,
-			      unsigned flags)
+			      unsigned dispatch_flags)
  {
  	int ret;
 
@@ -2406,7 +2410,8 @@ gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
 
  	intel_ring_emit(ring,
  			MI_BATCH_BUFFER_START |
-			(flags & I915_DISPATCH_SECURE ? 0 : MI_BATCH_NON_SECURE_I965));
+			(dispatch_flags & I915_DISPATCH_SECURE ?
+			 0 : MI_BATCH_NON_SECURE_I965));
  	/* bit0-7 is the length on GEN6+ */
  	intel_ring_emit(ring, offset);
  	intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
index b6c484f..ffa3724 100644
@@ -164,7 +164,7 @@ struct  intel_engine_cs {
  				     u32 seqno);
  	int		(*dispatch_execbuffer)(struct intel_engine_cs *ring,
  					       u64 offset, u32 length,
-					       unsigned flags);
+					       unsigned dispatch_flags);
  #define I915_DISPATCH_SECURE 0x1
  #define I915_DISPATCH_PINNED 0x2
  	void		(*cleanup)(struct intel_engine_cs *ring);

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

Quoted 8 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -1
@@ -242,7 +242,7 @@ struct  intel_engine_cs {
  				      u32 flush_domains);
  	int		(*emit_bb_start)(struct intel_ringbuffer *ringbuf,
  					 struct intel_context *ctx,
-					 u64 offset, unsigned flags);
+					 u64 offset, unsigned dispatch_flags);
 
  	/**
  	 * List of objects currently involved in rendering from the

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

#100 lore raw

Re: [PATCH 01/53] drm/i915: Rename 'flags' to 'dispatch_flags' for better code reading

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

From: John Harrison <[email protected]>

There is a flags word that is passed through the execbuffer code path all the way from initial decoding of the user parameters down to the very final dispatch buffer call. It is simply called 'flags'. Unfortuantely, there are many other flags words floating around in the same blocks of code. Even more once the GPU scheduler arrives.

This patch makes it more obvious exactly which flags word is which by renaming 'flags' to 'dispatch_flags'. Note that the bit definitions for this flags word already have an 'I915_DISPATCH_' prefix on them and so are not quite so ambiguous.

For: VIZ-1587

---
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   25 ++++++++++----------
  drivers/gpu/drm/i915/intel_lrc.c           |   10 ++++----
  drivers/gpu/drm/i915/intel_lrc.h           |    2 +-
  drivers/gpu/drm/i915/intel_ringbuffer.c    |   35 
++++++++++++++++------------
  drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ++--
  5 files changed, 41 insertions(+), 35 deletions(-)
Quoted 13 lines

drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_ringbuffer_submission(struct · line 1142

Quoted 11 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index b773368..ec9ea45 100644
@@ -1138,7 +1138,7 @@ i915_gem_ringbuffer_submission(struct 
 drm_device *dev, struct drm_file *file,
                     struct drm_i915_gem_execbuffer2 *args,
                     struct list_head *vmas,
                     struct drm_i915_gem_object *batch_obj,
-                   u64 exec_start, u32 flags)
+                   u64 exec_start, u32 dispatch_flags)

You didn't change the parameter name in the prototype declaration in i915_drv.h .

Bit late now, this patch has already been merged. Also, it isn't really worth following up with an extra fix patch as those parameters get removed in a later patch in this series anyway (albeit one that is being discussed as contentious).

Quoted 333 lines

Thanks,
Tomas

Quoted 329 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
  {
      struct drm_clip_rect *cliprects = NULL;
      struct drm_i915_private *dev_priv = dev->dev_private;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +3 -3
@@ -1266,19 +1266,19 @@ i915_gem_ringbuffer_submission(struct 
 drm_device *dev, struct drm_file *file,
 
              ret = ring->dispatch_execbuffer(ring,
                              exec_start, exec_len,
-                            flags);
+                            dispatch_flags);
              if (ret)
                  goto error;
          }
      } else {
          ret = ring->dispatch_execbuffer(ring,
                          exec_start, exec_len,
-                        flags);
+                        dispatch_flags);
          if (ret)
              return ret;
      }
 
-    trace_i915_gem_ring_dispatch(intel_ring_get_request(ring), flags);
+    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);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +4 -4
@@ -1353,7 +1353,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, 
 void *data,
      struct i915_address_space *vm;
      const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
      u64 exec_start = args->batch_start_offset;
-    u32 flags;
+    u32 dispatch_flags;
      int ret;
      bool need_relocs;
@@ -1364,15 +1364,15 @@ i915_gem_do_execbuffer(struct drm_device 
 *dev, void *data,
      if (ret)
          return ret;
 
-    flags = 0;
+    dispatch_flags = 0;
      if (args->flags & I915_EXEC_SECURE) {
          if (!file->is_master || !capable(CAP_SYS_ADMIN))
              return -EPERM;
 
-        flags |= I915_DISPATCH_SECURE;
+        dispatch_flags |= I915_DISPATCH_SECURE;
      }
      if (args->flags & I915_EXEC_IS_PINNED)
-        flags |= I915_DISPATCH_PINNED;
+        dispatch_flags |= I915_DISPATCH_PINNED;
 
      if ((args->flags & I915_EXEC_RING_MASK) > LAST_USER_RING) {

DRM_DEBUG("execbuf with unknown ring: %d\n",

drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1495,7 +1495,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, 
 void *data,
                                args->batch_start_offset,
                                args->batch_len,
                                file->is_master,
-                              &flags);
+                              &dispatch_flags);
          if (IS_ERR(batch_obj)) {
              ret = PTR_ERR(batch_obj);
              goto err;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
@@ -1507,7 +1507,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, 
 void *data,
      /* snb/ivb/vlv conflate the "batch in ppgtt" bit with the 

"non-secure
* batch" bit. Hence we need to pin secure batches into the
global gtt.
* hsw should have this fixed, but bdw mucks it up again. */

drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
-    if (flags & I915_DISPATCH_SECURE) {
+    if (dispatch_flags & I915_DISPATCH_SECURE) {
          /*
           * So on first glance it looks freaky that we pin the batch 

here
* outside of the reservation loop. But:

drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -1
@@ -1527,7 +1527,8 @@ i915_gem_do_execbuffer(struct drm_device *dev, 
 void *data,
          exec_start += i915_gem_obj_offset(batch_obj, vm);
 
      ret = dev_priv->gt.do_execbuf(dev, file, ring, ctx, args,
-                      &eb->vmas, batch_obj, exec_start, flags);
+                      &eb->vmas, batch_obj, exec_start,
+                      dispatch_flags);
 
      /*

* FIXME: We crucially rely upon the active tracking for the
(ppgtt)

drivers/gpu/drm/i915/i915_gem_execbuffer.c +0 -0
@@ -1535,7 +1536,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, 
 void *data,
       * needs to be adjusted to also track the ggtt batch vma 

properly as
* active.
*/

drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
-    if (flags & I915_DISPATCH_SECURE)
+    if (dispatch_flags & I915_DISPATCH_SECURE)
          i915_gem_object_ggtt_unpin(batch_obj);
  err:
      /* the request owns the ref now */
drivers/gpu/drm/i915/intel_lrc.c +1 -1
index aafcef3..f30a8e3 100644
@@ -620,7 +620,7 @@ static int execlists_move_to_gpu(struct 
 intel_ringbuffer *ringbuf,
   * @vmas: list of vmas.
   * @batch_obj: the batchbuffer to submit.
   * @exec_start: batchbuffer start virtual address pointer.
- * @flags: translated execbuffer call flags.
+ * @dispatch_flags: translated execbuffer call flags.
   *
   * This is the evil twin version of i915_gem_ringbuffer_submission. 

It abstracts
* away the submission details of the execbuffer ioctl call.

drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -633,7 +633,7 @@ int intel_execlists_submission(struct drm_device 
 *dev, struct drm_file *file,
                     struct drm_i915_gem_execbuffer2 *args,
                     struct list_head *vmas,
                     struct drm_i915_gem_object *batch_obj,
-                   u64 exec_start, u32 flags)
+                   u64 exec_start, u32 dispatch_flags)
  {
      struct drm_i915_private *dev_priv = dev->dev_private;
      struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
drivers/gpu/drm/i915/intel_lrc.c +1 -1
@@ -706,7 +706,7 @@ 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, flags);
+    ret = ring->emit_bb_start(ringbuf, ctx, exec_start, 
 dispatch_flags);
      if (ret)
          return ret;
drivers/gpu/drm/i915/intel_lrc.c +2 -2
@@ -1163,9 +1163,9 @@ static int gen9_init_render_ring(struct 
 intel_engine_cs *ring)
 
  static int gen8_emit_bb_start(struct intel_ringbuffer *ringbuf,
                    struct intel_context *ctx,
-                  u64 offset, unsigned flags)
+                  u64 offset, unsigned dispatch_flags)
  {
-    bool ppgtt = !(flags & I915_DISPATCH_SECURE);
+    bool ppgtt = !(dispatch_flags & I915_DISPATCH_SECURE);
      int ret;
 
      ret = intel_logical_ring_begin(ringbuf, ctx, 4);
drivers/gpu/drm/i915/intel_lrc.h +1 -1
index f635735..b66fc4d 100644
@@ -82,7 +82,7 @@ int intel_execlists_submission(struct drm_device 
 *dev, struct drm_file *file,
                     struct drm_i915_gem_execbuffer2 *args,
                     struct list_head *vmas,
                     struct drm_i915_gem_object *batch_obj,
-                   u64 exec_start, u32 flags);
+                   u64 exec_start, u32 dispatch_flags);
  u32 intel_execlists_ctx_id(struct drm_i915_gem_object *ctx_obj);
 
  void intel_lrc_irq_handler(struct intel_engine_cs *ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -2
index d17e76d..ca7de3d 100644
@@ -1690,7 +1690,7 @@ gen8_ring_put_irq(struct intel_engine_cs *ring)
  static int
  i965_dispatch_execbuffer(struct intel_engine_cs *ring,
               u64 offset, u32 length,
-             unsigned flags)
+             unsigned dispatch_flags)
  {
      int ret;
 
@@ -1701,7 +1701,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs 
 *ring,
      intel_ring_emit(ring,
              MI_BATCH_BUFFER_START |
              MI_BATCH_GTT |
-            (flags & I915_DISPATCH_SECURE ? 0 : 
 MI_BATCH_NON_SECURE_I965));
+            (dispatch_flags & I915_DISPATCH_SECURE ?
+             0 : MI_BATCH_NON_SECURE_I965));
      intel_ring_emit(ring, offset);
      intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -2
@@ -1714,8 +1715,8 @@ i965_dispatch_execbuffer(struct intel_engine_cs 
 *ring,
  #define I830_WA_SIZE max(I830_TLB_ENTRIES*4096, I830_BATCH_LIMIT)
  static int
  i830_dispatch_execbuffer(struct intel_engine_cs *ring,
-                u64 offset, u32 len,
-                unsigned flags)
+             u64 offset, u32 len,
+             unsigned dispatch_flags)
  {
      u32 cs_offset = ring->scratch.gtt_offset;
      int ret;
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -2
@@ -1733,7 +1734,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs 
 *ring,
      intel_ring_emit(ring, MI_NOOP);
      intel_ring_advance(ring);
 
-    if ((flags & I915_DISPATCH_PINNED) == 0) {
+    if ((dispatch_flags & I915_DISPATCH_PINNED) == 0) {
          if (len > I830_BATCH_LIMIT)
              return -ENOSPC;
@@ -1765,7 +1766,8 @@ i830_dispatch_execbuffer(struct intel_engine_cs 
 *ring,
          return ret;
 
      intel_ring_emit(ring, MI_BATCH_BUFFER);
-    intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 
 : MI_BATCH_NON_SECURE));
+    intel_ring_emit(ring, offset | (dispatch_flags & 

I915_DISPATCH_SECURE ?

drivers/gpu/drm/i915/intel_ringbuffer.c +3 -2
+                    0 : MI_BATCH_NON_SECURE));
      intel_ring_emit(ring, offset + len - 8);
      intel_ring_emit(ring, MI_NOOP);
      intel_ring_advance(ring);
@@ -1776,7 +1778,7 @@ i830_dispatch_execbuffer(struct intel_engine_cs 
 *ring,
  static int
  i915_dispatch_execbuffer(struct intel_engine_cs *ring,
               u64 offset, u32 len,
-             unsigned flags)
+             unsigned dispatch_flags)
  {
      int ret;
@@ -1785,7 +1787,8 @@ i915_dispatch_execbuffer(struct intel_engine_cs 
 *ring,
          return ret;
 
      intel_ring_emit(ring, MI_BATCH_BUFFER_START | MI_BATCH_GTT);
-    intel_ring_emit(ring, offset | (flags & I915_DISPATCH_SECURE ? 0 
 : MI_BATCH_NON_SECURE));
+    intel_ring_emit(ring, offset | (dispatch_flags & 

I915_DISPATCH_SECURE ?

drivers/gpu/drm/i915/intel_ringbuffer.c +4 -2
+                    0 : MI_BATCH_NON_SECURE));
      intel_ring_advance(ring);
 
      return 0;
@@ -2352,9 +2355,10 @@ static int gen6_bsd_ring_flush(struct 
 intel_engine_cs *ring,
  static int
  gen8_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
                    u64 offset, u32 len,
-                  unsigned flags)
+                  unsigned dispatch_flags)
  {
-    bool ppgtt = USES_PPGTT(ring->dev) && !(flags & 
 I915_DISPATCH_SECURE);
+    bool ppgtt = USES_PPGTT(ring->dev) &&
+            !(dispatch_flags & I915_DISPATCH_SECURE);
      int ret;
      ret = intel_ring_begin(ring, 4);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -3
@@ -2373,8 +2377,8 @@ gen8_ring_dispatch_execbuffer(struct 
 intel_engine_cs *ring,
 
  static int
  hsw_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
-                  u64 offset, u32 len,
-                  unsigned flags)
+                 u64 offset, u32 len,
+                 unsigned dispatch_flags)
  {
      int ret;
@@ -2384,7 +2388,7 @@ hsw_ring_dispatch_execbuffer(struct 
 intel_engine_cs *ring,
 
      intel_ring_emit(ring,
              MI_BATCH_BUFFER_START |
-            (flags & I915_DISPATCH_SECURE ?
+            (dispatch_flags & I915_DISPATCH_SECURE ?
               0 : MI_BATCH_PPGTT_HSW | MI_BATCH_NON_SECURE_HSW));
      /* bit0-7 is the length on GEN6+ */
      intel_ring_emit(ring, offset);
drivers/gpu/drm/i915/intel_ringbuffer.c +3 -2
@@ -2396,7 +2400,7 @@ hsw_ring_dispatch_execbuffer(struct 
 intel_engine_cs *ring,
  static int
  gen6_ring_dispatch_execbuffer(struct intel_engine_cs *ring,
                    u64 offset, u32 len,
-                  unsigned flags)
+                  unsigned dispatch_flags)
  {
      int ret;
@@ -2406,7 +2410,8 @@ gen6_ring_dispatch_execbuffer(struct 
 intel_engine_cs *ring,
 
      intel_ring_emit(ring,
              MI_BATCH_BUFFER_START |
-            (flags & I915_DISPATCH_SECURE ? 0 : 
 MI_BATCH_NON_SECURE_I965));
+            (dispatch_flags & I915_DISPATCH_SECURE ?
+             0 : MI_BATCH_NON_SECURE_I965));
      /* bit0-7 is the length on GEN6+ */
      intel_ring_emit(ring, offset);
      intel_ring_advance(ring);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index b6c484f..ffa3724 100644
@@ -164,7 +164,7 @@ struct  intel_engine_cs {
                       u32 seqno);
      int        (*dispatch_execbuffer)(struct intel_engine_cs *ring,
                             u64 offset, u32 length,
-                           unsigned flags);
+                           unsigned dispatch_flags);
  #define I915_DISPATCH_SECURE 0x1
  #define I915_DISPATCH_PINNED 0x2
      void        (*cleanup)(struct intel_engine_cs *ring);
@@ -242,7 +242,7 @@ struct  intel_engine_cs {
                        u32 flush_domains);
      int        (*emit_bb_start)(struct intel_ringbuffer *ringbuf,
                       struct intel_context *ctx,
-                     u64 offset, unsigned flags);
+                     u64 offset, unsigned dispatch_flags);
 
Quoted 4 lines

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

Quoted 3 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -0
      /**
       * List of objects currently involved in rendering from the

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

#101 lore raw

PATCH 1/53 drm/i915: Remove ironlake rc6 support

In reply to [email protected]

From: John Harrison <[email protected]>

Apparently, this has never worked reliably and is currently disabled. Also, the gains are not particularly impressive. Thus rather than try to keep unused code from decaying and having to update it for other driver changes, it was decided to simply remove it.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_debugfs.c  |   12 ---
 drivers/gpu/drm/i915/i915_drv.h      |    3 -
 drivers/gpu/drm/i915/intel_display.c |    2 -
 drivers/gpu/drm/i915/intel_drv.h     |    1 -
 drivers/gpu/drm/i915/intel_pm.c      |  155 ----------------------------------
 5 files changed, 173 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -12
index 68a1e6e..18e4900 100644
@@ -1846,18 +1846,6 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	if (ret)
 		return ret;
 
-	if (dev_priv->ips.pwrctx) {
-		seq_puts(m, "power context ");
-		describe_obj(m, dev_priv->ips.pwrctx);
-		seq_putc(m, '\n');
-	}
-
-	if (dev_priv->ips.renderctx) {
-		seq_puts(m, "render context ");
-		describe_obj(m, dev_priv->ips.renderctx);
-		seq_putc(m, '\n');
-	}
-
 	list_for_each_entry(ctx, &dev_priv->context_list, link) {
 		if (!i915.enable_execlists &&
 		    ctx->legacy_hw_ctx.rcs_state == NULL)
drivers/gpu/drm/i915/i915_drv.h +0 -3
index 798fa88..05f106d 100644
@@ -1053,9 +1053,6 @@ struct intel_ilk_power_mgmt {
 
 	int c_m;
 	int r_t;
-
-	struct drm_i915_gem_object *pwrctx;
-	struct drm_i915_gem_object *renderctx;
 };
 
 struct drm_i915_private;
drivers/gpu/drm/i915/intel_display.c +0 -2
index 5c35098..51f7ed4 100644
@@ -13904,8 +13904,6 @@ void intel_modeset_cleanup(struct drm_device *dev)
 
 	intel_fbc_disable(dev);
 
-	ironlake_teardown_rc6(dev);
-
 	mutex_unlock(&dev->struct_mutex);
 
 	/* flush any delayed tasks or pending work */
drivers/gpu/drm/i915/intel_drv.h +0 -1
index f4305be..b793558 100644
@@ -1229,7 +1229,6 @@ void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
 void intel_suspend_gt_powersave(struct drm_device *dev);
 void intel_reset_gt_powersave(struct drm_device *dev);
-void ironlake_teardown_rc6(struct drm_device *dev);
 void gen6_update_ring_freq(struct drm_device *dev);
 void gen6_rps_idle(struct drm_i915_private *dev_priv);
 void gen6_rps_boost(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_pm.c +0 -155

179 lines not on this page · raw message

Signature · 6 lines
1.7.9.5

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

Re: [PATCH 01/53] drm/i915: Remove ironlake rc6 support

Quoted 9 lines · On Thu, Mar 05, 2015 at 02:03:03PM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

Apparently, this has never worked reliably and is currently disabled. Also, the gains are not particularly impressive. Thus rather than try to keep unused code from decaying and having to update it for other driver changes, it was decided to simply remove it.

For: VIZ-5115

Queued for -next, thanks for the patch.
-Daniel

Quoted 264 lines
---
 drivers/gpu/drm/i915/i915_debugfs.c  |   12 ---
 drivers/gpu/drm/i915/i915_drv.h      |    3 -
 drivers/gpu/drm/i915/intel_display.c |    2 -
 drivers/gpu/drm/i915/intel_drv.h     |    1 -
 drivers/gpu/drm/i915/intel_pm.c      |  155 ----------------------------------
 5 files changed, 173 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -12
index 68a1e6e..18e4900 100644
@@ -1846,18 +1846,6 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	if (ret)
 		return ret;
 
-	if (dev_priv->ips.pwrctx) {
-		seq_puts(m, "power context ");
-		describe_obj(m, dev_priv->ips.pwrctx);
-		seq_putc(m, '\n');
-	}
-
-	if (dev_priv->ips.renderctx) {
-		seq_puts(m, "render context ");
-		describe_obj(m, dev_priv->ips.renderctx);
-		seq_putc(m, '\n');
-	}
-
 	list_for_each_entry(ctx, &dev_priv->context_list, link) {
 		if (!i915.enable_execlists &&
 		    ctx->legacy_hw_ctx.rcs_state == NULL)
drivers/gpu/drm/i915/i915_drv.h +0 -3
index 798fa88..05f106d 100644
@@ -1053,9 +1053,6 @@ struct intel_ilk_power_mgmt {
 
 	int c_m;
 	int r_t;
-
-	struct drm_i915_gem_object *pwrctx;
-	struct drm_i915_gem_object *renderctx;
 };
 
 struct drm_i915_private;
drivers/gpu/drm/i915/intel_display.c +0 -2
index 5c35098..51f7ed4 100644
@@ -13904,8 +13904,6 @@ void intel_modeset_cleanup(struct drm_device *dev)
 
 	intel_fbc_disable(dev);
 
-	ironlake_teardown_rc6(dev);
-
 	mutex_unlock(&dev->struct_mutex);
 
 	/* flush any delayed tasks or pending work */
drivers/gpu/drm/i915/intel_drv.h +0 -1
index f4305be..b793558 100644
@@ -1229,7 +1229,6 @@ void intel_enable_gt_powersave(struct drm_device *dev);
 void intel_disable_gt_powersave(struct drm_device *dev);
 void intel_suspend_gt_powersave(struct drm_device *dev);
 void intel_reset_gt_powersave(struct drm_device *dev);
-void ironlake_teardown_rc6(struct drm_device *dev);
 void gen6_update_ring_freq(struct drm_device *dev);
 void gen6_rps_idle(struct drm_i915_private *dev_priv);
 void gen6_rps_boost(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_pm.c +0 -155
index 542cf68..0762572 100644
@@ -3539,41 +3539,6 @@ void intel_update_sprite_watermarks(struct drm_plane *plane,
 						   pixel_size, enabled, scaled);
 }
 
-static struct drm_i915_gem_object *
-intel_alloc_context_page(struct drm_device *dev)
-{
-	struct drm_i915_gem_object *ctx;
-	int ret;
-
-	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
-	ctx = i915_gem_alloc_object(dev, 4096);
-	if (!ctx) {
-		DRM_DEBUG("failed to alloc power context, RC6 disabled\n");
-		return NULL;
-	}
-
-	ret = i915_gem_obj_ggtt_pin(ctx, 4096, 0);
-	if (ret) {
-		DRM_ERROR("failed to pin power context: %d\n", ret);
-		goto err_unref;
-	}
-
-	ret = i915_gem_object_set_to_gtt_domain(ctx, 1);
-	if (ret) {
-		DRM_ERROR("failed to set-domain on power context: %d\n", ret);
-		goto err_unpin;
-	}
-
-	return ctx;
-
-err_unpin:
-	i915_gem_object_ggtt_unpin(ctx);
-err_unref:
-	drm_gem_object_unreference(&ctx->base);
-	return NULL;
-}
-
 /**
  * Lock protecting IPS related data structures
  */
@@ -4990,124 +4955,6 @@ static void valleyview_enable_rps(struct drm_device *dev)
 	intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
 }
 
-void ironlake_teardown_rc6(struct drm_device *dev)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	if (dev_priv->ips.renderctx) {
-		i915_gem_object_ggtt_unpin(dev_priv->ips.renderctx);
-		drm_gem_object_unreference(&dev_priv->ips.renderctx->base);
-		dev_priv->ips.renderctx = NULL;
-	}
-
-	if (dev_priv->ips.pwrctx) {
-		i915_gem_object_ggtt_unpin(dev_priv->ips.pwrctx);
-		drm_gem_object_unreference(&dev_priv->ips.pwrctx->base);
-		dev_priv->ips.pwrctx = NULL;
-	}
-}
-
-static void ironlake_disable_rc6(struct drm_device *dev)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	if (I915_READ(PWRCTXA)) {
-		/* Wake the GPU, prevent RC6, then restore RSTDBYCTL */
-		I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) | RCX_SW_EXIT);
-		wait_for(((I915_READ(RSTDBYCTL) & RSX_STATUS_MASK) == RSX_STATUS_ON),
-			 50);
-
-		I915_WRITE(PWRCTXA, 0);
-		POSTING_READ(PWRCTXA);
-
-		I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
-		POSTING_READ(RSTDBYCTL);
-	}
-}
-
-static int ironlake_setup_rc6(struct drm_device *dev)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	if (dev_priv->ips.renderctx == NULL)
-		dev_priv->ips.renderctx = intel_alloc_context_page(dev);
-	if (!dev_priv->ips.renderctx)
-		return -ENOMEM;
-
-	if (dev_priv->ips.pwrctx == NULL)
-		dev_priv->ips.pwrctx = intel_alloc_context_page(dev);
-	if (!dev_priv->ips.pwrctx) {
-		ironlake_teardown_rc6(dev);
-		return -ENOMEM;
-	}
-
-	return 0;
-}
-
-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];
-	bool was_interruptible;
-	int ret;
-
-	/* rc6 disabled by default due to repeated reports of hanging during
-	 * boot and resume.
-	 */
-	if (!intel_enable_rc6(dev))
-		return;
-
-	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
-	ret = ironlake_setup_rc6(dev);
-	if (ret)
-		return;
-
-	was_interruptible = dev_priv->mm.interruptible;
-	dev_priv->mm.interruptible = false;
-
-	/*
-	 * 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;
-	}
-
-	intel_ring_emit(ring, MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
-	intel_ring_emit(ring, MI_SET_CONTEXT);
-	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(dev_priv->ips.renderctx) |
-			MI_MM_SPACE_GTT |
-			MI_SAVE_EXT_STATE_EN |
-			MI_RESTORE_EXT_STATE_EN |
-			MI_RESTORE_INHIBIT);
-	intel_ring_emit(ring, MI_SUSPEND_FLUSH);
-	intel_ring_emit(ring, MI_NOOP);
-	intel_ring_emit(ring, MI_FLUSH);
-	intel_ring_advance(ring);
-
-	/*
-	 * 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
-	 * safe to assume that renderctx is valid
-	 */
-	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;
-	}
-
-	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);
-}
-
 static unsigned long intel_pxfreq(u32 vidfreq)
 {
 	unsigned long freq;
@@ -5655,7 +5502,6 @@ void intel_disable_gt_powersave(struct drm_device *dev)
 
 	if (IS_IRONLAKE_M(dev)) {
 		ironlake_disable_drps(dev);
-		ironlake_disable_rc6(dev);
 	} else if (INTEL_INFO(dev)->gen >= 6) {
 		intel_suspend_gt_powersave(dev);
 
@@ -5726,7 +5572,6 @@ void intel_enable_gt_powersave(struct drm_device *dev)
 	if (IS_IRONLAKE_M(dev)) {
 		mutex_lock(&dev->struct_mutex);
 		ironlake_enable_drps(dev);
-		ironlake_enable_rc6(dev);
 		intel_init_emon(dev);
 		mutex_unlock(&dev->struct_mutex);
 	} else if (INTEL_INFO(dev)->gen >= 6) {
Signature · 6 lines
1.7.9.5

_______________________________________________
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
#103 lore raw

Re: [PATCH 01/53] drm/i915: Remove ironlake rc6 support

Quoted 8 lines · Daniel Vetter
Quoted 7 lines · On Thu, Mar 05, 2015 at 02:03:03PM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

Apparently, this has never worked reliably and is currently disabled. Also, the gains are not particularly impressive. Thus rather than try to keep unused code from decaying and having to update it for other driver changes, it was decided to simply remove it.

Quoted 4 lines
Quoted 2 lines

For: VIZ-5115

Queued for -next, thanks for the patch.
-Daniel

Can you hold off merging any of the other patches in the series for the moment. Tomas Elf is currently posting review comments, some with R-B some with change requests. Some of the re-work either for his comments or for yours causes changes which ripple through a number of the patches in the series. So I would like to repost the whole set once all the comments have been addressed. Otherwise, it all just gets far too messy as to which patches have or haven't been updated, what needs re-merging, which version is which, etc.

Thanks,
John.

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

#104 lore raw

Re: [PATCH 01/53] drm/i915: Remove ironlake rc6 support

Quoted 14 lines · John Harrison
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · On Thu, Mar 05, 2015 at 02:03:03PM +0000, [email protected] wrote:

From: John Harrison <[email protected]>

Apparently, this has never worked reliably and is currently disabled. Also, the gains are not particularly impressive. Thus rather than try to keep unused code from decaying and having to update it for other driver changes, it was decided to simply remove it.

Quoted 4 lines
Quoted 2 lines

For: VIZ-5115

Queued for -next, thanks for the patch.
-Daniel

Quoted 8 lines

Can you hold off merging any of the other patches in the series for the moment. Tomas Elf is currently posting review comments, some with R-B some with change requests. Some of the re-work either for his comments or for yours causes changes which ripple through a number of the patches in the series. So I would like to repost the whole set once all the comments have been addressed. Otherwise, it all just gets far too messy as to which patches have or haven't been updated, what needs re-merging, which version is which, etc.

Fully agreed since that was my plan. I specifically pulled this one here in since it should be otherwise free-standing and would likely cause needless conflicts. For all the other patches it's better to first converge on the review a bit more before proceeding with merging. -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
Reviewed-by on v1 1/53
#105 lore raw

Re: [PATCH 01/53] drm/i915: Remove ironlake rc6 support

In reply to [email protected]
Quoted 261 lines · On 05/03/2015 14:03, [email protected] wrote:

From: John Harrison <[email protected]>

Apparently, this has never worked reliably and is currently disabled. Also, the gains are not particularly impressive. Thus rather than try to keep unused code from decaying and having to update it for other driver changes, it was decided to simply remove it.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_debugfs.c  |   12 ---
  drivers/gpu/drm/i915/i915_drv.h      |    3 -
  drivers/gpu/drm/i915/intel_display.c |    2 -
  drivers/gpu/drm/i915/intel_drv.h     |    1 -
  drivers/gpu/drm/i915/intel_pm.c      |  155 ----------------------------------
  5 files changed, 173 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +0 -12
index 68a1e6e..18e4900 100644
@@ -1846,18 +1846,6 @@ static int i915_context_status(struct seq_file *m, void *unused)
  	if (ret)
  		return ret;
 
-	if (dev_priv->ips.pwrctx) {
-		seq_puts(m, "power context ");
-		describe_obj(m, dev_priv->ips.pwrctx);
-		seq_putc(m, '\n');
-	}
-
-	if (dev_priv->ips.renderctx) {
-		seq_puts(m, "render context ");
-		describe_obj(m, dev_priv->ips.renderctx);
-		seq_putc(m, '\n');
-	}
-
  	list_for_each_entry(ctx, &dev_priv->context_list, link) {
  		if (!i915.enable_execlists &&
  		    ctx->legacy_hw_ctx.rcs_state == NULL)
drivers/gpu/drm/i915/i915_drv.h +0 -3
index 798fa88..05f106d 100644
@@ -1053,9 +1053,6 @@ struct intel_ilk_power_mgmt {
 
  	int c_m;
  	int r_t;
-
-	struct drm_i915_gem_object *pwrctx;
-	struct drm_i915_gem_object *renderctx;
  };
 
  struct drm_i915_private;
drivers/gpu/drm/i915/intel_display.c +0 -2
index 5c35098..51f7ed4 100644
@@ -13904,8 +13904,6 @@ void intel_modeset_cleanup(struct drm_device *dev)
 
  	intel_fbc_disable(dev);
 
-	ironlake_teardown_rc6(dev);
-
  	mutex_unlock(&dev->struct_mutex);
 
  	/* flush any delayed tasks or pending work */
drivers/gpu/drm/i915/intel_drv.h +0 -1
index f4305be..b793558 100644
@@ -1229,7 +1229,6 @@ void intel_enable_gt_powersave(struct drm_device *dev);
  void intel_disable_gt_powersave(struct drm_device *dev);
  void intel_suspend_gt_powersave(struct drm_device *dev);
  void intel_reset_gt_powersave(struct drm_device *dev);
-void ironlake_teardown_rc6(struct drm_device *dev);
  void gen6_update_ring_freq(struct drm_device *dev);
  void gen6_rps_idle(struct drm_i915_private *dev_priv);
  void gen6_rps_boost(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_pm.c +0 -154
index 542cf68..0762572 100644
@@ -3539,41 +3539,6 @@ void intel_update_sprite_watermarks(struct drm_plane *plane,
  						   pixel_size, enabled, scaled);
  }
 
-static struct drm_i915_gem_object *
-intel_alloc_context_page(struct drm_device *dev)
-{
-	struct drm_i915_gem_object *ctx;
-	int ret;
-
-	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
-	ctx = i915_gem_alloc_object(dev, 4096);
-	if (!ctx) {
-		DRM_DEBUG("failed to alloc power context, RC6 disabled\n");
-		return NULL;
-	}
-
-	ret = i915_gem_obj_ggtt_pin(ctx, 4096, 0);
-	if (ret) {
-		DRM_ERROR("failed to pin power context: %d\n", ret);
-		goto err_unref;
-	}
-
-	ret = i915_gem_object_set_to_gtt_domain(ctx, 1);
-	if (ret) {
-		DRM_ERROR("failed to set-domain on power context: %d\n", ret);
-		goto err_unpin;
-	}
-
-	return ctx;
-
-err_unpin:
-	i915_gem_object_ggtt_unpin(ctx);
-err_unref:
-	drm_gem_object_unreference(&ctx->base);
-	return NULL;
-}
-
  /**
   * Lock protecting IPS related data structures
   */
@@ -4990,124 +4955,6 @@ static void valleyview_enable_rps(struct drm_device *dev)
  	intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);
  }
 
-void ironlake_teardown_rc6(struct drm_device *dev)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	if (dev_priv->ips.renderctx) {
-		i915_gem_object_ggtt_unpin(dev_priv->ips.renderctx);
-		drm_gem_object_unreference(&dev_priv->ips.renderctx->base);
-		dev_priv->ips.renderctx = NULL;
-	}
-
-	if (dev_priv->ips.pwrctx) {
-		i915_gem_object_ggtt_unpin(dev_priv->ips.pwrctx);
-		drm_gem_object_unreference(&dev_priv->ips.pwrctx->base);
-		dev_priv->ips.pwrctx = NULL;
-	}
-}
-
-static void ironlake_disable_rc6(struct drm_device *dev)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	if (I915_READ(PWRCTXA)) {
-		/* Wake the GPU, prevent RC6, then restore RSTDBYCTL */
-		I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) | RCX_SW_EXIT);
-		wait_for(((I915_READ(RSTDBYCTL) & RSX_STATUS_MASK) == RSX_STATUS_ON),
-			 50);
-
-		I915_WRITE(PWRCTXA, 0);
-		POSTING_READ(PWRCTXA);
-
-		I915_WRITE(RSTDBYCTL, I915_READ(RSTDBYCTL) & ~RCX_SW_EXIT);
-		POSTING_READ(RSTDBYCTL);
-	}
-}
-
-static int ironlake_setup_rc6(struct drm_device *dev)
-{
-	struct drm_i915_private *dev_priv = dev->dev_private;
-
-	if (dev_priv->ips.renderctx == NULL)
-		dev_priv->ips.renderctx = intel_alloc_context_page(dev);
-	if (!dev_priv->ips.renderctx)
-		return -ENOMEM;
-
-	if (dev_priv->ips.pwrctx == NULL)
-		dev_priv->ips.pwrctx = intel_alloc_context_page(dev);
-	if (!dev_priv->ips.pwrctx) {
-		ironlake_teardown_rc6(dev);
-		return -ENOMEM;
-	}
-
-	return 0;
-}
-
-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];
-	bool was_interruptible;
-	int ret;
-
-	/* rc6 disabled by default due to repeated reports of hanging during
-	 * boot and resume.
-	 */
-	if (!intel_enable_rc6(dev))
-		return;
-
-	WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
-	ret = ironlake_setup_rc6(dev);
-	if (ret)
-		return;
-
-	was_interruptible = dev_priv->mm.interruptible;
-	dev_priv->mm.interruptible = false;
-
-	/*
-	 * 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;
-	}
-
-	intel_ring_emit(ring, MI_SUSPEND_FLUSH | MI_SUSPEND_FLUSH_EN);
-	intel_ring_emit(ring, MI_SET_CONTEXT);
-	intel_ring_emit(ring, i915_gem_obj_ggtt_offset(dev_priv->ips.renderctx) |
-			MI_MM_SPACE_GTT |
-			MI_SAVE_EXT_STATE_EN |
-			MI_RESTORE_EXT_STATE_EN |
-			MI_RESTORE_INHIBIT);
-	intel_ring_emit(ring, MI_SUSPEND_FLUSH);
-	intel_ring_emit(ring, MI_NOOP);
-	intel_ring_emit(ring, MI_FLUSH);
-	intel_ring_advance(ring);
-
-	/*
-	 * 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
-	 * safe to assume that renderctx is valid
-	 */
-	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;
-	}
-
-	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);
-}
-
  static unsigned long intel_pxfreq(u32 vidfreq)
  {
  	unsigned long freq;
@@ -5655,7 +5502,6 @@ void intel_disable_gt_powersave(struct drm_device *dev)
 
  	if (IS_IRONLAKE_M(dev)) {
  		ironlake_disable_drps(dev);
-		ironlake_disable_rc6(dev);
  	} else if (INTEL_INFO(dev)->gen >= 6) {
  		intel_suspend_gt_powersave(dev);
 

drivers/gpu/drm/i915/intel_pm.c void intel_enable_gt_powersave(struct drm_device *dev) · line 5577

Quoted 7 lines
drivers/gpu/drm/i915/intel_pm.c +0 -1
@@ -5726,7 +5572,6 @@ void intel_enable_gt_powersave(struct drm_device *dev)
  	if (IS_IRONLAKE_M(dev)) {
  		mutex_lock(&dev->struct_mutex);
  		ironlake_enable_drps(dev);
-		ironlake_enable_rc6(dev);
  		intel_init_emon(dev);
  		mutex_unlock(&dev->struct_mutex);
  	} else if (INTEL_INFO(dev)->gen >= 6) {

Thanks,
Tomas

(I know this one has already been queued for merge... I'm going through these patches regardless, for my own bookkeeping)
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx