Skip to contentSkip to conversation

drm/i915: Split alloc from init for lrc

PATCH In review Nick Hoath 3 participants 4 messages Aug 19, 2015 – Aug 28, 2015

Subsystems (2)
lore
Share & tools
lore

Nick Hoath

author
#0 lore raw

PATCH 1/1 drm/i915: Split alloc from init for lrc

Extend init/init_hw split to context init.
- Move context initialisation in to i915_gem_init_hw
- Move one off initialisation for render ring to i915_gem_validate_context
- Move default context initialisation to logical_ring_init

Rename intel_lr_context_deferred_create to intel_lr_context_deferred_alloc, to reflect reduced functionality & alloc/init split.

This patch is intended to split out the allocation of resources & initialisation to allow easier reuse of code for resume/gpu reset.

v2: Removed function ptr wrapping of do_switch_context (Daniel Vetter)
Left ->init_context int intel_lr_context_deferred_alloc (Daniel Vetter) Remove unnecessary init flag & ring type test. (Daniel Vetter) Improve commit message (Daniel Vetter)
v3: On init/reinit, set the hw next sequence number to the sw next sequence
number. This is set to 1 at driver load time. This prevents the seqno being reset on reinit (Chris Wilson)

Issue: VIZ-4798

Cc Daniel Vetter <[email protected]>
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h            |   1 -
 drivers/gpu/drm/i915/i915_gem.c            |  18 ++--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   3 +-
 drivers/gpu/drm/i915/intel_lrc.c           | 147 ++++++++++++++---------------
 drivers/gpu/drm/i915/intel_lrc.h           |   4 +-
 5 files changed, 86 insertions(+), 87 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index f7fd519..844ccf0 100644
@@ -880,7 +880,6 @@ struct intel_context {
 	} legacy_hw_ctx;
 
 	/* Execlists */
-	bool rcs_initialized;
 	struct {
 		struct drm_i915_gem_object *state;
 		struct intel_ringbuffer *ringbuf;
drivers/gpu/drm/i915/i915_gem.c +11 -7
index 73293b4..eb7c1f2 100644
@@ -4603,14 +4603,8 @@ int i915_gem_init_rings(struct drm_device *dev)
 			goto cleanup_vebox_ring;
 	}
 
-	ret = i915_gem_set_seqno(dev, ((u32)~0 - 0x1000));
-	if (ret)
-		goto cleanup_bsd2_ring;
-
 	return 0;
 
-cleanup_bsd2_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[VCS2]);
 cleanup_vebox_ring:
 	intel_cleanup_ring_buffer(&dev_priv->ring[VECS]);
 cleanup_blt_ring:
@@ -4629,6 +4623,7 @@ i915_gem_init_hw(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring;
 	int ret, i, j;
+	struct drm_i915_gem_request *req;
 
 	if (INTEL_INFO(dev)->gen < 6 && !intel_enable_gtt())
 		return -EIO;
@@ -4680,9 +4675,12 @@ i915_gem_init_hw(struct drm_device *dev)
 			goto out;
 	}
 
+	ret = i915_gem_set_seqno(dev, dev_priv->next_seqno);
+	if (ret)
+		goto out;
+
 	/* 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);
 
@@ -4881,6 +4879,12 @@ i915_gem_load(struct drm_device *dev)
 		dev_priv->num_fence_regs =
 				I915_READ(vgtif_reg(avail_rs.fence_num));
 
+	/*
+	 * Set initial sequence number for requests.
+	  */
+	dev_priv->next_seqno = 1;
+	dev_priv->last_seqno = ~((uint32_t)0);
+
 	/* Initialize fence registers to zero */
 	INIT_LIST_HEAD(&dev_priv->mm.fence_list);
 	i915_gem_restore_fences(dev);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +2 -1
index 923a3c4..95f1a0d 100644
@@ -994,6 +994,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 {
 	struct intel_context *ctx = NULL;
 	struct i915_ctx_hang_stats *hs;
+	int ret;
 
 	if (ring->id != RCS && ctx_id != DEFAULT_CONTEXT_HANDLE)
 		return ERR_PTR(-EINVAL);
@@ -1009,7 +1010,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 	}
 
 	if (i915.enable_execlists && !ctx->engine[ring->id].state) {
-		int ret = intel_lr_context_deferred_create(ctx, ring);
+		ret = intel_lr_context_deferred_alloc(ctx, ring);
 		if (ret) {
 			DRM_DEBUG("Could not create LRC %u: %d\n", ctx_id, ret);
 			return ERR_PTR(ret);
drivers/gpu/drm/i915/intel_lrc.c +71 -76

227 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.h +2 -2
index 64f89f99..109147e 100644
@@ -69,8 +69,8 @@ static inline void intel_logical_ring_emit(struct intel_ringbuffer *ringbuf,
 
 /* Logical Ring Contexts */
 void intel_lr_context_free(struct intel_context *ctx);
-int intel_lr_context_deferred_create(struct intel_context *ctx,
-				     struct intel_engine_cs *ring);
+int intel_lr_context_deferred_alloc(struct intel_context *ctx,
+				    struct intel_engine_cs *ring);
 void intel_lr_context_unpin(struct drm_i915_gem_request *req);
 void intel_lr_context_reset(struct drm_device *dev,
 			struct intel_context *ctx);
Signature · 6 lines
2.1.1

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

Extend init/init_hw split to context init.
- Move context initialisation in to i915_gem_init_hw
- Move one off initialisation for render ring to i915_gem_validate_context
- Move default context initialisation to logical_ring_init

Rename intel_lr_context_deferred_create to intel_lr_context_deferred_alloc, to reflect reduced functionality & alloc/init split.

This patch is intended to split out the allocation of resources & initialisation to allow easier reuse of code for resume/gpu reset.

v2: Removed function ptr wrapping of do_switch_context (Daniel Vetter)
Left ->init_context int intel_lr_context_deferred_alloc (Daniel Vetter) Remove unnecessary init flag & ring type test. (Daniel Vetter) Improve commit message (Daniel Vetter)
v3: On init/reinit, set the hw next sequence number to the sw next sequence
number. This is set to 1 at driver load time. This prevents the seqno being reset on reinit (Chris Wilson)

Issue: VIZ-4798

Cc Daniel Vetter <[email protected]>
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h            |   1 -
 drivers/gpu/drm/i915/i915_gem.c            |  18 ++--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   3 +-
 drivers/gpu/drm/i915/intel_lrc.c           | 147 ++++++++++++++---------------
 drivers/gpu/drm/i915/intel_lrc.h           |   4 +-
 5 files changed, 86 insertions(+), 87 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index f7fd519..844ccf0 100644
@@ -880,7 +880,6 @@ struct intel_context {
 	} legacy_hw_ctx;
 
 	/* Execlists */
-	bool rcs_initialized;
 	struct {
 		struct drm_i915_gem_object *state;
 		struct intel_ringbuffer *ringbuf;
drivers/gpu/drm/i915/i915_gem.c +1 -6
index 73293b4..eb7c1f2 100644
@@ -4603,14 +4603,8 @@ int i915_gem_init_rings(struct drm_device *dev)
 			goto cleanup_vebox_ring;
 	}
 
-	ret = i915_gem_set_seqno(dev, ((u32)~0 - 0x1000));
-	if (ret)
-		goto cleanup_bsd2_ring;
-
 	return 0;
 
-cleanup_bsd2_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[VCS2]);
 cleanup_vebox_ring:
 	intel_cleanup_ring_buffer(&dev_priv->ring[VECS]);
 cleanup_blt_ring:
@@ -4629,6 +4623,7 @@ i915_gem_init_hw(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine_cs *ring;
 	int ret, i, j;
+	struct drm_i915_gem_request *req;
 
 	if (INTEL_INFO(dev)->gen < 6 && !intel_enable_gtt())
 		return -EIO;

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

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +3 -0
@@ -4680,9 +4675,12 @@ i915_gem_init_hw(struct drm_device *dev)
 			goto out;
 	}
 
+	ret = i915_gem_set_seqno(dev, dev_priv->next_seqno);
+	if (ret)
+		goto out;

The only reason to do this would be to ensure that the contents of the registers are valid (assuming we take over from ourselves). The right value to use then is last_seqno.

Quoted 13 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -0
index 923a3c4..95f1a0d 100644
@@ -994,6 +994,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 {
 	struct intel_context *ctx = NULL;
 	struct i915_ctx_hang_stats *hs;
+	int ret;
 
 	if (ring->id != RCS && ctx_id != DEFAULT_CONTEXT_HANDLE)
 		return ERR_PTR(-EINVAL);

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

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1009,7 +1010,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 	}
 
 	if (i915.enable_execlists && !ctx->engine[ring->id].state) {
-		int ret = intel_lr_context_deferred_create(ctx, ring);
+		ret = intel_lr_context_deferred_alloc(ctx, ring);
 		if (ret) {
 			DRM_DEBUG("Could not create LRC %u: %d\n", ctx_id, ret);
 			return ERR_PTR(ret);

Still modifying this for no reason, and you still haven't realised this call is redundant (hint there is already a hook in alloc_request).

From last year:
http://cgit.freedesktop.org/~ickle/linux-2.6/commit/?id=37fbd370152211688bc5bce3d28d13233cfe7d8b

More recent (i.e a couple of months ago):
http://cgit.freedesktop.org/~ickle/linux-2.6/commit/?h=nightly&id=ba4950a8f489d54ec4898f94dad44f9ec13301d2
-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
author
#2 lore raw
Quoted 77 lines · Chris Wilson
Quoted 76 lines · Nick Hoath

Extend init/init_hw split to context init.
- Move context initialisation in to i915_gem_init_hw
- Move one off initialisation for render ring to i915_gem_validate_context
- Move default context initialisation to logical_ring_init

Rename intel_lr_context_deferred_create to intel_lr_context_deferred_alloc, to reflect reduced functionality & alloc/init split.

This patch is intended to split out the allocation of resources & initialisation to allow easier reuse of code for resume/gpu reset.

v2: Removed function ptr wrapping of do_switch_context (Daniel Vetter)
Left ->init_context int intel_lr_context_deferred_alloc (Daniel Vetter) Remove unnecessary init flag & ring type test. (Daniel Vetter) Improve commit message (Daniel Vetter)
v3: On init/reinit, set the hw next sequence number to the sw next sequence
number. This is set to 1 at driver load time. This prevents the seqno being reset on reinit (Chris Wilson)

Issue: VIZ-4798

Cc Daniel Vetter <[email protected]>
Cc Chris Wilson <[email protected]>
---
  drivers/gpu/drm/i915/i915_drv.h            |   1 -
  drivers/gpu/drm/i915/i915_gem.c            |  18 ++--
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   3 +-
  drivers/gpu/drm/i915/intel_lrc.c           | 147 ++++++++++++++---------------
  drivers/gpu/drm/i915/intel_lrc.h           |   4 +-
  5 files changed, 86 insertions(+), 87 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index f7fd519..844ccf0 100644
@@ -880,7 +880,6 @@ struct intel_context {
  	} legacy_hw_ctx;
 
  	/* Execlists */
-	bool rcs_initialized;
  	struct {
  		struct drm_i915_gem_object *state;
  		struct intel_ringbuffer *ringbuf;
drivers/gpu/drm/i915/i915_gem.c +1 -6
index 73293b4..eb7c1f2 100644
@@ -4603,14 +4603,8 @@ int i915_gem_init_rings(struct drm_device *dev)
  			goto cleanup_vebox_ring;
  	}
 
-	ret = i915_gem_set_seqno(dev, ((u32)~0 - 0x1000));
-	if (ret)
-		goto cleanup_bsd2_ring;
-
  	return 0;
 
-cleanup_bsd2_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[VCS2]);
  cleanup_vebox_ring:
  	intel_cleanup_ring_buffer(&dev_priv->ring[VECS]);
  cleanup_blt_ring:
@@ -4629,6 +4623,7 @@ i915_gem_init_hw(struct drm_device *dev)
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct intel_engine_cs *ring;
  	int ret, i, j;
+	struct drm_i915_gem_request *req;
 
  	if (INTEL_INFO(dev)->gen < 6 && !intel_enable_gtt())
  		return -EIO;
@@ -4680,9 +4675,12 @@ i915_gem_init_hw(struct drm_device *dev)
  			goto out;
  	}
 
Quoted 7 lines

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

Quoted 3 lines
drivers/gpu/drm/i915/i915_gem.c +3 -0
+	ret = i915_gem_set_seqno(dev, dev_priv->next_seqno);
+	if (ret)
+		goto out;

The only reason to do this would be to ensure that the contents of the registers are valid (assuming we take over from ourselves). The right value to use then is last_seqno.

i915_gem_set_seqno uses the following code:

	ret = i915_gem_init_seqno(dev, seqno - 1);
......
	dev_priv->next_seqno = seqno;
	dev_priv->last_seqno = seqno - 1;

So using last_seqno would rewind the seqno by one...

Quoted 26 lines
Quoted 14 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -0
index 923a3c4..95f1a0d 100644
@@ -994,6 +994,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
  {
  	struct intel_context *ctx = NULL;
  	struct i915_ctx_hang_stats *hs;
+	int ret;
 
  	if (ring->id != RCS && ctx_id != DEFAULT_CONTEXT_HANDLE)
  		return ERR_PTR(-EINVAL);

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

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
@@ -1009,7 +1010,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
  	}
 
  	if (i915.enable_execlists && !ctx->engine[ring->id].state) {
-		int ret = intel_lr_context_deferred_create(ctx, ring);
+		ret = intel_lr_context_deferred_alloc(ctx, ring);
  		if (ret) {
  			DRM_DEBUG("Could not create LRC %u: %d\n", ctx_id, ret);
  			return ERR_PTR(ret);

Still modifying this for no reason, and you still haven't realised this call is redundant (hint there is already a hook in alloc_request).

Quoted 7 lines

From last year:
http://cgit.freedesktop.org/~ickle/linux-2.6/commit/?id=37fbd370152211688bc5bce3d28d13233cfe7d8b

More recent (i.e a couple of months ago):
http://cgit.freedesktop.org/~ickle/linux-2.6/commit/?h=nightly&id=ba4950a8f489d54ec4898f94dad44f9ec13301d2
-Chris

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

Tested-by on v1 1/1
#3 lore raw
In reply to Nick Hoath

Task id: 7233 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
ILK -1 302/302 301/302

SNB                                  315/315              315/315
IVB                                  336/336              336/336

BYT -1 283/283 282/283
HSW 378/378 378/378
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*ILK igt@kms_flip@rcs-wf_vblank-vs-dpms-interruptible PASS(1) DMESG_WARN(1)
*BYT igt@gem_tiled_partial_pwrite_pread@reads PASS(1) FAIL(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx