Skip to contentSkip to conversation

Execlists v2

PATCH In review [email protected] 5 participants 94 messages May 9, 2014 – Jun 12, 2014

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

cover Execlists v2

From: Oscar Mateo <[email protected]>

For a description of this patchset, please check the previous cover letter [1].

Together with this patchset, I'm also submitting an IGT test: gem_execlist [2].

v2:
- Use the same context struct for all the different engines (suggested by Brad Volkin).
- Rename write_tail to submit (suggested by Brad).
- Simplify hardware submission id creation by using LRCA[31:11] as hwCtxId[18:0].
- Non-render contexts are only two pages long (suggested by Damien Lespiau).
- Disable HWSTAM, as no one listens to it anyway (suggested by Damien).
- Do not write PDPs in the context every time, doing it at context creation time is enough.
- Various kmalloc changes in gen8_switch_context_queue (suggested by Damien).
- Module parameter to disable Execlists (as per Damien's patches).
- Update the HW read pointer in CONTEXT_STATUS_PTR (suggested by Damien).
- Fixed gpu reset and basic error reporting (verified by the new gem_error_capture test).
- Fix for unexpected full preemption in some scenarios (instead of lite restore).
- Ack the context switch interrupts as soon as possible (fix by Bob Beckett).
- Move default context backing object creation to intel_init_ring.
- Take into account the second BSD ring.
- Help out the ctx switch interrupt handler by sharing the burden of squashing requests together.

What I haven't done in this release:

- Get the context sizes from the CXT_SIZE registers, as suggested by Damien: the BSpec is full of holes with regards to the various CXT_SIZE registers, but the hardcoded values seem pretty clear.
- Allocate the ringbuffer together with the context, as suggested by Damien: now that every context has NUM_RINGS ringbuffers on it, the advantage of this is not clear anymore.
- Damien pointed out that we are missing the RS context restore, but I don't see any RS values that are needed on the first execution (the first save should take care of these).
- I have added a comment to clarify how the context population takes place (MI_LOAD_REGISTER_IMM plus <reg,value> pairs) but I haven't provided names for each position (as Jeff Mcgee suggested) or created an OUT_BATCH_REG_WRITE(reg, value) (as Daniel Vetter suggested).

[1]
http://lists.freedesktop.org/archives/intel-gfx/2014-March/042563.html
[2]
http://lists.freedesktop.org/archives/intel-gfx/2014-May/044846.html

Ben Widawsky (13):
drm/i915: s/for_each_ring/for_each_active_ring drm/i915: for_each_ring
drm/i915: Extract trivial parts of ring init (early init) drm/i915/bdw: Macro and module parameter for LRCs (Logical Ring
Contexts)
drm/i915/bdw: Rework init code for Logical Ring Contexts drm/i915/bdw: A bit more advanced context init/fini drm/i915/bdw: Populate LR contexts (somewhat) drm/i915/bdw: Status page for LR contexts drm/i915/bdw: Enable execlists in the hardware drm/i915/bdw: LR context ring init
drm/i915/bdw: GEN8 new ring flush
drm/i915/bdw: Implement context switching (somewhat) drm/i915/bdw: Print context state in debugfs

Michel Thierry (1):
drm/i915/bdw: Get prepared for a two-stage execlist submit process

Oscar Mateo (33):
drm/i915: Simplify a couple of functions thanks to for_each_ring drm/i915: Extract ringbuffer destroy, make destroy & alloc outside
accesible
drm/i915: s/intel_ring_buffer/intel_engine
drm/i915: Split the ringbuffers and the rings
drm/i915: Rename functions that mention ringbuffers (meaning rings) drm/i915: Plumb the context everywhere in the execbuffer path drm/i915: s/__intel_ring_advance/intel_ringbuffer_advance_and_submit drm/i915: Write a new set of context-aware ringbuffer management
functions
drm/i915: Final touches to ringbuffer and context plumbing and
refactoring
drm/i915: s/write_tail/submit
drm/i915: Introduce one context backing object per engine drm/i915: Make i915_gem_create_context outside accessible drm/i915: Option to skip backing object allocation during context
creation
drm/i915: Extract context backing object allocation drm/i915/bdw: New file for Logical Ring Contexts and Execlists drm/i915/bdw: Allocate ringbuffer backing objects for default global
LRC
drm/i915/bdw: Allocate ringbuffer for user-created LRCs drm/i915/bdw: Deferred creation of user-created LRCs drm/i915/bdw: Allow non-default, non-render, user-created LRCs drm/i915/bdw: Execlists ring tail writing
drm/i915/bdw: Set the request context information correctly in the LRC
case
drm/i915/bdw: Always write seqno to default context drm/i915/bdw: Write the tail pointer, LRC style drm/i915/bdw: Don't write PDP in the legacy way when using LRCs drm/i915/bdw: Start queueing contexts to be submitted drm/i915/bdw: Display execlists info in debugfs drm/i915/bdw: Display context backing obj & ringbuffer info in debugfs drm/i915/bdw: Document execlists and logical ring contexts drm/i915/bdw: Avoid non-lite-restore preemptions drm/i915/bdw: Make sure gpu reset still works with Execlists drm/i915/bdw: Make sure error capture keeps working with Execlists drm/i915/bdw: Help out the ctx switch interrupt handler drm/i915/bdw: Enable logical ring contexts

Thomas Daniel (3):
drm/i915/bdw: Add forcewake lock around ELSP writes drm/i915/bdw: LR context switch interrupts drm/i915/bdw: Handle context switch events

 drivers/gpu/drm/i915/Makefile              |   1 +
 drivers/gpu/drm/i915/i915_cmd_parser.c     |  16 +-
 drivers/gpu/drm/i915/i915_debugfs.c        | 180 ++++++-
 drivers/gpu/drm/i915/i915_dma.c            |  48 +-
 drivers/gpu/drm/i915/i915_drv.h            |  97 +++-
 drivers/gpu/drm/i915/i915_gem.c            | 172 ++++---
 drivers/gpu/drm/i915/i915_gem_context.c    | 220 +++++---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  85 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  41 +-
 drivers/gpu/drm/i915/i915_gem_gtt.h        |   2 +-
 drivers/gpu/drm/i915/i915_gpu_error.c      |  19 +-
 drivers/gpu/drm/i915/i915_irq.c            | 102 ++--
 drivers/gpu/drm/i915/i915_params.c         |   6 +
 drivers/gpu/drm/i915/i915_reg.h            |  11 +
 drivers/gpu/drm/i915/i915_trace.h          |  26 +-
 drivers/gpu/drm/i915/intel_display.c       |  26 +-
 drivers/gpu/drm/i915/intel_drv.h           |   4 +-
 drivers/gpu/drm/i915/intel_lrc.c           | 729 ++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_overlay.c       |  12 +-
 drivers/gpu/drm/i915/intel_pm.c            |  18 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 792 +++++++++++++++++++----------
 drivers/gpu/drm/i915/intel_ringbuffer.h    | 196 ++++---
 22 files changed, 2107 insertions(+), 696 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lrc.c
Signature · 1 line
1.9.0
#1 lore raw

PATCH 1/50 drm/i915: s/for_each_ring/for_each_active_ring

From: Ben Widawsky <[email protected]>

The name "active" was recommended by Chris.

With the ordering change of how we initialize things, it is desirable to be able to address each ring, whether initialized or not.

v2: Several rebases.

---
 drivers/gpu/drm/i915/i915_debugfs.c     | 12 ++++++------
 drivers/gpu/drm/i915/i915_drv.h         |  2 +-
 drivers/gpu/drm/i915/i915_gem.c         | 16 ++++++++--------
 drivers/gpu/drm/i915/i915_gem_context.c |  2 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c     | 10 +++++-----
 drivers/gpu/drm/i915/i915_irq.c         | 10 +++++-----
 drivers/gpu/drm/i915/intel_pm.c         |  8 ++++----
 drivers/gpu/drm/i915/intel_ringbuffer.c |  2 +-
 8 files changed, 31 insertions(+), 31 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +6 -6
index 18b3565..103e62c 100644
@@ -571,7 +571,7 @@ static int i915_gem_request_info(struct seq_file *m, void *data)
 		return ret;
 
 	count = 0;
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		if (list_empty(&ring->request_list))
 			continue;
 
@@ -615,7 +615,7 @@ static int i915_gem_seqno_info(struct seq_file *m, void *data)
 		return ret;
 	intel_runtime_pm_get(dev_priv);
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		i915_ring_seqno_info(m, ring);
 
 	intel_runtime_pm_put(dev_priv);
@@ -752,7 +752,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
 		seq_printf(m, "Graphics Interrupt mask:		%08x\n",
 			   I915_READ(GTIMR));
 	}
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		if (INTEL_INFO(dev)->gen >= 6) {
 			seq_printf(m,
 				   "Graphics Interrupt mask (%s):	%08x\n",
@@ -1703,7 +1703,7 @@ static int i915_context_status(struct seq_file *m, void *unused)
 
 		seq_puts(m, "HW context ");
 		describe_ctx(m, ctx);
-		for_each_ring(ring, dev_priv, i)
+		for_each_active_ring(ring, dev_priv, i)
 			if (ring->default_context == ctx)
 				seq_printf(m, "(default context %s) ", ring->name);
 
@@ -1835,7 +1835,7 @@ static void gen8_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 
 	seq_printf(m, "Page directories: %d\n", ppgtt->num_pd_pages);
 	seq_printf(m, "Page tables: %d\n", ppgtt->num_pd_entries);
-	for_each_ring(ring, dev_priv, unused) {
+	for_each_active_ring(ring, dev_priv, unused) {
 		seq_printf(m, "%s\n", ring->name);
 		for (i = 0; i < 4; i++) {
 			u32 offset = 0x270 + i * 8;
@@ -1857,7 +1857,7 @@ static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 	if (INTEL_INFO(dev)->gen == 6)
 		seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(GFX_MODE));
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		seq_printf(m, "%s\n", ring->name);
 		if (INTEL_INFO(dev)->gen == 7)
 			seq_printf(m, "GFX_MODE: 0x%08x\n", I915_READ(RING_MODE_GEN7(ring)));
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 26253c0..a53a028 100644
@@ -1545,7 +1545,7 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
 }
 
 /* Iterate over initialised rings */
-#define for_each_ring(ring__, dev_priv__, i__) \
+#define for_each_active_ring(ring__, dev_priv__, i__) \
 	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
 		if (((ring__) = &(dev_priv__)->ring[(i__)]), intel_ring_initialized((ring__)))
 
drivers/gpu/drm/i915/i915_gem.c +8 -8
index 8fd1824..ce941cf 100644
@@ -2108,7 +2108,7 @@ i915_gem_init_seqno(struct drm_device *dev, u32 seqno)
 	int ret, i, j;
 
 	/* Carefully retire all requests without writing to the rings */
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		ret = intel_ring_idle(ring);
 		if (ret)
 			return ret;
@@ -2116,7 +2116,7 @@ i915_gem_init_seqno(struct drm_device *dev, u32 seqno)
 	i915_gem_retire_requests(dev);
 
 	/* Finally reset hw state */
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		intel_ring_init_seqno(ring, seqno);
 
 		for (j = 0; j < ARRAY_SIZE(ring->semaphore.sync_seqno); j++)
@@ -2434,10 +2434,10 @@ void i915_gem_reset(struct drm_device *dev)
 	 * them for finding the guilty party. As the requests only borrow
 	 * their reference to the objects, the inspection must be done first.
 	 */
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		i915_gem_reset_ring_status(dev_priv, ring);
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		i915_gem_reset_ring_cleanup(dev_priv, ring);
 
 	i915_gem_context_reset(dev);
@@ -2516,7 +2516,7 @@ i915_gem_retire_requests(struct drm_device *dev)
 	bool idle = true;
 	int i;
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		i915_gem_retire_requests_ring(ring);
 		idle &= list_empty(&ring->request_list);
 	}
@@ -2804,7 +2804,7 @@ int i915_gpu_idle(struct drm_device *dev)
 	int ret, i;
 
 	/* Flush everything onto the inactive list. */
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		ret = i915_switch_context(ring, ring->default_context);
 		if (ret)
 			return ret;
@@ -4261,7 +4261,7 @@ i915_gem_stop_ringbuffers(struct drm_device *dev)
 	struct intel_ring_buffer *ring;
 	int i;
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		intel_stop_ring_buffer(ring);
 }
 
@@ -4533,7 +4533,7 @@ i915_gem_cleanup_ringbuffer(struct drm_device *dev)
 	struct intel_ring_buffer *ring;
 	int i;
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		intel_cleanup_ring_buffer(ring);
 }
 
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index f77b4c1..948df20 100644
@@ -483,7 +483,7 @@ int i915_gem_context_enable(struct drm_i915_private *dev_priv)
 
 	BUG_ON(!dev_priv->ring[RCS].default_context);
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		ret = i915_switch_context(ring, ring->default_context);
 		if (ret)
 			return ret;
drivers/gpu/drm/i915/i915_gem_gtt.c +5 -5
index 72b1bf8..1dff805 100644
@@ -835,7 +835,7 @@ static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 	struct intel_ring_buffer *ring;
 	int j, ret;
 
-	for_each_ring(ring, dev_priv, j) {
+	for_each_active_ring(ring, dev_priv, j) {
 		I915_WRITE(RING_MODE_GEN7(ring),
 			   _MASKED_BIT_ENABLE(GFX_PPGTT_ENABLE));
 
@@ -852,7 +852,7 @@ static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 	return 0;
 
 err_out:
-	for_each_ring(ring, dev_priv, j)
+	for_each_active_ring(ring, dev_priv, j)
 		I915_WRITE(RING_MODE_GEN7(ring),
 			   _MASKED_BIT_DISABLE(GFX_PPGTT_ENABLE));
 	return ret;
@@ -878,7 +878,7 @@ static int gen7_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 	}
 	I915_WRITE(GAM_ECOCHK, ecochk);
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		int ret;
 		/* GFX_MODE is per-ring on gen7+ */
 		I915_WRITE(RING_MODE_GEN7(ring),
@@ -917,7 +917,7 @@ static int gen6_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 
 	I915_WRITE(GFX_MODE, _MASKED_BIT_ENABLE(GFX_PPGTT_ENABLE));
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		int ret = ppgtt->switch_mm(ppgtt, ring, true);
 		if (ret)
 			return ret;
@@ -1275,7 +1275,7 @@ void i915_check_and_clear_faults(struct drm_device *dev)
 	if (INTEL_INFO(dev)->gen < 6)
 		return;
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		u32 fault_reg;
 		fault_reg = I915_READ(RING_FAULT_REG(ring));
 		if (fault_reg & RING_FAULT_VALID) {
drivers/gpu/drm/i915/i915_irq.c +5 -5
index 2d76183..4a8e8cb 100644
@@ -2122,7 +2122,7 @@ static void i915_error_wake_up(struct drm_i915_private *dev_priv,
 	 */
 
 	/* Wake up __wait_seqno, potentially holding dev->struct_mutex. */
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		wake_up_all(&ring->irq_queue);
 
 	/* Wake up intel_crtc_wait_for_pending_flips, holding crtc->mutex. */
@@ -2591,7 +2591,7 @@ semaphore_wait_to_signaller_ring(struct intel_ring_buffer *ring, u32 ipehr)
 	} else {
 		u32 sync_bits = ipehr & MI_SEMAPHORE_SYNC_MASK;
 
-		for_each_ring(signaller, dev_priv, i) {
+		for_each_active_ring(signaller, dev_priv, i) {
 			if(ring == signaller)
 				continue;
 
@@ -2674,7 +2674,7 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
 	struct intel_ring_buffer *ring;
 	int i;
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		ring->hangcheck.deadlock = false;
 }
 
@@ -2746,7 +2746,7 @@ static void i915_hangcheck_elapsed(unsigned long data)
 	if (!i915.enable_hangcheck)
 		return;
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		u64 acthd;
 		u32 seqno;
 		bool busy = true;
@@ -2825,7 +2825,7 @@ static void i915_hangcheck_elapsed(unsigned long data)
 		busy_count += busy;
 	}
 
-	for_each_ring(ring, dev_priv, i) {
+	for_each_active_ring(ring, dev_priv, i) {
 		if (ring->hangcheck.score >= HANGCHECK_SCORE_RING_HUNG) {
 			DRM_INFO("%s on %s\n",
 				 stuck[i] ? "stuck" : "no progress",
drivers/gpu/drm/i915/intel_pm.c +4 -4
index 834c49c..acfded3 100644
@@ -3400,7 +3400,7 @@ static void gen8_enable_rps(struct drm_device *dev)
 	I915_WRITE(GEN6_RC6_WAKE_RATE_LIMIT, 40 << 16);
 	I915_WRITE(GEN6_RC_EVALUATION_INTERVAL, 125000); /* 12500 * 1280ns */
 	I915_WRITE(GEN6_RC_IDLE_HYSTERSIS, 25); /* 25 * 1280ns */
-	for_each_ring(ring, dev_priv, unused)
+	for_each_active_ring(ring, dev_priv, unused)
 		I915_WRITE(RING_MAX_IDLE(ring->mmio_base), 10);
 	I915_WRITE(GEN6_RC_SLEEP, 0);
 	I915_WRITE(GEN6_RC6_THRESHOLD, 50000); /* 50/125ms per EI */
@@ -3494,7 +3494,7 @@ static void gen6_enable_rps(struct drm_device *dev)
 	I915_WRITE(GEN6_RC_EVALUATION_INTERVAL, 125000);
 	I915_WRITE(GEN6_RC_IDLE_HYSTERSIS, 25);
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		I915_WRITE(RING_MAX_IDLE(ring->mmio_base), 10);
 
 	I915_WRITE(GEN6_RC_SLEEP, 0);
@@ -3819,7 +3819,7 @@ static void valleyview_enable_rps(struct drm_device *dev)
 	I915_WRITE(GEN6_RC_EVALUATION_INTERVAL, 125000);
 	I915_WRITE(GEN6_RC_IDLE_HYSTERSIS, 25);
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		I915_WRITE(RING_MAX_IDLE(ring->mmio_base), 10);
 
 	I915_WRITE(GEN6_RC6_THRESHOLD, 0x557);
@@ -4435,7 +4435,7 @@ bool i915_gpu_busy(void)
 		goto out_unlock;
 	dev_priv = i915_mch_dev;
 
-	for_each_ring(ring, dev_priv, i)
+	for_each_active_ring(ring, dev_priv, i)
 		ret |= !list_empty(&ring->request_list);
 
 out_unlock:
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -1
index 40a7aa4..a112971 100644
@@ -685,7 +685,7 @@ static int gen6_signal(struct intel_ring_buffer *signaller,
 		return ret;
 #undef MBOX_UPDATE_DWORDS
 
-	for_each_ring(useless, dev_priv, i) {
+	for_each_active_ring(useless, dev_priv, i) {
 		u32 mbox_reg = signaller->semaphore.mbox.signal[i];
 		if (mbox_reg != GEN6_NOSYNC) {
 			intel_ring_emit(signaller, MI_LOAD_REGISTER_IMM(1));
Signature · 1 line
1.9.0
#2 lore raw

PATCH 2/50 drm/i915: for_each_ring

In reply to [email protected]

From: Ben Widawsky <[email protected]>

for_each_ring() iterates over all rings supported by the hardware, not just those which have been initialized as in for_each_active_ring()

---
 drivers/gpu/drm/i915/i915_drv.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +11 -0
index a53a028..b1725c6 100644
@@ -1544,6 +1544,17 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
 	return dev->dev_private;
 }
 
+/* NB: Typically you want to use for_each_ring in init code before ringbuffers
+ * are setup, or in debug code. for_each_active_ring is more suited for code
+ * which is dynamically handling active rings, ie. normal code. In most
+ * (currently all cases except on pre-production hardware) for_each_ring will
+ * work even if it's a bad idea to use it - so be careful.
+ */
+#define for_each_ring(ring__, dev_priv__, i__) \
+	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
+		if (((ring__) = &(dev_priv__)->ring[(i__)]), \
+		    INTEL_INFO((dev_priv__)->dev)->ring_mask & (1<<(i__)))
+
 /* Iterate over initialised rings */
 #define for_each_active_ring(ring__, dev_priv__, i__) \
 	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
Signature · 1 line
1.9.0
#3 lore raw

Re: [PATCH 02/50] drm/i915: for_each_ring

Quoted 16 lines · On Fri, May 09, 2014 at 01:08:32PM +0100, [email protected] wrote:

From: Ben Widawsky <[email protected]>

for_each_ring() iterates over all rings supported by the hardware, not just those which have been initialized as in for_each_active_ring()

---
 drivers/gpu/drm/i915/i915_drv.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index a53a028..b1725c6 100644

drivers/gpu/drm/i915/i915_drv.h static inline struct drm_i915_private *to_i915(const struct drm_device *dev) · line 1552

Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +6 -0
@@ -1544,6 +1544,17 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
 	return dev->dev_private;
 }
 
+/* NB: Typically you want to use for_each_ring in init code before ringbuffers
+ * are setup, or in debug code. for_each_active_ring is more suited for code
+ * which is dynamically handling active rings, ie. normal code. In most
+ * (currently all cases except on pre-production hardware) for_each_ring will
+ * work even if it's a bad idea to use it - so be careful.
+ */

Proper kerneldoc comment would look neater imo instead of an "NB:". Bonus points if you pull it into the drm docbook (just the header files with the !I directive in the DocBook template).
-Daniel

Quoted 15 lines
drivers/gpu/drm/i915/i915_drv.h +5 -0
+#define for_each_ring(ring__, dev_priv__, i__) \
+	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
+		if (((ring__) = &(dev_priv__)->ring[(i__)]), \
+		    INTEL_INFO((dev_priv__)->dev)->ring_mask & (1<<(i__)))
+
 /* Iterate over initialised rings */
 #define for_each_active_ring(ring__, dev_priv__, i__) \
 	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
Signature · 6 lines
1.9.0

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

Re: [PATCH 02/50] drm/i915: for_each_ring

In reply to [email protected]
Quoted 4 lines · On Fri, May 09, 2014 at 05:08:32AM -0700, [email protected] wrote:

From: Ben Widawsky <[email protected]>

for_each_ring() iterates over all rings supported by the hardware, not just those which have been initialized as in for_each_active_ring()

I think we should give this a new name; something like for_each_supported_ring. My concern is that, with all of the patches in flight, we'll merge something that uses for_each_ring when it should have been changed to for_each_active_ring. Better that such a patch not even compile.

Brad

Quoted 36 lines
---
 drivers/gpu/drm/i915/i915_drv.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +11 -0
index a53a028..b1725c6 100644
@@ -1544,6 +1544,17 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
 	return dev->dev_private;
 }
 
+/* NB: Typically you want to use for_each_ring in init code before ringbuffers
+ * are setup, or in debug code. for_each_active_ring is more suited for code
+ * which is dynamically handling active rings, ie. normal code. In most
+ * (currently all cases except on pre-production hardware) for_each_ring will
+ * work even if it's a bad idea to use it - so be careful.
+ */
+#define for_each_ring(ring__, dev_priv__, i__) \
+	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
+		if (((ring__) = &(dev_priv__)->ring[(i__)]), \
+		    INTEL_INFO((dev_priv__)->dev)->ring_mask & (1<<(i__)))
+
 /* Iterate over initialised rings */
 #define for_each_active_ring(ring__, dev_priv__, i__) \
 	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
Signature · 6 lines
1.9.0

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

Re: [PATCH 02/50] drm/i915: for_each_ring

Quoted 10 lines

-----Original Message-----
From: Volkin, Bradley D
Sent: Monday, May 19, 2014 5:34 PM
To: Mateo Lozano, Oscar
Cc: [email protected]; Ben Widawsky; Widawsky, Benjamin
Subject: Re: [Intel-gfx] [PATCH 02/50] drm/i915: for_each_ring

Quoted 2 lines · On Fri, May 09, 2014 at 05:08:32AM -0700, [email protected] wrote:

From: Ben Widawsky <[email protected]>

Quoted 8 lines
Quoted 2 lines

for_each_ring() iterates over all rings supported by the hardware, not just those which have been initialized as in for_each_active_ring()

I think we should give this a new name; something like for_each_supported_ring.
My concern is that, with all of the patches in flight, we'll merge something that uses for_each_ring when it should have been changed to for_each_active_ring. Better that such a patch not even compile.

I can kill this patch off completely: when we started with Execlists, it simplified a lot of things and made life easier in general, but with each new iteration it just becomes more and more useless...

Quoted 40 lines

drivers/gpu/drm/i915/i915_drv.h static inline struct drm_i915_private

Quoted 11 lines
---
 drivers/gpu/drm/i915/i915_drv.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index a53a028..b1725c6 100644

drivers/gpu/drm/i915/i915_drv.h +0 -0
@@ -1544,6 +1544,17 @@ static inline struct drm_i915_private

*to_i915(const struct drm_device *dev)

Quoted 28 lines
drivers/gpu/drm/i915/i915_drv.h +15 -1
 	return dev->dev_private;
 }
 
+/* NB: Typically you want to use for_each_ring in init code before
+ringbuffers
+ * are setup, or in debug code. for_each_active_ring is more suited
+for code
+ * which is dynamically handling active rings, ie. normal code. In
+most
+ * (currently all cases except on pre-production hardware)
+for_each_ring will
+ * work even if it's a bad idea to use it - so be careful.
+ */
+#define for_each_ring(ring__, dev_priv__, i__) \
+	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
+		if (((ring__) = &(dev_priv__)->ring[(i__)]), \
+		    INTEL_INFO((dev_priv__)->dev)->ring_mask & (1<<(i__)))
+
 /* Iterate over initialised rings */
 #define for_each_active_ring(ring__, dev_priv__, i__) \
 	for ((i__) = 0; (i__) < I915_NUM_RINGS; (i__)++) \
--

1.9.0

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

#6 lore raw

PATCH 3/50 drm/i915: Simplify a couple of functions thanks to for_each_ring

In reply to [email protected]

From: Oscar Mateo <[email protected]>

This patch should have no functional changes.

---
 drivers/gpu/drm/i915/i915_gem_context.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +9 -9
index 948df20..014fb8f 100644
@@ -359,12 +359,12 @@ err_destroy:
 void i915_gem_context_reset(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_ring_buffer *ring;
 	int i;
 
 	/* Prevent the hardware from restoring the last context (which hung) on
 	 * the next switch */
-	for (i = 0; i < I915_NUM_RINGS; i++) {
-		struct intel_ring_buffer *ring = &dev_priv->ring[i];
+	for_each_ring(ring, dev_priv, i) {
 		struct i915_hw_context *dctx = ring->default_context;
 
 		/* Do a fake switch to the default context */
@@ -392,7 +392,8 @@ int i915_gem_context_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *ctx;
-	int i;
+	struct intel_ring_buffer *ring;
+	int unused;
 
 	/* Init should only be called once per module load. Eventually the
 	 * restriction on the context_disabled check can be loosened. */
@@ -416,8 +417,8 @@ int i915_gem_context_init(struct drm_device *dev)
 	}
 
 	/* NB: RCS will hold a ref for all rings */
-	for (i = 0; i < I915_NUM_RINGS; i++)
-		dev_priv->ring[i].default_context = ctx;
+	for_each_ring(ring, dev_priv, unused)
+		ring->default_context = ctx;
 
 	DRM_DEBUG_DRIVER("%s context support initialized\n", dev_priv->hw_context_size ? "HW" : "fake");
 	return 0;
@@ -427,7 +428,8 @@ void i915_gem_context_fini(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *dctx = dev_priv->ring[RCS].default_context;
-	int i;
+	struct intel_ring_buffer *ring;
+	int unused;
 
 	if (dctx->obj) {
 		/* The only known way to stop the gpu from accessing the hw context is
@@ -451,9 +453,7 @@ void i915_gem_context_fini(struct drm_device *dev)
 		}
 	}
 
-	for (i = 0; i < I915_NUM_RINGS; i++) {
-		struct intel_ring_buffer *ring = &dev_priv->ring[i];
-
+	for_each_ring(ring, dev_priv, unused) {
 		if (ring->last_context)
 			i915_gem_context_unreference(ring->last_context);
 
Signature · 1 line
1.9.0
#7 lore raw

PATCH 4/50 drm/i915: Extract trivial parts of ring init (early init)

In reply to [email protected]

From: Ben Widawsky <[email protected]>

It's beneficial to be able to get a name, base, and id before we've actually initialized the rings. This ability was effectively destroyed in the ringbuffer fire which Daniel started.

With the simple early init function, that ability is restored.

v2: The Full PPGTT series have moved things around a little bit. Also, don't forget the VEBOX.

v3: Checking ring->dev is not a good way to test if a ring is initialized...

---
 drivers/gpu/drm/i915/i915_gem.c         |  2 ++
 drivers/gpu/drm/i915/i915_gpu_error.c   |  2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c | 60 ++++++++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 4 files changed, 37 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -0
index ce941cf..6ef53bd 100644
@@ -4502,6 +4502,8 @@ int i915_gem_init(struct drm_device *dev)
 
 	i915_gem_init_global_gtt(dev);
 
+	intel_init_rings_early(dev);
+
 	ret = i915_gem_context_init(dev);
 	if (ret) {
 		mutex_unlock(&dev->struct_mutex);
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
index 2d81985..8f37238 100644
@@ -886,7 +886,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 	for (i = 0; i < I915_NUM_RINGS; i++) {
 		struct intel_ring_buffer *ring = &dev_priv->ring[i];
 
-		if (ring->dev == NULL)
+		if (!intel_ring_initialized(ring))
 			continue;
 
 		error->ring[i].valid = true;
drivers/gpu/drm/i915/intel_ringbuffer.c +33 -27

120 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index 72c3c15..b1bf767 100644
@@ -297,6 +297,7 @@ void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno);
 int intel_ring_flush_all_caches(struct intel_ring_buffer *ring);
 int intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring);
 
+void intel_init_rings_early(struct drm_device *dev);
 int intel_init_render_ring_buffer(struct drm_device *dev);
 int intel_init_bsd_ring_buffer(struct drm_device *dev);
 int intel_init_bsd2_ring_buffer(struct drm_device *dev);
Signature · 1 line
1.9.0
#8 lore raw

Re: [PATCH 04/50] drm/i915: Extract trivial parts of ring init (early init)

Quoted 10 lines · On Fri, May 09, 2014 at 01:08:34PM +0100, [email protected] wrote:

From: Ben Widawsky <[email protected]>

It's beneficial to be able to get a name, base, and id before we've actually initialized the rings. This ability was effectively destroyed in the ringbuffer fire which Daniel started.

With the simple early init function, that ability is restored.

Quoted 7 lines

v2: The Full PPGTT series have moved things around a little bit. Also, don't forget the VEBOX.

v3: Checking ring->dev is not a good way to test if a ring is initialized...

Needs to be updated for VEBOX2. Also I don't really see the point, where exactly do we need this? Ripping apart the ring init like this doesn't look too great imo.
-Daniel

Quoted 186 lines
---
 drivers/gpu/drm/i915/i915_gem.c         |  2 ++
 drivers/gpu/drm/i915/i915_gpu_error.c   |  2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c | 60 ++++++++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 4 files changed, 37 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -0
index ce941cf..6ef53bd 100644
@@ -4502,6 +4502,8 @@ int i915_gem_init(struct drm_device *dev)
 
 	i915_gem_init_global_gtt(dev);
 
+	intel_init_rings_early(dev);
+
 	ret = i915_gem_context_init(dev);
 	if (ret) {
 		mutex_unlock(&dev->struct_mutex);
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
index 2d81985..8f37238 100644
@@ -886,7 +886,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 	for (i = 0; i < I915_NUM_RINGS; i++) {
 		struct intel_ring_buffer *ring = &dev_priv->ring[i];
 
-		if (ring->dev == NULL)
+		if (!intel_ring_initialized(ring))
 			continue;
 
 		error->ring[i].valid = true;
drivers/gpu/drm/i915/intel_ringbuffer.c +33 -27
index a112971..fc737c8 100644
@@ -1417,7 +1417,6 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 {
 	int ret;
 
-	ring->dev = dev;
 	INIT_LIST_HEAD(&ring->active_list);
 	INIT_LIST_HEAD(&ring->request_list);
 	ring->size = 32 * PAGE_SIZE;
@@ -1908,10 +1907,6 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
 
-	ring->name = "render ring";
-	ring->id = RCS;
-	ring->mmio_base = RENDER_RING_BASE;
-
 	if (INTEL_INFO(dev)->gen >= 6) {
 		ring->add_request = gen6_add_request;
 		ring->flush = gen7_render_ring_flush;
@@ -2019,10 +2014,6 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
 	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
 	int ret;
 
-	ring->name = "render ring";
-	ring->id = RCS;
-	ring->mmio_base = RENDER_RING_BASE;
-
 	if (INTEL_INFO(dev)->gen >= 6) {
 		/* non-kms not supported on gen6+ */
 		return -ENODEV;
@@ -2056,7 +2047,6 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
 	ring->init = init_render_ring;
 	ring->cleanup = render_ring_cleanup;
 
-	ring->dev = dev;
 	INIT_LIST_HEAD(&ring->active_list);
 	INIT_LIST_HEAD(&ring->request_list);
 
@@ -2086,12 +2076,8 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[VCS];
 
-	ring->name = "bsd ring";
-	ring->id = VCS;
-
 	ring->write_tail = ring_write_tail;
 	if (INTEL_INFO(dev)->gen >= 6) {
-		ring->mmio_base = GEN6_BSD_RING_BASE;
 		/* gen6 bsd needs a special wa for tail updates */
 		if (IS_GEN6(dev))
 			ring->write_tail = gen6_bsd_ring_write_tail;
@@ -2132,7 +2118,6 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev)
 		ring->semaphore.mbox.signal[VECS] = GEN6_VEVSYNC;
 		ring->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC;
 	} else {
-		ring->mmio_base = BSD_RING_BASE;
 		ring->flush = bsd_ring_flush;
 		ring->add_request = i9xx_add_request;
 		ring->get_seqno = ring_get_seqno;
@@ -2167,11 +2152,7 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev)
 		return -EINVAL;
 	}
 
-	ring->name = "bds2_ring";
-	ring->id = VCS2;
-
 	ring->write_tail = ring_write_tail;
-	ring->mmio_base = GEN8_BSD2_RING_BASE;
 	ring->flush = gen6_bsd_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
@@ -2210,10 +2191,6 @@ int intel_init_blt_ring_buffer(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[BCS];
 
-	ring->name = "blitter ring";
-	ring->id = BCS;
-
-	ring->mmio_base = BLT_RING_BASE;
 	ring->write_tail = ring_write_tail;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
@@ -2259,10 +2236,6 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_ring_buffer *ring = &dev_priv->ring[VECS];
 
-	ring->name = "video enhancement ring";
-	ring->id = VECS;
-
-	ring->mmio_base = VEBOX_RING_BASE;
 	ring->write_tail = ring_write_tail;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
@@ -2351,3 +2324,36 @@ intel_stop_ring_buffer(struct intel_ring_buffer *ring)
 
 	stop_ring(ring);
 }
+
+void intel_init_rings_early(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	dev_priv->ring[RCS].name = "render ring";
+	dev_priv->ring[RCS].id = RCS;
+	dev_priv->ring[RCS].mmio_base = RENDER_RING_BASE;
+	dev_priv->ring[RCS].dev = dev;
+
+	dev_priv->ring[BCS].name = "blitter ring";
+	dev_priv->ring[BCS].id = BCS;
+	dev_priv->ring[BCS].mmio_base = BLT_RING_BASE;
+	dev_priv->ring[BCS].dev = dev;
+
+	dev_priv->ring[VCS].name = "bsd ring";
+	dev_priv->ring[VCS].id = VCS;
+	if (INTEL_INFO(dev)->gen >= 6)
+		dev_priv->ring[VCS].mmio_base = GEN6_BSD_RING_BASE;
+	else
+		dev_priv->ring[VCS].mmio_base = BSD_RING_BASE;
+	dev_priv->ring[VCS].dev = dev;
+
+	dev_priv->ring[VCS2].name = "bds2_ring";
+	dev_priv->ring[VCS2].id = VCS2;
+	dev_priv->ring[VCS2].mmio_base = GEN8_BSD2_RING_BASE;
+	dev_priv->ring[VCS2].dev = dev;
+
+	dev_priv->ring[VECS].name = "video enhancement ring";
+	dev_priv->ring[VECS].id = VECS;
+	dev_priv->ring[VECS].mmio_base = VEBOX_RING_BASE;
+	dev_priv->ring[VECS].dev = dev;
+}
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index 72c3c15..b1bf767 100644
@@ -297,6 +297,7 @@ void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno);
 int intel_ring_flush_all_caches(struct intel_ring_buffer *ring);
 int intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring);
 
+void intel_init_rings_early(struct drm_device *dev);
 int intel_init_render_ring_buffer(struct drm_device *dev);
 int intel_init_bsd_ring_buffer(struct drm_device *dev);
 int intel_init_bsd2_ring_buffer(struct drm_device *dev);
Signature · 6 lines
1.9.0

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

Re: [PATCH 04/50] drm/i915: Extract trivial parts of ring init (early init)

Quoted 9 lines · Daniel Vetter
Quoted 8 lines · On Fri, May 09, 2014 at 01:08:34PM +0100, [email protected] wrote:
drivers/gpu/drm/i915/i915_gpu_error.c +0 -0
index 2d81985..8f37238 100644
@@ -886,7 +886,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 	for (i = 0; i < I915_NUM_RINGS; i++) {
 		struct intel_ring_buffer *ring = &dev_priv->ring[i];
 
Quoted 3 lines

drivers/gpu/drm/i915/i915_gpu_error.c static void i915_gem_record_rings(struct drm_device *dev, · line 890

Quoted 3 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
-		if (ring->dev == NULL)
+		if (!intel_ring_initialized(ring))
 			continue;

Besides this was deliberately written not to use
intel_ring_initialized().
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#10 lore raw

Re: [PATCH 04/50] drm/i915: Extract trivial parts of ring init (early init)

In reply to Daniel Vetter
Quoted 22 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, May 13, 2014 2:27 PM
To: Mateo Lozano, Oscar
Cc: [email protected]; Ben Widawsky; Widawsky, Benjamin
Subject: Re: [Intel-gfx] [PATCH 04/50] drm/i915: Extract trivial parts of ring init (early init)

Quoted 13 lines · On Fri, May 09, 2014 at 01:08:34PM +0100, [email protected] wrote:

From: Ben Widawsky <[email protected]>

It's beneficial to be able to get a name, base, and id before we've actually initialized the rings. This ability was effectively destroyed in the ringbuffer fire which Daniel started.

With the simple early init function, that ability is restored.

v2: The Full PPGTT series have moved things around a little bit. Also, don't forget the VEBOX.

Quoted 8 lines
Quoted 4 lines

v3: Checking ring->dev is not a good way to test if a ring is initialized...

Needs to be updated for VEBOX2. Also I don't really see the point, where exactly do we need this? Ripping apart the ring init like this doesn't look too great imo.

VEBOX2?? Not one week ago I updated it for BSD2 :(
Anyway, this patch is a legacy carry over from previous versions, I can perfectly make do without it. Thanks!

#11 lore raw

Re: [PATCH 04/50] drm/i915: Extract trivial parts of ring init (early init)

Quoted 25 lines · Oscar
Quoted 25 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, May 13, 2014 2:27 PM
To: Mateo Lozano, Oscar
Cc: [email protected]; Ben Widawsky; Widawsky, Benjamin
Subject: Re: [Intel-gfx] [PATCH 04/50] drm/i915: Extract trivial parts of ring init (early init)

Quoted 16 lines · On Fri, May 09, 2014 at 01:08:34PM +0100, [email protected] wrote:

From: Ben Widawsky <[email protected]>

It's beneficial to be able to get a name, base, and id before we've actually initialized the rings. This ability was effectively destroyed in the ringbuffer fire which Daniel started.

With the simple early init function, that ability is restored.

v2: The Full PPGTT series have moved things around a little bit. Also, don't forget the VEBOX.

v3: Checking ring->dev is not a good way to test if a ring is initialized...

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Needs to be updated for VEBOX2. Also I don't really see the point, where exactly do we need this? Ripping apart the ring init like this doesn't look too great imo.

VEBOX2?? Not one week ago I updated it for BSD2 :(
Anyway, this patch is a legacy carry over from previous versions, I can perfectly make do without it.

Oops, I've meant VCS2, must have been asleep while reading it ;-) -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#12 lore raw

PATCH 5/50 drm/i915: Extract ringbuffer destroy, make destroy & alloc outside accesible

In reply to [email protected]

From: Oscar Mateo <[email protected]>

No functional changes.

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 21 ++++++++++++++-------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  3 +++
 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +14 -7
index fc737c8..5d61923 100644
@@ -1368,7 +1368,18 @@ static int init_phys_status_page(struct intel_ring_buffer *ring)
 	return 0;
 }
 
-static int allocate_ring_buffer(struct intel_ring_buffer *ring)
+void intel_destroy_ring_buffer(struct intel_ring_buffer *ring)
+{
+	if (!ring->obj)
+		return;
+
+	iounmap(ring->virtual_start);
+	i915_gem_object_ggtt_unpin(ring->obj);
+	drm_gem_object_unreference(&ring->obj->base);
+	ring->obj = NULL;
+}
+
+int intel_allocate_ring_buffer(struct intel_ring_buffer *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
@@ -1435,7 +1446,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 			return ret;
 	}
 
-	ret = allocate_ring_buffer(ring);
+	ret = intel_allocate_ring_buffer(ring);
 	if (ret) {
 		DRM_ERROR("Failed to allocate ringbuffer %s: %d\n", ring->name, ret);
 		return ret;
@@ -1464,11 +1475,7 @@ void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring)
 	intel_stop_ring_buffer(ring);
 	WARN_ON((I915_READ_MODE(ring) & MODE_IDLE) == 0);
 
-	iounmap(ring->virtual_start);
-
-	i915_gem_object_ggtt_unpin(ring->obj);
-	drm_gem_object_unreference(&ring->obj->base);
-	ring->obj = NULL;
+	intel_destroy_ring_buffer(ring);
 	ring->preallocated_lazy_request = NULL;
 	ring->outstanding_lazy_seqno = 0;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +3 -0
index b1bf767..680e451 100644
@@ -307,6 +307,9 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev);
 u64 intel_ring_get_active_head(struct intel_ring_buffer *ring);
 void intel_ring_setup_status_page(struct intel_ring_buffer *ring);
 
+void intel_destroy_ring_buffer(struct intel_ring_buffer *ring);
+int intel_allocate_ring_buffer(struct intel_ring_buffer *ring);
+
 static inline u32 intel_ring_get_tail(struct intel_ring_buffer *ring)
 {
 	return ring->tail;
Signature · 1 line
1.9.0
#13 lore raw

PATCH 6/50 drm/i915: s/intel_ring_buffer/intel_engine

In reply to [email protected]

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

No functional changes.

---
 drivers/gpu/drm/i915/i915_cmd_parser.c     |  16 +--
 drivers/gpu/drm/i915/i915_debugfs.c        |  16 +--
 drivers/gpu/drm/i915/i915_dma.c            |  10 +-
 drivers/gpu/drm/i915/i915_drv.h            |  32 +++---
 drivers/gpu/drm/i915/i915_gem.c            |  58 +++++------
 drivers/gpu/drm/i915/i915_gem_context.c    |  14 +--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  18 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  18 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.h        |   2 +-
 drivers/gpu/drm/i915/i915_gpu_error.c      |   6 +-
 drivers/gpu/drm/i915/i915_irq.c            |  28 ++---
 drivers/gpu/drm/i915/i915_trace.h          |  26 ++---
 drivers/gpu/drm/i915/intel_display.c       |  14 +--
 drivers/gpu/drm/i915/intel_drv.h           |   4 +-
 drivers/gpu/drm/i915/intel_overlay.c       |  12 +--
 drivers/gpu/drm/i915/intel_pm.c            |  10 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 158 ++++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |  76 +++++++-------
 18 files changed, 259 insertions(+), 259 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +8 -8
index 69d34e4..3234d36 100644
@@ -498,7 +498,7 @@ static u32 gen7_blt_get_cmd_length_mask(u32 cmd_header)
 	return 0;
 }
 
-static bool validate_cmds_sorted(struct intel_ring_buffer *ring)
+static bool validate_cmds_sorted(struct intel_engine *ring)
 {
 	int i;
 	bool ret = true;
@@ -550,7 +550,7 @@ static bool check_sorted(int ring_id, const u32 *reg_table, int reg_count)
 	return ret;
 }
 
-static bool validate_regs_sorted(struct intel_ring_buffer *ring)
+static bool validate_regs_sorted(struct intel_engine *ring)
 {
 	return check_sorted(ring->id, ring->reg_table, ring->reg_count) &&
 		check_sorted(ring->id, ring->master_reg_table,
@@ -562,10 +562,10 @@ static bool validate_regs_sorted(struct intel_ring_buffer *ring)
  * @ring: the ringbuffer to initialize
  *
  * Optionally initializes fields related to batch buffer command parsing in the
- * struct intel_ring_buffer based on whether the platform requires software
+ * struct intel_engine based on whether the platform requires software
  * command parsing.
  */
-void i915_cmd_parser_init_ring(struct intel_ring_buffer *ring)
+void i915_cmd_parser_init_ring(struct intel_engine *ring)
 {
 	if (!IS_GEN7(ring->dev))
 		return;
@@ -664,7 +664,7 @@ find_cmd_in_table(const struct drm_i915_cmd_table *table,
  * ring's default length encoding and returns default_desc.
  */
 static const struct drm_i915_cmd_descriptor*
-find_cmd(struct intel_ring_buffer *ring,
+find_cmd(struct intel_engine *ring,
 	 u32 cmd_header,
 	 struct drm_i915_cmd_descriptor *default_desc)
 {
@@ -744,7 +744,7 @@ finish:
  *
  * Return: true if the ring requires software command parsing
  */
-bool i915_needs_cmd_parser(struct intel_ring_buffer *ring)
+bool i915_needs_cmd_parser(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 
@@ -763,7 +763,7 @@ bool i915_needs_cmd_parser(struct intel_ring_buffer *ring)
 	return (i915.enable_cmd_parser == 1);
 }
 
-static bool check_cmd(const struct intel_ring_buffer *ring,
+static bool check_cmd(const struct intel_engine *ring,
 		      const struct drm_i915_cmd_descriptor *desc,
 		      const u32 *cmd,
 		      const bool is_master,
@@ -865,7 +865,7 @@ static bool check_cmd(const struct intel_ring_buffer *ring,
  *
  * Return: non-zero if the parser finds violations or otherwise fails
  */
-int i915_parse_cmds(struct intel_ring_buffer *ring,
+int i915_parse_cmds(struct intel_engine *ring,
 		    struct drm_i915_gem_object *batch_obj,
 		    u32 batch_start_offset,
 		    bool is_master)
drivers/gpu/drm/i915/i915_debugfs.c +8 -8
index 103e62c..0052460 100644
@@ -562,7 +562,7 @@ static int i915_gem_request_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct drm_i915_gem_request *gem_request;
 	int ret, count, i;
 
@@ -594,7 +594,7 @@ static int i915_gem_request_info(struct seq_file *m, void *data)
 }
 
 static void i915_ring_seqno_info(struct seq_file *m,
-				 struct intel_ring_buffer *ring)
+				 struct intel_engine *ring)
 {
 	if (ring->get_seqno) {
 		seq_printf(m, "Current sequence (%s): %u\n",
@@ -607,7 +607,7 @@ static int i915_gem_seqno_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i;
 
 	ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -630,7 +630,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i, pipe;
 
 	ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -800,7 +800,7 @@ static int i915_hws_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	const u32 *hws;
 	int i;
 
@@ -1677,7 +1677,7 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct i915_hw_context *ctx;
 	int ret, i;
 
@@ -1826,7 +1826,7 @@ static int per_file_ctx(int id, void *ptr, void *data)
 static void gen8_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
 	int unused, i;
 
@@ -1850,7 +1850,7 @@ static void gen8_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct drm_file *file;
 	int i;
 
drivers/gpu/drm/i915/i915_dma.c +5 -5
index d02c8de..5263d63 100644
@@ -119,7 +119,7 @@ static void i915_write_hws_pga(struct drm_device *dev)
 static void i915_free_hws(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	if (dev_priv->status_page_dmah) {
 		drm_pci_free(dev, dev_priv->status_page_dmah);
@@ -139,7 +139,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_master_private *master_priv;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	/*
 	 * We should never lose context on the ring with modesetting
@@ -234,7 +234,7 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
 static int i915_dma_resume(struct drm_device * dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	DRM_DEBUG_DRIVER("%s\n", __func__);
 
@@ -782,7 +782,7 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
 	int ret = 0;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	DRM_DEBUG_DRIVER("irq_nr=%d breadcrumb=%d\n", irq_nr,
 		  READ_BREADCRUMB(dev_priv));
@@ -1073,7 +1073,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	drm_i915_hws_addr_t *hws = data;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return -ENODEV;
drivers/gpu/drm/i915/i915_drv.h +16 -16
index b1725c6..3b7a36f9 100644
@@ -594,7 +594,7 @@ struct i915_hw_context {
 	bool is_initialized;
 	uint8_t remap_slice;
 	struct drm_i915_file_private *file_priv;
-	struct intel_ring_buffer *last_ring;
+	struct intel_engine *last_ring;
 	struct drm_i915_gem_object *obj;
 	struct i915_ctx_hang_stats hang_stats;
 	struct i915_address_space *vm;
@@ -1354,7 +1354,7 @@ struct drm_i915_private {
 	wait_queue_head_t gmbus_wait_queue;
 
 	struct pci_dev *bridge_dev;
-	struct intel_ring_buffer ring[I915_NUM_RINGS];
+	struct intel_engine ring[I915_NUM_RINGS];
 	uint32_t last_seqno, next_seqno;
 
 	drm_dma_handle_t *status_page_dmah;
@@ -1675,7 +1675,7 @@ struct drm_i915_gem_object {
 	void *dma_buf_vmapping;
 	int vmapping_count;
 
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 
 	/** Breadcrumb of last rendering to the buffer. */
 	uint32_t last_read_seqno;
@@ -1714,7 +1714,7 @@ struct drm_i915_gem_object {
  */
 struct drm_i915_gem_request {
 	/** On Which ring this request was generated */
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 
 	/** GEM sequence number associated with this request. */
 	uint32_t seqno;
@@ -1755,7 +1755,7 @@ struct drm_i915_file_private {
 
 	struct i915_hw_context *private_default_ctx;
 	atomic_t rps_wait_boost;
-	struct  intel_ring_buffer *bsd_ring;
+	struct  intel_engine *bsd_ring;
 };
 
 /*
@@ -2182,9 +2182,9 @@ 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_ring_buffer *to);
+			 struct intel_engine *to);
 void i915_vma_move_to_active(struct i915_vma *vma,
-			     struct intel_ring_buffer *ring);
+			     struct intel_engine *ring);
 int i915_gem_dumb_create(struct drm_file *file_priv,
 			 struct drm_device *dev,
 			 struct drm_mode_create_dumb *args);
@@ -2226,7 +2226,7 @@ i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj)
 }
 
 struct drm_i915_gem_request *
-i915_gem_find_active_request(struct intel_ring_buffer *ring);
+i915_gem_find_active_request(struct intel_engine *ring);
 
 bool i915_gem_retire_requests(struct drm_device *dev);
 int __must_check i915_gem_check_wedge(struct i915_gpu_error *error,
@@ -2264,18 +2264,18 @@ bool i915_gem_clflush_object(struct drm_i915_gem_object *obj, bool force);
 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 __must_check i915_gem_init_hw(struct drm_device *dev);
-int i915_gem_l3_remap(struct intel_ring_buffer *ring, int slice);
+int i915_gem_l3_remap(struct intel_engine *ring, 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);
 int __must_check i915_gem_suspend(struct drm_device *dev);
-int __i915_add_request(struct intel_ring_buffer *ring,
+int __i915_add_request(struct intel_engine *ring,
 		       struct drm_file *file,
 		       struct drm_i915_gem_object *batch_obj,
 		       u32 *seqno);
 #define i915_add_request(ring, seqno) \
 	__i915_add_request(ring, NULL, NULL, seqno)
-int __must_check i915_wait_seqno(struct intel_ring_buffer *ring,
+int __must_check i915_wait_seqno(struct intel_engine *ring,
 				 uint32_t seqno);
 int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 int __must_check
@@ -2286,7 +2286,7 @@ i915_gem_object_set_to_cpu_domain(struct drm_i915_gem_object *obj, bool write);
 int __must_check
 i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 				     u32 alignment,
-				     struct intel_ring_buffer *pipelined);
+				     struct intel_engine *pipelined);
 void i915_gem_object_unpin_from_display_plane(struct drm_i915_gem_object *obj);
 int i915_gem_attach_phys_object(struct drm_device *dev,
 				struct drm_i915_gem_object *obj,
@@ -2388,7 +2388,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_private *dev_priv);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
-int i915_switch_context(struct intel_ring_buffer *ring,
+int i915_switch_context(struct intel_engine *ring,
 			struct i915_hw_context *to);
 struct i915_hw_context *
 i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);
@@ -2497,9 +2497,9 @@ const char *i915_cache_level_str(int type);
 
 /* i915_cmd_parser.c */
 int i915_cmd_parser_get_version(void);
-void i915_cmd_parser_init_ring(struct intel_ring_buffer *ring);
-bool i915_needs_cmd_parser(struct intel_ring_buffer *ring);
-int i915_parse_cmds(struct intel_ring_buffer *ring,
+void i915_cmd_parser_init_ring(struct intel_engine *ring);
+bool i915_needs_cmd_parser(struct intel_engine *ring);
+int i915_parse_cmds(struct intel_engine *ring,
 		    struct drm_i915_gem_object *batch_obj,
 		    u32 batch_start_offset,
 		    bool is_master);
drivers/gpu/drm/i915/i915_gem.c +29 -29

227 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_context.c +7 -7
index 014fb8f..4d37e20 100644
@@ -359,7 +359,7 @@ err_destroy:
 void i915_gem_context_reset(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	/* Prevent the hardware from restoring the last context (which hung) on
@@ -392,7 +392,7 @@ int i915_gem_context_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *ctx;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int unused;
 
 	/* Init should only be called once per module load. Eventually the
@@ -428,7 +428,7 @@ void i915_gem_context_fini(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *dctx = dev_priv->ring[RCS].default_context;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int unused;
 
 	if (dctx->obj) {
@@ -467,7 +467,7 @@ void i915_gem_context_fini(struct drm_device *dev)
 
 int i915_gem_context_enable(struct drm_i915_private *dev_priv)
 {
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i;
 
 	/* This is the only place the aliasing PPGTT gets enabled, which means
@@ -546,7 +546,7 @@ i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)
 }
 
 static inline int
-mi_set_context(struct intel_ring_buffer *ring,
+mi_set_context(struct intel_engine *ring,
 	       struct i915_hw_context *new_context,
 	       u32 hw_flags)
 {
@@ -596,7 +596,7 @@ mi_set_context(struct intel_ring_buffer *ring,
 	return ret;
 }
 
-static int do_switch(struct intel_ring_buffer *ring,
+static int do_switch(struct intel_engine *ring,
 		     struct i915_hw_context *to)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -726,7 +726,7 @@ unpin_out:
  * it will have a refoucnt > 1. This allows us to destroy the context abstract
  * object while letting the normal object tracking destroy the backing BO.
  */
-int i915_switch_context(struct intel_ring_buffer *ring,
+int i915_switch_context(struct intel_engine *ring,
 			struct i915_hw_context *to)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +9 -9
index 47fe8ec..95e797e 100644
@@ -541,7 +541,7 @@ need_reloc_mappable(struct i915_vma *vma)
 
 static int
 i915_gem_execbuffer_reserve_vma(struct i915_vma *vma,
-				struct intel_ring_buffer *ring,
+				struct intel_engine *ring,
 				bool *need_reloc)
 {
 	struct drm_i915_gem_object *obj = vma->obj;
@@ -596,7 +596,7 @@ i915_gem_execbuffer_reserve_vma(struct i915_vma *vma,
 }
 
 static int
-i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,
+i915_gem_execbuffer_reserve(struct intel_engine *ring,
 			    struct list_head *vmas,
 			    bool *need_relocs)
 {
@@ -711,7 +711,7 @@ static int
 i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
 				  struct drm_i915_gem_execbuffer2 *args,
 				  struct drm_file *file,
-				  struct intel_ring_buffer *ring,
+				  struct intel_engine *ring,
 				  struct eb_vmas *eb,
 				  struct drm_i915_gem_exec_object2 *exec)
 {
@@ -827,7 +827,7 @@ err:
 }
 
 static int
-i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
+i915_gem_execbuffer_move_to_gpu(struct intel_engine *ring,
 				struct list_head *vmas)
 {
 	struct i915_vma *vma;
@@ -912,7 +912,7 @@ validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
 
 static struct i915_hw_context *
 i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
-			  struct intel_ring_buffer *ring, const u32 ctx_id)
+			  struct intel_engine *ring, const u32 ctx_id)
 {
 	struct i915_hw_context *ctx = NULL;
 	struct i915_ctx_hang_stats *hs;
@@ -935,7 +935,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 
 static void
 i915_gem_execbuffer_move_to_active(struct list_head *vmas,
-				   struct intel_ring_buffer *ring)
+				   struct intel_engine *ring)
 {
 	struct i915_vma *vma;
 
@@ -970,7 +970,7 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
 static void
 i915_gem_execbuffer_retire_commands(struct drm_device *dev,
 				    struct drm_file *file,
-				    struct intel_ring_buffer *ring,
+				    struct intel_engine *ring,
 				    struct drm_i915_gem_object *obj)
 {
 	/* Unconditionally force add_request to emit a full flush. */
@@ -982,7 +982,7 @@ i915_gem_execbuffer_retire_commands(struct drm_device *dev,
 
 static int
 i915_reset_gen7_sol_offsets(struct drm_device *dev,
-			    struct intel_ring_buffer *ring)
+			    struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret, i;
@@ -1048,7 +1048,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct eb_vmas *eb;
 	struct drm_i915_gem_object *batch_obj;
 	struct drm_clip_rect *cliprects = NULL;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct i915_hw_context *ctx;
 	struct i915_address_space *vm;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
drivers/gpu/drm/i915/i915_gem_gtt.c +9 -9
index 1dff805..31b58ee 100644
@@ -207,7 +207,7 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr,
 }
 
 /* Broadwell Page Directory Pointer Descriptors */
-static int gen8_write_pdp(struct intel_ring_buffer *ring, unsigned entry,
+static int gen8_write_pdp(struct intel_engine *ring, unsigned entry,
 			   uint64_t val, bool synchronous)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -237,7 +237,7 @@ static int gen8_write_pdp(struct intel_ring_buffer *ring, unsigned entry,
 }
 
 static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_ring_buffer *ring,
+			  struct intel_engine *ring,
 			  bool synchronous)
 {
 	int i, ret;
@@ -716,7 +716,7 @@ static uint32_t get_pd_offset(struct i915_hw_ppgtt *ppgtt)
 }
 
 static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_ring_buffer *ring,
+			 struct intel_engine *ring,
 			 bool synchronous)
 {
 	struct drm_device *dev = ppgtt->base.dev;
@@ -760,7 +760,7 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_ring_buffer *ring,
+			  struct intel_engine *ring,
 			  bool synchronous)
 {
 	struct drm_device *dev = ppgtt->base.dev;
@@ -811,7 +811,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static int gen6_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_ring_buffer *ring,
+			  struct intel_engine *ring,
 			  bool synchronous)
 {
 	struct drm_device *dev = ppgtt->base.dev;
@@ -832,7 +832,7 @@ static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 {
 	struct drm_device *dev = ppgtt->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int j, ret;
 
 	for_each_active_ring(ring, dev_priv, j) {
@@ -862,7 +862,7 @@ static int gen7_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 {
 	struct drm_device *dev = ppgtt->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t ecochk, ecobits;
 	int i;
 
@@ -901,7 +901,7 @@ static int gen6_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 {
 	struct drm_device *dev = ppgtt->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t ecochk, gab_ctl, ecobits;
 	int i;
 
@@ -1269,7 +1269,7 @@ static void undo_idling(struct drm_i915_private *dev_priv, bool interruptible)
 void i915_check_and_clear_faults(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	if (INTEL_INFO(dev)->gen < 6)
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
index cfca023..0775662 100644
@@ -261,7 +261,7 @@ struct i915_hw_ppgtt {
 
 	int (*enable)(struct i915_hw_ppgtt *ppgtt);
 	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_ring_buffer *ring,
+			 struct intel_engine *ring,
 			 bool synchronous);
 	void (*debug_dump)(struct i915_hw_ppgtt *ppgtt, struct seq_file *m);
 };
drivers/gpu/drm/i915/i915_gpu_error.c +3 -3
index 8f37238..0853db3 100644
@@ -745,7 +745,7 @@ static void i915_gem_record_fences(struct drm_device *dev,
 }
 
 static void i915_record_ring_state(struct drm_device *dev,
-				   struct intel_ring_buffer *ring,
+				   struct intel_engine *ring,
 				   struct drm_i915_error_ring *ering)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -857,7 +857,7 @@ static void i915_record_ring_state(struct drm_device *dev,
 }
 
 
-static void i915_gem_record_active_context(struct intel_ring_buffer *ring,
+static void i915_gem_record_active_context(struct intel_engine *ring,
 					   struct drm_i915_error_state *error,
 					   struct drm_i915_error_ring *ering)
 {
@@ -884,7 +884,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 	int i, count;
 
 	for (i = 0; i < I915_NUM_RINGS; i++) {
-		struct intel_ring_buffer *ring = &dev_priv->ring[i];
+		struct intel_engine *ring = &dev_priv->ring[i];
 
 		if (!intel_ring_initialized(ring))
 			continue;
drivers/gpu/drm/i915/i915_irq.c +14 -14
index 4a8e8cb..58c8812 100644
@@ -1077,7 +1077,7 @@ static void ironlake_rps_change_irq_handler(struct drm_device *dev)
 }
 
 static void notify_ring(struct drm_device *dev,
-			struct intel_ring_buffer *ring)
+			struct intel_engine *ring)
 {
 	if (ring->obj == NULL)
 		return;
@@ -2111,7 +2111,7 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg)
 static void i915_error_wake_up(struct drm_i915_private *dev_priv,
 			       bool reset_completed)
 {
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	/*
@@ -2544,14 +2544,14 @@ static void gen8_disable_vblank(struct drm_device *dev, int pipe)
 }
 
 static u32
-ring_last_seqno(struct intel_ring_buffer *ring)
+ring_last_seqno(struct intel_engine *ring)
 {
 	return list_entry(ring->request_list.prev,
 			  struct drm_i915_gem_request, list)->seqno;
 }
 
 static bool
-ring_idle(struct intel_ring_buffer *ring, u32 seqno)
+ring_idle(struct intel_engine *ring, u32 seqno)
 {
 	return (list_empty(&ring->request_list) ||
 		i915_seqno_passed(seqno, ring_last_seqno(ring)));
@@ -2574,11 +2574,11 @@ ipehr_is_semaphore_wait(struct drm_device *dev, u32 ipehr)
 	}
 }
 
-static struct intel_ring_buffer *
-semaphore_wait_to_signaller_ring(struct intel_ring_buffer *ring, u32 ipehr)
+static struct intel_engine *
+semaphore_wait_to_signaller_ring(struct intel_engine *ring, u32 ipehr)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct intel_ring_buffer *signaller;
+	struct intel_engine *signaller;
 	int i;
 
 	if (INTEL_INFO(dev_priv->dev)->gen >= 8) {
@@ -2606,8 +2606,8 @@ semaphore_wait_to_signaller_ring(struct intel_ring_buffer *ring, u32 ipehr)
 	return NULL;
 }
 
-static struct intel_ring_buffer *
-semaphore_waits_for(struct intel_ring_buffer *ring, u32 *seqno)
+static struct intel_engine *
+semaphore_waits_for(struct intel_engine *ring, u32 *seqno)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	u32 cmd, ipehr, head;
@@ -2649,10 +2649,10 @@ semaphore_waits_for(struct intel_ring_buffer *ring, u32 *seqno)
 	return semaphore_wait_to_signaller_ring(ring, ipehr);
 }
 
-static int semaphore_passed(struct intel_ring_buffer *ring)
+static int semaphore_passed(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct intel_ring_buffer *signaller;
+	struct intel_engine *signaller;
 	u32 seqno, ctl;
 
 	ring->hangcheck.deadlock = true;
@@ -2671,7 +2671,7 @@ static int semaphore_passed(struct intel_ring_buffer *ring)
 
 static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
 {
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	for_each_active_ring(ring, dev_priv, i)
@@ -2679,7 +2679,7 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
 }
 
 static enum intel_ring_hangcheck_action
-ring_stuck(struct intel_ring_buffer *ring, u64 acthd)
+ring_stuck(struct intel_engine *ring, u64 acthd)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2735,7 +2735,7 @@ static void i915_hangcheck_elapsed(unsigned long data)
 {
 	struct drm_device *dev = (struct drm_device *)data;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 	int busy_count = 0, rings_hung = 0;
 	bool stuck[I915_NUM_RINGS] = { 0 };
drivers/gpu/drm/i915/i915_trace.h +13 -13
index b29d7b1..a4f9e62 100644
@@ -326,8 +326,8 @@ TRACE_EVENT(i915_gem_evict_vm,
 );
 
 TRACE_EVENT(i915_gem_ring_sync_to,
-	    TP_PROTO(struct intel_ring_buffer *from,
-		     struct intel_ring_buffer *to,
+	    TP_PROTO(struct intel_engine *from,
+		     struct intel_engine *to,
 		     u32 seqno),
 	    TP_ARGS(from, to, seqno),
 
@@ -352,7 +352,7 @@ TRACE_EVENT(i915_gem_ring_sync_to,
 );
 
 TRACE_EVENT(i915_gem_ring_dispatch,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno, u32 flags),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno, u32 flags),
 	    TP_ARGS(ring, seqno, flags),
 
 	    TP_STRUCT__entry(
@@ -375,7 +375,7 @@ TRACE_EVENT(i915_gem_ring_dispatch,
 );
 
 TRACE_EVENT(i915_gem_ring_flush,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 invalidate, u32 flush),
+	    TP_PROTO(struct intel_engine *ring, u32 invalidate, u32 flush),
 	    TP_ARGS(ring, invalidate, flush),
 
 	    TP_STRUCT__entry(
@@ -398,7 +398,7 @@ TRACE_EVENT(i915_gem_ring_flush,
 );
 
 DECLARE_EVENT_CLASS(i915_gem_request,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno),
 
 	    TP_STRUCT__entry(
@@ -418,12 +418,12 @@ DECLARE_EVENT_CLASS(i915_gem_request,
 );
 
 DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno)
 );
 
 TRACE_EVENT(i915_gem_request_complete,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring),
 
 	    TP_STRUCT__entry(
@@ -443,12 +443,12 @@ TRACE_EVENT(i915_gem_request_complete,
 );
 
 DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno)
 );
 
 TRACE_EVENT(i915_gem_request_wait_begin,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno),
 
 	    TP_STRUCT__entry(
@@ -477,12 +477,12 @@ TRACE_EVENT(i915_gem_request_wait_begin,
 );
 
 DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno)
 );
 
 DECLARE_EVENT_CLASS(i915_ring,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring),
 
 	    TP_STRUCT__entry(
@@ -499,12 +499,12 @@ DECLARE_EVENT_CLASS(i915_ring,
 );
 
 DEFINE_EVENT(i915_ring, i915_ring_wait_begin,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring)
 );
 
 DEFINE_EVENT(i915_ring, i915_ring_wait_end,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring)
 );
 
drivers/gpu/drm/i915/intel_display.c +7 -7
index c65e7f7..f821147 100644
@@ -1944,7 +1944,7 @@ static int intel_align_height(struct drm_device *dev, int height, bool tiled)
 int
 intel_pin_and_fence_fb_obj(struct drm_device *dev,
 			   struct drm_i915_gem_object *obj,
-			   struct intel_ring_buffer *pipelined)
+			   struct intel_engine *pipelined)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	u32 alignment;
@@ -8424,7 +8424,7 @@ out:
 }
 
 void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
-			struct intel_ring_buffer *ring)
+			struct intel_engine *ring)
 {
 	struct drm_device *dev = obj->base.dev;
 	struct drm_crtc *crtc;
@@ -8582,7 +8582,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	u32 flip_mask;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -8627,7 +8627,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	u32 flip_mask;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -8669,7 +8669,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	uint32_t pf, pipesrc;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -8717,7 +8717,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	uint32_t pf, pipesrc;
 	int ret;
 
@@ -8762,7 +8762,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t plane_bit = 0;
 	int len, ret;
 
drivers/gpu/drm/i915/intel_drv.h +2 -2
index d8b540b..23b5abf 100644
@@ -694,7 +694,7 @@ int intel_pch_rawclk(struct drm_device *dev);
 int valleyview_cur_cdclk(struct drm_i915_private *dev_priv);
 void intel_mark_busy(struct drm_device *dev);
 void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
-			struct intel_ring_buffer *ring);
+			struct intel_engine *ring);
 void intel_mark_idle(struct drm_device *dev);
 void intel_crtc_restore_mode(struct drm_crtc *crtc);
 void intel_crtc_update_dpms(struct drm_crtc *crtc);
@@ -726,7 +726,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
 				    struct intel_load_detect_pipe *old);
 int intel_pin_and_fence_fb_obj(struct drm_device *dev,
 			       struct drm_i915_gem_object *obj,
-			       struct intel_ring_buffer *pipelined);
+			       struct intel_engine *pipelined);
 void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
 struct drm_framebuffer *
 __intel_framebuffer_create(struct drm_device *dev,
drivers/gpu/drm/i915/intel_overlay.c +6 -6
index d8adc91..965eec1 100644
@@ -213,7 +213,7 @@ static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
 {
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	BUG_ON(overlay->last_flip_req);
@@ -236,7 +236,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_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	BUG_ON(overlay->active);
@@ -263,7 +263,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_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	u32 flip_addr = overlay->flip_addr;
 	u32 tmp;
 	int ret;
@@ -320,7 +320,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_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	u32 flip_addr = overlay->flip_addr;
 	int ret;
 
@@ -363,7 +363,7 @@ static int intel_overlay_recover_from_interrupt(struct intel_overlay *overlay)
 {
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	if (overlay->last_flip_req == 0)
@@ -389,7 +389,7 @@ static int intel_overlay_release_old_vid(struct intel_overlay *overlay)
 {
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	/* Only wait if there is actually an old frame to release to
drivers/gpu/drm/i915/intel_pm.c +5 -5
index acfded3..17f636e 100644
@@ -3379,7 +3379,7 @@ static void parse_rp_state_cap(struct drm_i915_private *dev_priv, u32 rp_state_c
 static void gen8_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t rc6_mask = 0, rp_state_cap;
 	int unused;
 
@@ -3454,7 +3454,7 @@ static void gen8_enable_rps(struct drm_device *dev)
 static void gen6_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	u32 rp_state_cap;
 	u32 gt_perf_status;
 	u32 rc6vids, pcu_mbox = 0, rc6_mask = 0;
@@ -3783,7 +3783,7 @@ static void valleyview_cleanup_gt_powersave(struct drm_device *dev)
 static void valleyview_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	u32 gtfifodbg, val, rc6_mode = 0;
 	int i;
 
@@ -3914,7 +3914,7 @@ static int ironlake_setup_rc6(struct drm_device *dev)
 static void ironlake_enable_rc6(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	bool was_interruptible;
 	int ret;
 
@@ -4426,7 +4426,7 @@ EXPORT_SYMBOL_GPL(i915_gpu_lower);
 bool i915_gpu_busy(void)
 {
 	struct drm_i915_private *dev_priv;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	bool ret = false;
 	int i;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +79 -79

619 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +38 -38

173 lines not on this page · raw message

Signature · 1 line
1.9.0
#14 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 9 lines · On Fri, May 09, 2014 at 01:08:36PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

No functional changes.

If we rename stuff I'd vote for something close to Bspec language, like CS. So maybe intel_cs_engine?

/me sucks at this naming game
-Daniel

Quoted 2,169 lines
---
 drivers/gpu/drm/i915/i915_cmd_parser.c     |  16 +--
 drivers/gpu/drm/i915/i915_debugfs.c        |  16 +--
 drivers/gpu/drm/i915/i915_dma.c            |  10 +-
 drivers/gpu/drm/i915/i915_drv.h            |  32 +++---
 drivers/gpu/drm/i915/i915_gem.c            |  58 +++++------
 drivers/gpu/drm/i915/i915_gem_context.c    |  14 +--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  18 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  18 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.h        |   2 +-
 drivers/gpu/drm/i915/i915_gpu_error.c      |   6 +-
 drivers/gpu/drm/i915/i915_irq.c            |  28 ++---
 drivers/gpu/drm/i915/i915_trace.h          |  26 ++---
 drivers/gpu/drm/i915/intel_display.c       |  14 +--
 drivers/gpu/drm/i915/intel_drv.h           |   4 +-
 drivers/gpu/drm/i915/intel_overlay.c       |  12 +--
 drivers/gpu/drm/i915/intel_pm.c            |  10 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 158 ++++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |  76 +++++++-------
 18 files changed, 259 insertions(+), 259 deletions(-)
drivers/gpu/drm/i915/i915_cmd_parser.c +8 -8
index 69d34e4..3234d36 100644
@@ -498,7 +498,7 @@ static u32 gen7_blt_get_cmd_length_mask(u32 cmd_header)
 	return 0;
 }
 
-static bool validate_cmds_sorted(struct intel_ring_buffer *ring)
+static bool validate_cmds_sorted(struct intel_engine *ring)
 {
 	int i;
 	bool ret = true;
@@ -550,7 +550,7 @@ static bool check_sorted(int ring_id, const u32 *reg_table, int reg_count)
 	return ret;
 }
 
-static bool validate_regs_sorted(struct intel_ring_buffer *ring)
+static bool validate_regs_sorted(struct intel_engine *ring)
 {
 	return check_sorted(ring->id, ring->reg_table, ring->reg_count) &&
 		check_sorted(ring->id, ring->master_reg_table,
@@ -562,10 +562,10 @@ static bool validate_regs_sorted(struct intel_ring_buffer *ring)
  * @ring: the ringbuffer to initialize
  *
  * Optionally initializes fields related to batch buffer command parsing in the
- * struct intel_ring_buffer based on whether the platform requires software
+ * struct intel_engine based on whether the platform requires software
  * command parsing.
  */
-void i915_cmd_parser_init_ring(struct intel_ring_buffer *ring)
+void i915_cmd_parser_init_ring(struct intel_engine *ring)
 {
 	if (!IS_GEN7(ring->dev))
 		return;
@@ -664,7 +664,7 @@ find_cmd_in_table(const struct drm_i915_cmd_table *table,
  * ring's default length encoding and returns default_desc.
  */
 static const struct drm_i915_cmd_descriptor*
-find_cmd(struct intel_ring_buffer *ring,
+find_cmd(struct intel_engine *ring,
 	 u32 cmd_header,
 	 struct drm_i915_cmd_descriptor *default_desc)
 {
@@ -744,7 +744,7 @@ finish:
  *
  * Return: true if the ring requires software command parsing
  */
-bool i915_needs_cmd_parser(struct intel_ring_buffer *ring)
+bool i915_needs_cmd_parser(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 
@@ -763,7 +763,7 @@ bool i915_needs_cmd_parser(struct intel_ring_buffer *ring)
 	return (i915.enable_cmd_parser == 1);
 }
 
-static bool check_cmd(const struct intel_ring_buffer *ring,
+static bool check_cmd(const struct intel_engine *ring,
 		      const struct drm_i915_cmd_descriptor *desc,
 		      const u32 *cmd,
 		      const bool is_master,
@@ -865,7 +865,7 @@ static bool check_cmd(const struct intel_ring_buffer *ring,
  *
  * Return: non-zero if the parser finds violations or otherwise fails
  */
-int i915_parse_cmds(struct intel_ring_buffer *ring,
+int i915_parse_cmds(struct intel_engine *ring,
 		    struct drm_i915_gem_object *batch_obj,
 		    u32 batch_start_offset,
 		    bool is_master)
drivers/gpu/drm/i915/i915_debugfs.c +8 -8
index 103e62c..0052460 100644
@@ -562,7 +562,7 @@ static int i915_gem_request_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct drm_i915_gem_request *gem_request;
 	int ret, count, i;
 
@@ -594,7 +594,7 @@ static int i915_gem_request_info(struct seq_file *m, void *data)
 }
 
 static void i915_ring_seqno_info(struct seq_file *m,
-				 struct intel_ring_buffer *ring)
+				 struct intel_engine *ring)
 {
 	if (ring->get_seqno) {
 		seq_printf(m, "Current sequence (%s): %u\n",
@@ -607,7 +607,7 @@ static int i915_gem_seqno_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i;
 
 	ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -630,7 +630,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i, pipe;
 
 	ret = mutex_lock_interruptible(&dev->struct_mutex);
@@ -800,7 +800,7 @@ static int i915_hws_info(struct seq_file *m, void *data)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	const u32 *hws;
 	int i;
 
@@ -1677,7 +1677,7 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
 	struct drm_device *dev = node->minor->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct i915_hw_context *ctx;
 	int ret, i;
 
@@ -1826,7 +1826,7 @@ static int per_file_ctx(int id, void *ptr, void *data)
 static void gen8_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct i915_hw_ppgtt *ppgtt = dev_priv->mm.aliasing_ppgtt;
 	int unused, i;
 
@@ -1850,7 +1850,7 @@ static void gen8_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 static void gen6_ppgtt_info(struct seq_file *m, struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct drm_file *file;
 	int i;
 
drivers/gpu/drm/i915/i915_dma.c +5 -5
index d02c8de..5263d63 100644
@@ -119,7 +119,7 @@ static void i915_write_hws_pga(struct drm_device *dev)
 static void i915_free_hws(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	if (dev_priv->status_page_dmah) {
 		drm_pci_free(dev, dev_priv->status_page_dmah);
@@ -139,7 +139,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_master_private *master_priv;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	/*
 	 * We should never lose context on the ring with modesetting
@@ -234,7 +234,7 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
 static int i915_dma_resume(struct drm_device * dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	DRM_DEBUG_DRIVER("%s\n", __func__);
 
@@ -782,7 +782,7 @@ static int i915_wait_irq(struct drm_device * dev, int irq_nr)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_master_private *master_priv = dev->primary->master->driver_priv;
 	int ret = 0;
-	struct intel_ring_buffer *ring = LP_RING(dev_priv);
+	struct intel_engine *ring = LP_RING(dev_priv);
 
 	DRM_DEBUG_DRIVER("irq_nr=%d breadcrumb=%d\n", irq_nr,
 		  READ_BREADCRUMB(dev_priv));
@@ -1073,7 +1073,7 @@ static int i915_set_status_page(struct drm_device *dev, void *data,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	drm_i915_hws_addr_t *hws = data;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return -ENODEV;
drivers/gpu/drm/i915/i915_drv.h +16 -16
index b1725c6..3b7a36f9 100644
@@ -594,7 +594,7 @@ struct i915_hw_context {
 	bool is_initialized;
 	uint8_t remap_slice;
 	struct drm_i915_file_private *file_priv;
-	struct intel_ring_buffer *last_ring;
+	struct intel_engine *last_ring;
 	struct drm_i915_gem_object *obj;
 	struct i915_ctx_hang_stats hang_stats;
 	struct i915_address_space *vm;
@@ -1354,7 +1354,7 @@ struct drm_i915_private {
 	wait_queue_head_t gmbus_wait_queue;
 
 	struct pci_dev *bridge_dev;
-	struct intel_ring_buffer ring[I915_NUM_RINGS];
+	struct intel_engine ring[I915_NUM_RINGS];
 	uint32_t last_seqno, next_seqno;
 
 	drm_dma_handle_t *status_page_dmah;
@@ -1675,7 +1675,7 @@ struct drm_i915_gem_object {
 	void *dma_buf_vmapping;
 	int vmapping_count;
 
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 
 	/** Breadcrumb of last rendering to the buffer. */
 	uint32_t last_read_seqno;
@@ -1714,7 +1714,7 @@ struct drm_i915_gem_object {
  */
 struct drm_i915_gem_request {
 	/** On Which ring this request was generated */
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 
 	/** GEM sequence number associated with this request. */
 	uint32_t seqno;
@@ -1755,7 +1755,7 @@ struct drm_i915_file_private {
 
 	struct i915_hw_context *private_default_ctx;
 	atomic_t rps_wait_boost;
-	struct  intel_ring_buffer *bsd_ring;
+	struct  intel_engine *bsd_ring;
 };
 
 /*
@@ -2182,9 +2182,9 @@ 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_ring_buffer *to);
+			 struct intel_engine *to);
 void i915_vma_move_to_active(struct i915_vma *vma,
-			     struct intel_ring_buffer *ring);
+			     struct intel_engine *ring);
 int i915_gem_dumb_create(struct drm_file *file_priv,
 			 struct drm_device *dev,
 			 struct drm_mode_create_dumb *args);
@@ -2226,7 +2226,7 @@ i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj)
 }
 
 struct drm_i915_gem_request *
-i915_gem_find_active_request(struct intel_ring_buffer *ring);
+i915_gem_find_active_request(struct intel_engine *ring);
 
 bool i915_gem_retire_requests(struct drm_device *dev);
 int __must_check i915_gem_check_wedge(struct i915_gpu_error *error,
@@ -2264,18 +2264,18 @@ bool i915_gem_clflush_object(struct drm_i915_gem_object *obj, bool force);
 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 __must_check i915_gem_init_hw(struct drm_device *dev);
-int i915_gem_l3_remap(struct intel_ring_buffer *ring, int slice);
+int i915_gem_l3_remap(struct intel_engine *ring, 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);
 int __must_check i915_gem_suspend(struct drm_device *dev);
-int __i915_add_request(struct intel_ring_buffer *ring,
+int __i915_add_request(struct intel_engine *ring,
 		       struct drm_file *file,
 		       struct drm_i915_gem_object *batch_obj,
 		       u32 *seqno);
 #define i915_add_request(ring, seqno) \
 	__i915_add_request(ring, NULL, NULL, seqno)
-int __must_check i915_wait_seqno(struct intel_ring_buffer *ring,
+int __must_check i915_wait_seqno(struct intel_engine *ring,
 				 uint32_t seqno);
 int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 int __must_check
@@ -2286,7 +2286,7 @@ i915_gem_object_set_to_cpu_domain(struct drm_i915_gem_object *obj, bool write);
 int __must_check
 i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 				     u32 alignment,
-				     struct intel_ring_buffer *pipelined);
+				     struct intel_engine *pipelined);
 void i915_gem_object_unpin_from_display_plane(struct drm_i915_gem_object *obj);
 int i915_gem_attach_phys_object(struct drm_device *dev,
 				struct drm_i915_gem_object *obj,
@@ -2388,7 +2388,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_private *dev_priv);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
-int i915_switch_context(struct intel_ring_buffer *ring,
+int i915_switch_context(struct intel_engine *ring,
 			struct i915_hw_context *to);
 struct i915_hw_context *
 i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);
@@ -2497,9 +2497,9 @@ const char *i915_cache_level_str(int type);
 
 /* i915_cmd_parser.c */
 int i915_cmd_parser_get_version(void);
-void i915_cmd_parser_init_ring(struct intel_ring_buffer *ring);
-bool i915_needs_cmd_parser(struct intel_ring_buffer *ring);
-int i915_parse_cmds(struct intel_ring_buffer *ring,
+void i915_cmd_parser_init_ring(struct intel_engine *ring);
+bool i915_needs_cmd_parser(struct intel_engine *ring);
+int i915_parse_cmds(struct intel_engine *ring,
 		    struct drm_i915_gem_object *batch_obj,
 		    u32 batch_start_offset,
 		    bool is_master);
drivers/gpu/drm/i915/i915_gem.c +29 -29
index 6ef53bd..a3b697b 100644
@@ -64,7 +64,7 @@ static unsigned long i915_gem_inactive_scan(struct shrinker *shrinker,
 static unsigned long i915_gem_purge(struct drm_i915_private *dev_priv, long target);
 static unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv);
 static void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
-static void i915_gem_retire_requests_ring(struct intel_ring_buffer *ring);
+static void i915_gem_retire_requests_ring(struct intel_engine *ring);
 
 static bool cpu_cache_is_coherent(struct drm_device *dev,
 				  enum i915_cache_level level)
@@ -977,7 +977,7 @@ i915_gem_check_wedge(struct i915_gpu_error *error,
  * equal.
  */
 static int
-i915_gem_check_olr(struct intel_ring_buffer *ring, u32 seqno)
+i915_gem_check_olr(struct intel_engine *ring, u32 seqno)
 {
 	int ret;
 
@@ -996,7 +996,7 @@ static void fake_irq(unsigned long data)
 }
 
 static bool missed_irq(struct drm_i915_private *dev_priv,
-		       struct intel_ring_buffer *ring)
+		       struct intel_engine *ring)
 {
 	return test_bit(ring->id, &dev_priv->gpu_error.missed_irq_rings);
 }
@@ -1027,7 +1027,7 @@ static bool can_wait_boost(struct drm_i915_file_private *file_priv)
  * Returns 0 if the seqno was found within the alloted time. Else returns the
  * errno with remaining time filled in timeout argument.
  */
-static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
+static int __wait_seqno(struct intel_engine *ring, u32 seqno,
 			unsigned reset_counter,
 			bool interruptible,
 			struct timespec *timeout,
@@ -1134,7 +1134,7 @@ static int __wait_seqno(struct intel_ring_buffer *ring, u32 seqno,
  * request and object lists appropriately for that event.
  */
 int
-i915_wait_seqno(struct intel_ring_buffer *ring, uint32_t seqno)
+i915_wait_seqno(struct intel_engine *ring, uint32_t seqno)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1159,7 +1159,7 @@ i915_wait_seqno(struct intel_ring_buffer *ring, uint32_t seqno)
 
 static int
 i915_gem_object_wait_rendering__tail(struct drm_i915_gem_object *obj,
-				     struct intel_ring_buffer *ring)
+				     struct intel_engine *ring)
 {
 	if (!obj->active)
 		return 0;
@@ -1184,7 +1184,7 @@ static __must_check int
 i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj,
 			       bool readonly)
 {
-	struct intel_ring_buffer *ring = obj->ring;
+	struct intel_engine *ring = obj->ring;
 	u32 seqno;
 	int ret;
 
@@ -1209,7 +1209,7 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
 {
 	struct drm_device *dev = obj->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = obj->ring;
+	struct intel_engine *ring = obj->ring;
 	unsigned reset_counter;
 	u32 seqno;
 	int ret;
@@ -2011,7 +2011,7 @@ 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_ring_buffer *ring)
+			       struct intel_engine *ring)
 {
 	struct drm_device *dev = obj->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2049,7 +2049,7 @@ i915_gem_object_move_to_active(struct drm_i915_gem_object *obj,
 }
 
 void i915_vma_move_to_active(struct i915_vma *vma,
-			     struct intel_ring_buffer *ring)
+			     struct intel_engine *ring)
 {
 	list_move_tail(&vma->mm_list, &vma->vm->active_list);
 	return i915_gem_object_move_to_active(vma->obj, ring);
@@ -2090,7 +2090,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)
 static void
 i915_gem_object_retire(struct drm_i915_gem_object *obj)
 {
-	struct intel_ring_buffer *ring = obj->ring;
+	struct intel_engine *ring = obj->ring;
 
 	if (ring == NULL)
 		return;
@@ -2104,7 +2104,7 @@ static int
 i915_gem_init_seqno(struct drm_device *dev, u32 seqno)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i, j;
 
 	/* Carefully retire all requests without writing to the rings */
@@ -2170,7 +2170,7 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
 	return 0;
 }
 
-int __i915_add_request(struct intel_ring_buffer *ring,
+int __i915_add_request(struct intel_engine *ring,
 		       struct drm_file *file,
 		       struct drm_i915_gem_object *obj,
 		       u32 *out_seqno)
@@ -2330,7 +2330,7 @@ static void i915_gem_free_request(struct drm_i915_gem_request *request)
 }
 
 struct drm_i915_gem_request *
-i915_gem_find_active_request(struct intel_ring_buffer *ring)
+i915_gem_find_active_request(struct intel_engine *ring)
 {
 	struct drm_i915_gem_request *request;
 	u32 completed_seqno;
@@ -2348,7 +2348,7 @@ i915_gem_find_active_request(struct intel_ring_buffer *ring)
 }
 
 static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv,
-				       struct intel_ring_buffer *ring)
+				       struct intel_engine *ring)
 {
 	struct drm_i915_gem_request *request;
 	bool ring_hung;
@@ -2367,7 +2367,7 @@ static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv,
 }
 
 static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
-					struct intel_ring_buffer *ring)
+					struct intel_engine *ring)
 {
 	while (!list_empty(&ring->active_list)) {
 		struct drm_i915_gem_object *obj;
@@ -2426,7 +2426,7 @@ void i915_gem_restore_fences(struct drm_device *dev)
 void i915_gem_reset(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	/*
@@ -2449,7 +2449,7 @@ void i915_gem_reset(struct drm_device *dev)
  * This function clears the request list as sequence numbers are passed.
  */
 static void
-i915_gem_retire_requests_ring(struct intel_ring_buffer *ring)
+i915_gem_retire_requests_ring(struct intel_engine *ring)
 {
 	uint32_t seqno;
 
@@ -2512,7 +2512,7 @@ bool
 i915_gem_retire_requests(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	bool idle = true;
 	int i;
 
@@ -2606,7 +2606,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_wait *args = data;
 	struct drm_i915_gem_object *obj;
-	struct intel_ring_buffer *ring = NULL;
+	struct intel_engine *ring = NULL;
 	struct timespec timeout_stack, *timeout = NULL;
 	unsigned reset_counter;
 	u32 seqno = 0;
@@ -2677,9 +2677,9 @@ out:
  */
 int
 i915_gem_object_sync(struct drm_i915_gem_object *obj,
-		     struct intel_ring_buffer *to)
+		     struct intel_engine *to)
 {
-	struct intel_ring_buffer *from = obj->ring;
+	struct intel_engine *from = obj->ring;
 	u32 seqno;
 	int ret, idx;
 
@@ -2800,7 +2800,7 @@ int i915_vma_unbind(struct i915_vma *vma)
 int i915_gpu_idle(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i;
 
 	/* Flush everything onto the inactive list. */
@@ -3659,7 +3659,7 @@ static bool is_pin_display(struct drm_i915_gem_object *obj)
 int
 i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 				     u32 alignment,
-				     struct intel_ring_buffer *pipelined)
+				     struct intel_engine *pipelined)
 {
 	u32 old_read_domains, old_write_domain;
 	int ret;
@@ -3812,7 +3812,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
 	struct drm_i915_file_private *file_priv = file->driver_priv;
 	unsigned long recent_enough = jiffies - msecs_to_jiffies(20);
 	struct drm_i915_gem_request *request;
-	struct intel_ring_buffer *ring = NULL;
+	struct intel_engine *ring = NULL;
 	unsigned reset_counter;
 	u32 seqno = 0;
 	int ret;
@@ -4258,7 +4258,7 @@ static void
 i915_gem_stop_ringbuffers(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	for_each_active_ring(ring, dev_priv, i)
@@ -4307,7 +4307,7 @@ err:
 	return ret;
 }
 
-int i915_gem_l3_remap(struct intel_ring_buffer *ring, int slice)
+int i915_gem_l3_remap(struct intel_engine *ring, int slice)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4532,7 +4532,7 @@ void
 i915_gem_cleanup_ringbuffer(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	for_each_active_ring(ring, dev_priv, i)
@@ -4608,7 +4608,7 @@ i915_gem_lastclose(struct drm_device *dev)
 }
 
 static void
-init_ring_lists(struct intel_ring_buffer *ring)
+init_ring_lists(struct intel_engine *ring)
 {
 	INIT_LIST_HEAD(&ring->active_list);
 	INIT_LIST_HEAD(&ring->request_list);
drivers/gpu/drm/i915/i915_gem_context.c +7 -7
index 014fb8f..4d37e20 100644
@@ -359,7 +359,7 @@ err_destroy:
 void i915_gem_context_reset(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	/* Prevent the hardware from restoring the last context (which hung) on
@@ -392,7 +392,7 @@ int i915_gem_context_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *ctx;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int unused;
 
 	/* Init should only be called once per module load. Eventually the
@@ -428,7 +428,7 @@ void i915_gem_context_fini(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *dctx = dev_priv->ring[RCS].default_context;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int unused;
 
 	if (dctx->obj) {
@@ -467,7 +467,7 @@ void i915_gem_context_fini(struct drm_device *dev)
 
 int i915_gem_context_enable(struct drm_i915_private *dev_priv)
 {
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int ret, i;
 
 	/* This is the only place the aliasing PPGTT gets enabled, which means
@@ -546,7 +546,7 @@ i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)
 }
 
 static inline int
-mi_set_context(struct intel_ring_buffer *ring,
+mi_set_context(struct intel_engine *ring,
 	       struct i915_hw_context *new_context,
 	       u32 hw_flags)
 {
@@ -596,7 +596,7 @@ mi_set_context(struct intel_ring_buffer *ring,
 	return ret;
 }
 
-static int do_switch(struct intel_ring_buffer *ring,
+static int do_switch(struct intel_engine *ring,
 		     struct i915_hw_context *to)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -726,7 +726,7 @@ unpin_out:
  * it will have a refoucnt > 1. This allows us to destroy the context abstract
  * object while letting the normal object tracking destroy the backing BO.
  */
-int i915_switch_context(struct intel_ring_buffer *ring,
+int i915_switch_context(struct intel_engine *ring,
 			struct i915_hw_context *to)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +9 -9
index 47fe8ec..95e797e 100644
@@ -541,7 +541,7 @@ need_reloc_mappable(struct i915_vma *vma)
 
 static int
 i915_gem_execbuffer_reserve_vma(struct i915_vma *vma,
-				struct intel_ring_buffer *ring,
+				struct intel_engine *ring,
 				bool *need_reloc)
 {
 	struct drm_i915_gem_object *obj = vma->obj;
@@ -596,7 +596,7 @@ i915_gem_execbuffer_reserve_vma(struct i915_vma *vma,
 }
 
 static int
-i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,
+i915_gem_execbuffer_reserve(struct intel_engine *ring,
 			    struct list_head *vmas,
 			    bool *need_relocs)
 {
@@ -711,7 +711,7 @@ static int
 i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
 				  struct drm_i915_gem_execbuffer2 *args,
 				  struct drm_file *file,
-				  struct intel_ring_buffer *ring,
+				  struct intel_engine *ring,
 				  struct eb_vmas *eb,
 				  struct drm_i915_gem_exec_object2 *exec)
 {
@@ -827,7 +827,7 @@ err:
 }
 
 static int
-i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
+i915_gem_execbuffer_move_to_gpu(struct intel_engine *ring,
 				struct list_head *vmas)
 {
 	struct i915_vma *vma;
@@ -912,7 +912,7 @@ validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
 
 static struct i915_hw_context *
 i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
-			  struct intel_ring_buffer *ring, const u32 ctx_id)
+			  struct intel_engine *ring, const u32 ctx_id)
 {
 	struct i915_hw_context *ctx = NULL;
 	struct i915_ctx_hang_stats *hs;
@@ -935,7 +935,7 @@ i915_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 
 static void
 i915_gem_execbuffer_move_to_active(struct list_head *vmas,
-				   struct intel_ring_buffer *ring)
+				   struct intel_engine *ring)
 {
 	struct i915_vma *vma;
 
@@ -970,7 +970,7 @@ i915_gem_execbuffer_move_to_active(struct list_head *vmas,
 static void
 i915_gem_execbuffer_retire_commands(struct drm_device *dev,
 				    struct drm_file *file,
-				    struct intel_ring_buffer *ring,
+				    struct intel_engine *ring,
 				    struct drm_i915_gem_object *obj)
 {
 	/* Unconditionally force add_request to emit a full flush. */
@@ -982,7 +982,7 @@ i915_gem_execbuffer_retire_commands(struct drm_device *dev,
 
 static int
 i915_reset_gen7_sol_offsets(struct drm_device *dev,
-			    struct intel_ring_buffer *ring)
+			    struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret, i;
@@ -1048,7 +1048,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	struct eb_vmas *eb;
 	struct drm_i915_gem_object *batch_obj;
 	struct drm_clip_rect *cliprects = NULL;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	struct i915_hw_context *ctx;
 	struct i915_address_space *vm;
 	const u32 ctx_id = i915_execbuffer2_get_context_id(*args);
drivers/gpu/drm/i915/i915_gem_gtt.c +9 -9
index 1dff805..31b58ee 100644
@@ -207,7 +207,7 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr,
 }
 
 /* Broadwell Page Directory Pointer Descriptors */
-static int gen8_write_pdp(struct intel_ring_buffer *ring, unsigned entry,
+static int gen8_write_pdp(struct intel_engine *ring, unsigned entry,
 			   uint64_t val, bool synchronous)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -237,7 +237,7 @@ static int gen8_write_pdp(struct intel_ring_buffer *ring, unsigned entry,
 }
 
 static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_ring_buffer *ring,
+			  struct intel_engine *ring,
 			  bool synchronous)
 {
 	int i, ret;
@@ -716,7 +716,7 @@ static uint32_t get_pd_offset(struct i915_hw_ppgtt *ppgtt)
 }
 
 static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_ring_buffer *ring,
+			 struct intel_engine *ring,
 			 bool synchronous)
 {
 	struct drm_device *dev = ppgtt->base.dev;
@@ -760,7 +760,7 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_ring_buffer *ring,
+			  struct intel_engine *ring,
 			  bool synchronous)
 {
 	struct drm_device *dev = ppgtt->base.dev;
@@ -811,7 +811,7 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 }
 
 static int gen6_mm_switch(struct i915_hw_ppgtt *ppgtt,
-			  struct intel_ring_buffer *ring,
+			  struct intel_engine *ring,
 			  bool synchronous)
 {
 	struct drm_device *dev = ppgtt->base.dev;
@@ -832,7 +832,7 @@ static int gen8_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 {
 	struct drm_device *dev = ppgtt->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int j, ret;
 
 	for_each_active_ring(ring, dev_priv, j) {
@@ -862,7 +862,7 @@ static int gen7_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 {
 	struct drm_device *dev = ppgtt->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t ecochk, ecobits;
 	int i;
 
@@ -901,7 +901,7 @@ static int gen6_ppgtt_enable(struct i915_hw_ppgtt *ppgtt)
 {
 	struct drm_device *dev = ppgtt->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t ecochk, gab_ctl, ecobits;
 	int i;
 
@@ -1269,7 +1269,7 @@ static void undo_idling(struct drm_i915_private *dev_priv, bool interruptible)
 void i915_check_and_clear_faults(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	if (INTEL_INFO(dev)->gen < 6)
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
index cfca023..0775662 100644
@@ -261,7 +261,7 @@ struct i915_hw_ppgtt {
 
 	int (*enable)(struct i915_hw_ppgtt *ppgtt);
 	int (*switch_mm)(struct i915_hw_ppgtt *ppgtt,
-			 struct intel_ring_buffer *ring,
+			 struct intel_engine *ring,
 			 bool synchronous);
 	void (*debug_dump)(struct i915_hw_ppgtt *ppgtt, struct seq_file *m);
 };
drivers/gpu/drm/i915/i915_gpu_error.c +3 -3
index 8f37238..0853db3 100644
@@ -745,7 +745,7 @@ static void i915_gem_record_fences(struct drm_device *dev,
 }
 
 static void i915_record_ring_state(struct drm_device *dev,
-				   struct intel_ring_buffer *ring,
+				   struct intel_engine *ring,
 				   struct drm_i915_error_ring *ering)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -857,7 +857,7 @@ static void i915_record_ring_state(struct drm_device *dev,
 }
 
 
-static void i915_gem_record_active_context(struct intel_ring_buffer *ring,
+static void i915_gem_record_active_context(struct intel_engine *ring,
 					   struct drm_i915_error_state *error,
 					   struct drm_i915_error_ring *ering)
 {
@@ -884,7 +884,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 	int i, count;
 
 	for (i = 0; i < I915_NUM_RINGS; i++) {
-		struct intel_ring_buffer *ring = &dev_priv->ring[i];
+		struct intel_engine *ring = &dev_priv->ring[i];
 
 		if (!intel_ring_initialized(ring))
 			continue;
drivers/gpu/drm/i915/i915_irq.c +14 -14
index 4a8e8cb..58c8812 100644
@@ -1077,7 +1077,7 @@ static void ironlake_rps_change_irq_handler(struct drm_device *dev)
 }
 
 static void notify_ring(struct drm_device *dev,
-			struct intel_ring_buffer *ring)
+			struct intel_engine *ring)
 {
 	if (ring->obj == NULL)
 		return;
@@ -2111,7 +2111,7 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg)
 static void i915_error_wake_up(struct drm_i915_private *dev_priv,
 			       bool reset_completed)
 {
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	/*
@@ -2544,14 +2544,14 @@ static void gen8_disable_vblank(struct drm_device *dev, int pipe)
 }
 
 static u32
-ring_last_seqno(struct intel_ring_buffer *ring)
+ring_last_seqno(struct intel_engine *ring)
 {
 	return list_entry(ring->request_list.prev,
 			  struct drm_i915_gem_request, list)->seqno;
 }
 
 static bool
-ring_idle(struct intel_ring_buffer *ring, u32 seqno)
+ring_idle(struct intel_engine *ring, u32 seqno)
 {
 	return (list_empty(&ring->request_list) ||
 		i915_seqno_passed(seqno, ring_last_seqno(ring)));
@@ -2574,11 +2574,11 @@ ipehr_is_semaphore_wait(struct drm_device *dev, u32 ipehr)
 	}
 }
 
-static struct intel_ring_buffer *
-semaphore_wait_to_signaller_ring(struct intel_ring_buffer *ring, u32 ipehr)
+static struct intel_engine *
+semaphore_wait_to_signaller_ring(struct intel_engine *ring, u32 ipehr)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct intel_ring_buffer *signaller;
+	struct intel_engine *signaller;
 	int i;
 
 	if (INTEL_INFO(dev_priv->dev)->gen >= 8) {
@@ -2606,8 +2606,8 @@ semaphore_wait_to_signaller_ring(struct intel_ring_buffer *ring, u32 ipehr)
 	return NULL;
 }
 
-static struct intel_ring_buffer *
-semaphore_waits_for(struct intel_ring_buffer *ring, u32 *seqno)
+static struct intel_engine *
+semaphore_waits_for(struct intel_engine *ring, u32 *seqno)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	u32 cmd, ipehr, head;
@@ -2649,10 +2649,10 @@ semaphore_waits_for(struct intel_ring_buffer *ring, u32 *seqno)
 	return semaphore_wait_to_signaller_ring(ring, ipehr);
 }
 
-static int semaphore_passed(struct intel_ring_buffer *ring)
+static int semaphore_passed(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct intel_ring_buffer *signaller;
+	struct intel_engine *signaller;
 	u32 seqno, ctl;
 
 	ring->hangcheck.deadlock = true;
@@ -2671,7 +2671,7 @@ static int semaphore_passed(struct intel_ring_buffer *ring)
 
 static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
 {
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 
 	for_each_active_ring(ring, dev_priv, i)
@@ -2679,7 +2679,7 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv)
 }
 
 static enum intel_ring_hangcheck_action
-ring_stuck(struct intel_ring_buffer *ring, u64 acthd)
+ring_stuck(struct intel_engine *ring, u64 acthd)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2735,7 +2735,7 @@ static void i915_hangcheck_elapsed(unsigned long data)
 {
 	struct drm_device *dev = (struct drm_device *)data;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	int i;
 	int busy_count = 0, rings_hung = 0;
 	bool stuck[I915_NUM_RINGS] = { 0 };
drivers/gpu/drm/i915/i915_trace.h +13 -13
index b29d7b1..a4f9e62 100644
@@ -326,8 +326,8 @@ TRACE_EVENT(i915_gem_evict_vm,
 );
 
 TRACE_EVENT(i915_gem_ring_sync_to,
-	    TP_PROTO(struct intel_ring_buffer *from,
-		     struct intel_ring_buffer *to,
+	    TP_PROTO(struct intel_engine *from,
+		     struct intel_engine *to,
 		     u32 seqno),
 	    TP_ARGS(from, to, seqno),
 
@@ -352,7 +352,7 @@ TRACE_EVENT(i915_gem_ring_sync_to,
 );
 
 TRACE_EVENT(i915_gem_ring_dispatch,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno, u32 flags),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno, u32 flags),
 	    TP_ARGS(ring, seqno, flags),
 
 	    TP_STRUCT__entry(
@@ -375,7 +375,7 @@ TRACE_EVENT(i915_gem_ring_dispatch,
 );
 
 TRACE_EVENT(i915_gem_ring_flush,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 invalidate, u32 flush),
+	    TP_PROTO(struct intel_engine *ring, u32 invalidate, u32 flush),
 	    TP_ARGS(ring, invalidate, flush),
 
 	    TP_STRUCT__entry(
@@ -398,7 +398,7 @@ TRACE_EVENT(i915_gem_ring_flush,
 );
 
 DECLARE_EVENT_CLASS(i915_gem_request,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno),
 
 	    TP_STRUCT__entry(
@@ -418,12 +418,12 @@ DECLARE_EVENT_CLASS(i915_gem_request,
 );
 
 DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno)
 );
 
 TRACE_EVENT(i915_gem_request_complete,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring),
 
 	    TP_STRUCT__entry(
@@ -443,12 +443,12 @@ TRACE_EVENT(i915_gem_request_complete,
 );
 
 DEFINE_EVENT(i915_gem_request, i915_gem_request_retire,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno)
 );
 
 TRACE_EVENT(i915_gem_request_wait_begin,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno),
 
 	    TP_STRUCT__entry(
@@ -477,12 +477,12 @@ TRACE_EVENT(i915_gem_request_wait_begin,
 );
 
 DEFINE_EVENT(i915_gem_request, i915_gem_request_wait_end,
-	    TP_PROTO(struct intel_ring_buffer *ring, u32 seqno),
+	    TP_PROTO(struct intel_engine *ring, u32 seqno),
 	    TP_ARGS(ring, seqno)
 );
 
 DECLARE_EVENT_CLASS(i915_ring,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring),
 
 	    TP_STRUCT__entry(
@@ -499,12 +499,12 @@ DECLARE_EVENT_CLASS(i915_ring,
 );
 
 DEFINE_EVENT(i915_ring, i915_ring_wait_begin,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring)
 );
 
 DEFINE_EVENT(i915_ring, i915_ring_wait_end,
-	    TP_PROTO(struct intel_ring_buffer *ring),
+	    TP_PROTO(struct intel_engine *ring),
 	    TP_ARGS(ring)
 );
 
drivers/gpu/drm/i915/intel_display.c +7 -7
index c65e7f7..f821147 100644
@@ -1944,7 +1944,7 @@ static int intel_align_height(struct drm_device *dev, int height, bool tiled)
 int
 intel_pin_and_fence_fb_obj(struct drm_device *dev,
 			   struct drm_i915_gem_object *obj,
-			   struct intel_ring_buffer *pipelined)
+			   struct intel_engine *pipelined)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	u32 alignment;
@@ -8424,7 +8424,7 @@ out:
 }
 
 void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
-			struct intel_ring_buffer *ring)
+			struct intel_engine *ring)
 {
 	struct drm_device *dev = obj->base.dev;
 	struct drm_crtc *crtc;
@@ -8582,7 +8582,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	u32 flip_mask;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -8627,7 +8627,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	u32 flip_mask;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -8669,7 +8669,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	uint32_t pf, pipesrc;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	ret = intel_pin_and_fence_fb_obj(dev, obj, ring);
@@ -8717,7 +8717,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	uint32_t pf, pipesrc;
 	int ret;
 
@@ -8762,7 +8762,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t plane_bit = 0;
 	int len, ret;
 
drivers/gpu/drm/i915/intel_drv.h +2 -2
index d8b540b..23b5abf 100644
@@ -694,7 +694,7 @@ int intel_pch_rawclk(struct drm_device *dev);
 int valleyview_cur_cdclk(struct drm_i915_private *dev_priv);
 void intel_mark_busy(struct drm_device *dev);
 void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
-			struct intel_ring_buffer *ring);
+			struct intel_engine *ring);
 void intel_mark_idle(struct drm_device *dev);
 void intel_crtc_restore_mode(struct drm_crtc *crtc);
 void intel_crtc_update_dpms(struct drm_crtc *crtc);
@@ -726,7 +726,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
 				    struct intel_load_detect_pipe *old);
 int intel_pin_and_fence_fb_obj(struct drm_device *dev,
 			       struct drm_i915_gem_object *obj,
-			       struct intel_ring_buffer *pipelined);
+			       struct intel_engine *pipelined);
 void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
 struct drm_framebuffer *
 __intel_framebuffer_create(struct drm_device *dev,
drivers/gpu/drm/i915/intel_overlay.c +6 -6
index d8adc91..965eec1 100644
@@ -213,7 +213,7 @@ static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
 {
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	BUG_ON(overlay->last_flip_req);
@@ -236,7 +236,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_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	BUG_ON(overlay->active);
@@ -263,7 +263,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_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	u32 flip_addr = overlay->flip_addr;
 	u32 tmp;
 	int ret;
@@ -320,7 +320,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_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	u32 flip_addr = overlay->flip_addr;
 	int ret;
 
@@ -363,7 +363,7 @@ static int intel_overlay_recover_from_interrupt(struct intel_overlay *overlay)
 {
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	if (overlay->last_flip_req == 0)
@@ -389,7 +389,7 @@ static int intel_overlay_release_old_vid(struct intel_overlay *overlay)
 {
 	struct drm_device *dev = overlay->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	/* Only wait if there is actually an old frame to release to
drivers/gpu/drm/i915/intel_pm.c +5 -5
index acfded3..17f636e 100644
@@ -3379,7 +3379,7 @@ static void parse_rp_state_cap(struct drm_i915_private *dev_priv, u32 rp_state_c
 static void gen8_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	uint32_t rc6_mask = 0, rp_state_cap;
 	int unused;
 
@@ -3454,7 +3454,7 @@ static void gen8_enable_rps(struct drm_device *dev)
 static void gen6_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	u32 rp_state_cap;
 	u32 gt_perf_status;
 	u32 rc6vids, pcu_mbox = 0, rc6_mask = 0;
@@ -3783,7 +3783,7 @@ static void valleyview_cleanup_gt_powersave(struct drm_device *dev)
 static void valleyview_enable_rps(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	u32 gtfifodbg, val, rc6_mode = 0;
 	int i;
 
@@ -3914,7 +3914,7 @@ static int ironlake_setup_rc6(struct drm_device *dev)
 static void ironlake_enable_rc6(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	bool was_interruptible;
 	int ret;
 
@@ -4426,7 +4426,7 @@ EXPORT_SYMBOL_GPL(i915_gpu_lower);
 bool i915_gpu_busy(void)
 {
 	struct drm_i915_private *dev_priv;
-	struct intel_ring_buffer *ring;
+	struct intel_engine *ring;
 	bool ret = false;
 	int i;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +79 -79
index 5d61923..4c3cc44 100644
@@ -40,7 +40,7 @@
  */
 #define CACHELINE_BYTES 64
 
-static inline int ring_space(struct intel_ring_buffer *ring)
+static inline int ring_space(struct intel_engine *ring)
 {
 	int space = (ring->head & HEAD_ADDR) - (ring->tail + I915_RING_FREE_SPACE);
 	if (space < 0)
@@ -48,13 +48,13 @@ static inline int ring_space(struct intel_ring_buffer *ring)
 	return space;
 }
 
-static bool intel_ring_stopped(struct intel_ring_buffer *ring)
+static bool intel_ring_stopped(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	return dev_priv->gpu_error.stop_rings & intel_ring_flag(ring);
 }
 
-void __intel_ring_advance(struct intel_ring_buffer *ring)
+void __intel_ring_advance(struct intel_engine *ring)
 {
 	ring->tail &= ring->size - 1;
 	if (intel_ring_stopped(ring))
@@ -63,7 +63,7 @@ void __intel_ring_advance(struct intel_ring_buffer *ring)
 }
 
 static int
-gen2_render_ring_flush(struct intel_ring_buffer *ring,
+gen2_render_ring_flush(struct intel_engine *ring,
 		       u32	invalidate_domains,
 		       u32	flush_domains)
 {
@@ -89,7 +89,7 @@ gen2_render_ring_flush(struct intel_ring_buffer *ring,
 }
 
 static int
-gen4_render_ring_flush(struct intel_ring_buffer *ring,
+gen4_render_ring_flush(struct intel_engine *ring,
 		       u32	invalidate_domains,
 		       u32	flush_domains)
 {
@@ -184,7 +184,7 @@ gen4_render_ring_flush(struct intel_ring_buffer *ring,
  * really our business.  That leaves only stall at scoreboard.
  */
 static int
-intel_emit_post_sync_nonzero_flush(struct intel_ring_buffer *ring)
+intel_emit_post_sync_nonzero_flush(struct intel_engine *ring)
 {
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
@@ -219,7 +219,7 @@ intel_emit_post_sync_nonzero_flush(struct intel_ring_buffer *ring)
 }
 
 static int
-gen6_render_ring_flush(struct intel_ring_buffer *ring,
+gen6_render_ring_flush(struct intel_engine *ring,
                          u32 invalidate_domains, u32 flush_domains)
 {
 	u32 flags = 0;
@@ -271,7 +271,7 @@ gen6_render_ring_flush(struct intel_ring_buffer *ring,
 }
 
 static int
-gen7_render_ring_cs_stall_wa(struct intel_ring_buffer *ring)
+gen7_render_ring_cs_stall_wa(struct intel_engine *ring)
 {
 	int ret;
 
@@ -289,7 +289,7 @@ gen7_render_ring_cs_stall_wa(struct intel_ring_buffer *ring)
 	return 0;
 }
 
-static int gen7_ring_fbc_flush(struct intel_ring_buffer *ring, u32 value)
+static int gen7_ring_fbc_flush(struct intel_engine *ring, u32 value)
 {
 	int ret;
 
@@ -313,7 +313,7 @@ static int gen7_ring_fbc_flush(struct intel_ring_buffer *ring, u32 value)
 }
 
 static int
-gen7_render_ring_flush(struct intel_ring_buffer *ring,
+gen7_render_ring_flush(struct intel_engine *ring,
 		       u32 invalidate_domains, u32 flush_domains)
 {
 	u32 flags = 0;
@@ -374,7 +374,7 @@ gen7_render_ring_flush(struct intel_ring_buffer *ring,
 }
 
 static int
-gen8_render_ring_flush(struct intel_ring_buffer *ring,
+gen8_render_ring_flush(struct intel_engine *ring,
 		       u32 invalidate_domains, u32 flush_domains)
 {
 	u32 flags = 0;
@@ -414,14 +414,14 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring,
 
 }
 
-static void ring_write_tail(struct intel_ring_buffer *ring,
+static void ring_write_tail(struct intel_engine *ring,
 			    u32 value)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	I915_WRITE_TAIL(ring, value);
 }
 
-u64 intel_ring_get_active_head(struct intel_ring_buffer *ring)
+u64 intel_ring_get_active_head(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	u64 acthd;
@@ -437,7 +437,7 @@ u64 intel_ring_get_active_head(struct intel_ring_buffer *ring)
 	return acthd;
 }
 
-static void ring_setup_phys_status_page(struct intel_ring_buffer *ring)
+static void ring_setup_phys_status_page(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	u32 addr;
@@ -448,7 +448,7 @@ static void ring_setup_phys_status_page(struct intel_ring_buffer *ring)
 	I915_WRITE(HWS_PGA, addr);
 }
 
-static bool stop_ring(struct intel_ring_buffer *ring)
+static bool stop_ring(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = to_i915(ring->dev);
 
@@ -472,7 +472,7 @@ static bool stop_ring(struct intel_ring_buffer *ring)
 	return (I915_READ_HEAD(ring) & HEAD_ADDR) == 0;
 }
 
-static int init_ring_common(struct intel_ring_buffer *ring)
+static int init_ring_common(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -550,7 +550,7 @@ out:
 }
 
 static int
-init_pipe_control(struct intel_ring_buffer *ring)
+init_pipe_control(struct intel_engine *ring)
 {
 	int ret;
 
@@ -591,7 +591,7 @@ err:
 	return ret;
 }
 
-static int init_render_ring(struct intel_ring_buffer *ring)
+static int init_render_ring(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -647,7 +647,7 @@ static int init_render_ring(struct intel_ring_buffer *ring)
 	return ret;
 }
 
-static void render_ring_cleanup(struct intel_ring_buffer *ring)
+static void render_ring_cleanup(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 
@@ -663,12 +663,12 @@ static void render_ring_cleanup(struct intel_ring_buffer *ring)
 	ring->scratch.obj = NULL;
 }
 
-static int gen6_signal(struct intel_ring_buffer *signaller,
+static int gen6_signal(struct intel_engine *signaller,
 		       unsigned int num_dwords)
 {
 	struct drm_device *dev = signaller->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *useless;
+	struct intel_engine *useless;
 	int i, ret;
 
 	/* NB: In order to be able to do semaphore MBOX updates for varying
@@ -713,7 +713,7 @@ static int gen6_signal(struct intel_ring_buffer *signaller,
  * This acts like a signal in the canonical semaphore.
  */
 static int
-gen6_add_request(struct intel_ring_buffer *ring)
+gen6_add_request(struct intel_engine *ring)
 {
 	int ret;
 
@@ -745,8 +745,8 @@ static inline bool i915_gem_has_seqno_wrapped(struct drm_device *dev,
  * @seqno - seqno which the waiter will block on
  */
 static int
-gen6_ring_sync(struct intel_ring_buffer *waiter,
-	       struct intel_ring_buffer *signaller,
+gen6_ring_sync(struct intel_engine *waiter,
+	       struct intel_engine *signaller,
 	       u32 seqno)
 {
 	u32 dw1 = MI_SEMAPHORE_MBOX |
@@ -794,7 +794,7 @@ do {									\
 } while (0)
 
 static int
-pc_render_add_request(struct intel_ring_buffer *ring)
+pc_render_add_request(struct intel_engine *ring)
 {
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
 	int ret;
@@ -842,7 +842,7 @@ pc_render_add_request(struct intel_ring_buffer *ring)
 }
 
 static u32
-gen6_ring_get_seqno(struct intel_ring_buffer *ring, bool lazy_coherency)
+gen6_ring_get_seqno(struct intel_engine *ring, bool lazy_coherency)
 {
 	/* Workaround to force correct ordering between irq and seqno writes on
 	 * ivb (and maybe also on snb) by reading from a CS register (like
@@ -856,31 +856,31 @@ gen6_ring_get_seqno(struct intel_ring_buffer *ring, bool lazy_coherency)
 }
 
 static u32
-ring_get_seqno(struct intel_ring_buffer *ring, bool lazy_coherency)
+ring_get_seqno(struct intel_engine *ring, bool lazy_coherency)
 {
 	return intel_read_status_page(ring, I915_GEM_HWS_INDEX);
 }
 
 static void
-ring_set_seqno(struct intel_ring_buffer *ring, u32 seqno)
+ring_set_seqno(struct intel_engine *ring, u32 seqno)
 {
 	intel_write_status_page(ring, I915_GEM_HWS_INDEX, seqno);
 }
 
 static u32
-pc_render_get_seqno(struct intel_ring_buffer *ring, bool lazy_coherency)
+pc_render_get_seqno(struct intel_engine *ring, bool lazy_coherency)
 {
 	return ring->scratch.cpu_page[0];
 }
 
 static void
-pc_render_set_seqno(struct intel_ring_buffer *ring, u32 seqno)
+pc_render_set_seqno(struct intel_engine *ring, u32 seqno)
 {
 	ring->scratch.cpu_page[0] = seqno;
 }
 
 static bool
-gen5_ring_get_irq(struct intel_ring_buffer *ring)
+gen5_ring_get_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -898,7 +898,7 @@ gen5_ring_get_irq(struct intel_ring_buffer *ring)
 }
 
 static void
-gen5_ring_put_irq(struct intel_ring_buffer *ring)
+gen5_ring_put_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -911,7 +911,7 @@ gen5_ring_put_irq(struct intel_ring_buffer *ring)
 }
 
 static bool
-i9xx_ring_get_irq(struct intel_ring_buffer *ring)
+i9xx_ring_get_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -932,7 +932,7 @@ i9xx_ring_get_irq(struct intel_ring_buffer *ring)
 }
 
 static void
-i9xx_ring_put_irq(struct intel_ring_buffer *ring)
+i9xx_ring_put_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -948,7 +948,7 @@ i9xx_ring_put_irq(struct intel_ring_buffer *ring)
 }
 
 static bool
-i8xx_ring_get_irq(struct intel_ring_buffer *ring)
+i8xx_ring_get_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -969,7 +969,7 @@ i8xx_ring_get_irq(struct intel_ring_buffer *ring)
 }
 
 static void
-i8xx_ring_put_irq(struct intel_ring_buffer *ring)
+i8xx_ring_put_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -984,7 +984,7 @@ i8xx_ring_put_irq(struct intel_ring_buffer *ring)
 	spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
 }
 
-void intel_ring_setup_status_page(struct intel_ring_buffer *ring)
+void intel_ring_setup_status_page(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -1047,7 +1047,7 @@ void intel_ring_setup_status_page(struct intel_ring_buffer *ring)
 }
 
 static int
-bsd_ring_flush(struct intel_ring_buffer *ring,
+bsd_ring_flush(struct intel_engine *ring,
 	       u32     invalidate_domains,
 	       u32     flush_domains)
 {
@@ -1064,7 +1064,7 @@ bsd_ring_flush(struct intel_ring_buffer *ring,
 }
 
 static int
-i9xx_add_request(struct intel_ring_buffer *ring)
+i9xx_add_request(struct intel_engine *ring)
 {
 	int ret;
 
@@ -1082,7 +1082,7 @@ i9xx_add_request(struct intel_ring_buffer *ring)
 }
 
 static bool
-gen6_ring_get_irq(struct intel_ring_buffer *ring)
+gen6_ring_get_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1107,7 +1107,7 @@ gen6_ring_get_irq(struct intel_ring_buffer *ring)
 }
 
 static void
-gen6_ring_put_irq(struct intel_ring_buffer *ring)
+gen6_ring_put_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1125,7 +1125,7 @@ gen6_ring_put_irq(struct intel_ring_buffer *ring)
 }
 
 static bool
-hsw_vebox_get_irq(struct intel_ring_buffer *ring)
+hsw_vebox_get_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1145,7 +1145,7 @@ hsw_vebox_get_irq(struct intel_ring_buffer *ring)
 }
 
 static void
-hsw_vebox_put_irq(struct intel_ring_buffer *ring)
+hsw_vebox_put_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1163,7 +1163,7 @@ hsw_vebox_put_irq(struct intel_ring_buffer *ring)
 }
 
 static bool
-gen8_ring_get_irq(struct intel_ring_buffer *ring)
+gen8_ring_get_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1189,7 +1189,7 @@ gen8_ring_get_irq(struct intel_ring_buffer *ring)
 }
 
 static void
-gen8_ring_put_irq(struct intel_ring_buffer *ring)
+gen8_ring_put_irq(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1209,7 +1209,7 @@ gen8_ring_put_irq(struct intel_ring_buffer *ring)
 }
 
 static int
-i965_dispatch_execbuffer(struct intel_ring_buffer *ring,
+i965_dispatch_execbuffer(struct intel_engine *ring,
 			 u64 offset, u32 length,
 			 unsigned flags)
 {
@@ -1232,7 +1232,7 @@ i965_dispatch_execbuffer(struct intel_ring_buffer *ring,
 /* Just userspace ABI convention to limit the wa batch bo to a resonable size */
 #define I830_BATCH_LIMIT (256*1024)
 static int
-i830_dispatch_execbuffer(struct intel_ring_buffer *ring,
+i830_dispatch_execbuffer(struct intel_engine *ring,
 				u64 offset, u32 len,
 				unsigned flags)
 {
@@ -1283,7 +1283,7 @@ i830_dispatch_execbuffer(struct intel_ring_buffer *ring,
 }
 
 static int
-i915_dispatch_execbuffer(struct intel_ring_buffer *ring,
+i915_dispatch_execbuffer(struct intel_engine *ring,
 			 u64 offset, u32 len,
 			 unsigned flags)
 {
@@ -1300,7 +1300,7 @@ i915_dispatch_execbuffer(struct intel_ring_buffer *ring,
 	return 0;
 }
 
-static void cleanup_status_page(struct intel_ring_buffer *ring)
+static void cleanup_status_page(struct intel_engine *ring)
 {
 	struct drm_i915_gem_object *obj;
 
@@ -1314,7 +1314,7 @@ static void cleanup_status_page(struct intel_ring_buffer *ring)
 	ring->status_page.obj = NULL;
 }
 
-static int init_status_page(struct intel_ring_buffer *ring)
+static int init_status_page(struct intel_engine *ring)
 {
 	struct drm_i915_gem_object *obj;
 
@@ -1351,7 +1351,7 @@ err_unref:
 	return 0;
 }
 
-static int init_phys_status_page(struct intel_ring_buffer *ring)
+static int init_phys_status_page(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 
@@ -1368,7 +1368,7 @@ static int init_phys_status_page(struct intel_ring_buffer *ring)
 	return 0;
 }
 
-void intel_destroy_ring_buffer(struct intel_ring_buffer *ring)
+void intel_destroy_ring_buffer(struct intel_engine *ring)
 {
 	if (!ring->obj)
 		return;
@@ -1379,7 +1379,7 @@ void intel_destroy_ring_buffer(struct intel_ring_buffer *ring)
 	ring->obj = NULL;
 }
 
-int intel_allocate_ring_buffer(struct intel_ring_buffer *ring)
+int intel_allocate_ring_buffer(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
@@ -1424,7 +1424,7 @@ err_unref:
 }
 
 static int intel_init_ring_buffer(struct drm_device *dev,
-				  struct intel_ring_buffer *ring)
+				  struct intel_engine *ring)
 {
 	int ret;
 
@@ -1465,7 +1465,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 	return ring->init(ring);
 }
 
-void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring)
+void intel_cleanup_ring_buffer(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = to_i915(ring->dev);
 
@@ -1485,7 +1485,7 @@ void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring)
 	cleanup_status_page(ring);
 }
 
-static int intel_ring_wait_request(struct intel_ring_buffer *ring, int n)
+static int intel_ring_wait_request(struct intel_engine *ring, int n)
 {
 	struct drm_i915_gem_request *request;
 	u32 seqno = 0, tail;
@@ -1538,7 +1538,7 @@ static int intel_ring_wait_request(struct intel_ring_buffer *ring, int n)
 	return 0;
 }
 
-static int ring_wait_for_space(struct intel_ring_buffer *ring, int n)
+static int ring_wait_for_space(struct intel_engine *ring, int n)
 {
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1586,7 +1586,7 @@ static int ring_wait_for_space(struct intel_ring_buffer *ring, int n)
 	return -EBUSY;
 }
 
-static int intel_wrap_ring_buffer(struct intel_ring_buffer *ring)
+static int intel_wrap_ring_buffer(struct intel_engine *ring)
 {
 	uint32_t __iomem *virt;
 	int rem = ring->size - ring->tail;
@@ -1608,7 +1608,7 @@ static int intel_wrap_ring_buffer(struct intel_ring_buffer *ring)
 	return 0;
 }
 
-int intel_ring_idle(struct intel_ring_buffer *ring)
+int intel_ring_idle(struct intel_engine *ring)
 {
 	u32 seqno;
 	int ret;
@@ -1632,7 +1632,7 @@ int intel_ring_idle(struct intel_ring_buffer *ring)
 }
 
 static int
-intel_ring_alloc_seqno(struct intel_ring_buffer *ring)
+intel_ring_alloc_seqno(struct intel_engine *ring)
 {
 	if (ring->outstanding_lazy_seqno)
 		return 0;
@@ -1650,7 +1650,7 @@ intel_ring_alloc_seqno(struct intel_ring_buffer *ring)
 	return i915_gem_get_seqno(ring->dev, &ring->outstanding_lazy_seqno);
 }
 
-static int __intel_ring_prepare(struct intel_ring_buffer *ring,
+static int __intel_ring_prepare(struct intel_engine *ring,
 				int bytes)
 {
 	int ret;
@@ -1670,7 +1670,7 @@ static int __intel_ring_prepare(struct intel_ring_buffer *ring,
 	return 0;
 }
 
-int intel_ring_begin(struct intel_ring_buffer *ring,
+int intel_ring_begin(struct intel_engine *ring,
 		     int num_dwords)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -1695,7 +1695,7 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
 }
 
 /* Align the ring tail to a cacheline boundary */
-int intel_ring_cacheline_align(struct intel_ring_buffer *ring)
+int intel_ring_cacheline_align(struct intel_engine *ring)
 {
 	int num_dwords = (ring->tail & (CACHELINE_BYTES - 1)) / sizeof(uint32_t);
 	int ret;
@@ -1716,7 +1716,7 @@ int intel_ring_cacheline_align(struct intel_ring_buffer *ring)
 	return 0;
 }
 
-void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno)
+void intel_ring_init_seqno(struct intel_engine *ring, u32 seqno)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 
@@ -1733,7 +1733,7 @@ void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno)
 	ring->hangcheck.seqno = seqno;
 }
 
-static void gen6_bsd_ring_write_tail(struct intel_ring_buffer *ring,
+static void gen6_bsd_ring_write_tail(struct intel_engine *ring,
 				     u32 value)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -1766,7 +1766,7 @@ static void gen6_bsd_ring_write_tail(struct intel_ring_buffer *ring,
 		   _MASKED_BIT_DISABLE(GEN6_BSD_SLEEP_MSG_DISABLE));
 }
 
-static int gen6_bsd_ring_flush(struct intel_ring_buffer *ring,
+static int gen6_bsd_ring_flush(struct intel_engine *ring,
 			       u32 invalidate, u32 flush)
 {
 	uint32_t cmd;
@@ -1802,7 +1802,7 @@ static int gen6_bsd_ring_flush(struct intel_ring_buffer *ring,
 }
 
 static int
-gen8_ring_dispatch_execbuffer(struct intel_ring_buffer *ring,
+gen8_ring_dispatch_execbuffer(struct intel_engine *ring,
 			      u64 offset, u32 len,
 			      unsigned flags)
 {
@@ -1826,7 +1826,7 @@ gen8_ring_dispatch_execbuffer(struct intel_ring_buffer *ring,
 }
 
 static int
-hsw_ring_dispatch_execbuffer(struct intel_ring_buffer *ring,
+hsw_ring_dispatch_execbuffer(struct intel_engine *ring,
 			      u64 offset, u32 len,
 			      unsigned flags)
 {
@@ -1847,7 +1847,7 @@ hsw_ring_dispatch_execbuffer(struct intel_ring_buffer *ring,
 }
 
 static int
-gen6_ring_dispatch_execbuffer(struct intel_ring_buffer *ring,
+gen6_ring_dispatch_execbuffer(struct intel_engine *ring,
 			      u64 offset, u32 len,
 			      unsigned flags)
 {
@@ -1869,7 +1869,7 @@ gen6_ring_dispatch_execbuffer(struct intel_ring_buffer *ring,
 
 /* Blitter support (SandyBridge+) */
 
-static int gen6_ring_flush(struct intel_ring_buffer *ring,
+static int gen6_ring_flush(struct intel_engine *ring,
 			   u32 invalidate, u32 flush)
 {
 	struct drm_device *dev = ring->dev;
@@ -1912,7 +1912,7 @@ static int gen6_ring_flush(struct intel_ring_buffer *ring,
 int intel_init_render_ring_buffer(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 
 	if (INTEL_INFO(dev)->gen >= 6) {
 		ring->add_request = gen6_add_request;
@@ -2018,7 +2018,7 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
 int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
+	struct intel_engine *ring = &dev_priv->ring[RCS];
 	int ret;
 
 	if (INTEL_INFO(dev)->gen >= 6) {
@@ -2081,7 +2081,7 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
 int intel_init_bsd_ring_buffer(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[VCS];
+	struct intel_engine *ring = &dev_priv->ring[VCS];
 
 	ring->write_tail = ring_write_tail;
 	if (INTEL_INFO(dev)->gen >= 6) {
@@ -2152,7 +2152,7 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev)
 int intel_init_bsd2_ring_buffer(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[VCS2];
+	struct intel_engine *ring = &dev_priv->ring[VCS2];
 
 	if ((INTEL_INFO(dev)->gen != 8)) {
 		DRM_ERROR("No dual-BSD ring on non-BDW machine\n");
@@ -2196,7 +2196,7 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev)
 int intel_init_blt_ring_buffer(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[BCS];
+	struct intel_engine *ring = &dev_priv->ring[BCS];
 
 	ring->write_tail = ring_write_tail;
 	ring->flush = gen6_ring_flush;
@@ -2241,7 +2241,7 @@ int intel_init_blt_ring_buffer(struct drm_device *dev)
 int intel_init_vebox_ring_buffer(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_ring_buffer *ring = &dev_priv->ring[VECS];
+	struct intel_engine *ring = &dev_priv->ring[VECS];
 
 	ring->write_tail = ring_write_tail;
 	ring->flush = gen6_ring_flush;
@@ -2279,7 +2279,7 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev)
 }
 
 int
-intel_ring_flush_all_caches(struct intel_ring_buffer *ring)
+intel_ring_flush_all_caches(struct intel_engine *ring)
 {
 	int ret;
 
@@ -2297,7 +2297,7 @@ intel_ring_flush_all_caches(struct intel_ring_buffer *ring)
 }
 
 int
-intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring)
+intel_ring_invalidate_all_caches(struct intel_engine *ring)
 {
 	uint32_t flush_domains;
 	int ret;
@@ -2317,7 +2317,7 @@ intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring)
 }
 
 void
-intel_stop_ring_buffer(struct intel_ring_buffer *ring)
+intel_stop_ring_buffer(struct intel_engine *ring)
 {
 	int ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +38 -38
index 680e451..50cc525 100644
@@ -54,7 +54,7 @@ struct intel_ring_hangcheck {
 	bool deadlock;
 };
 
-struct  intel_ring_buffer {
+struct intel_engine {
 	const char	*name;
 	enum intel_ring_id {
 		RCS = 0x0,
@@ -90,33 +90,33 @@ struct  intel_ring_buffer {
 	unsigned irq_refcount; /* protected by dev_priv->irq_lock */
 	u32		irq_enable_mask;	/* bitmask to enable ring interrupt */
 	u32		trace_irq_seqno;
-	bool __must_check (*irq_get)(struct intel_ring_buffer *ring);
-	void		(*irq_put)(struct intel_ring_buffer *ring);
+	bool __must_check (*irq_get)(struct intel_engine *ring);
+	void		(*irq_put)(struct intel_engine *ring);
 
-	int		(*init)(struct intel_ring_buffer *ring);
+	int		(*init)(struct intel_engine *ring);
 
-	void		(*write_tail)(struct intel_ring_buffer *ring,
+	void		(*write_tail)(struct intel_engine *ring,
 				      u32 value);
-	int __must_check (*flush)(struct intel_ring_buffer *ring,
+	int __must_check (*flush)(struct intel_engine *ring,
 				  u32	invalidate_domains,
 				  u32	flush_domains);
-	int		(*add_request)(struct intel_ring_buffer *ring);
+	int		(*add_request)(struct intel_engine *ring);
 	/* 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
 	 * seen value is good enough. Note that the seqno will always be
 	 * monotonic, even if not coherent.
 	 */
-	u32		(*get_seqno)(struct intel_ring_buffer *ring,
+	u32		(*get_seqno)(struct intel_engine *ring,
 				     bool lazy_coherency);
-	void		(*set_seqno)(struct intel_ring_buffer *ring,
+	void		(*set_seqno)(struct intel_engine *ring,
 				     u32 seqno);
-	int		(*dispatch_execbuffer)(struct intel_ring_buffer *ring,
+	int		(*dispatch_execbuffer)(struct intel_engine *ring,
 					       u64 offset, u32 length,
 					       unsigned flags);
 #define I915_DISPATCH_SECURE 0x1
 #define I915_DISPATCH_PINNED 0x2
-	void		(*cleanup)(struct intel_ring_buffer *ring);
+	void		(*cleanup)(struct intel_engine *ring);
 
 	struct {
 		u32	sync_seqno[I915_NUM_RINGS-1];
@@ -129,10 +129,10 @@ struct  intel_ring_buffer {
 		} mbox;
 
 		/* AKA wait() */
-		int	(*sync_to)(struct intel_ring_buffer *ring,
-				   struct intel_ring_buffer *to,
+		int	(*sync_to)(struct intel_engine *ring,
+				   struct intel_engine *to,
 				   u32 seqno);
-		int	(*signal)(struct intel_ring_buffer *signaller,
+		int	(*signal)(struct intel_engine *signaller,
 				  /* num_dwords needed by caller */
 				  unsigned int num_dwords);
 	} semaphore;
@@ -210,20 +210,20 @@ struct  intel_ring_buffer {
 };
 
 static inline bool
-intel_ring_initialized(struct intel_ring_buffer *ring)
+intel_ring_initialized(struct intel_engine *ring)
 {
 	return ring->obj != NULL;
 }
 
 static inline unsigned
-intel_ring_flag(struct intel_ring_buffer *ring)
+intel_ring_flag(struct intel_engine *ring)
 {
 	return 1 << ring->id;
 }
 
 static inline u32
-intel_ring_sync_index(struct intel_ring_buffer *ring,
-		      struct intel_ring_buffer *other)
+intel_ring_sync_index(struct intel_engine *ring,
+		      struct intel_engine *other)
 {
 	int idx;
 
@@ -241,7 +241,7 @@ intel_ring_sync_index(struct intel_ring_buffer *ring,
 }
 
 static inline u32
-intel_read_status_page(struct intel_ring_buffer *ring,
+intel_read_status_page(struct intel_engine *ring,
 		       int reg)
 {
 	/* Ensure that the compiler doesn't optimize away the load. */
@@ -250,7 +250,7 @@ intel_read_status_page(struct intel_ring_buffer *ring,
 }
 
 static inline void
-intel_write_status_page(struct intel_ring_buffer *ring,
+intel_write_status_page(struct intel_engine *ring,
 			int reg, u32 value)
 {
 	ring->status_page.page_addr[reg] = value;
@@ -275,27 +275,27 @@ intel_write_status_page(struct intel_ring_buffer *ring,
 #define I915_GEM_HWS_SCRATCH_INDEX	0x30
 #define I915_GEM_HWS_SCRATCH_ADDR (I915_GEM_HWS_SCRATCH_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
 
-void intel_stop_ring_buffer(struct intel_ring_buffer *ring);
-void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring);
+void intel_stop_ring_buffer(struct intel_engine *ring);
+void intel_cleanup_ring_buffer(struct intel_engine *ring);
 
-int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n);
-int __must_check intel_ring_cacheline_align(struct intel_ring_buffer *ring);
-static inline void intel_ring_emit(struct intel_ring_buffer *ring,
+int __must_check intel_ring_begin(struct intel_engine *ring, int n);
+int __must_check intel_ring_cacheline_align(struct intel_engine *ring);
+static inline void intel_ring_emit(struct intel_engine *ring,
 				   u32 data)
 {
 	iowrite32(data, ring->virtual_start + ring->tail);
 	ring->tail += 4;
 }
-static inline void intel_ring_advance(struct intel_ring_buffer *ring)
+static inline void intel_ring_advance(struct intel_engine *ring)
 {
 	ring->tail &= ring->size - 1;
 }
-void __intel_ring_advance(struct intel_ring_buffer *ring);
+void __intel_ring_advance(struct intel_engine *ring);
 
-int __must_check intel_ring_idle(struct intel_ring_buffer *ring);
-void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno);
-int intel_ring_flush_all_caches(struct intel_ring_buffer *ring);
-int intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring);
+int __must_check intel_ring_idle(struct intel_engine *ring);
+void intel_ring_init_seqno(struct intel_engine *ring, u32 seqno);
+int intel_ring_flush_all_caches(struct intel_engine *ring);
+int intel_ring_invalidate_all_caches(struct intel_engine *ring);
 
 void intel_init_rings_early(struct drm_device *dev);
 int intel_init_render_ring_buffer(struct drm_device *dev);
@@ -304,24 +304,24 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev);
 int intel_init_blt_ring_buffer(struct drm_device *dev);
 int intel_init_vebox_ring_buffer(struct drm_device *dev);
 
-u64 intel_ring_get_active_head(struct intel_ring_buffer *ring);
-void intel_ring_setup_status_page(struct intel_ring_buffer *ring);
+u64 intel_ring_get_active_head(struct intel_engine *ring);
+void intel_ring_setup_status_page(struct intel_engine *ring);
 
-void intel_destroy_ring_buffer(struct intel_ring_buffer *ring);
-int intel_allocate_ring_buffer(struct intel_ring_buffer *ring);
+void intel_destroy_ring_buffer(struct intel_engine *ring);
+int intel_allocate_ring_buffer(struct intel_engine *ring);
 
-static inline u32 intel_ring_get_tail(struct intel_ring_buffer *ring)
+static inline u32 intel_ring_get_tail(struct intel_engine *ring)
 {
 	return ring->tail;
 }
 
-static inline u32 intel_ring_get_seqno(struct intel_ring_buffer *ring)
+static inline u32 intel_ring_get_seqno(struct intel_engine *ring)
 {
 	BUG_ON(ring->outstanding_lazy_seqno == 0);
 	return ring->outstanding_lazy_seqno;
 }
 
-static inline void i915_trace_irq_get(struct intel_ring_buffer *ring, u32 seqno)
+static inline void i915_trace_irq_get(struct intel_engine *ring, u32 seqno)
 {
 	if (ring->trace_irq_seqno == 0 && ring->irq_get(ring))
 		ring->trace_irq_seqno = seqno;
Signature · 6 lines
1.9.0

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

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 7 lines · Daniel Vetter
Quoted 6 lines · On Fri, May 09, 2014 at 01:08:36PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

Quoted 6 lines
Quoted 3 lines

No functional changes.

If we rename stuff I'd vote for something close to Bspec language, like CS. So maybe intel_cs_engine?

Also, can we have such patches (and the like of "drm/i915:
for_each_ring") pushed early when everyone is happy with them, they cause constant rebasing pain.

Thanks,

Signature · 1 line
Damien
#16 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 8 lines

-----Original Message-----
From: Lespiau, Damien
Sent: Wednesday, May 14, 2014 2:26 PM
To: Daniel Vetter
Cc: Mateo Lozano, Oscar; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 14 lines
Quoted 13 lines · Daniel Vetter
Quoted 9 lines · On Fri, May 09, 2014 at 01:08:36PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

No functional changes.

If we rename stuff I'd vote for something close to Bspec language, like CS. So maybe intel_cs_engine?

Bikeshedding much, are we? :)
If we want to get closer to bspecish, intel_engine_cs would be better.

Quoted 3 lines

Also, can we have such patches (and the like of "drm/i915:
for_each_ring") pushed early when everyone is happy with them, they cause constant rebasing pain.

I second that motion!

#17 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 18 lines · Oscar
Quoted 18 lines

-----Original Message-----
From: Lespiau, Damien
Sent: Wednesday, May 14, 2014 2:26 PM
To: Daniel Vetter
Cc: Mateo Lozano, Oscar; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 9 lines · Daniel Vetter
Quoted 8 lines · On Fri, May 09, 2014 at 01:08:36PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

No functional changes.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

If we rename stuff I'd vote for something close to Bspec language, like CS. So maybe intel_cs_engine?

Bikeshedding much, are we? :)
If we want to get closer to bspecish, intel_engine_cs would be better.

I'm ok with that too ;-)

Quoted 5 lines
Quoted 3 lines

Also, can we have such patches (and the like of "drm/i915:
for_each_ring") pushed early when everyone is happy with them, they cause constant rebasing pain.

I second that motion!

Fully agreed - as soon as we have a rough sketch of where we want to go to I'll pull in the rename. Aside I highly suggest to do the rename with coccinelle and regerate it on rebases - that's much less error-prone than doing it by hand.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#18 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Hi Daniel,

Quoted 42 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, May 15, 2014 9:52 PM
To: Mateo Lozano, Oscar
Cc: Lespiau, Damien; Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 10 lines · Oscar
Quoted 10 lines

-----Original Message-----
From: Lespiau, Damien
Sent: Wednesday, May 14, 2014 2:26 PM
To: Daniel Vetter
Cc: Mateo Lozano, Oscar; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 1 line · Daniel Vetter

On Fri, May 09, 2014 at 01:08:36PM +0100, [email protected]

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

No functional changes.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

If we rename stuff I'd vote for something close to Bspec language, like CS. So maybe intel_cs_engine?

Bikeshedding much, are we? :)
If we want to get closer to bspecish, intel_engine_cs would be better.

I'm ok with that too ;-)

Quoted 4 lines
Quoted 3 lines

Also, can we have such patches (and the like of "drm/i915:
for_each_ring") pushed early when everyone is happy with them, they cause constant rebasing pain.

Quoted 6 lines
Quoted 1 line

I second that motion!

Fully agreed - as soon as we have a rough sketch of where we want to go to I'll pull in the rename. Aside I highly suggest to do the rename with coccinelle and regerate it on rebases - that's much less error-prone than doing it by hand. -Daniel

I propose the following code refactoring at a minimum. Even if I abstract away all the "i915_gem_context.c" and "intel_ringbuffer.c" functionality, and part of "i915_gem_execbuffer.c", to keep changes to legacy code to a minimum, I still think the following changes are good for the overall code:

1) s/intel_ring_buffer/intel_engine_cs

Straight renaming: if the actual ring buffers can live either inside the engine/ring (legacy ringbuffer submission) or inside the context (execlists), it doesn´t make sense that the engine/ring is called "intel_ring_buffer".

2) Split the ringbuffers and the rings

New struct:

+struct intel_ringbuffer {
+ struct drm_i915_gem_object *obj;
+ void __iomem *virtual_start;
+

+       u32 head;
+       u32 tail;
+       int space;
+       int size;
+       int effective_size;
+
+       /** We track the position of the requests in the ring buffer, and
+        * when each is retired we increment last_retired_head as the GPU
+        * must have finished processing the request and so we know we
+        * can advance the ringbuffer up to that position.
+        *
+        * last_retired_head is set to -1 after the value is consumed so
+        * we can detect new retirements.
+        */

+ u32 last_retired_head;
+};

And "struct intel_engine_cs" now groups all these elements into "buffer":

-       void            __iomem *virtual_start;
-       struct          drm_i915_gem_object *obj;
-       u32             head;
-       u32             tail;
-       int             space;
-       int             size;
-       int             effective_size;
-       u32             last_retired_head;
+       struct intel_ringbuffer buffer;

3) Introduce one context backing object per engine

- struct drm_i915_gem_object *obj;
+ struct {
+ struct drm_i915_gem_object *obj;
+ } engine[I915_NUM_RINGS];

Legacy code only ever uses engine[RCS], so I can use it everywhere in the existing code.

If we agree on this minimum set, I´ll send the patches right away.

Cheers,
Oscar

#19 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 57 lines · Oscar

Hi Daniel,

Quoted 42 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, May 15, 2014 9:52 PM
To: Mateo Lozano, Oscar
Cc: Lespiau, Damien; Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 10 lines · Oscar
Quoted 10 lines

-----Original Message-----
From: Lespiau, Damien
Sent: Wednesday, May 14, 2014 2:26 PM
To: Daniel Vetter
Cc: Mateo Lozano, Oscar; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 1 line · Daniel Vetter

On Fri, May 09, 2014 at 01:08:36PM +0100, [email protected]

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

No functional changes.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

If we rename stuff I'd vote for something close to Bspec language, like CS. So maybe intel_cs_engine?

Bikeshedding much, are we? :)
If we want to get closer to bspecish, intel_engine_cs would be better.

I'm ok with that too ;-)

Quoted 4 lines
Quoted 3 lines

Also, can we have such patches (and the like of "drm/i915:
for_each_ring") pushed early when everyone is happy with them, they cause constant rebasing pain.

Quoted 6 lines
Quoted 1 line

I second that motion!

Fully agreed - as soon as we have a rough sketch of where we want to go to I'll pull in the rename. Aside I highly suggest to do the rename with coccinelle and regerate it on rebases - that's much less error-prone than doing it by hand. -Daniel

I propose the following code refactoring at a minimum. Even if I abstract away all the "i915_gem_context.c" and "intel_ringbuffer.c" functionality, and part of "i915_gem_execbuffer.c", to keep changes to legacy code to a minimum, I still think the following changes are good for the overall code:

Quoted 6 lines

1) s/intel_ring_buffer/intel_engine_cs

Straight renaming: if the actual ring buffers can live either inside the engine/ring (legacy ringbuffer submission) or inside the context (execlists), it doesn´t make sense that the engine/ring is called "intel_ring_buffer".

Ack. Like I've said probably best done with coccinelle to cut down on potential mistakes. One thing this provokes is the obj->ring pointers we use all over the place. But I guess we can fix those up later on once this all has settled.

Quoted 27 lines

2) Split the ringbuffers and the rings

New struct:

(quoted diff) +20 -0
+struct intel_ringbuffer {
+       struct drm_i915_gem_object *obj;
+       void __iomem *virtual_start;
+
+       u32 head;
+       u32 tail;
+       int space;
+       int size;
+       int effective_size;
+
+       /** We track the position of the requests in the ring buffer, and
+        * when each is retired we increment last_retired_head as the GPU
+        * must have finished processing the request and so we know we
+        * can advance the ringbuffer up to that position.
+        *
+        * last_retired_head is set to -1 after the value is consumed so
+        * we can detect new retirements.
+        */
+       u32 last_retired_head;
+};

And "struct intel_engine_cs" now groups all these elements into "buffer":

Review

Quoted 9 lines
(quoted diff) +1 -8
-       void            __iomem *virtual_start;
-       struct          drm_i915_gem_object *obj;
-       u32             head;
-       u32             tail;
-       int             space;
-       int             size;
-       int             effective_size;
-       u32             last_retired_head;
+       struct intel_ringbuffer buffer;

Is the idea to embed this new intel_ringbuffer struct into the lrc context structure so that we can share a bit of the low-level frobbing? I wonder whether we should switch right away to a pointer and leave the engine_cs->ring pointer NULL for lrc. That would be good for catching bugs where we accidentally mix up old and new styles. If you agree that a engine_cs->ring pointer would fit your design this is acked.

Btw for such code design issues I usually refer to Rusty's api design manifesto:

http://sweng.the-davies.net/Home/rustys-api-design-manifesto

Oopsing at runtime is still considerid a bad level, but much better than silently failing.

Again I recommend to look into coccinelle for the sed part of this.

Quoted 8 lines

3) Introduce one context backing object per engine

(quoted diff) +3 -1
-       struct drm_i915_gem_object *obj;
+       struct {
+               struct drm_i915_gem_object *obj;
+       } engine[I915_NUM_RINGS];

Legacy code only ever uses engine[RCS], so I can use it everywhere in the existing code.

Unsure about this. If I understand this correctly we only need to be able to support multiple backing objects for the same logical ring object (i.e. what is tracked by struct i915_hw_context) for the implicit per-filp context 0. But our handling of context id 0 is already magical, so we might as well add a bit more magic and shovel this array into the filp data structure:

drivers/gpu/drm/i915/i915_drv.h +3 -1
index 108e1ec2fa4b..e34db43dead3 100644
@@ -1825,7 +1825,9 @@ struct drm_i915_file_private {
 	} mm;
 	struct idr context_idr;
 
-	struct i915_hw_context *private_default_ctx;
+	/* default context for each ring, NULL if hw doesn't support hw contexts
+	 * (or fancy new lrcs) on that ring. */
+	struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];
 	atomic_t rps_wait_boost;
 };
 

Of course we need to add an i915_hw_context->engine_cs pointer and we need to check that at execbuf to make sure we don't run contexts on the wrong engine.

If we later on decide that we want to expose multiple hw contexts for !RCS to userspace we can easily add a bunch of ring flags to the context create ioctl. So this doesn't restrict us at all in the features we can support without jumping through hoops.

Also if we'd shovel all per-ring lrcs into the same i915_hw_context structure then we'd need to rename that and drop the _hw part - it's no longer a 1:1 correspondence to an actual hw ring/context/lrc/whatever wizzbang thingy.

Cheers, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#20 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 71 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, May 19, 2014 1:21 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; Lespiau, Damien; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 51 lines · Oscar

Hi Daniel,

Quoted 49 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Thursday, May 15, 2014 9:52 PM
To: Mateo Lozano, Oscar
Cc: Lespiau, Damien; Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 11 lines · Oscar
Quoted 11 lines

-----Original Message-----
From: Lespiau, Damien
Sent: Wednesday, May 14, 2014 2:26 PM
To: Daniel Vetter
Cc: Mateo Lozano, Oscar; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 2 lines · Daniel Vetter

On Fri, May 09, 2014 at 01:08:36PM +0100,
[email protected]

Quoted 8 lines · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

From: Oscar Mateo <[email protected]>

In the upcoming patches, we plan to break the correlation between engines (a.k.a. rings) and ringbuffers, so it makes sense to refactor the code and make the change obvious.

No functional changes.

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

If we rename stuff I'd vote for something close to Bspec language, like CS. So maybe intel_cs_engine?

Bikeshedding much, are we? :)
If we want to get closer to bspecish, intel_engine_cs would be better.

I'm ok with that too ;-)

Quoted 5 lines
Quoted 3 lines

Also, can we have such patches (and the like of "drm/i915:
for_each_ring") pushed early when everyone is happy with them, they cause constant rebasing pain.

I second that motion!

Fully agreed - as soon as we have a rough sketch of where we want to go to I'll pull in the rename. Aside I highly suggest to do the rename with coccinelle and regerate it on rebases - that's much less error-

prone than doing it by hand.

Quoted 10 lines
Quoted 1 line

-Daniel

I propose the following code refactoring at a minimum. Even if I abstract away all the "i915_gem_context.c" and "intel_ringbuffer.c" functionality, and part of "i915_gem_execbuffer.c", to keep changes to legacy code to a minimum, I still think the following changes are good for the overall code:

1) s/intel_ring_buffer/intel_engine_cs

Quoted 8 lines
Quoted 4 lines

Straight renaming: if the actual ring buffers can live either inside the engine/ring (legacy ringbuffer submission) or inside the context (execlists), it doesn´t make sense that the engine/ring is called "intel_ring_buffer".

Ack. Like I've said probably best done with coccinelle to cut down on potential mistakes. One thing this provokes is the obj->ring pointers we use all over the place. But I guess we can fix those up later on once this all has settled.

ACK, FIN

Quoted 27 lines
Quoted 27 lines

2) Split the ringbuffers and the rings

New struct:

(quoted diff) +20 -0
+struct intel_ringbuffer {
+       struct drm_i915_gem_object *obj;
+       void __iomem *virtual_start;
+
+       u32 head;
+       u32 tail;
+       int space;
+       int size;
+       int effective_size;
+
+       /** We track the position of the requests in the ring buffer, and
+        * when each is retired we increment last_retired_head as the GPU
+        * must have finished processing the request and so we know we
+        * can advance the ringbuffer up to that position.
+        *
+        * last_retired_head is set to -1 after the value is consumed so
+        * we can detect new retirements.
+        */
+       u32 last_retired_head;
+};

And "struct intel_engine_cs" now groups all these elements into "buffer":

Quoted 12 lines

Review

Quoted 9 lines
(quoted diff) +1 -8
-       void            __iomem *virtual_start;
-       struct          drm_i915_gem_object *obj;
-       u32             head;
-       u32             tail;
-       int             space;
-       int             size;
-       int             effective_size;
-       u32             last_retired_head;
+       struct intel_ringbuffer buffer;

Is the idea to embed this new intel_ringbuffer struct into the lrc context structure so that we can share a bit of the low-level frobbing?

Yes, that is the idea.

Quoted 8 lines

I wonder
whether we should switch right away to a pointer and leave the engine_cs-

Quoted 1 line

ring pointer NULL for lrc. That would be good for catching bugs where we

accidentally mix up old and new styles. If you agree that a engine_cs->ring pointer would fit your design this is acked.
Btw for such code design issues I usually refer to Rusty's api design manifesto:

Quoted 6 lines

http://sweng.the-davies.net/Home/rustys-api-design-manifesto

Oopsing at runtime is still considerid a bad level, but much better than silently failing.

Again I recommend to look into coccinelle for the sed part of this.

Ok, "struct intel_ringbuffer *buffer;" it is, then (NULL when we use LRCs).

Quoted 41 lines
Quoted 8 lines

3) Introduce one context backing object per engine

(quoted diff) +3 -1
-       struct drm_i915_gem_object *obj;
+       struct {
+               struct drm_i915_gem_object *obj;
+       } engine[I915_NUM_RINGS];

Legacy code only ever uses engine[RCS], so I can use it everywhere in the

existing code.

Unsure about this. If I understand this correctly we only need to be able to support multiple backing objects for the same logical ring object (i.e. what is tracked by struct i915_hw_context) for the implicit per-filp context 0. But our handling of context id 0 is already magical, so we might as well add a bit more magic and shovel this array into the filp data structure:

(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 108e1ec2fa4b..e34db43dead3 100644

drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1825,7 +1825,9 @@ struct drm_i915_file_private {
 	} mm;
 	struct idr context_idr;
 
-	struct i915_hw_context *private_default_ctx;
+	/* default context for each ring, NULL if hw doesn't support hw

contexts

drivers/gpu/drm/i915/i915_drv.h +2 -0
+	 * (or fancy new lrcs) on that ring. */
+	struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];
 	atomic_t rps_wait_boost;
 };

Of course we need to add an i915_hw_context->engine_cs pointer and we need to check that at execbuf to make sure we don't run contexts on the wrong engine.
If we later on decide that we want to expose multiple hw contexts for !RCS to userspace we can easily add a bunch of ring flags to the context create ioctl. So this doesn't restrict us at all in the features we can support without jumping through hoops.

Quoted 3 lines

Also if we'd shovel all per-ring lrcs into the same i915_hw_context structure then we'd need to rename that and drop the _hw part - it's no longer a 1:1 correspondence to an actual hw ring/context/lrc/whatever wizzbang thingy.

Ok, so we create I915_NUM_RINGS contexts for the global default contexts, plus I915_NUM_RINGS contexts for every filp and 1 render context for every create ioctl.
But the magic stuff is going to pop out in many more places: I cannot idr_alloc/idr_find for the per-filp contexts, because all of them cannot have ctx->id = DEFAULT_CONTEXT_ID at the same time (I´ll have to special-case them by using dev_priv->private_default_ctx[RING] to find them). Of course, if you prefer, I can abstract away most of the functionality in i915_gem_context.c and make sure this kind magic is only done for the LRC path (similar to what you propose to do with intel_ringbuffer.c).

-- Oscar

#21 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 25 lines · Oscar
Quoted 25 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 108e1ec2fa4b..e34db43dead3 100644

drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1825,7 +1825,9 @@ struct drm_i915_file_private {
      } mm;
      struct idr context_idr;
 
-     struct i915_hw_context *private_default_ctx;
+     /* default context for each ring, NULL if hw doesn't support hw

contexts

drivers/gpu/drm/i915/i915_drv.h +2 -0
+      * (or fancy new lrcs) on that ring. */
+     struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];
      atomic_t rps_wait_boost;
 };

Of course we need to add an i915_hw_context->engine_cs pointer and we need to check that at execbuf to make sure we don't run contexts on the wrong engine.
If we later on decide that we want to expose multiple hw contexts for !RCS to userspace we can easily add a bunch of ring flags to the context create ioctl. So this doesn't restrict us at all in the features we can support without jumping through hoops.

Quoted 6 lines
Quoted 3 lines

Also if we'd shovel all per-ring lrcs into the same i915_hw_context structure then we'd need to rename that and drop the _hw part - it's no longer a 1:1 correspondence to an actual hw ring/context/lrc/whatever wizzbang thingy.

Ok, so we create I915_NUM_RINGS contexts for the global default contexts, plus I915_NUM_RINGS contexts for every filp and 1 render context for every create ioctl.
But the magic stuff is going to pop out in many more places: I cannot idr_alloc/idr_find for the per-filp contexts, because all of them cannot have ctx->id = DEFAULT_CONTEXT_ID at the same time (I´ll have to special-case them by using dev_priv->private_default_ctx[RING] to find them). Of course, if you prefer, I can abstract away most of the functionality in i915_gem_context.c and make sure this kind magic is only done for the LRC path (similar to what you propose to do with intel_ringbuffer.c).

Argh, forgotten about the pageflips again. But for those we already need some other context pointer, and thus far we've only supported ring-switching on one ring (well, almost everywhere at least). Since the mmio base pageflip patch seems mostly ready I think we could just merge that one first and then forget about ring-based pageflips for execlists. Way too much pain to be worth it really ;-)

For the default context special-casing I've somehow though we special-case that in the lookup code. But the code in there is a bit convoluted, so a bit of tidying up (and shoveling more of the checking and lookup logic into i915_gem_context.c) can't hurt really. Also we seem to lack error checking for the creation of the default context. -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
#22 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 52 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, May 19, 2014 2:53 PM
To: Mateo Lozano, Oscar
Cc: Lespiau, Damien; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 25 lines · Oscar
Quoted 25 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 108e1ec2fa4b..e34db43dead3 100644

drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1825,7 +1825,9 @@ struct drm_i915_file_private {
      } mm;
      struct idr context_idr;
 
-     struct i915_hw_context *private_default_ctx;
+     /* default context for each ring, NULL if hw doesn't support hw

contexts

drivers/gpu/drm/i915/i915_drv.h +2 -0
+      * (or fancy new lrcs) on that ring. */
+     struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];
      atomic_t rps_wait_boost;
 };

Of course we need to add an i915_hw_context->engine_cs pointer and we need to check that at execbuf to make sure we don't run contexts on the wrong engine.
If we later on decide that we want to expose multiple hw contexts for !RCS to userspace we can easily add a bunch of ring flags to the context create ioctl. So this doesn't restrict us at all in the features we can support without jumping through hoops.

Quoted 3 lines
Quoted 3 lines

Also if we'd shovel all per-ring lrcs into the same i915_hw_context structure then we'd need to rename that and drop the _hw part - it's no longer a 1:1 correspondence to an actual hw ring/context/lrc/whatever

wizzbang thingy.

Quoted 2 lines

Ok, so we create I915_NUM_RINGS contexts for the global default contexts,

plus I915_NUM_RINGS contexts for every filp and 1 render context for every create ioctl.

Quoted 1 line

But the magic stuff is going to pop out in many more places: I cannot

idr_alloc/idr_find for the per-filp contexts, because all of them cannot have ctx->id = DEFAULT_CONTEXT_ID at the same time (I´ll have to special-case them by using dev_priv->private_default_ctx[RING] to find them). Of course, if you prefer, I can abstract away most of the functionality in i915_gem_context.c and make sure this kind magic is only done for the LRC path (similar to what you propose to do with intel_ringbuffer.c).

Quoted 6 lines

Argh, forgotten about the pageflips again. But for those we already need some other context pointer, and thus far we've only supported ring-switching on one ring (well, almost everywhere at least). Since the mmio base pageflip patch seems mostly ready I think we could just merge that one first and then forget about ring-based pageflips for execlists. Way too much pain to be worth it really ;-)

Sound like a plan :)

Quoted 5 lines

For the default context special-casing I've somehow though we special-case that in the lookup code. But the code in there is a bit convoluted, so a bit of tidying up (and shoveling more of the checking and lookup logic into i915_gem_context.c) can't hurt really. Also we seem to lack error checking for the creation of the default context.

Nope, we don´t special case the per-filp default context search: it uses an idr_find, same as the others. Actually, I don´t really see why private_default_ctx is needed at all in the current code?

So, for the per-filp default contexts:

+ struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];

and we special-case the hell out of them?
for legacy and execlists code, or do you want to abstract i915_gem_context.c away as well?
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#23 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 67 lines · Oscar
Quoted 52 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, May 19, 2014 2:53 PM
To: Mateo Lozano, Oscar
Cc: Lespiau, Damien; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 25 lines · Oscar
Quoted 25 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index 108e1ec2fa4b..e34db43dead3 100644

drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1825,7 +1825,9 @@ struct drm_i915_file_private {
      } mm;
      struct idr context_idr;
 
-     struct i915_hw_context *private_default_ctx;
+     /* default context for each ring, NULL if hw doesn't support hw

contexts

drivers/gpu/drm/i915/i915_drv.h +2 -0
+      * (or fancy new lrcs) on that ring. */
+     struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];
      atomic_t rps_wait_boost;
 };

Of course we need to add an i915_hw_context->engine_cs pointer and we need to check that at execbuf to make sure we don't run contexts on the wrong engine.
If we later on decide that we want to expose multiple hw contexts for !RCS to userspace we can easily add a bunch of ring flags to the context create ioctl. So this doesn't restrict us at all in the features we can support without jumping through hoops.

Quoted 3 lines
Quoted 3 lines

Also if we'd shovel all per-ring lrcs into the same i915_hw_context structure then we'd need to rename that and drop the _hw part - it's no longer a 1:1 correspondence to an actual hw ring/context/lrc/whatever

wizzbang thingy.

Quoted 2 lines

Ok, so we create I915_NUM_RINGS contexts for the global default contexts,

plus I915_NUM_RINGS contexts for every filp and 1 render context for every create ioctl.

Quoted 1 line

But the magic stuff is going to pop out in many more places: I cannot

idr_alloc/idr_find for the per-filp contexts, because all of them cannot have ctx->id = DEFAULT_CONTEXT_ID at the same time (I´ll have to special-case them by using dev_priv->private_default_ctx[RING] to find them). Of course, if you prefer, I can abstract away most of the functionality in i915_gem_context.c and make sure this kind magic is only done for the LRC path (similar to what you propose to do with intel_ringbuffer.c).

Quoted 6 lines

Argh, forgotten about the pageflips again. But for those we already need some other context pointer, and thus far we've only supported ring-switching on one ring (well, almost everywhere at least). Since the mmio base pageflip patch seems mostly ready I think we could just merge that one first and then forget about ring-based pageflips for execlists. Way too much pain to be worth it really ;-)

Sound like a plan :)

Quoted 5 lines

For the default context special-casing I've somehow though we special-case that in the lookup code. But the code in there is a bit convoluted, so a bit of tidying up (and shoveling more of the checking and lookup logic into i915_gem_context.c) can't hurt really. Also we seem to lack error checking for the creation of the default context.

Quoted 8 lines

Nope, we don´t special case the per-filp default context search: it uses an idr_find, same as the others. Actually, I don´t really see why private_default_ctx is needed at all in the current code?

So, for the per-filp default contexts:

+ struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];

and we special-case the hell out of them?
for legacy and execlists code, or do you want to abstract i915_gem_context.c away as well?

I think special-casing the i915_gem_context_get function for the default context and using private_default_ctx a bit more sounds good. We need to adjust the idr allocator a bit though to reserve 0, and a bit of frobbing in the context create code.

Wrt ctx abstraction I think separate functions for execlist/legacy contexts should be good enough. The lookup/create/destroy logic should carry over.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#24 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 93 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, May 19, 2014 4:12 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; Lespiau, Damien; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 69 lines · Oscar
Quoted 60 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, May 19, 2014 2:53 PM
To: Mateo Lozano, Oscar
Cc: Lespiau, Damien; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 28 lines · Oscar
Quoted 28 lines
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_drv.h index
108e1ec2fa4b..e34db43dead3
100644

drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -1825,7 +1825,9 @@ struct drm_i915_file_private {
      } mm;
      struct idr context_idr;
 
-     struct i915_hw_context *private_default_ctx;
+     /* default context for each ring, NULL if hw doesn't
+ support hw

contexts

drivers/gpu/drm/i915/i915_drv.h +3 -0
+      * (or fancy new lrcs) on that ring. */
+     struct i915_hw_context
+ *private_default_ctx[I915_NUM_RINGS];
      atomic_t rps_wait_boost;
 };

Of course we need to add an i915_hw_context->engine_cs pointer and we need to check that at execbuf to make sure we don't run contexts on the wrong engine.
If we later on decide that we want to expose multiple hw contexts for !RCS to userspace we can easily add a bunch of ring flags to the context create ioctl. So this doesn't restrict us at all in the features we can support without jumping through hoops.

Quoted 4 lines
Quoted 4 lines

Also if we'd shovel all per-ring lrcs into the same i915_hw_context structure then we'd need to rename that and drop the _hw part - it's no longer a 1:1 correspondence to an actual hw ring/context/lrc/whatever

wizzbang thingy.

Quoted 3 lines

Ok, so we create I915_NUM_RINGS contexts for the global default contexts,

plus I915_NUM_RINGS contexts for every filp and 1 render context for every create ioctl.

Quoted 2 lines

But the magic stuff is going to pop out in many more places: I cannot

idr_alloc/idr_find for the per-filp contexts, because all of them cannot have
ctx->id = DEFAULT_CONTEXT_ID at the same time (I´ll have to ctx->special-case
them by using dev_priv->private_default_ctx[RING] to find them). Of course, if you prefer, I can abstract away most of the functionality in i915_gem_context.c and make sure this kind magic is only done for the LRC path (similar to what you propose to do with intel_ringbuffer.c).

Quoted 6 lines

Argh, forgotten about the pageflips again. But for those we already need some other context pointer, and thus far we've only supported ring-switching on one ring (well, almost everywhere at least). Since the mmio base pageflip patch seems mostly ready I think we could just merge that one first and then forget about ring-based pageflips for execlists. Way too much pain to be worth it really ;-)

Sound like a plan :)

Quoted 8 lines
Quoted 6 lines

For the default context special-casing I've somehow though we special-case that in the lookup code. But the code in there is a bit convoluted, so a bit of tidying up (and shoveling more of the checking and lookup logic into
i915_gem_context.c) can't hurt really. Also we seem to lack error checking for the creation of the default context.

Nope, we don´t special case the per-filp default context search: it uses an

idr_find, same as the others. Actually, I don´t really see why private_default_ctx is needed at all in the current code?

Quoted 5 lines

So, for the per-filp default contexts:

+ struct i915_hw_context *private_default_ctx[I915_NUM_RINGS];

Quoted 8 lines
Quoted 2 lines

and we special-case the hell out of them?
for legacy and execlists code, or do you want to abstract i915_gem_context.c

away as well?

I think special-casing the i915_gem_context_get function for the default context and using private_default_ctx a bit more sounds good. We need to adjust the idr allocator a bit though to reserve 0, and a bit of frobbing in the context create code.

Ok, no problem. I´ll send an early patch that uses private_default_ctx to do the special casing (no functionality change) together with the other refactoring patches.

Quoted 2 lines

Wrt ctx abstraction I think separate functions for execlist/legacy contexts should be good enough. The lookup/create/destroy logic should carry over.

Including the creation of I915_NUM_RINGS contexts per-filp? do you want that to happen for the legacy case as well? This implies a number of other changes, like struct intel_engine *last_ring not making sense anymore and frobbing i915_gem_create_context so that we can create more than one context with the same ppgtt...

#25 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 9 lines · Oscar
Quoted 4 lines

I think special-casing the i915_gem_context_get function for the default context and using private_default_ctx a bit more sounds good. We need to adjust the idr allocator a bit though to reserve 0, and a bit of frobbing in the context create code.

Ok, no problem. I´ll send an early patch that uses private_default_ctx to do the special casing (no functionality change) together with the other refactoring patches.

Quoted 8 lines
Quoted 2 lines

Wrt ctx abstraction I think separate functions for execlist/legacy contexts should be good enough. The lookup/create/destroy logic should carry over.

Including the creation of I915_NUM_RINGS contexts per-filp? do you want that to happen for the legacy case as well? This implies a number of other changes, like struct intel_engine *last_ring not making sense anymore and frobbing i915_gem_create_context so that we can create more than one context with the same ppgtt...

Damn, I didn't think this through. ctx->hang_stats already tracks random stuff for logical contexts and we only have one of those for the implicit per-filp default context. Still, allocating backing storage for the big execlist contexts looks really wasteful since a lot of userspace will just use 1 ring (e.g. mesa or opencl).

Also we've decided to at least for now support vcs2 implicitly, so I915_NUM_RINGS is kinda already the wrong thing to use (presuming we can indeed switch hw contexts between vcs and vcs2).

Otoh adding fake contexts for the legacy case also feels ugly.

So maybe we should rename i915_hw_context to i915_context and figure out a sane design for the differences later on. Same option would be to embedded struct i915_context into a i915_legacy_rcs_context and i915_execlist_context structures, but meh.

So now I think we should:
a) s/i915_hw_context/i915_context/ since its long past a 1:1 relationship with hw
b) create a union in i915_context for legacy and execlists contexts. Legacy contexts would just have the single gem bo backing storage needed for rcs, execlists contexts would have an array of rings plus the backing storage (since the ring is just embedded in there).

How does this sound?

If we decide later on that the union is too ugly and we want a cleaner split, we can do the usual subclassing later on.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#26 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

Quoted 53 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, May 19, 2014 4:50 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; Lespiau, Damien; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 11 lines · Oscar
Quoted 4 lines

I think special-casing the i915_gem_context_get function for the default context and using private_default_ctx a bit more sounds good. We need to adjust the idr allocator a bit though to reserve 0, and a bit of frobbing in the context create code.

Ok, no problem. I´ll send an early patch that uses private_default_ctx to do the special casing (no functionality change) together with the other refactoring patches.

Quoted 2 lines

Wrt ctx abstraction I think separate functions for execlist/legacy contexts should be good enough. The lookup/create/destroy logic should

carry over.

Quoted 6 lines

Including the creation of I915_NUM_RINGS contexts per-filp? do you want that to happen for the legacy case as well? This implies a number of other changes, like struct intel_engine *last_ring not making sense anymore and frobbing i915_gem_create_context so that we can create more than one context with the same ppgtt...

Damn, I didn't think this through. ctx->hang_stats already tracks random stuff for logical contexts and we only have one of those for the implicit per-filp default context. Still, allocating backing storage for the big execlist contexts looks really wasteful since a lot of userspace will just use 1 ring (e.g. mesa or opencl).

Also we've decided to at least for now support vcs2 implicitly, so I915_NUM_RINGS is kinda already the wrong thing to use (presuming we can indeed switch hw contexts between vcs and vcs2).

Otoh adding fake contexts for the legacy case also feels ugly.

So maybe we should rename i915_hw_context to i915_context and figure out a sane design for the differences later on. Same option would be to embedded struct i915_context into a i915_legacy_rcs_context and i915_execlist_context structures, but meh.

So now I think we should:
a) s/i915_hw_context/i915_context/ since its long past a 1:1 relationship with hw
b) create a union in i915_context for legacy and execlists contexts. Legacy contexts would just have the single gem bo backing storage needed for rcs, execlists contexts would have an array of rings plus the backing storage (since the ring is just embedded in there).

Quoted 1 line

How does this sound?

Sounds good: other than using a union, my latest patchset already looked like this :) (and this means bringing back from life the deferred ctx creation idea...)

Summarizing the entire conversation, we have agreed to three refactoring patches:

A) s/intel_ring_buffer/intel_engine_cs/
B) Split the ringbuffers and the rings (the ringbuffer lives inside the ring thanks to a pointer, that will be NULL for the LRC case).
C) s/i915_hw_context/i915_context/

Plus an LRC-specific patch:

D) Introduce one context backing object per engine (using a union that leaves one backing object for the legacy case and an array of backing objects and ringbuffers for the LRC case).

BTW: do you want me to kill private_default_ctx as well? It doesn´t look very useful...

#28 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 8 lines

-----Original Message-----
From: Volkin, Bradley D
Sent: Monday, May 19, 2014 5:24 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 6 lines
Quoted 1 line · Oscar

BTW: do you want me to kill private_default_ctx as well? It doesn´t look very

useful...

Isn't private_default_ctx the one that's actually used when userspace specifies DEFAULT_CONTEXT_ID?

What I see is a normal idr_find:

struct i915_hw_context *
i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)

{
	struct i915_hw_context *ctx;

	ctx = (struct i915_hw_context *)idr_find(&file_priv->context_idr, id);
	if (!ctx)
		return ERR_PTR(-ENOENT);

	return ctx;
}

I think Chris has almost killed it off completely:

commit 691e6415c891b8b2b082a120b896b443531c4d45

Author: Chris Wilson <[email protected]>
Date:   Wed Apr 9 09:07:36 2014 +0100

drm/i915: Always use kref tracking for all contexts.

If we always initialize kref for the context, even if we are using fake contexts for hangstats when there is no hw support, we can forgo the dance to dereference the ctx->obj and inspect whether we are permitted to use kref inside i915_gem_context_reference() and _unreference().

My ulterior motive here is to improve the debugging of a use-after-free of ctx->obj. This patch avoids the dereference here and instead forces the assertion checks associated with kref.

v2: Refactor the fake contexts to being even more like the real contexts, so that there is much less duplicated and special case code.

v3: Tweaks.
v4: Tweaks, minor.

#29 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 8 lines · Oscar
Quoted 8 lines

-----Original Message-----
From: Volkin, Bradley D
Sent: Monday, May 19, 2014 5:24 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 8 lines
Quoted 6 lines · Oscar
Quoted 1 line

BTW: do you want me to kill private_default_ctx as well? It doesn´t look very

useful...

Isn't private_default_ctx the one that's actually used when userspace specifies DEFAULT_CONTEXT_ID?

What I see is a normal idr_find:

Right, but i915_gem_context_open() does:

	idr_init(&file_priv->context_idr);
	file_priv->private_default_ctx =
		i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev));

And i915_gem_create_context() calls __create_hw_context(), which does:

	if (file_priv != NULL) {
		ret = idr_alloc(&file_priv->context_idr, ctx,
				DEFAULT_CONTEXT_ID, 0, GFP_KERNEL);
		if (ret < 0)
			goto err_out;
	} else
		ret = DEFAULT_CONTEXT_ID;

So I think the idr_find() should indirectly give us private_default_ctx.

Brad

Quoted 35 lines

struct i915_hw_context *
i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)

{
	struct i915_hw_context *ctx;

	ctx = (struct i915_hw_context *)idr_find(&file_priv->context_idr, id);
	if (!ctx)
		return ERR_PTR(-ENOENT);

	return ctx;
}

I think Chris has almost killed it off completely:

commit 691e6415c891b8b2b082a120b896b443531c4d45

Author: Chris Wilson <[email protected]>
Date:   Wed Apr 9 09:07:36 2014 +0100

drm/i915: Always use kref tracking for all contexts.

If we always initialize kref for the context, even if we are using fake contexts for hangstats when there is no hw support, we can forgo the dance to dereference the ctx->obj and inspect whether we are permitted to use kref inside i915_gem_context_reference() and _unreference().

My ulterior motive here is to improve the debugging of a use-after-free of ctx->obj. This patch avoids the dereference here and instead forces the assertion checks associated with kref.

v2: Refactor the fake contexts to being even more like the real contexts, so that there is much less duplicated and special case code.

v3: Tweaks.
v4: Tweaks, minor.

#30 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 42 lines

-----Original Message-----
From: Volkin, Bradley D
Sent: Monday, May 19, 2014 5:41 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 9 lines · Oscar
Quoted 9 lines

-----Original Message-----
From: Volkin, Bradley D
Sent: Monday, May 19, 2014 5:24 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

On Mon, May 19, 2014 at 09:12:26AM -0700, Mateo Lozano, Oscar wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

BTW: do you want me to kill private_default_ctx as well? It doesn´t look very

useful...

Isn't private_default_ctx the one that's actually used when userspace specifies DEFAULT_CONTEXT_ID?

What I see is a normal idr_find:

Right, but i915_gem_context_open() does:

	idr_init(&file_priv->context_idr);
	file_priv->private_default_ctx =
		i915_gem_create_context(dev, file_priv,

USES_FULL_PPGTT(dev));

And i915_gem_create_context() calls __create_hw_context(), which does:

	if (file_priv != NULL) {
		ret = idr_alloc(&file_priv->context_idr, ctx,
				DEFAULT_CONTEXT_ID, 0, GFP_KERNEL);
		if (ret < 0)
			goto err_out;
	} else
		ret = DEFAULT_CONTEXT_ID;
Quoted 1 line

So I think the idr_find() should indirectly give us private_default_ctx.

Exactly!: why are we keeping file_priv->private_default_ctx then? If you need to get it somewehere, you can simply do idr_find(&file_priv->context_idr, DEFAULT_CONTEXT_ID);

#31 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

Quoted 42 lines · Oscar
Quoted 42 lines

-----Original Message-----
From: Volkin, Bradley D
Sent: Monday, May 19, 2014 5:41 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 9 lines · Oscar
Quoted 9 lines

-----Original Message-----
From: Volkin, Bradley D
Sent: Monday, May 19, 2014 5:24 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

On Mon, May 19, 2014 at 09:12:26AM -0700, Mateo Lozano, Oscar wrote:

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

BTW: do you want me to kill private_default_ctx as well? It doesn´t look very

useful...

Isn't private_default_ctx the one that's actually used when userspace specifies DEFAULT_CONTEXT_ID?

What I see is a normal idr_find:

Right, but i915_gem_context_open() does:

	idr_init(&file_priv->context_idr);
	file_priv->private_default_ctx =
		i915_gem_create_context(dev, file_priv,

USES_FULL_PPGTT(dev));

And i915_gem_create_context() calls __create_hw_context(), which does:

	if (file_priv != NULL) {
		ret = idr_alloc(&file_priv->context_idr, ctx,
				DEFAULT_CONTEXT_ID, 0, GFP_KERNEL);
		if (ret < 0)
			goto err_out;
	} else
		ret = DEFAULT_CONTEXT_ID;
Quoted 3 lines
Quoted 1 line

So I think the idr_find() should indirectly give us private_default_ctx.

Exactly!: why are we keeping file_priv->private_default_ctx then? If you need to get it somewehere, you can simply do idr_find(&file_priv->context_idr, DEFAULT_CONTEXT_ID);

Oh, sorry, I completely misunderstood what you were suggesting. Kill away :)

#32 lore raw

Re: [PATCH 06/50] drm/i915: s/intel_ring_buffer/intel_engine

In reply to Mateo Lozano, Oscar
Quoted 62 lines · Oscar

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

Quoted 53 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, May 19, 2014 4:50 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; Lespiau, Damien; [email protected]
Subject: Re: [Intel-gfx] [PATCH 06/50] drm/i915:
s/intel_ring_buffer/intel_engine

Quoted 11 lines · Oscar
Quoted 4 lines

I think special-casing the i915_gem_context_get function for the default context and using private_default_ctx a bit more sounds good. We need to adjust the idr allocator a bit though to reserve 0, and a bit of frobbing in the context create code.

Ok, no problem. I´ll send an early patch that uses private_default_ctx to do the special casing (no functionality change) together with the other refactoring patches.

Quoted 2 lines

Wrt ctx abstraction I think separate functions for execlist/legacy contexts should be good enough. The lookup/create/destroy logic should

carry over.

Quoted 6 lines

Including the creation of I915_NUM_RINGS contexts per-filp? do you want that to happen for the legacy case as well? This implies a number of other changes, like struct intel_engine *last_ring not making sense anymore and frobbing i915_gem_create_context so that we can create more than one context with the same ppgtt...

Damn, I didn't think this through. ctx->hang_stats already tracks random stuff for logical contexts and we only have one of those for the implicit per-filp default context. Still, allocating backing storage for the big execlist contexts looks really wasteful since a lot of userspace will just use 1 ring (e.g. mesa or opencl).

Also we've decided to at least for now support vcs2 implicitly, so I915_NUM_RINGS is kinda already the wrong thing to use (presuming we can indeed switch hw contexts between vcs and vcs2).

Otoh adding fake contexts for the legacy case also feels ugly.

So maybe we should rename i915_hw_context to i915_context and figure out a sane design for the differences later on. Same option would be to embedded struct i915_context into a i915_legacy_rcs_context and i915_execlist_context structures, but meh.

So now I think we should:
a) s/i915_hw_context/i915_context/ since its long past a 1:1 relationship with hw
b) create a union in i915_context for legacy and execlists contexts. Legacy contexts would just have the single gem bo backing storage needed for rcs, execlists contexts would have an array of rings plus the backing storage (since the ring is just embedded in there).

Quoted 4 lines
Quoted 1 line

How does this sound?

Sounds good: other than using a union, my latest patchset already looked like this :) (and this means bringing back from life the deferred ctx creation idea...)

Yeah, it took me a while to see the light here ;-) But if we split up the sw ctx tracking structure a bit from the low-level stuff I think this indeed makes sense. The lazy context allocation simply irked me while we still called the structure a _hw_ context. Which at that point it just isn't any more.

Quoted 8 lines

Summarizing the entire conversation, we have agreed to three refactoring patches:

A) s/intel_ring_buffer/intel_engine_cs/
B) Split the ringbuffers and the rings (the ringbuffer lives inside the ring thanks to a pointer, that will be NULL for the LRC case).
C) s/i915_hw_context/i915_context/

Quoted 5 lines

Plus an LRC-specific patch:

D) Introduce one context backing object per engine (using a union that leaves one backing object for the legacy case and an array of backing objects and ringbuffers for the LRC case).

Yes, ack on this prep-work refactor plan. And in case I didn't mention it yet ofc ack for shoveling all the new execlist stuff into intel_lrc.c.

Btw for intel_lrc.c can you please (at the end is probably best) add a patch to add kerneldoc for non-static functions and pull them into the i915 guide? Similar to how we've done it for Brad's cmd parser. I think we need better docs, so best to get started with new features.

Quoted 1 line

BTW: do you want me to kill private_default_ctx as well? It doesn´t look very useful...

Yeah, might as well throw this on top.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#33 lore raw

PATCH 7/50 drm/i915: Split the ringbuffers and the rings

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Following the logic behind the previous patch, the ringbuffers and the rings belong in different structs. For the time being, we will keep the relationship between the two via the default_ringbuf living inside each ring.

This commit should not introduce functional changes (unless I made an error, this is).

---
 drivers/gpu/drm/i915/i915_dma.c         |  25 ++++---
 drivers/gpu/drm/i915/i915_gem.c         |   2 +-
 drivers/gpu/drm/i915/i915_gpu_error.c   |   6 +-
 drivers/gpu/drm/i915/i915_irq.c         |   9 +--
 drivers/gpu/drm/i915/intel_ringbuffer.c | 123 ++++++++++++++++++--------------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  61 ++++++++++------
 6 files changed, 131 insertions(+), 95 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +14 -11
index 5263d63..8ec8963 100644
@@ -47,6 +47,8 @@
 
 #define LP_RING(d) (&((struct drm_i915_private *)(d))->ring[RCS])
 
+#define LP_RINGBUF(d) (&((struct drm_i915_private *)(d))->ring[RCS].default_ringbuf)
+
 #define BEGIN_LP_RING(n) \
 	intel_ring_begin(LP_RING(dev_priv), (n))
 
@@ -63,7 +65,7 @@
  * has access to the ring.
  */
 #define RING_LOCK_TEST_WITH_RETURN(dev, file) do {			\
-	if (LP_RING(dev->dev_private)->obj == NULL)			\
+	if (LP_RINGBUF(dev->dev_private)->obj == NULL)			\
 		LOCK_TEST_WITH_RETURN(dev, file);			\
 } while (0)
 
@@ -140,6 +142,7 @@ void i915_kernel_lost_context(struct drm_device * dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_master_private *master_priv;
 	struct intel_engine *ring = LP_RING(dev_priv);
+	struct intel_ringbuffer *ringbuf = LP_RINGBUF(dev_priv);
 
 	/*
 	 * We should never lose context on the ring with modesetting
@@ -148,17 +151,17 @@ void i915_kernel_lost_context(struct drm_device * dev)
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return;
 
-	ring->head = I915_READ_HEAD(ring) & HEAD_ADDR;
-	ring->tail = I915_READ_TAIL(ring) & TAIL_ADDR;
-	ring->space = ring->head - (ring->tail + I915_RING_FREE_SPACE);
-	if (ring->space < 0)
-		ring->space += ring->size;
+	ringbuf->head = I915_READ_HEAD(ring) & HEAD_ADDR;
+	ringbuf->tail = I915_READ_TAIL(ring) & TAIL_ADDR;
+	ringbuf->space = ringbuf->head - (ringbuf->tail + I915_RING_FREE_SPACE);
+	if (ringbuf->space < 0)
+		ringbuf->space += ringbuf->size;
 
 	if (!dev->primary->master)
 		return;
 
 	master_priv = dev->primary->master->driver_priv;
-	if (ring->head == ring->tail && master_priv->sarea_priv)
+	if (ringbuf->head == ringbuf->tail && master_priv->sarea_priv)
 		master_priv->sarea_priv->perf_boxes |= I915_BOX_RING_EMPTY;
 }
 
@@ -201,7 +204,7 @@ static int i915_initialize(struct drm_device * dev, drm_i915_init_t * init)
 	}
 
 	if (init->ring_size != 0) {
-		if (LP_RING(dev_priv)->obj != NULL) {
+		if (LP_RINGBUF(dev_priv)->obj != NULL) {
 			i915_dma_cleanup(dev);
 			DRM_ERROR("Client tried to initialize ringbuffer in "
 				  "GEM mode\n");
@@ -238,7 +241,7 @@ static int i915_dma_resume(struct drm_device * dev)
 
 	DRM_DEBUG_DRIVER("%s\n", __func__);
 
-	if (ring->virtual_start == NULL) {
+	if (__get_ringbuf(ring)->virtual_start == NULL) {
 		DRM_ERROR("can not ioremap virtual address for"
 			  " ring buffer\n");
 		return -ENOMEM;
@@ -360,7 +363,7 @@ static int i915_emit_cmds(struct drm_device * dev, int *buffer, int dwords)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int i, ret;
 
-	if ((dwords+1) * sizeof(int) >= LP_RING(dev_priv)->size - 8)
+	if ((dwords+1) * sizeof(int) >= LP_RINGBUF(dev_priv)->size - 8)
 		return -EINVAL;
 
 	for (i = 0; i < dwords;) {
@@ -823,7 +826,7 @@ static int i915_irq_emit(struct drm_device *dev, void *data,
 	if (drm_core_check_feature(dev, DRIVER_MODESET))
 		return -ENODEV;
 
-	if (!dev_priv || !LP_RING(dev_priv)->virtual_start) {
+	if (!dev_priv || !LP_RINGBUF(dev_priv)->virtual_start) {
 		DRM_ERROR("called with no initialization\n");
 		return -EINVAL;
 	}
drivers/gpu/drm/i915/i915_gem.c +1 -1
index a3b697b..d9253c4 100644
@@ -2494,7 +2494,7 @@ i915_gem_retire_requests_ring(struct intel_engine *ring)
 		 * of tail of the request to update the last known position
 		 * of the GPU head.
 		 */
-		ring->last_retired_head = request->tail;
+		__get_ringbuf(ring)->last_retired_head = request->tail;
 
 		i915_gem_free_request(request);
 	}
drivers/gpu/drm/i915/i915_gpu_error.c +3 -3
index 0853db3..a7b165f 100644
@@ -823,8 +823,8 @@ static void i915_record_ring_state(struct drm_device *dev,
 		ering->hws = I915_READ(mmio);
 	}
 
-	ering->cpu_ring_head = ring->head;
-	ering->cpu_ring_tail = ring->tail;
+	ering->cpu_ring_head = __get_ringbuf(ring)->head;
+	ering->cpu_ring_tail = __get_ringbuf(ring)->tail;
 
 	ering->hangcheck_score = ring->hangcheck.score;
 	ering->hangcheck_action = ring->hangcheck.action;
@@ -928,7 +928,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 		}
 
 		error->ring[i].ringbuffer =
-			i915_error_ggtt_object_create(dev_priv, ring->obj);
+			i915_error_ggtt_object_create(dev_priv, __get_ringbuf(ring)->obj);
 
 		if (ring->status_page.obj)
 			error->ring[i].hws_page =
drivers/gpu/drm/i915/i915_irq.c +5 -4
index 58c8812..e0c3a01 100644
@@ -1079,7 +1079,7 @@ static void ironlake_rps_change_irq_handler(struct drm_device *dev)
 static void notify_ring(struct drm_device *dev,
 			struct intel_engine *ring)
 {
-	if (ring->obj == NULL)
+	if (!intel_ring_initialized(ring))
 		return;
 
 	trace_i915_gem_request_complete(ring);
@@ -2610,6 +2610,7 @@ static struct intel_engine *
 semaphore_waits_for(struct intel_engine *ring, u32 *seqno)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	struct intel_ringbuffer *ringbuf = __get_ringbuf(ring);
 	u32 cmd, ipehr, head;
 	int i;
 
@@ -2632,10 +2633,10 @@ semaphore_waits_for(struct intel_engine *ring, u32 *seqno)
 		 * our ring is smaller than what the hardware (and hence
 		 * HEAD_ADDR) allows. Also handles wrap-around.
 		 */
-		head &= ring->size - 1;
+		head &= ringbuf->size - 1;
 
 		/* This here seems to blow up */
-		cmd = ioread32(ring->virtual_start + head);
+		cmd = ioread32(ringbuf->virtual_start + head);
 		if (cmd == ipehr)
 			break;
 
@@ -2645,7 +2646,7 @@ semaphore_waits_for(struct intel_engine *ring, u32 *seqno)
 	if (!i)
 		return NULL;
 
-	*seqno = ioread32(ring->virtual_start + head + 4) + 1;
+	*seqno = ioread32(ringbuf->virtual_start + head + 4) + 1;
 	return semaphore_wait_to_signaller_ring(ring, ipehr);
 }
 
drivers/gpu/drm/i915/intel_ringbuffer.c +70 -53

308 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +38 -23

107 lines not on this page · raw message

Signature · 1 line
1.9.0
#34 lore raw

PATCH 8/50 drm/i915: Rename functions that mention ringbuffers (meaning rings)

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Continue with the refactoring: do not init or clean a "ringbuffer" when you actually mean a "ring", because they are not the same thing anymore.

Again, no functional changes.

---
 drivers/gpu/drm/i915/i915_dma.c         |  6 +++---
 drivers/gpu/drm/i915/i915_drv.h         |  2 +-
 drivers/gpu/drm/i915/i915_gem.c         | 30 +++++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.c | 30 +++++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h | 14 +++++++-------
 5 files changed, 41 insertions(+), 41 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +3 -3
index 8ec8963..eb3ce6d 100644
@@ -179,7 +179,7 @@ static int i915_dma_cleanup(struct drm_device * dev)
 
 	mutex_lock(&dev->struct_mutex);
 	for (i = 0; i < I915_NUM_RINGS; i++)
-		intel_cleanup_ring_buffer(&dev_priv->ring[i]);
+		intel_cleanup_ring(&dev_priv->ring[i]);
 	mutex_unlock(&dev->struct_mutex);
 
 	/* Clear the HWS virtual address at teardown */
@@ -1383,7 +1383,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
 cleanup_gem:
 	mutex_lock(&dev->struct_mutex);
-	i915_gem_cleanup_ringbuffer(dev);
+	i915_gem_cleanup_ring(dev);
 	i915_gem_context_fini(dev);
 	mutex_unlock(&dev->struct_mutex);
 	WARN_ON(dev_priv->mm.aliasing_ppgtt);
@@ -1839,7 +1839,7 @@ int i915_driver_unload(struct drm_device *dev)
 
 		mutex_lock(&dev->struct_mutex);
 		i915_gem_free_all_phys_object(dev);
-		i915_gem_cleanup_ringbuffer(dev);
+		i915_gem_cleanup_ring(dev);
 		i915_gem_context_fini(dev);
 		WARN_ON(dev_priv->mm.aliasing_ppgtt);
 		mutex_unlock(&dev->struct_mutex);
drivers/gpu/drm/i915/i915_drv.h +1 -1
index 3b7a36f9..ee27ce8 100644
@@ -2266,7 +2266,7 @@ int __must_check i915_gem_init(struct drm_device *dev);
 int __must_check i915_gem_init_hw(struct drm_device *dev);
 int i915_gem_l3_remap(struct intel_engine *ring, int slice);
 void i915_gem_init_swizzling(struct drm_device *dev);
-void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
+void i915_gem_cleanup_ring(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 *ring,
drivers/gpu/drm/i915/i915_gem.c +15 -15
index d9253c4..e7565d9 100644
@@ -4262,7 +4262,7 @@ i915_gem_stop_ringbuffers(struct drm_device *dev)
 	int i;
 
 	for_each_active_ring(ring, dev_priv, i)
-		intel_stop_ring_buffer(ring);
+		intel_stop_ring(ring);
 }
 
 int
@@ -4384,30 +4384,30 @@ static int i915_gem_init_rings(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret;
 
-	ret = intel_init_render_ring_buffer(dev);
+	ret = intel_init_render_ring(dev);
 	if (ret)
 		return ret;
 
 	if (HAS_BSD(dev)) {
-		ret = intel_init_bsd_ring_buffer(dev);
+		ret = intel_init_bsd_ring(dev);
 		if (ret)
 			goto cleanup_render_ring;
 	}
 
 	if (intel_enable_blt(dev)) {
-		ret = intel_init_blt_ring_buffer(dev);
+		ret = intel_init_blt_ring(dev);
 		if (ret)
 			goto cleanup_bsd_ring;
 	}
 
 	if (HAS_VEBOX(dev)) {
-		ret = intel_init_vebox_ring_buffer(dev);
+		ret = intel_init_vebox_ring(dev);
 		if (ret)
 			goto cleanup_blt_ring;
 	}
 
 	if (HAS_BSD2(dev)) {
-		ret = intel_init_bsd2_ring_buffer(dev);
+		ret = intel_init_bsd2_ring(dev);
 		if (ret)
 			goto cleanup_vebox_ring;
 	}
@@ -4419,15 +4419,15 @@ static int i915_gem_init_rings(struct drm_device *dev)
 	return 0;
 
 cleanup_bsd2_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[VCS2]);
+	intel_cleanup_ring(&dev_priv->ring[VCS2]);
 cleanup_vebox_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[VECS]);
+	intel_cleanup_ring(&dev_priv->ring[VECS]);
 cleanup_blt_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[BCS]);
+	intel_cleanup_ring(&dev_priv->ring[BCS]);
 cleanup_bsd_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[VCS]);
+	intel_cleanup_ring(&dev_priv->ring[VCS]);
 cleanup_render_ring:
-	intel_cleanup_ring_buffer(&dev_priv->ring[RCS]);
+	intel_cleanup_ring(&dev_priv->ring[RCS]);
 
 	return ret;
 }
@@ -4479,7 +4479,7 @@ i915_gem_init_hw(struct drm_device *dev)
 	ret = i915_gem_context_enable(dev_priv);
 	if (ret && ret != -EIO) {
 		DRM_ERROR("Context enable failed %d\n", ret);
-		i915_gem_cleanup_ringbuffer(dev);
+		i915_gem_cleanup_ring(dev);
 	}
 
 	return ret;
@@ -4529,14 +4529,14 @@ int i915_gem_init(struct drm_device *dev)
 }
 
 void
-i915_gem_cleanup_ringbuffer(struct drm_device *dev)
+i915_gem_cleanup_ring(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring;
 	int i;
 
 	for_each_active_ring(ring, dev_priv, i)
-		intel_cleanup_ring_buffer(ring);
+		intel_cleanup_ring(ring);
 }
 
 int
@@ -4573,7 +4573,7 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
 	return 0;
 
 cleanup_ringbuffer:
-	i915_gem_cleanup_ringbuffer(dev);
+	i915_gem_cleanup_ring(dev);
 	dev_priv->ums.mm_suspended = 1;
 	mutex_unlock(&dev->struct_mutex);
 
drivers/gpu/drm/i915/intel_ringbuffer.c +15 -15
index f02c21e..6d14dcb 100644
@@ -1431,8 +1431,8 @@ err_unref:
 	return ret;
 }
 
-static int intel_init_ring_buffer(struct drm_device *dev,
-				  struct intel_engine *ring)
+static int intel_init_ring(struct drm_device *dev,
+			   struct intel_engine *ring)
 {
 	struct intel_ringbuffer *ringbuf = __get_ringbuf(ring);
 	int ret;
@@ -1474,7 +1474,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 	return ring->init(ring);
 }
 
-void intel_cleanup_ring_buffer(struct intel_engine *ring)
+void intel_cleanup_ring(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = to_i915(ring->dev);
 	struct intel_ringbuffer *ringbuf = __get_ringbuf(ring);
@@ -1482,7 +1482,7 @@ void intel_cleanup_ring_buffer(struct intel_engine *ring)
 	if (ringbuf->obj == NULL)
 		return;
 
-	intel_stop_ring_buffer(ring);
+	intel_stop_ring(ring);
 	WARN_ON((I915_READ_MODE(ring) & MODE_IDLE) == 0);
 
 	intel_destroy_ring_buffer(ring);
@@ -1925,7 +1925,7 @@ static int gen6_ring_flush(struct intel_engine *ring,
 	return 0;
 }
 
-int intel_init_render_ring_buffer(struct drm_device *dev)
+int intel_init_render_ring(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[RCS];
@@ -2028,7 +2028,7 @@ int intel_init_render_ring_buffer(struct drm_device *dev)
 		ring->scratch.gtt_offset = i915_gem_obj_ggtt_offset(obj);
 	}
 
-	return intel_init_ring_buffer(dev, ring);
+	return intel_init_ring(dev, ring);
 }
 
 int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
@@ -2095,7 +2095,7 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
 	return 0;
 }
 
-int intel_init_bsd_ring_buffer(struct drm_device *dev)
+int intel_init_bsd_ring(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[VCS];
@@ -2159,14 +2159,14 @@ int intel_init_bsd_ring_buffer(struct drm_device *dev)
 	}
 	ring->init = init_ring_common;
 
-	return intel_init_ring_buffer(dev, ring);
+	return intel_init_ring(dev, ring);
 }
 
 /**
  * Initialize the second BSD ring for Broadwell GT3.
  * It is noted that this only exists on Broadwell GT3.
  */
-int intel_init_bsd2_ring_buffer(struct drm_device *dev)
+int intel_init_bsd2_ring(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[VCS2];
@@ -2207,10 +2207,10 @@ int intel_init_bsd2_ring_buffer(struct drm_device *dev)
 
 	ring->init = init_ring_common;
 
-	return intel_init_ring_buffer(dev, ring);
+	return intel_init_ring(dev, ring);
 }
 
-int intel_init_blt_ring_buffer(struct drm_device *dev)
+int intel_init_blt_ring(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[BCS];
@@ -2252,10 +2252,10 @@ int intel_init_blt_ring_buffer(struct drm_device *dev)
 	ring->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC;
 	ring->init = init_ring_common;
 
-	return intel_init_ring_buffer(dev, ring);
+	return intel_init_ring(dev, ring);
 }
 
-int intel_init_vebox_ring_buffer(struct drm_device *dev)
+int intel_init_vebox_ring(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[VECS];
@@ -2292,7 +2292,7 @@ int intel_init_vebox_ring_buffer(struct drm_device *dev)
 	ring->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC;
 	ring->init = init_ring_common;
 
-	return intel_init_ring_buffer(dev, ring);
+	return intel_init_ring(dev, ring);
 }
 
 int
@@ -2334,7 +2334,7 @@ intel_ring_invalidate_all_caches(struct intel_engine *ring)
 }
 
 void
-intel_stop_ring_buffer(struct intel_engine *ring)
+intel_stop_ring(struct intel_engine *ring)
 {
 	int ret;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +7 -7
index 7299bff..c9328fd 100644
@@ -286,8 +286,8 @@ intel_write_status_page(struct intel_engine *ring,
 #define I915_GEM_HWS_SCRATCH_INDEX	0x30
 #define I915_GEM_HWS_SCRATCH_ADDR (I915_GEM_HWS_SCRATCH_INDEX << MI_STORE_DWORD_INDEX_SHIFT)
 
-void intel_stop_ring_buffer(struct intel_engine *ring);
-void intel_cleanup_ring_buffer(struct intel_engine *ring);
+void intel_stop_ring(struct intel_engine *ring);
+void intel_cleanup_ring(struct intel_engine *ring);
 
 int __must_check intel_ring_begin(struct intel_engine *ring, int n);
 int __must_check intel_ring_cacheline_align(struct intel_engine *ring);
@@ -313,11 +313,11 @@ int intel_ring_flush_all_caches(struct intel_engine *ring);
 int intel_ring_invalidate_all_caches(struct intel_engine *ring);
 
 void intel_init_rings_early(struct drm_device *dev);
-int intel_init_render_ring_buffer(struct drm_device *dev);
-int intel_init_bsd_ring_buffer(struct drm_device *dev);
-int intel_init_bsd2_ring_buffer(struct drm_device *dev);
-int intel_init_blt_ring_buffer(struct drm_device *dev);
-int intel_init_vebox_ring_buffer(struct drm_device *dev);
+int intel_init_render_ring(struct drm_device *dev);
+int intel_init_bsd_ring(struct drm_device *dev);
+int intel_init_bsd2_ring(struct drm_device *dev);
+int intel_init_blt_ring(struct drm_device *dev);
+int intel_init_vebox_ring(struct drm_device *dev);
 
 u64 intel_ring_get_active_head(struct intel_engine *ring);
 void intel_ring_setup_status_page(struct intel_engine *ring);
Signature · 1 line
1.9.0
#35 lore raw

PATCH 9/50 drm/i915: Plumb the context everywhere in the execbuffer path

In reply to [email protected]

From: Oscar Mateo <[email protected]>

The context are going to become very important pretty soon, and we need to be able to access them in a number of places inside the command submission path. The idea is that, when we need to place commands inside a ringbuffer or update the tail register, we know which context we are working with.

We left intel_ring_begin() as a function macro to quickly adapt legacy code, an introduce intel_ringbuffer_begin() as the first of a set of new functions for ringbuffer manipulation (the rest will come in subsequent patches).

No functional changes.

v2: Do not set the context to NULL. In legacy code, set it to the default ring context (even if it doesn't get used later on).

---
 drivers/gpu/drm/i915/i915_dma.c            |  2 +-
 drivers/gpu/drm/i915/i915_drv.h            |  3 +-
 drivers/gpu/drm/i915/i915_gem.c            |  5 +-
 drivers/gpu/drm/i915/i915_gem_context.c    |  2 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 23 +++++----
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  9 ++--
 drivers/gpu/drm/i915/intel_display.c       | 10 ++--
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 80 +++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_ringbuffer.h    | 23 ++++++---
 9 files changed, 100 insertions(+), 57 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index eb3ce6d..a582a64 100644
@@ -56,7 +56,7 @@
 	intel_ring_emit(LP_RING(dev_priv), x)
 
 #define ADVANCE_LP_RING() \
-	__intel_ring_advance(LP_RING(dev_priv))
+	__intel_ring_advance(LP_RING(dev_priv), LP_RING(dev_priv)->default_context)
 
 /**
  * Lock test for when it's just for synchronization of ring access.
drivers/gpu/drm/i915/i915_drv.h +2 -1
index ee27ce8..35b2ae4 100644
@@ -2270,11 +2270,12 @@ void i915_gem_cleanup_ring(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 *ring,
+		       struct i915_hw_context *ctx,
 		       struct drm_file *file,
 		       struct drm_i915_gem_object *batch_obj,
 		       u32 *seqno);
 #define i915_add_request(ring, seqno) \
-	__i915_add_request(ring, NULL, NULL, seqno)
+	__i915_add_request(ring, ring->default_context, NULL, NULL, seqno)
 int __must_check i915_wait_seqno(struct intel_engine *ring,
 				 uint32_t seqno);
 int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
drivers/gpu/drm/i915/i915_gem.c +3 -2
index e7565d9..774151c 100644
@@ -2171,6 +2171,7 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
 }
 
 int __i915_add_request(struct intel_engine *ring,
+		       struct i915_hw_context *ctx,
 		       struct drm_file *file,
 		       struct drm_i915_gem_object *obj,
 		       u32 *out_seqno)
@@ -2188,7 +2189,7 @@ int __i915_add_request(struct intel_engine *ring,
 	 * is that the flush _must_ happen before the next request, no matter
 	 * what.
 	 */
-	ret = intel_ring_flush_all_caches(ring);
+	ret = intel_ring_flush_all_caches(ring, ctx);
 	if (ret)
 		return ret;
 
@@ -2203,7 +2204,7 @@ int __i915_add_request(struct intel_engine *ring,
 	 */
 	request_ring_position = intel_ring_get_tail(ring);
 
-	ret = ring->add_request(ring);
+	ret = ring->add_request(ring, ctx);
 	if (ret)
 		return ret;
 
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index 4d37e20..50337ae 100644
@@ -558,7 +558,7 @@ mi_set_context(struct intel_engine *ring,
 	 * itlb_before_ctx_switch.
 	 */
 	if (IS_GEN6(ring->dev)) {
-		ret = ring->flush(ring, I915_GEM_GPU_DOMAINS, 0);
+		ret = ring->flush(ring, new_context, I915_GEM_GPU_DOMAINS, 0);
 		if (ret)
 			return ret;
 	}
drivers/gpu/drm/i915/i915_gem_execbuffer.c +13 -10
index 95e797e..c93941d 100644
@@ -828,6 +828,7 @@ err:
 
 static int
 i915_gem_execbuffer_move_to_gpu(struct intel_engine *ring,
+				struct i915_hw_context *ctx,
 				struct list_head *vmas)
 {
 	struct i915_vma *vma;
@@ -856,7 +857,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_engine *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(ring, ctx);
 }
 
 static bool
@@ -971,18 +972,20 @@ static void
 i915_gem_execbuffer_retire_commands(struct drm_device *dev,
 				    struct drm_file *file,
 				    struct intel_engine *ring,
+				    struct i915_hw_context *ctx,
 				    struct drm_i915_gem_object *obj)
 {
 	/* Unconditionally force add_request to emit a full flush. */
 	ring->gpu_caches_dirty = true;
 
 	/* Add a breadcrumb for the completion of the batch buffer */
-	(void)__i915_add_request(ring, file, obj, NULL);
+	(void)__i915_add_request(ring, ctx, file, obj, NULL);
 }
 
 static int
 i915_reset_gen7_sol_offsets(struct drm_device *dev,
-			    struct intel_engine *ring)
+			    struct intel_engine *ring,
+			    struct i915_hw_context *ctx)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret, i;
@@ -992,7 +995,7 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	ret = intel_ring_begin(ring, 4 * 3);
+	ret = intel_ringbuffer_begin(ring, ctx, 4 * 3);
 	if (ret)
 		return ret;
 
@@ -1277,7 +1280,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	else
 		exec_start += i915_gem_obj_offset(batch_obj, vm);
 
-	ret = i915_gem_execbuffer_move_to_gpu(ring, &eb->vmas);
+	ret = i915_gem_execbuffer_move_to_gpu(ring, ctx, &eb->vmas);
 	if (ret)
 		goto err;
 
@@ -1287,7 +1290,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 
 	if (ring == &dev_priv->ring[RCS] &&
 	    mode != dev_priv->relative_constants_mode) {
-		ret = intel_ring_begin(ring, 4);
+		ret = intel_ringbuffer_begin(ring, ctx, 4);
 		if (ret)
 				goto err;
 
@@ -1301,7 +1304,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	}
 
 	if (args->flags & I915_EXEC_GEN7_SOL_RESET) {
-		ret = i915_reset_gen7_sol_offsets(dev, ring);
+		ret = i915_reset_gen7_sol_offsets(dev, ring, ctx);
 		if (ret)
 			goto err;
 	}
@@ -1315,14 +1318,14 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 			if (ret)
 				goto err;
 
-			ret = ring->dispatch_execbuffer(ring,
+			ret = ring->dispatch_execbuffer(ring, ctx,
 							exec_start, exec_len,
 							flags);
 			if (ret)
 				goto err;
 		}
 	} else {
-		ret = ring->dispatch_execbuffer(ring,
+		ret = ring->dispatch_execbuffer(ring, ctx,
 						exec_start, exec_len,
 						flags);
 		if (ret)
@@ -1332,7 +1335,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	trace_i915_gem_ring_dispatch(ring, intel_ring_get_seqno(ring), flags);
 
 	i915_gem_execbuffer_move_to_active(&eb->vmas, ring);
-	i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
+	i915_gem_execbuffer_retire_commands(dev, file, ring, ctx, batch_obj);
 
 err:
 	/* the request owns the ref now */
drivers/gpu/drm/i915/i915_gem_gtt.c +6 -3
index 31b58ee..a0993c0 100644
@@ -740,7 +740,8 @@ static int hsw_mm_switch(struct i915_hw_ppgtt *ppgtt,
 	}
 
 	/* 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(ring, ring->default_context,
+			I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
 	if (ret)
 		return ret;
 
@@ -784,7 +785,8 @@ static int gen7_mm_switch(struct i915_hw_ppgtt *ppgtt,
 	}
 
 	/* 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(ring, ring->default_context,
+			I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
 	if (ret)
 		return ret;
 
@@ -802,7 +804,8 @@ 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(ring, ring->default_context,
+				I915_GEM_GPU_DOMAINS, I915_GEM_GPU_DOMAINS);
 		if (ret)
 			return ret;
 	}
drivers/gpu/drm/i915/intel_display.c +5 -5
index f821147..d7c6ce5 100644
@@ -8609,7 +8609,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, 0); /* aux display base address, unused */
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
+	__intel_ring_advance(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8651,7 +8651,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, MI_NOOP);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
+	__intel_ring_advance(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8700,7 +8700,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, pf | pipesrc);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
+	__intel_ring_advance(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8745,7 +8745,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, pf | pipesrc);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
+	__intel_ring_advance(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8855,7 +8855,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, (MI_NOOP));
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring);
+	__intel_ring_advance(ring, ring->default_context);
 	return 0;
 
 err_unpin:
drivers/gpu/drm/i915/intel_ringbuffer.c +52 -28

316 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +17 -6
index c9328fd..4ed68b4 100644
@@ -75,6 +75,8 @@ struct intel_ringbuffer {
 	u32 last_retired_head;
 };
 
+struct i915_hw_context;
+
 struct intel_engine {
 	const char	*name;
 	enum intel_ring_id {
@@ -101,11 +103,13 @@ struct intel_engine {
 	int		(*init)(struct intel_engine *ring);
 
 	void		(*write_tail)(struct intel_engine *ring,
-				      u32 value);
+				      struct i915_hw_context *ctx, u32 value);
 	int __must_check (*flush)(struct intel_engine *ring,
+				  struct i915_hw_context *ctx,
 				  u32	invalidate_domains,
 				  u32	flush_domains);
-	int		(*add_request)(struct intel_engine *ring);
+	int		(*add_request)(struct intel_engine *ring,
+				       struct i915_hw_context *ctx);
 	/* 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
@@ -117,6 +121,7 @@ struct intel_engine {
 	void		(*set_seqno)(struct intel_engine *ring,
 				     u32 seqno);
 	int		(*dispatch_execbuffer)(struct intel_engine *ring,
+					       struct i915_hw_context *ctx,
 					       u64 offset, u32 length,
 					       unsigned flags);
 #define I915_DISPATCH_SECURE 0x1
@@ -289,7 +294,10 @@ intel_write_status_page(struct intel_engine *ring,
 void intel_stop_ring(struct intel_engine *ring);
 void intel_cleanup_ring(struct intel_engine *ring);
 
-int __must_check intel_ring_begin(struct intel_engine *ring, int n);
+int __must_check intel_ringbuffer_begin(struct intel_engine *ring,
+					   struct i915_hw_context *ctx, int n);
+#define intel_ring_begin(ring, n) \
+		intel_ringbuffer_begin(ring, ring->default_context, n)
 int __must_check intel_ring_cacheline_align(struct intel_engine *ring);
 static inline void intel_ring_emit(struct intel_engine *ring,
 				   u32 data)
@@ -305,12 +313,15 @@ static inline void intel_ring_advance(struct intel_engine *ring)
 
 	ringbuf->tail &= ringbuf->size - 1;
 }
-void __intel_ring_advance(struct intel_engine *ring);
+void __intel_ring_advance(struct intel_engine *ring,
+			  struct i915_hw_context *ctx);
 
 int __must_check intel_ring_idle(struct intel_engine *ring);
 void intel_ring_init_seqno(struct intel_engine *ring, u32 seqno);
-int intel_ring_flush_all_caches(struct intel_engine *ring);
-int intel_ring_invalidate_all_caches(struct intel_engine *ring);
+int intel_ring_flush_all_caches(struct intel_engine *ring,
+				struct i915_hw_context *ctx);
+int intel_ring_invalidate_all_caches(struct intel_engine *ring,
+				     struct i915_hw_context *ctx);
 
 void intel_init_rings_early(struct drm_device *dev);
 int intel_init_render_ring(struct drm_device *dev);
Signature · 1 line
1.9.0
#36 lore raw

Re: [PATCH 09/50] drm/i915: Plumb the context everywhere in the execbuffer path

Quoted 13 lines · On Fri, May 09, 2014 at 01:08:39PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

The context are going to become very important pretty soon, and we need to be able to access them in a number of places inside the command submission path. The idea is that, when we need to place commands inside a ringbuffer or update the tail register, we know which context we are working with.

We left intel_ring_begin() as a function macro to quickly adapt legacy code, an introduce intel_ringbuffer_begin() as the first of a set of new functions for ringbuffer manipulation (the rest will come in subsequent patches).

Quoted 4 lines

No functional changes.

v2: Do not set the context to NULL. In legacy code, set it to the default ring context (even if it doesn't get used later on).

Won't rings be stored within the context? So the context should be derivable from which ring the operation is being issued on. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#37 lore raw

Re: [PATCH 09/50] drm/i915: Plumb the context everywhere in the execbuffer path

Quoted 22 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, May 16, 2014 12:05 PM
To: Mateo Lozano, Oscar
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 09/50] drm/i915: Plumb the context everywhere in the execbuffer path

Quoted 13 lines · On Fri, May 09, 2014 at 01:08:39PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

The context are going to become very important pretty soon, and we need to be able to access them in a number of places inside the command submission path. The idea is that, when we need to place commands inside a ringbuffer or update the tail register, we know which context we are working with.

We left intel_ring_begin() as a function macro to quickly adapt legacy code, an introduce intel_ringbuffer_begin() as the first of a set of new functions for ringbuffer manipulation (the rest will come in subsequent patches).

Quoted 8 lines
Quoted 4 lines

No functional changes.

v2: Do not set the context to NULL. In legacy code, set it to the default ring context (even if it doesn't get used later on).

Won't rings be stored within the context? So the context should be derivable from which ring the operation is being issued on.
-Chris

Rings (as in "engine command streamer") still remain in dev_priv and there are only four/five of them. What we store in the context is the new ringbuffer structure (which stores the head, tail, etc...) and the ringbuffer backing object. Knowing only the ring is not enough to derive the context.

- Oscar

#38 lore raw

Re: [PATCH 09/50] drm/i915: Plumb the context everywhere in the execbuffer path

Quoted 24 lines · Oscar
Quoted 24 lines

-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Friday, May 16, 2014 12:05 PM
To: Mateo Lozano, Oscar
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 09/50] drm/i915: Plumb the context everywhere in the execbuffer path

Quoted 15 lines · On Fri, May 09, 2014 at 01:08:39PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

The context are going to become very important pretty soon, and we need to be able to access them in a number of places inside the command submission path. The idea is that, when we need to place commands inside a ringbuffer or update the tail register, we know which context we are working with.

We left intel_ring_begin() as a function macro to quickly adapt legacy code, an introduce intel_ringbuffer_begin() as the first of a set of new functions for ringbuffer manipulation (the rest will come in subsequent patches).

No functional changes.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

v2: Do not set the context to NULL. In legacy code, set it to the default ring context (even if it doesn't get used later on).

Won't rings be stored within the context? So the context should be derivable from which ring the operation is being issued on.
-Chris

Rings (as in "engine command streamer") still remain in dev_priv and there are only four/five of them. What we store in the context is the new ringbuffer structure (which stores the head, tail, etc...) and the ringbuffer backing object. Knowing only the ring is not enough to derive the context.

Ugh, I thought an earlier restructuring request was that the logical ring interface was context specific.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#39 lore raw

PATCH 10/50 drm/i915: s/__intel_ring_advance/intel_ringbuffer_advance_and_submit

In reply to [email protected]

From: Oscar Mateo <[email protected]>

The "__" name is too confusing, specially given the refactoring patch that comes soon with more new ringbuffer management functions.

---
 drivers/gpu/drm/i915/i915_dma.c         |  3 ++-
 drivers/gpu/drm/i915/intel_display.c    | 10 +++++-----
 drivers/gpu/drm/i915/intel_ringbuffer.c | 10 +++++-----
 drivers/gpu/drm/i915/intel_ringbuffer.h |  4 ++--
 4 files changed, 14 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -1
index a582a64..166fbdf 100644
@@ -56,7 +56,8 @@
 	intel_ring_emit(LP_RING(dev_priv), x)
 
 #define ADVANCE_LP_RING() \
-	__intel_ring_advance(LP_RING(dev_priv), LP_RING(dev_priv)->default_context)
+	intel_ringbuffer_advance_and_submit(LP_RING(dev_priv), \
+			LP_RING(dev_priv)->default_context)
 
 /**
  * Lock test for when it's just for synchronization of ring access.
drivers/gpu/drm/i915/intel_display.c +5 -5
index d7c6ce5..e0550c6 100644
@@ -8609,7 +8609,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, 0); /* aux display base address, unused */
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring, ring->default_context);
+	intel_ringbuffer_advance_and_submit(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8651,7 +8651,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, MI_NOOP);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring, ring->default_context);
+	intel_ringbuffer_advance_and_submit(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8700,7 +8700,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, pf | pipesrc);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring, ring->default_context);
+	intel_ringbuffer_advance_and_submit(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8745,7 +8745,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, pf | pipesrc);
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring, ring->default_context);
+	intel_ringbuffer_advance_and_submit(ring, ring->default_context);
 	return 0;
 
 err_unpin:
@@ -8855,7 +8855,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
 	intel_ring_emit(ring, (MI_NOOP));
 
 	intel_mark_page_flip_active(intel_crtc);
-	__intel_ring_advance(ring, ring->default_context);
+	intel_ringbuffer_advance_and_submit(ring, ring->default_context);
 	return 0;
 
 err_unpin:
drivers/gpu/drm/i915/intel_ringbuffer.c +5 -5
index 3b43070..0f4d3b6 100644
@@ -56,7 +56,7 @@ static bool intel_ring_stopped(struct intel_engine *ring)
 	return dev_priv->gpu_error.stop_rings & intel_ring_flag(ring);
 }
 
-void __intel_ring_advance(struct intel_engine *ring,
+void intel_ringbuffer_advance_and_submit(struct intel_engine *ring,
 			  struct i915_hw_context *ctx)
 {
 	struct intel_ringbuffer *ringbuf = __get_ringbuf(ring);
@@ -738,7 +738,7 @@ gen6_add_request(struct intel_engine *ring,
 	intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
 	intel_ring_emit(ring, ring->outstanding_lazy_seqno);
 	intel_ring_emit(ring, MI_USER_INTERRUPT);
-	__intel_ring_advance(ring, ctx);
+	intel_ringbuffer_advance_and_submit(ring, ctx);
 
 	return 0;
 }
@@ -850,7 +850,7 @@ pc_render_add_request(struct intel_engine *ring,
 	intel_ring_emit(ring, ring->scratch.gtt_offset | PIPE_CONTROL_GLOBAL_GTT);
 	intel_ring_emit(ring, ring->outstanding_lazy_seqno);
 	intel_ring_emit(ring, 0);
-	__intel_ring_advance(ring, ctx);
+	intel_ringbuffer_advance_and_submit(ring, ctx);
 
 	return 0;
 }
@@ -1092,7 +1092,7 @@ i9xx_add_request(struct intel_engine *ring,
 	intel_ring_emit(ring, I915_GEM_HWS_INDEX << MI_STORE_DWORD_INDEX_SHIFT);
 	intel_ring_emit(ring, ring->outstanding_lazy_seqno);
 	intel_ring_emit(ring, MI_USER_INTERRUPT);
-	__intel_ring_advance(ring, ctx);
+	intel_ringbuffer_advance_and_submit(ring, ctx);
 
 	return 0;
 }
@@ -1577,7 +1577,7 @@ static int ring_wait_for_space(struct intel_engine *ring,
 		return ret;
 
 	/* force the tail write in case we have been skipping them */
-	__intel_ring_advance(ring, ctx);
+	intel_ringbuffer_advance_and_submit(ring, ctx);
 
 	trace_i915_ring_wait_begin(ring);
 	/* With GEM the hangcheck timer should kick us out of the loop,
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index 4ed68b4..b2dcad4 100644
@@ -313,8 +313,8 @@ static inline void intel_ring_advance(struct intel_engine *ring)
 
 	ringbuf->tail &= ringbuf->size - 1;
 }
-void __intel_ring_advance(struct intel_engine *ring,
-			  struct i915_hw_context *ctx);
+void intel_ringbuffer_advance_and_submit(struct intel_engine *ring,
+					 struct i915_hw_context *ctx);
 
 int __must_check intel_ring_idle(struct intel_engine *ring);
 void intel_ring_init_seqno(struct intel_engine *ring, u32 seqno);
Signature · 1 line
1.9.0
#40 lore raw

PATCH 11/50 drm/i915: Write a new set of context-aware ringbuffer management functions

In reply to [email protected]

From: Oscar Mateo <[email protected]>

We need functions that are aware of the fact that the ringbuffer might be living somewhere else than in the engine. After this commit and some of the previous, these new ringbuffer functions finally are:

intel_ringbuffer_get
intel_ringbuffer_begin
intel_ringbuffer_cacheline_align
intel_ringbuffer_emit
intel_ringbuffer_advance
intel_ringbuffer_advance_and_submit
intel_ringbuffer_get_tail

Some of the old ones remain after the refactoring as deprecated functions, simply calling the previous set of functions to manipulate the engine's default ringbuffer:

intel_ring_begin
intel_ring_emit
intel_ring_advance

---
 drivers/gpu/drm/i915/i915_gem.c            |  4 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 19 ++++++---
 drivers/gpu/drm/i915/intel_display.c       |  2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 37 ++++++++--------
 drivers/gpu/drm/i915/intel_ringbuffer.h    | 68 ++++++++++++++++++++++--------
 5 files changed, 86 insertions(+), 44 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -2
index 774151c..26bd68f 100644
@@ -2181,7 +2181,7 @@ int __i915_add_request(struct intel_engine *ring,
 	u32 request_ring_position, request_start;
 	int ret;
 
-	request_start = intel_ring_get_tail(ring);
+	request_start = intel_ringbuffer_get_tail(ring, ctx);
 	/*
 	 * Emit any outstanding flushes - execbuf can fail to emit the flush
 	 * after having emitted the batchbuffer command. Hence we need to fix
@@ -2202,7 +2202,7 @@ int __i915_add_request(struct intel_engine *ring,
 	 * GPU processing the request, we never over-estimate the
 	 * position of the head.
 	 */
-	request_ring_position = intel_ring_get_tail(ring);
+	request_ring_position = intel_ringbuffer_get_tail(ring, ctx);
 
 	ret = ring->add_request(ring, ctx);
 	if (ret)
drivers/gpu/drm/i915/i915_gem_execbuffer.c +12 -7
index c93941d..e78ed94 100644
@@ -988,16 +988,17 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
 			    struct i915_hw_context *ctx)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	int ret, i;
+	struct intel_ringbuffer *ringbuf;
+	int i;
 
 	if (!IS_GEN7(dev) || ring != &dev_priv->ring[RCS]) {
 		DRM_DEBUG("sol reset is gen7/rcs only\n");
 		return -EINVAL;
 	}
 
-	ret = intel_ringbuffer_begin(ring, ctx, 4 * 3);
-	if (ret)
-		return ret;
+	ringbuf = intel_ringbuffer_begin(ring, ctx, 4 * 3);
+	if (IS_ERR_OR_NULL(ringbuf))
+		return PTR_ERR(ringbuf);
 
 	for (i = 0; i < 4; i++) {
 		intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
@@ -1290,9 +1291,13 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 
 	if (ring == &dev_priv->ring[RCS] &&
 	    mode != dev_priv->relative_constants_mode) {
-		ret = intel_ringbuffer_begin(ring, ctx, 4);
-		if (ret)
-				goto err;
+		struct intel_ringbuffer *ringbuf;
+
+		ringbuf = intel_ringbuffer_begin(ring, ctx, 4);
+		if (IS_ERR_OR_NULL(ringbuf)) {
+			ret = PTR_ERR(ringbuf);
+			goto err;
+		}
 
 		intel_ring_emit(ring, MI_NOOP);
 		intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
drivers/gpu/drm/i915/intel_display.c +1 -1
index e0550c6..24e2e3f 100644
@@ -8812,7 +8812,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_ringbuffer_cacheline_align(ring, ring->default_context);
 	if (ret)
 		goto err_unpin;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -17
index 0f4d3b6..6292e75 100644
@@ -388,9 +388,9 @@ gen8_render_ring_flush(struct intel_engine *ring,
 		       struct i915_hw_context *ctx,
 		       u32 invalidate_domains, u32 flush_domains)
 {
+	struct intel_ringbuffer *ringbuf;
 	u32 flags = 0;
 	u32 scratch_addr = ring->scratch.gtt_offset + 2 * CACHELINE_BYTES;
-	int ret;
 
 	flags |= PIPE_CONTROL_CS_STALL;
 
@@ -409,9 +409,9 @@ gen8_render_ring_flush(struct intel_engine *ring,
 		flags |= PIPE_CONTROL_GLOBAL_GTT_IVB;
 	}
 
-	ret = intel_ringbuffer_begin(ring, ctx, 6);
-	if (ret)
-		return ret;
+	ringbuf = intel_ringbuffer_begin(ring, ctx, 6);
+	if (IS_ERR_OR_NULL(ringbuf))
+		return PTR_ERR(ringbuf);
 
 	intel_ring_emit(ring, GFX_OP_PIPE_CONTROL(6));
 	intel_ring_emit(ring, flags);
@@ -1700,34 +1700,37 @@ static int __intel_ring_prepare(struct intel_engine *ring,
 	return 0;
 }
 
-int intel_ringbuffer_begin(struct intel_engine *ring,
-			      struct i915_hw_context *ctx,
-			      int num_dwords)
+struct intel_ringbuffer *
+intel_ringbuffer_begin(struct intel_engine *ring,
+		       struct i915_hw_context *ctx,
+		       int num_dwords)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct intel_ringbuffer *ringbuf = __get_ringbuf(ring);
+	struct intel_ringbuffer *ringbuf = intel_ringbuffer_get(ring, ctx);
 	int ret;
 
 	ret = i915_gem_check_wedge(&dev_priv->gpu_error,
 				   dev_priv->mm.interruptible);
 	if (ret)
-		return ret;
+		return ERR_PTR(ret);
 
 	ret = __intel_ring_prepare(ring, ctx, num_dwords * sizeof(uint32_t));
 	if (ret)
-		return ret;
+		return ERR_PTR(ret);
 
 	/* Preallocate the olr before touching the ring */
 	ret = intel_ring_alloc_seqno(ring);
 	if (ret)
-		return ret;
+		return ERR_PTR(ret);
 
 	ringbuf->space -= num_dwords * sizeof(uint32_t);
-	return 0;
+
+	return ringbuf;
 }
 
 /* Align the ring tail to a cacheline boundary */
-int intel_ring_cacheline_align(struct intel_engine *ring)
+int intel_ringbuffer_cacheline_align(struct intel_engine *ring,
+				     struct i915_hw_context *ctx)
 {
 	struct intel_ringbuffer *ringbuf = __get_ringbuf(ring);
 	int num_dwords = (ringbuf->tail & (CACHELINE_BYTES - 1)) / sizeof(uint32_t);
@@ -1844,11 +1847,11 @@ gen8_ring_dispatch_execbuffer(struct intel_engine *ring,
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	bool ppgtt = dev_priv->mm.aliasing_ppgtt != NULL &&
 		!(flags & I915_DISPATCH_SECURE);
-	int ret;
+	struct intel_ringbuffer *ringbuf;
 
-	ret = intel_ringbuffer_begin(ring, ctx, 4);
-	if (ret)
-		return ret;
+	ringbuf = intel_ringbuffer_begin(ring, ctx, 4);
+	if (IS_ERR_OR_NULL(ringbuf))
+		return PTR_ERR(ringbuf);
 
 	/* FIXME(BDW): Address space and security selectors. */
 	intel_ring_emit(ring, MI_BATCH_BUFFER_START_GEN8 | (ppgtt<<8));
drivers/gpu/drm/i915/intel_ringbuffer.h +51 -17

89 lines not on this page · raw message

Signature · 1 line
1.9.0
#41 lore raw

PATCH 12/50 drm/i915: Final touches to ringbuffer and context plumbing and refactoring

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Thanks to the previous functions and intel_ringbuffer_get(), every function that needs to be context-aware can get the ringbuffer from the appropriate place. Others (either pre-GEN8 or that clearly manipulate the rings's default ringbuffer) get it directly from the engine.

---
 drivers/gpu/drm/i915/i915_dma.c            |  2 +-
 drivers/gpu/drm/i915/i915_gem.c            |  6 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 18 +++---
 drivers/gpu/drm/i915/i915_gpu_error.c      |  6 +-
 drivers/gpu/drm/i915/i915_irq.c            |  2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 92 +++++++++++++++---------------
 drivers/gpu/drm/i915/intel_ringbuffer.h    | 13 ++---
 7 files changed, 70 insertions(+), 69 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index 166fbdf..7bdb9be 100644
@@ -242,7 +242,7 @@ static int i915_dma_resume(struct drm_device * dev)
 
 	DRM_DEBUG_DRIVER("%s\n", __func__);
 
-	if (__get_ringbuf(ring)->virtual_start == NULL) {
+	if (ring->default_ringbuf.virtual_start == NULL) {
 		DRM_ERROR("can not ioremap virtual address for"
 			  " ring buffer\n");
 		return -ENOMEM;
drivers/gpu/drm/i915/i915_gem.c +5 -1
index 26bd68f..4a22560 100644
@@ -2481,6 +2481,7 @@ i915_gem_retire_requests_ring(struct intel_engine *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,
@@ -2490,12 +2491,15 @@ i915_gem_retire_requests_ring(struct intel_engine *ring)
 			break;
 
 		trace_i915_gem_request_retire(ring, request->seqno);
+
+		ringbuf = intel_ringbuffer_get(ring, request->ctx);
+
 		/* 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.
 		 */
-		__get_ringbuf(ring)->last_retired_head = request->tail;
+		ringbuf->last_retired_head = request->tail;
 
 		i915_gem_free_request(request);
 	}
drivers/gpu/drm/i915/i915_gem_execbuffer.c +9 -9
index e78ed94..823ad3d 100644
@@ -1001,12 +1001,12 @@ i915_reset_gen7_sol_offsets(struct drm_device *dev,
 		return PTR_ERR(ringbuf);
 
 	for (i = 0; i < 4; i++) {
-		intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-		intel_ring_emit(ring, GEN7_SO_WRITE_OFFSET(i));
-		intel_ring_emit(ring, 0);
+		intel_ringbuffer_emit(ringbuf, MI_LOAD_REGISTER_IMM(1));
+		intel_ringbuffer_emit(ringbuf, GEN7_SO_WRITE_OFFSET(i));
+		intel_ringbuffer_emit(ringbuf, 0);
 	}
 
-	intel_ring_advance(ring);
+	intel_ringbuffer_advance(ringbuf);
 
 	return 0;
 }
@@ -1299,11 +1299,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 			goto err;
 		}
 
-		intel_ring_emit(ring, MI_NOOP);
-		intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
-		intel_ring_emit(ring, INSTPM);
-		intel_ring_emit(ring, mask << 16 | mode);
-		intel_ring_advance(ring);
+		intel_ringbuffer_emit(ringbuf, MI_NOOP);
+		intel_ringbuffer_emit(ringbuf, MI_LOAD_REGISTER_IMM(1));
+		intel_ringbuffer_emit(ringbuf, INSTPM);
+		intel_ringbuffer_emit(ringbuf, mask << 16 | mode);
+		intel_ringbuffer_advance(ringbuf);
 
 		dev_priv->relative_constants_mode = mode;
 	}
drivers/gpu/drm/i915/i915_gpu_error.c +3 -3
index a7b165f..6724e32 100644
@@ -823,8 +823,8 @@ static void i915_record_ring_state(struct drm_device *dev,
 		ering->hws = I915_READ(mmio);
 	}
 
-	ering->cpu_ring_head = __get_ringbuf(ring)->head;
-	ering->cpu_ring_tail = __get_ringbuf(ring)->tail;
+	ering->cpu_ring_head = ring->default_ringbuf.head;
+	ering->cpu_ring_tail = ring->default_ringbuf.tail;
 
 	ering->hangcheck_score = ring->hangcheck.score;
 	ering->hangcheck_action = ring->hangcheck.action;
@@ -928,7 +928,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 		}
 
 		error->ring[i].ringbuffer =
-			i915_error_ggtt_object_create(dev_priv, __get_ringbuf(ring)->obj);
+			i915_error_ggtt_object_create(dev_priv, ring->default_ringbuf.obj);
 
 		if (ring->status_page.obj)
 			error->ring[i].hws_page =
drivers/gpu/drm/i915/i915_irq.c +1 -1
index e0c3a01..873ae50 100644
@@ -2610,7 +2610,7 @@ static struct intel_engine *
 semaphore_waits_for(struct intel_engine *ring, u32 *seqno)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-	struct intel_ringbuffer *ringbuf = __get_ringbuf(ring);
+	struct intel_ringbuffer *ringbuf = &ring->default_ringbuf;
 	u32 cmd, ipehr, head;
 	int i;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +47 -45

250 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.h +4 -9
index 59280b2..dd85a2b 100644
@@ -219,16 +219,10 @@ struct intel_engine {
 	u32 (*get_cmd_length_mask)(u32 cmd_header);
 };
 
-/* This is a temporary define to help us transition to per-context ringbuffers */
-static inline struct intel_ringbuffer *__get_ringbuf(struct intel_engine *ring)
-{
-	return &ring->default_ringbuf;
-}
-
 static inline bool
 intel_ring_initialized(struct intel_engine *ring)
 {
-	return __get_ringbuf(ring)->obj != NULL;
+	return ring->default_ringbuf.obj != NULL;
 }
 
 static inline unsigned
@@ -372,8 +366,9 @@ int intel_init_vebox_ring(struct drm_device *dev);
 u64 intel_ring_get_active_head(struct intel_engine *ring);
 void intel_ring_setup_status_page(struct intel_engine *ring);
 
-void intel_destroy_ring_buffer(struct intel_engine *ring);
-int intel_allocate_ring_buffer(struct intel_engine *ring);
+void intel_destroy_ring_buffer(struct intel_ringbuffer *ringbuf);
+int intel_allocate_ring_buffer(struct drm_device *dev,
+		struct intel_ringbuffer *ringbuf);
 
 static inline u32 intel_ring_get_seqno(struct intel_engine *ring)
 {
Signature · 1 line
1.9.0
#42 lore raw

PATCH 13/50 drm/i915: s/write_tail/submit

In reply to [email protected]

From: Oscar Mateo <[email protected]>

In Execlists we don't really write to the tail register to submit a workload to the GPU, so the name is going to stop being accurate soon.

Change and name suggested by Brad.

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 18 +++++++++---------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +9 -9
index f18bfb2..6225123 100644
@@ -63,7 +63,7 @@ void intel_ringbuffer_advance_and_submit(struct intel_engine *ring,
 	if (intel_ring_stopped(ring))
 		return;
 
-	ring->write_tail(ring, ctx, ringbuf->tail);
+	ring->submit(ring, ctx, ringbuf->tail);
 }
 
 static int
@@ -471,7 +471,7 @@ static bool stop_ring(struct intel_engine *ring)
 
 	I915_WRITE_CTL(ring, 0);
 	I915_WRITE_HEAD(ring, 0);
-	ring->write_tail(ring, ring->default_context, 0);
+	ring->submit(ring, ring->default_context, 0);
 
 	if (!IS_GEN2(ring->dev)) {
 		(void)I915_READ_CTL(ring);
@@ -2017,7 +2017,7 @@ int intel_init_render_ring(struct drm_device *dev)
 		}
 		ring->irq_enable_mask = I915_USER_INTERRUPT;
 	}
-	ring->write_tail = ring_write_tail;
+	ring->submit = ring_write_tail;
 	if (IS_HASWELL(dev))
 		ring->dispatch_execbuffer = hsw_ring_dispatch_execbuffer;
 	else if (IS_GEN8(dev))
@@ -2088,7 +2088,7 @@ int intel_render_ring_init_dri(struct drm_device *dev, u64 start, u32 size)
 		ring->irq_put = i9xx_ring_put_irq;
 	}
 	ring->irq_enable_mask = I915_USER_INTERRUPT;
-	ring->write_tail = ring_write_tail;
+	ring->submit = ring_write_tail;
 	if (INTEL_INFO(dev)->gen >= 4)
 		ring->dispatch_execbuffer = i965_dispatch_execbuffer;
 	else if (IS_I830(dev) || IS_845G(dev))
@@ -2127,11 +2127,11 @@ int intel_init_bsd_ring(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[VCS];
 
-	ring->write_tail = ring_write_tail;
+	ring->submit = ring_write_tail;
 	if (INTEL_INFO(dev)->gen >= 6) {
 		/* gen6 bsd needs a special wa for tail updates */
 		if (IS_GEN6(dev))
-			ring->write_tail = gen6_bsd_ring_write_tail;
+			ring->submit = gen6_bsd_ring_write_tail;
 		ring->flush = gen6_bsd_ring_flush;
 		ring->add_request = gen6_add_request;
 		ring->get_seqno = gen6_ring_get_seqno;
@@ -2203,7 +2203,7 @@ int intel_init_bsd2_ring(struct drm_device *dev)
 		return -EINVAL;
 	}
 
-	ring->write_tail = ring_write_tail;
+	ring->submit = ring_write_tail;
 	ring->flush = gen6_bsd_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
@@ -2242,7 +2242,7 @@ int intel_init_blt_ring(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[BCS];
 
-	ring->write_tail = ring_write_tail;
+	ring->submit = ring_write_tail;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
@@ -2287,7 +2287,7 @@ int intel_init_vebox_ring(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[VECS];
 
-	ring->write_tail = ring_write_tail;
+	ring->submit = ring_write_tail;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -2
index dd85a2b..c224fdc 100644
@@ -102,8 +102,8 @@ struct intel_engine {
 
 	int		(*init)(struct intel_engine *ring);
 
-	void		(*write_tail)(struct intel_engine *ring,
-				      struct i915_hw_context *ctx, u32 value);
+	void		(*submit)(struct intel_engine *ring,
+				    struct i915_hw_context *ctx, u32 value);
 	int __must_check (*flush)(struct intel_engine *ring,
 				  struct i915_hw_context *ctx,
 				  u32	invalidate_domains,
Signature · 1 line
1.9.0
#43 lore raw

PATCH 14/50 drm/i915: Introduce one context backing object per engine

In reply to [email protected]

From: Oscar Mateo <[email protected]>

When we start using Execlists, a context backing object only makes sense for a given engine (because it will hold state data specific to it) so multiplex the context struct to contain <no-of-engines> objects.

In legacy ringbuffer sumission mode, the only MI_SET_CONTEXT we really perform is for the render engine, so the RCS backing object is the one to use troughout the HW context code.

Originally, I colored this code by instantiating one new context for every engine I wanted to use, but this change suggested by Brad makes it more elegant.

No functional changes.

---
 drivers/gpu/drm/i915/i915_debugfs.c     |  2 +-
 drivers/gpu/drm/i915/i915_drv.h         |  4 +-
 drivers/gpu/drm/i915/i915_gem_context.c | 75 ++++++++++++++++++---------------
 3 files changed, 46 insertions(+), 35 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 0052460..65a740e 100644
@@ -1707,7 +1707,7 @@ static int i915_context_status(struct seq_file *m, void *unused)
 			if (ring->default_context == ctx)
 				seq_printf(m, "(default context %s) ", ring->name);
 
-		describe_obj(m, ctx->obj);
+		describe_obj(m, ctx->engine[RCS].obj);
 		seq_putc(m, '\n');
 	}
 
drivers/gpu/drm/i915/i915_drv.h +3 -1
index 35b2ae4..5be09a0 100644
@@ -595,7 +595,9 @@ struct i915_hw_context {
 	uint8_t remap_slice;
 	struct drm_i915_file_private *file_priv;
 	struct intel_engine *last_ring;
-	struct drm_i915_gem_object *obj;
+	struct {
+		struct drm_i915_gem_object *obj;
+	} engine[I915_NUM_RINGS];
 	struct i915_ctx_hang_stats hang_stats;
 	struct i915_address_space *vm;
 
drivers/gpu/drm/i915/i915_gem_context.c +42 -33

222 lines not on this page · raw message

Signature · 1 line
1.9.0
#44 lore raw

PATCH 15/50 drm/i915: Make i915_gem_create_context outside accessible

In reply to [email protected]

From: Oscar Mateo <[email protected]>

We are going to reuse it during logical ring context creation.

---
 drivers/gpu/drm/i915/i915_drv.h         | 2 ++
 drivers/gpu/drm/i915/i915_gem_context.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 5be09a0..2d5a65d 100644
@@ -2387,6 +2387,8 @@ void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 #define ctx_to_ppgtt(ctx) container_of((ctx)->vm, struct i915_hw_ppgtt, base)
 int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
+struct i915_hw_context *i915_gem_create_context(struct drm_device *dev,
+		struct drm_i915_file_private *file_priv, bool create_vm);
 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);
drivers/gpu/drm/i915/i915_gem_context.c +1 -1
index f92cba9..b2abe9a 100644
@@ -288,7 +288,7 @@ err_out:
  * context state of the GPU for applications that don't utilize HW contexts, as
  * well as an idle case.
  */
-static struct i915_hw_context *
+struct i915_hw_context *
 i915_gem_create_context(struct drm_device *dev,
 			struct drm_i915_file_private *file_priv,
 			bool create_vm)
Signature · 1 line
1.9.0
#45 lore raw

PATCH 16/50 drm/i915: Option to skip backing object allocation during context creation

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Allocating only the RCS backing object won't be enough for LRCs, so give callers the opportunity to skip it.

No functional changes.

---
 drivers/gpu/drm/i915/i915_drv.h         |  3 ++-
 drivers/gpu/drm/i915/i915_gem_context.c | 15 ++++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -1
index 2d5a65d..6f45bf0 100644
@@ -2388,7 +2388,8 @@ void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 struct i915_hw_context *i915_gem_create_context(struct drm_device *dev,
-		struct drm_i915_file_private *file_priv, bool create_vm);
+		struct drm_i915_file_private *file_priv,
+		bool create_vm, bool create_obj);
 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);
drivers/gpu/drm/i915/i915_gem_context.c +8 -7
index b2abe9a..2d47532 100644
@@ -221,7 +221,8 @@ create_vm_for_ctx(struct drm_device *dev, struct i915_hw_context *ctx)
 
 static struct i915_hw_context *
 __create_hw_context(struct drm_device *dev,
-		  struct drm_i915_file_private *file_priv)
+		struct drm_i915_file_private *file_priv,
+		bool create_obj)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *ctx;
@@ -235,7 +236,7 @@ __create_hw_context(struct drm_device *dev,
 	kref_init(&ctx->ref);
 	list_add_tail(&ctx->link, &dev_priv->context_list);
 
-	if (dev_priv->hw_context_size) {
+	if (dev_priv->hw_context_size && create_obj) {
 		ctx->engine[RCS].obj = ctx_obj = i915_gem_alloc_object(dev,
 							dev_priv->hw_context_size);
 		if (ctx_obj == NULL) {
@@ -291,7 +292,7 @@ err_out:
 struct i915_hw_context *
 i915_gem_create_context(struct drm_device *dev,
 			struct drm_i915_file_private *file_priv,
-			bool create_vm)
+			bool create_vm, bool create_obj)
 {
 	const bool is_global_default_ctx = file_priv == NULL;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -301,7 +302,7 @@ i915_gem_create_context(struct drm_device *dev,
 
 	BUG_ON(!mutex_is_locked(&dev->struct_mutex));
 
-	ctx = __create_hw_context(dev, file_priv);
+	ctx = __create_hw_context(dev, file_priv, create_obj);
 	if (IS_ERR(ctx))
 		return ctx;
 
@@ -415,7 +416,7 @@ int i915_gem_context_init(struct drm_device *dev)
 		}
 	}
 
-	ctx = i915_gem_create_context(dev, NULL, USES_PPGTT(dev));
+	ctx = i915_gem_create_context(dev, NULL, USES_PPGTT(dev), true);
 	if (IS_ERR(ctx)) {
 		DRM_ERROR("Failed to create default global context (error %ld)\n",
 			  PTR_ERR(ctx));
@@ -519,7 +520,7 @@ int i915_gem_context_open(struct drm_device *dev, struct drm_file *file)
 
 	mutex_lock(&dev->struct_mutex);
 	file_priv->private_default_ctx =
-		i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev));
+		i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev), true);
 	mutex_unlock(&dev->struct_mutex);
 
 	if (IS_ERR(file_priv->private_default_ctx)) {
@@ -775,7 +776,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev));
+	ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev), true);
 	mutex_unlock(&dev->struct_mutex);
 	if (IS_ERR(ctx))
 		return PTR_ERR(ctx);
Signature · 1 line
1.9.0
#46 lore raw

PATCH 17/50 drm/i915: Extract context backing object allocation

In reply to [email protected]

From: Oscar Mateo <[email protected]>

We are going to use it later to allocate our own objects.

No functional changes.

---
 drivers/gpu/drm/i915/i915_debugfs.c     |  2 +-
 drivers/gpu/drm/i915/i915_drv.h         |  2 ++
 drivers/gpu/drm/i915/i915_gem_context.c | 54 +++++++++++++++++++++------------
 3 files changed, 38 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 65a740e..204b432 100644
@@ -1698,7 +1698,7 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	}
 
 	list_for_each_entry(ctx, &dev_priv->context_list, link) {
-		if (ctx->obj == NULL)
+		if (ctx->engine[RCS].obj == NULL)
 			continue;
 
 		seq_puts(m, "HW context ");
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 6f45bf0..86730d5 100644
@@ -2387,6 +2387,8 @@ void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 #define ctx_to_ppgtt(ctx) container_of((ctx)->vm, struct i915_hw_ppgtt, base)
 int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
+struct drm_i915_gem_object *intel_allocate_ctx_backing_obj(struct drm_device *dev,
+		size_t size);
 struct i915_hw_context *i915_gem_create_context(struct drm_device *dev,
 		struct drm_i915_file_private *file_priv,
 		bool create_vm, bool create_obj);
drivers/gpu/drm/i915/i915_gem_context.c +35 -19

69 lines not on this page · raw message

Signature · 1 line
1.9.0
#47 lore raw

PATCH 18/50 drm/i915/bdw: Macro and module parameter for LRCs (Logical Ring Contexts)

In reply to [email protected]

From: Ben Widawsky <[email protected]>

GEN8 brings an expansion of the HW contexts: "Logical Ring Contexts". These expanded contexts enable a number of new abilities, especially "Execlists".

In dev_priv, lrc_enabled will reflect the state of whether or not we've actually properly initialized these new contexts. This helps the transition in the code but is a candidate for removal at some point.

The macro is defined to off until we have things in place to hope to work.

v2: Rename "advanced contexts" to the more correct "logical ring contexts"

v3: Add a module parameter to enable execlists. Execlist are relatively new, and so it'd be wise to be able to switch back to ring submission to debug subtle problems that will inevitably arise.

---
 drivers/gpu/drm/i915/i915_drv.h    | 4 ++++
 drivers/gpu/drm/i915/i915_params.c | 6 ++++++
 2 files changed, 10 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +4 -0
index 86730d5..bd93dc2 100644
@@ -1506,6 +1506,8 @@ struct drm_i915_private {
 
 	uint32_t hw_context_size;
 	struct list_head context_list;
+	/* Logical Ring Contexts */
+	bool lrc_enabled;
 
 	u32 fdi_rx_config;
 
@@ -1926,6 +1928,7 @@ struct drm_i915_cmd_table {
 #define I915_NEED_GFX_HWS(dev)	(INTEL_INFO(dev)->need_gfx_hws)
 
 #define HAS_HW_CONTEXTS(dev)	(INTEL_INFO(dev)->gen >= 6)
+#define HAS_LOGICAL_RING_CONTEXTS(dev)	0
 #define HAS_ALIASING_PPGTT(dev)	(INTEL_INFO(dev)->gen >= 6 && \
 				 (!IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)))
 #define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 \
@@ -2013,6 +2016,7 @@ struct i915_params {
 	int enable_rc6;
 	int enable_fbc;
 	int enable_ppgtt;
+	int enable_execlists;
 	int enable_psr;
 	unsigned int preliminary_hw_support;
 	int disable_power_well;
drivers/gpu/drm/i915/i915_params.c +6 -0
index d05a2af..96eb3ef 100644
@@ -37,6 +37,7 @@ struct i915_params i915 __read_mostly = {
 	.enable_fbc = -1,
 	.enable_hangcheck = true,
 	.enable_ppgtt = -1,
+	.enable_execlists = -1,
 	.enable_psr = 0,
 	.preliminary_hw_support = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT),
 	.disable_power_well = 1,
@@ -116,6 +117,11 @@ MODULE_PARM_DESC(enable_ppgtt,
 	"Override PPGTT usage. "
 	"(-1=auto [default], 0=disabled, 1=aliasing, 2=full)");
 
+module_param_named(enable_execlists, i915.enable_execlists, int, 0400);
+MODULE_PARM_DESC(enable_execlists,
+	"Override execlists usage. "
+	"(-1=auto, 0=disabled [default], 1=enabled)");
+
 module_param_named(enable_psr, i915.enable_psr, int, 0600);
 MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
 
Signature · 1 line
1.9.0
#48 lore raw

PATCH 19/50 drm/i915/bdw: New file for Logical Ring Contexts and Execlists

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Some legacy HW context and ringbuffer code assumptions don't make sense for this new submission method, so we will place this stuff in a separate file.

Note for reviewers: I've carefully considered the best name for this file and this was my best option (other possibilities were intel_lr_context.c or intel_execlist.c). I am open to a certain bikeshedding on this matter, anyway. Regarding splitting execlists and logical ring contexts, it is probably not worth it for the moment.

v2: Change to intel_lrc.c

---
 drivers/gpu/drm/i915/Makefile    |  1 +
 drivers/gpu/drm/i915/intel_lrc.c | 42 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/Makefile +1 -0
index b1445b7..428cff9 100644
@@ -29,6 +29,7 @@ i915-y += i915_cmd_parser.o \
 	  i915_gpu_error.o \
 	  i915_irq.o \
 	  i915_trace_points.o \
+	  intel_lrc.o \
 	  intel_ringbuffer.o \
 	  intel_uncore.o
 
drivers/gpu/drm/i915/intel_lrc.c new file +42 -0

42 lines not on this page · raw message

Signature · 6 lines
1.9.0

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

PATCH 20/50 drm/i915/bdw: Rework init code for Logical Ring Contexts

In reply to [email protected]

From: Ben Widawsky <[email protected]>

This modifies the init code to try to start logical ring contexts when possible, and fall back to legacy ringbuffers when not.

Most importantly, things make things easy if we do the context creation before ringbuffer initialization. Upcoming patches will make it clearer why that is. For the initial enabling of execlists, the ringbuffer code will be reused a decent amount. As such this code will have to change, but it helps with enabling to be able to run through a bunch of the context init, and still have a system boot.

Finally, for the bikeshedders out there: I've tried merging the legacy hw context init functionality, ie. one init function, and this logic was in the context creation. The resulting code was much uglier and for no real gain.

v2: Rebased on top of the Full PPGTT series.

v3: Factor out a enable_execlists() function so it's clear what the condition is. Use module parameter to enable.

---
 drivers/gpu/drm/i915/i915_drv.h  |  3 +++
 drivers/gpu/drm/i915/i915_gem.c  | 24 +++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_lrc.c |  5 +++++
 3 files changed, 27 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index bd93dc2..41d3f95 100644
@@ -2425,6 +2425,9 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 				   struct drm_file *file);
 
+/* intel_lrc.c */
+int gen8_gem_context_init(struct drm_device *dev);
+
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
 					  struct i915_address_space *vm,
drivers/gpu/drm/i915/i915_gem.c +19 -5
index 4a22560..f8acf3d 100644
@@ -4490,10 +4490,18 @@ i915_gem_init_hw(struct drm_device *dev)
 	return ret;
 }
 
+static bool enable_execlists(struct drm_device *dev)
+{
+	if (!i915.enable_execlists)
+		return false;
+
+	return HAS_LOGICAL_RING_CONTEXTS(dev) && USES_PPGTT(dev);
+}
+
 int i915_gem_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	int ret;
+	int ret = -1;
 
 	mutex_lock(&dev->struct_mutex);
 
@@ -4509,11 +4517,17 @@ int i915_gem_init(struct drm_device *dev)
 
 	intel_init_rings_early(dev);
 
-	ret = i915_gem_context_init(dev);
+	if (enable_execlists(dev))
+		ret = gen8_gem_context_init(dev);
+
 	if (ret) {
-		mutex_unlock(&dev->struct_mutex);
-		return ret;
-	}
+		ret = i915_gem_context_init(dev);
+		if (ret) {
+			mutex_unlock(&dev->struct_mutex);
+			return ret;
+		}
+	} else
+		dev_priv->lrc_enabled = true;
 
 	ret = i915_gem_init_hw(dev);
 	if (ret == -EIO) {
drivers/gpu/drm/i915/intel_lrc.c +5 -0
index 49bb6fc..3a93e99 100644
@@ -40,3 +40,8 @@
 #include <drm/drmP.h>
 #include <drm/i915_drm.h>
 #include "i915_drv.h"
+
+int gen8_gem_context_init(struct drm_device *dev)
+{
+	return -ENOSYS;
+}
Signature · 1 line
1.9.0
#50 lore raw

PATCH 21/50 drm/i915/bdw: A bit more advanced context init/fini

In reply to [email protected]

From: Ben Widawsky <[email protected]>

There are a few big differences between context init and fini with the previous implementation of hardware contexts. One of them is demonstrated in this patch: we must allocate a ctx backing object for each engine.

Regarding the context size, reading the register to calculate the sizes can work, I think, however the docs are very clear about the actual context sizes on GEN8, so just hardcode that and use it.

v2: Rebased on top of the Full PPGTT series. It is important to notice that at this point we have one global default context per engine, all of them using the aliasing PPGTT (as opposed to the single global default context we have with legacy HW contexts).

v3:
- Go back to one single global default context, this time with multiple backing objects inside.
- Use different context sizes for non-render engines, as suggested by Damien (still hardcoded, since the information about the context size registers in the BSpec is, well, *lacking*).
- Render ctx size is 20 (or 19) pages, but not 21 (caught by Damien).
- Move default context backing object creation to intel_init_ring (so that we don't waste memory in rings that might not get initialized).

Cc Damien Lespiau <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c         |  4 +-
 drivers/gpu/drm/i915/i915_drv.h         |  5 +-
 drivers/gpu/drm/i915/i915_gem_context.c | 37 +++++++++-----
 drivers/gpu/drm/i915/intel_lrc.c        | 85 ++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_ringbuffer.c | 10 ++++
 5 files changed, 124 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +2 -2
index 7bdb9be..e0f56f5 100644
@@ -1385,7 +1385,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 cleanup_gem:
 	mutex_lock(&dev->struct_mutex);
 	i915_gem_cleanup_ring(dev);
-	i915_gem_context_fini(dev);
+	i915_gem_context_fini(dev, dev_priv->lrc_enabled);
 	mutex_unlock(&dev->struct_mutex);
 	WARN_ON(dev_priv->mm.aliasing_ppgtt);
 	drm_mm_takedown(&dev_priv->gtt.base.mm);
@@ -1841,7 +1841,7 @@ int i915_driver_unload(struct drm_device *dev)
 		mutex_lock(&dev->struct_mutex);
 		i915_gem_free_all_phys_object(dev);
 		i915_gem_cleanup_ring(dev);
-		i915_gem_context_fini(dev);
+		i915_gem_context_fini(dev, dev_priv->lrc_enabled);
 		WARN_ON(dev_priv->mm.aliasing_ppgtt);
 		mutex_unlock(&dev->struct_mutex);
 		i915_gem_cleanup_stolen(dev);
drivers/gpu/drm/i915/i915_drv.h +4 -1
index 41d3f95..1cc1042 100644
@@ -2390,7 +2390,7 @@ void i915_gem_object_ggtt_unpin(struct drm_i915_gem_object *obj);
 /* i915_gem_context.c */
 #define ctx_to_ppgtt(ctx) container_of((ctx)->vm, struct i915_hw_ppgtt, base)
 int __must_check i915_gem_context_init(struct drm_device *dev);
-void i915_gem_context_fini(struct drm_device *dev);
+void i915_gem_context_fini(struct drm_device *dev, bool is_lrc);
 struct drm_i915_gem_object *intel_allocate_ctx_backing_obj(struct drm_device *dev,
 		size_t size);
 struct i915_hw_context *i915_gem_create_context(struct drm_device *dev,
@@ -2427,6 +2427,9 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 
 /* intel_lrc.c */
 int gen8_gem_context_init(struct drm_device *dev);
+int gen8_create_lr_context(struct i915_hw_context *ctx,
+			   struct intel_engine *ring,
+			   struct drm_i915_file_private *file_priv);
 
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
drivers/gpu/drm/i915/i915_gem_context.c +24 -13
index 708111d..16fc780 100644
@@ -181,16 +181,22 @@ void i915_gem_context_free(struct kref *ctx_ref)
 	struct i915_hw_context *ctx = container_of(ctx_ref,
 						   typeof(*ctx), ref);
 	struct i915_hw_ppgtt *ppgtt = NULL;
-	struct drm_i915_gem_object *ctx_obj = ctx->engine[RCS].obj;
+	int i;
 
-	if (ctx_obj) {
-		/* We refcount even the aliasing PPGTT to keep the code symmetric */
-		if (USES_PPGTT(ctx_obj->base.dev))
-			ppgtt = ctx_to_ppgtt(ctx);
+	for (i = 0; i < I915_NUM_RINGS; i++) {
+		struct drm_i915_gem_object *ctx_obj = ctx->engine[i].obj;
+		if (ctx_obj) {
+			if (i == RCS) {
+				/* We refcount even the aliasing PPGTT to keep the
+				 * code symmetric */
+				if (USES_PPGTT(ctx_obj->base.dev))
+					ppgtt = ctx_to_ppgtt(ctx);
+			}
 
-		/* XXX: Free up the object before tearing down the address space, in
-		 * case we're bound in the PPGTT */
-		drm_gem_object_unreference(&ctx_obj->base);
+			/* XXX: Free up the object before tearing down the address
+			 * space, in case we're bound in the PPGTT */
+			drm_gem_object_unreference(&ctx_obj->base);
+		}
 	}
 
 	if (ppgtt)
@@ -447,15 +453,15 @@ int i915_gem_context_init(struct drm_device *dev)
 	return 0;
 }
 
-void i915_gem_context_fini(struct drm_device *dev)
+void i915_gem_context_fini(struct drm_device *dev, bool is_lrc)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct i915_hw_context *dctx = dev_priv->ring[RCS].default_context;
 	struct drm_i915_gem_object *dctx_obj = dctx->engine[RCS].obj;
 	struct intel_engine *ring;
-	int unused;
+	int ring_id;
 
-	if (dctx_obj) {
+	if (dctx_obj && !is_lrc) {
 		/* The only known way to stop the gpu from accessing the hw context is
 		 * to reset it. Do this as the very last operation to avoid confusing
 		 * other code, leading to spurious errors. */
@@ -477,15 +483,20 @@ void i915_gem_context_fini(struct drm_device *dev)
 		}
 	}
 
-	for_each_ring(ring, dev_priv, unused) {
+	for_each_ring(ring, dev_priv, ring_id) {
 		if (ring->last_context)
 			i915_gem_context_unreference(ring->last_context);
 
 		ring->default_context = NULL;
 		ring->last_context = NULL;
+
+		dctx_obj = dctx->engine[ring_id].obj;
+		if (dctx_obj) {
+			BUG_ON(ring_id != RCS && !is_lrc);
+			i915_gem_object_ggtt_unpin(dctx_obj);
+		}
 	}
 
-	i915_gem_object_ggtt_unpin(dctx_obj);
 	i915_gem_context_unreference(dctx);
 }
 
drivers/gpu/drm/i915/intel_lrc.c +84 -1

91 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.c +10 -0
index 6225123..e7f61d9 100644
@@ -1443,6 +1443,7 @@ err_unref:
 static int intel_init_ring(struct drm_device *dev,
 			   struct intel_engine *ring)
 {
+	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_ringbuffer *ringbuf = &ring->default_ringbuf;
 	int ret;
 
@@ -1453,6 +1454,15 @@ static int intel_init_ring(struct drm_device *dev,
 
 	init_waitqueue_head(&ring->irq_queue);
 
+	if (dev_priv->lrc_enabled) {
+		ret = gen8_create_lr_context(ring->default_context, ring, NULL);
+		if (ret) {
+			DRM_ERROR("Create LR context for %s failed: %d\n",
+					ring->name, ret);
+			return ret;
+		}
+	}
+
 	if (I915_NEED_GFX_HWS(dev)) {
 		ret = init_status_page(ring);
 		if (ret)
Signature · 1 line
1.9.0
#51 lore raw

PATCH 22/50 drm/i915/bdw: Allocate ringbuffer backing objects for default global LRC

In reply to [email protected]

From: Oscar Mateo <[email protected]>

The default context holds pointers to every engine's default ringbuffer, and makes its own allocation of the corresponding backing objects. During ringbuffer creation we might try to allocate them again, but this will fail silently (same thing with deallocation).

This patch replaces a similar patch by Ben Widawsky in the early series
called: "drm/i915/bdw: Allocate ringbuffer for LR contexts"

---
 drivers/gpu/drm/i915/i915_drv.h         |  1 +
 drivers/gpu/drm/i915/i915_gem_context.c |  5 +++++
 drivers/gpu/drm/i915/intel_lrc.c        | 19 +++++++++++++++++++
 3 files changed, 25 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 1cc1042..4d58167 100644
@@ -597,6 +597,7 @@ struct i915_hw_context {
 	struct intel_engine *last_ring;
 	struct {
 		struct drm_i915_gem_object *obj;
+		struct intel_ringbuffer *ringbuf;
 	} engine[I915_NUM_RINGS];
 	struct i915_ctx_hang_stats hang_stats;
 	struct i915_address_space *vm;
drivers/gpu/drm/i915/i915_gem_context.c +5 -0
index 16fc780..76314e3 100644
@@ -185,6 +185,8 @@ void i915_gem_context_free(struct kref *ctx_ref)
 
 	for (i = 0; i < I915_NUM_RINGS; i++) {
 		struct drm_i915_gem_object *ctx_obj = ctx->engine[i].obj;
+		struct intel_ringbuffer *ringbuf = ctx->engine[i].ringbuf;
+
 		if (ctx_obj) {
 			if (i == RCS) {
 				/* We refcount even the aliasing PPGTT to keep the
@@ -197,6 +199,9 @@ void i915_gem_context_free(struct kref *ctx_ref)
 			 * space, in case we're bound in the PPGTT */
 			drm_gem_object_unreference(&ctx_obj->base);
 		}
+
+		if (ringbuf)
+			intel_destroy_ring_buffer(ringbuf);
 	}
 
 	if (ppgtt)
drivers/gpu/drm/i915/intel_lrc.c +19 -0
index 875d7b9..64d40e4 100644
@@ -95,6 +95,25 @@ int gen8_create_lr_context(struct i915_hw_context *ctx,
 		return ret;
 	}
 
+	if (!file_priv) {
+		ring->default_ringbuf.size = 32 * PAGE_SIZE;
+
+		/* TODO: For now we put this in the mappable region so that we can reuse
+		 * the existing ringbuffer code which ioremaps it. When we start
+		 * creating many contexts, this will no longer work and we must switch
+		 * to a kmapish interface.
+		 */
+		ret = intel_allocate_ring_buffer(dev, &ring->default_ringbuf);
+		if (ret) {
+			DRM_DEBUG_DRIVER("Failed to allocate ringbuffer %s: %d\n",
+					ring->name, ret);
+			i915_gem_object_ggtt_unpin(ctx_obj);
+			drm_gem_object_unreference(&ctx_obj->base);
+			return ret;
+		}
+		ctx->engine[ring->id].ringbuf = &ring->default_ringbuf;
+	}
+
 	ctx->engine[ring->id].obj = ctx_obj;
 
 	return 0;
Signature · 1 line
1.9.0
#52 lore raw

PATCH 23/50 drm/i915/bdw: Allocate ringbuffer for user-created LRCs

In reply to [email protected]

From: Oscar Mateo <[email protected]>

As we said earlier, logical ring contexts created by the user have their own ringbuffer: not only the backing pages, but the whole management struct.

Since this is now ready, we use the context ringbuffer or the engine's default ringbuffer depending on whether LRCs are enabled or not.

This patch replaces a similar patch in the early series called:
"drm/i915/bdw: Prepare for user-created LR contexts"

---
 drivers/gpu/drm/i915/i915_gem_context.c |  5 +++-
 drivers/gpu/drm/i915/intel_lrc.c        | 45 +++++++++++++++++++++++----------
 drivers/gpu/drm/i915/intel_ringbuffer.c |  8 ++++--
 3 files changed, 42 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_gem_context.c +4 -1
index 76314e3..e4e616d 100644
@@ -200,8 +200,11 @@ void i915_gem_context_free(struct kref *ctx_ref)
 			drm_gem_object_unreference(&ctx_obj->base);
 		}
 
-		if (ringbuf)
+		if (ringbuf) {
 			intel_destroy_ring_buffer(ringbuf);
+			if (ctx->file_priv)
+				kfree(ringbuf);
+		}
 	}
 
 	if (ppgtt)
drivers/gpu/drm/i915/intel_lrc.c +32 -13

63 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.c +6 -2
index e7f61d9..8b0260d 100644
@@ -1709,8 +1709,12 @@ static int __intel_ring_prepare(struct intel_engine *ring,
 struct intel_ringbuffer *
 intel_ringbuffer_get(struct intel_engine *ring, struct i915_hw_context *ctx)
 {
-	/* For the time being, the only ringbuffer is in the engine */
-	return &ring->default_ringbuf;
+	struct drm_i915_private *dev_priv = to_i915(ring->dev);
+
+	if (dev_priv->lrc_enabled)
+		return ctx->engine[ring->id].ringbuf;
+	else
+		return &ring->default_ringbuf;
 }
 
 struct intel_ringbuffer *
Signature · 1 line
1.9.0
#53 lore raw

PATCH 24/50 drm/i915/bdw: Populate LR contexts (somewhat)

In reply to [email protected]

From: Ben Widawsky <[email protected]>

For the most part, logical ring context objects are similar to hardware contexts in that the backing object is meant to be opaque. There are some exceptions where we need to poke certain offsets of the object for initialization, updating the tail pointer or updating the PDPs.

For our basic execlist implementation we'll only need our PPGTT PDs, and ringbuffer addresses in order to set up the context. With previous patches, we have both, so start prepping the context to be load.

Before running a context for the first time you must populate some fields in the context object. These fields begin 1 PAGE + LRCA, ie. the first page (in 0 based counting) of the context image. These same fields will be read and written to as contexts are saved and restored once the system is up and running.

Many of these fields are completely reused from previous global
registers: ringbuffer head/tail/control, context control matches some previous MI_SET_CONTEXT flags, and page directories. There are other fields which we don't touch which we may want in the future.

v2: CTX_LRI_HEADER_0 is MI_LOAD_REGISTER_IMM(14) for render and (11) for other engines.

v3: Several rebases and general changes to the code.

v4: Squash with "Extract LR context object populating"
Also, Damien's review comments:
- Set the Force Posted bit on the LRI header, as the BSpec suggest we do.
- Prevent warning when compiling a 32-bits kernel without HIGHMEM64.
- Add a clarifying comment to the context population code.

---
 drivers/gpu/drm/i915/i915_reg.h  |   1 +
 drivers/gpu/drm/i915/intel_lrc.c | 159 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 160 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 03ffc57..33d007d 100644
@@ -269,6 +269,7 @@
  *   address/value pairs. Don't overdue it, though, x <= 2^4 must hold!
  */
 #define MI_LOAD_REGISTER_IMM(x)	MI_INSTR(0x22, 2*(x)-1)
+#define   MI_LRI_FORCE_POSTED		(1<<12)
 #define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*(x)-1)
 #define MI_STORE_REGISTER_MEM_GEN8(x) MI_INSTR(0x24, 3*(x)-1)
 #define   MI_SRM_LRM_GLOBAL_GTT		(1<<22)
drivers/gpu/drm/i915/intel_lrc.c +159 -0

171 lines not on this page · raw message

Signature · 1 line
1.9.0
#54 lore raw

Re: [PATCH 24/50] drm/i915/bdw: Populate LR contexts (somewhat)

drivers/gpu/drm/i915/intel_lrc.c line 176

Quoted 3 lines · On Fri, May 09, 2014 at 01:08:54PM +0100, [email protected] wrote:
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+	if (ring->id == RCS) {
+		reg_state[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
+		reg_state[CTX_LRI_HEADER_2] |= MI_LRI_FORCE_POSTED;

This header doesn't have bit 12 set in BSpec.

drivers/gpu/drm/i915/intel_lrc.c line 183

Quoted 7 lines
drivers/gpu/drm/i915/intel_lrc.c +7 -0
+		reg_state[CTX_R_PWR_CLK_STATE] = 0x20c8;
+		reg_state[CTX_R_PWR_CLK_STATE+1] = 0;
+#if 0
+		/* Offsets not yet defined for these */
+		reg_state[CTX_GPGPU_CSR_BASE_ADDRESS] = 0;
+		reg_state[CTX_GPGPU_CSR_BASE_ADDRESS+1] = 0;
+#endif

Remove dead code?

Signature · 1 line
Damien
#55 lore raw

PATCH v2 24/50 drm/i915/bdw: Populate LR contexts (somewhat)

In reply to [email protected]

From: Ben Widawsky <[email protected]>

For the most part, logical ring context objects are similar to hardware contexts in that the backing object is meant to be opaque. There are some exceptions where we need to poke certain offsets of the object for initialization, updating the tail pointer or updating the PDPs.

For our basic execlist implementation we'll only need our PPGTT PDs, and ringbuffer addresses in order to set up the context. With previous patches, we have both, so start prepping the context to be load.

Before running a context for the first time you must populate some fields in the context object. These fields begin 1 PAGE + LRCA, ie. the first page (in 0 based counting) of the context image. These same fields will be read and written to as contexts are saved and restored once the system is up and running.

Many of these fields are completely reused from previous global
registers: ringbuffer head/tail/control, context control matches some previous MI_SET_CONTEXT flags, and page directories. There are other fields which we don't touch which we may want in the future.

v2: CTX_LRI_HEADER_0 is MI_LOAD_REGISTER_IMM(14) for render and (11) for other engines.

v3: Several rebases and general changes to the code.

v4: Squash with "Extract LR context object populating"
Also, Damien's review comments:
- Set the Force Posted bit on the LRI header, as the BSpec suggest we do.
- Prevent warning when compiling a 32-bits kernel without HIGHMEM64.
- Add a clarifying comment to the context population code.

v5: Damien's review comments:
- The third MI_LOAD_REGISTER_IMM in the context does not set Force Posted.
- Remove dead code.

---
 drivers/gpu/drm/i915/i915_reg.h  |   1 +
 drivers/gpu/drm/i915/intel_lrc.c | 153 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 154 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 03ffc57..33d007d 100644
@@ -269,6 +269,7 @@
  *   address/value pairs. Don't overdue it, though, x <= 2^4 must hold!
  */
 #define MI_LOAD_REGISTER_IMM(x)	MI_INSTR(0x22, 2*(x)-1)
+#define   MI_LRI_FORCE_POSTED		(1<<12)
 #define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*(x)-1)
 #define MI_STORE_REGISTER_MEM_GEN8(x) MI_INSTR(0x24, 3*(x)-1)
 #define   MI_SRM_LRM_GLOBAL_GTT		(1<<22)
drivers/gpu/drm/i915/intel_lrc.c +153 -0

165 lines not on this page · raw message

Signature · 1 line
1.9.0
#56 lore raw

PATCH 25/50 drm/i915/bdw: Deferred creation of user-created LRCs

In reply to [email protected]

From: Oscar Mateo <[email protected]>

The backing objects for user-created contexts (either via open fd or create context ioctl) are actually empty until the user starts sending execbuffers to them. We do this because, at create time, we really don't know which engine is going to be used with the context later on.

---
 drivers/gpu/drm/i915/i915_drv.h            |  3 +++
 drivers/gpu/drm/i915/i915_gem_context.c    | 31 +++++++++++++++++----------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  5 ++++-
 drivers/gpu/drm/i915/intel_lrc.c           | 34 ++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 4d58167..7d06a66 100644
@@ -2431,6 +2431,9 @@ int gen8_gem_context_init(struct drm_device *dev);
 int gen8_create_lr_context(struct i915_hw_context *ctx,
 			   struct intel_engine *ring,
 			   struct drm_i915_file_private *file_priv);
+struct i915_hw_context *
+gen8_gem_validate_context(struct drm_device *dev, struct drm_file *file,
+			  struct intel_engine *ring, const u32 ctx_id);
 
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
drivers/gpu/drm/i915/i915_gem_context.c +20 -11
index e4e616d..d4c6863 100644
@@ -181,6 +181,7 @@ void i915_gem_context_free(struct kref *ctx_ref)
 	struct i915_hw_context *ctx = container_of(ctx_ref,
 						   typeof(*ctx), ref);
 	struct i915_hw_ppgtt *ppgtt = NULL;
+	bool ppgtt_unref = false;
 	int i;
 
 	for (i = 0; i < I915_NUM_RINGS; i++) {
@@ -188,12 +189,12 @@ void i915_gem_context_free(struct kref *ctx_ref)
 		struct intel_ringbuffer *ringbuf = ctx->engine[i].ringbuf;
 
 		if (ctx_obj) {
-			if (i == RCS) {
-				/* We refcount even the aliasing PPGTT to keep the
-				 * code symmetric */
-				if (USES_PPGTT(ctx_obj->base.dev))
-					ppgtt = ctx_to_ppgtt(ctx);
-			}
+			struct drm_device *dev = ctx_obj->base.dev;
+			struct drm_i915_private *dev_priv = to_i915(dev);
+			ppgtt_unref = USES_PPGTT(dev);
+
+			if (dev_priv->lrc_enabled && ctx->file_priv)
+				i915_gem_object_ggtt_unpin(ctx_obj);
 
 			/* XXX: Free up the object before tearing down the address
 			 * space, in case we're bound in the PPGTT */
@@ -207,8 +208,13 @@ void i915_gem_context_free(struct kref *ctx_ref)
 		}
 	}
 
-	if (ppgtt)
-		kref_put(&ppgtt->ref, ppgtt_release);
+	if (ppgtt_unref) {
+		/* We refcount even the aliasing PPGTT to keep the
+		 * code symmetric */
+		ppgtt = ctx_to_ppgtt(ctx);
+		if (ppgtt)
+			kref_put(&ppgtt->ref, ppgtt_release);
+	}
 	list_del(&ctx->link);
 	kfree(ctx);
 }
@@ -550,12 +556,13 @@ static int context_idr_cleanup(int id, void *p, void *data)
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file)
 {
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	struct drm_i915_private *dev_priv = to_i915(dev);
 
 	idr_init(&file_priv->context_idr);
 
 	mutex_lock(&dev->struct_mutex);
-	file_priv->private_default_ctx =
-		i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev), true);
+	file_priv->private_default_ctx = i915_gem_create_context(dev, file_priv,
+			USES_FULL_PPGTT(dev), !dev_priv->lrc_enabled);
 	mutex_unlock(&dev->struct_mutex);
 
 	if (IS_ERR(file_priv->private_default_ctx)) {
@@ -801,6 +808,7 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 {
 	struct drm_i915_gem_context_create *args = data;
 	struct drm_i915_file_private *file_priv = file->driver_priv;
+	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct i915_hw_context *ctx;
 	int ret;
 
@@ -811,7 +819,8 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		return ret;
 
-	ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev), true);
+	ctx = i915_gem_create_context(dev, file_priv, USES_FULL_PPGTT(dev),
+			!dev_priv->lrc_enabled);
 	mutex_unlock(&dev->struct_mutex);
 	if (IS_ERR(ctx))
 		return PTR_ERR(ctx);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +4 -1
index 823ad3d..f7dad8c 100644
@@ -1190,7 +1190,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 		goto pre_mutex_err;
 	}
 
-	ctx = i915_gem_validate_context(dev, file, ring, ctx_id);
+	if (dev_priv->lrc_enabled)
+		ctx = gen8_gem_validate_context(dev, file, ring, ctx_id);
+	else
+		ctx = i915_gem_validate_context(dev, file, ring, ctx_id);
 	if (IS_ERR(ctx)) {
 		mutex_unlock(&dev->struct_mutex);
 		ret = PTR_ERR(ctx);
drivers/gpu/drm/i915/intel_lrc.c +34 -0
index 5a85496..a656b48 100644
@@ -78,6 +78,40 @@
 #define CTX_R_PWR_CLK_STATE		0x42
 #define CTX_GPGPU_CSR_BASE_ADDRESS	0x44
 
+struct i915_hw_context *
+gen8_gem_validate_context(struct drm_device *dev, struct drm_file *file,
+			  struct intel_engine *ring, const u32 ctx_id)
+{
+	struct i915_hw_context *ctx = NULL;
+	struct i915_ctx_hang_stats *hs;
+
+	/* There is no reason why we cannot accept non-default, non-render contexts,
+	 * other than it changes the ABI (these kind of custom contexts have not been
+	 * allowed before) */
+	if (ring->id != RCS && ctx_id != DEFAULT_CONTEXT_ID)
+		return ERR_PTR(-EINVAL);
+
+	ctx = i915_gem_context_get(file->driver_priv, ctx_id);
+	if (IS_ERR(ctx))
+		return ctx;
+
+	hs = &ctx->hang_stats;
+	if (hs->banned) {
+		DRM_DEBUG("Context %u tried to submit while banned\n", ctx_id);
+		return ERR_PTR(-EIO);
+	}
+
+	if (!ctx->engine[ring->id].obj) {
+		int ret = gen8_create_lr_context(ctx, ring, file->driver_priv);
+		if (ret) {
+			DRM_DEBUG("Could not create LRC %u\n", ctx_id);
+			return ERR_PTR(ret);
+		}
+	}
+
+	return ctx;
+}
+
 static int
 intel_populate_lr_context(struct i915_hw_context *ctx,
 			  struct intel_engine *ring)
Signature · 1 line
1.9.0
#57 lore raw

PATCH 26/50 drm/i915/bdw: Allow non-default, non-render, user-created LRCs

In reply to [email protected]

From: Oscar Mateo <[email protected]>

This commit changes the ABI, so it is provided separately so that it can be dropped by the maintainer is so he wishes.

---
 drivers/gpu/drm/i915/intel_lrc.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +0 -6
index a656b48..0a944c2 100644
@@ -85,12 +85,6 @@ gen8_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 	struct i915_hw_context *ctx = NULL;
 	struct i915_ctx_hang_stats *hs;
 
-	/* There is no reason why we cannot accept non-default, non-render contexts,
-	 * other than it changes the ABI (these kind of custom contexts have not been
-	 * allowed before) */
-	if (ring->id != RCS && ctx_id != DEFAULT_CONTEXT_ID)
-		return ERR_PTR(-EINVAL);
-
 	ctx = i915_gem_context_get(file->driver_priv, ctx_id);
 	if (IS_ERR(ctx))
 		return ctx;
Signature · 1 line
1.9.0
#58 lore raw

Re: [PATCH 26/50] drm/i915/bdw: Allow non-default, non-render, user-created LRCs

Quoted 6 lines · On Fri, May 09, 2014 at 01:08:56PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

This commit changes the ABI, so it is provided separately so that it can be dropped by the maintainer is so he wishes.

This looks eerily like a patch from full-ppgtt that I've reverted, originally authored by Ben ;-) Anyway now that we have per-file contexts I think we can forgo this for now, since every open fd will get its own per-ring implicit contxt for blt, vcs and vecs anyway.

And if we have a need for more contexts on those engines the usual rules
apply: I need a fully enabled open-source userspace implementation using this new capability.
-Daniel

Quoted 28 lines
---
 drivers/gpu/drm/i915/intel_lrc.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +0 -6
index a656b48..0a944c2 100644
@@ -85,12 +85,6 @@ gen8_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 	struct i915_hw_context *ctx = NULL;
 	struct i915_ctx_hang_stats *hs;
 
-	/* There is no reason why we cannot accept non-default, non-render contexts,
-	 * other than it changes the ABI (these kind of custom contexts have not been
-	 * allowed before) */
-	if (ring->id != RCS && ctx_id != DEFAULT_CONTEXT_ID)
-		return ERR_PTR(-EINVAL);
-
 	ctx = i915_gem_context_get(file->driver_priv, ctx_id);
 	if (IS_ERR(ctx))
 		return ctx;
Signature · 6 lines
1.9.0

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

Re: [PATCH 26/50] drm/i915/bdw: Allow non-default, non-render, user-created LRCs

Quoted 21 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, May 13, 2014 2:36 PM
To: Mateo Lozano, Oscar
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 26/50] drm/i915/bdw: Allow non-default, non- render, user-created LRCs

Quoted 6 lines · On Fri, May 09, 2014 at 01:08:56PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

This commit changes the ABI, so it is provided separately so that it can be dropped by the maintainer is so he wishes.

This looks eerily like a patch from full-ppgtt that I've reverted, originally authored by Ben ;-) Anyway now that we have per-file contexts I think we can forgo this for now, since every open fd will get its own per-ring implicit contxt for blt, vcs and vecs anyway.

Quoted 4 lines

And if we have a need for more contexts on those engines the usual rules
apply: I need a fully enabled open-source userspace implementation using this new capability.
-Daniel

I know: I saw the patch and your revert, but I had to try anyway :)

#60 lore raw

PATCH 27/50 drm/i915/bdw: Status page for LR contexts

In reply to [email protected]

From: Ben Widawsky <[email protected]>

The status page with logical ring contexts is included already in the context object. Update the init and cleanup functions to reflect that. The status page is offset 0 from the context object when using logical ring contexts.

v2: Several rebases.

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +15 -3
index 8b0260d..eef7094 100644
@@ -1319,16 +1319,21 @@ i915_dispatch_execbuffer(struct intel_engine *ring,
 
 static void cleanup_status_page(struct intel_engine *ring)
 {
+	struct drm_i915_private *dev_priv = to_i915(ring->dev);
 	struct drm_i915_gem_object *obj;
 
 	obj = ring->status_page.obj;
 	if (obj == NULL)
 		return;
+	ring->status_page.obj = NULL;
 
 	kunmap(sg_page(obj->pages->sgl));
+
+	if (dev_priv->lrc_enabled)
+		return;
+
 	i915_gem_object_ggtt_unpin(obj);
 	drm_gem_object_unreference(&obj->base);
-	ring->status_page.obj = NULL;
 }
 
 static int init_status_page(struct intel_engine *ring)
@@ -1455,15 +1460,22 @@ static int intel_init_ring(struct drm_device *dev,
 	init_waitqueue_head(&ring->irq_queue);
 
 	if (dev_priv->lrc_enabled) {
+		struct drm_i915_gem_object *obj;
+
 		ret = gen8_create_lr_context(ring->default_context, ring, NULL);
 		if (ret) {
 			DRM_ERROR("Create LR context for %s failed: %d\n",
 					ring->name, ret);
 			return ret;
 		}
-	}
 
-	if (I915_NEED_GFX_HWS(dev)) {
+		obj = ring->default_context->engine[ring->id].obj;
+		ring->status_page.gfx_addr = i915_gem_obj_ggtt_offset(obj);
+		ring->status_page.page_addr = kmap(sg_page(obj->pages->sgl));
+		if (ring->status_page.page_addr == NULL)
+			return -ENOMEM;
+		ring->status_page.obj = obj;
+	} else if (I915_NEED_GFX_HWS(dev)) {
 		ret = init_status_page(ring);
 		if (ret)
 			return ret;
Signature · 1 line
1.9.0
#61 lore raw

PATCH 28/50 drm/i915/bdw: Enable execlists in the hardware

In reply to [email protected]

From: Ben Widawsky <[email protected]>

v2: Set Replay Mode to 0 per BSpec

Michel Thierry <[email protected]>

v3: Several rebases.

---
 drivers/gpu/drm/i915/intel_lrc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_lrc.c +9 -1
index 0a944c2..a85f91c 100644
@@ -343,9 +343,17 @@ int gen8_gem_context_init(struct drm_device *dev)
 		goto err_out;
 	}
 
-	for_each_ring(ring, dev_priv, ring_id)
+	for_each_ring(ring, dev_priv, ring_id) {
 		ring->default_context = ctx;
 
+		I915_WRITE(RING_MODE_GEN7(ring),
+			_MASKED_BIT_DISABLE(GFX_REPLAY_MODE) |
+			_MASKED_BIT_ENABLE(GFX_RUN_LIST_ENABLE));
+		POSTING_READ(RING_MODE_GEN7(ring));
+		DRM_DEBUG_DRIVER("Execlists enabled for %s\n",
+				ring->name);
+	}
+
 	DRM_DEBUG_DRIVER("LR context support initialized\n");
 	return 0;
 
Signature · 1 line
1.9.0
#62 lore raw

PATCH 29/50 drm/i915/bdw: Execlists ring tail writing

In reply to [email protected]

From: Oscar Mateo <[email protected]>

The write tail function is a very special place for execlists: since all access to the ring is mediated through requests (thanks to Chris Wilson's "Write RING_TAIL once per-request" for that) and all requests end up with a write tail, this is the place we are going to use to submit contexts for execution.

For the moment, just mark the place (we still need to do a lot of preparation before execlists are ready to start submitting things).

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +20 -2
index eef7094..03719b0 100644
@@ -430,6 +430,12 @@ static void ring_write_tail(struct intel_engine *ring,
 	I915_WRITE_TAIL(ring, value);
 }
 
+static void gen8_submit_ctx(struct intel_engine *ring,
+			    struct i915_hw_context *ctx, u32 value)
+{
+	DRM_ERROR("Execlists still not ready!\n");
+}
+
 u64 intel_ring_get_active_head(struct intel_engine *ring)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
@@ -1983,12 +1989,15 @@ int intel_init_render_ring(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_engine *ring = &dev_priv->ring[RCS];
 
+	ring->submit = ring_write_tail;
 	if (INTEL_INFO(dev)->gen >= 6) {
 		ring->add_request = gen6_add_request;
 		ring->flush = gen7_render_ring_flush;
 		if (INTEL_INFO(dev)->gen == 6)
 			ring->flush = gen6_render_ring_flush;
 		if (INTEL_INFO(dev)->gen >= 8) {
+			if (dev_priv->lrc_enabled)
+				ring->submit = gen8_submit_ctx;
 			ring->flush = gen8_render_ring_flush;
 			ring->irq_get = gen8_ring_get_irq;
 			ring->irq_put = gen8_ring_put_irq;
@@ -2043,7 +2052,7 @@ int intel_init_render_ring(struct drm_device *dev)
 		}
 		ring->irq_enable_mask = I915_USER_INTERRUPT;
 	}
-	ring->submit = ring_write_tail;
+
 	if (IS_HASWELL(dev))
 		ring->dispatch_execbuffer = hsw_ring_dispatch_execbuffer;
 	else if (IS_GEN8(dev))
@@ -2163,6 +2172,8 @@ int intel_init_bsd_ring(struct drm_device *dev)
 		ring->get_seqno = gen6_ring_get_seqno;
 		ring->set_seqno = ring_set_seqno;
 		if (INTEL_INFO(dev)->gen >= 8) {
+			if (dev_priv->lrc_enabled)
+				ring->submit = gen8_submit_ctx;
 			ring->irq_enable_mask =
 				GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT;
 			ring->irq_get = gen8_ring_get_irq;
@@ -2229,7 +2240,10 @@ int intel_init_bsd2_ring(struct drm_device *dev)
 		return -EINVAL;
 	}
 
-	ring->submit = ring_write_tail;
+	if (dev_priv->lrc_enabled)
+		ring->submit = gen8_submit_ctx;
+	else
+		ring->submit = ring_write_tail;
 	ring->flush = gen6_bsd_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
@@ -2274,6 +2288,8 @@ int intel_init_blt_ring(struct drm_device *dev)
 	ring->get_seqno = gen6_ring_get_seqno;
 	ring->set_seqno = ring_set_seqno;
 	if (INTEL_INFO(dev)->gen >= 8) {
+		if (dev_priv->lrc_enabled)
+			ring->submit = gen8_submit_ctx;
 		ring->irq_enable_mask =
 			GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT;
 		ring->irq_get = gen8_ring_get_irq;
@@ -2320,6 +2336,8 @@ int intel_init_vebox_ring(struct drm_device *dev)
 	ring->set_seqno = ring_set_seqno;
 
 	if (INTEL_INFO(dev)->gen >= 8) {
+		if (dev_priv->lrc_enabled)
+			ring->submit = gen8_submit_ctx;
 		ring->irq_enable_mask =
 			GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT;
 		ring->irq_get = gen8_ring_get_irq;
Signature · 1 line
1.9.0
#63 lore raw

PATCH 30/50 drm/i915/bdw: LR context ring init

In reply to [email protected]

From: Ben Widawsky <[email protected]>

Logical ring contexts do not need most of the ring init: we just need the pipe control object for the render ring and a few workarounds (some more stuff to be added later).

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 67 +++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +55 -12
index 03719b0..35e89c9 100644
@@ -565,6 +565,11 @@ out:
 	return ret;
 }
 
+static int init_ring_common_lrc(struct intel_engine *ring)
+{
+	return 0;
+}
+
 static int
 init_pipe_control(struct intel_engine *ring)
 {
@@ -663,6 +668,35 @@ static int init_render_ring(struct intel_engine *ring)
 	return ret;
 }
 
+static int init_render_ring_lrc(struct intel_engine *ring)
+{
+	struct drm_device *dev = ring->dev;
+	struct drm_i915_private *dev_priv = to_i915(dev);
+	int ret;
+
+	ret = init_ring_common_lrc(ring);
+	if (ret)
+		return ret;
+
+	/* We need to disable the AsyncFlip performance optimisations in order
+	 * to use MI_WAIT_FOR_EVENT within the CS. It should already be
+	 * programmed to '1' on all products.
+	 *
+	 * WaDisableAsyncFlipPerfMode:snb,ivb,hsw,vlv,bdw
+	 */
+	if (INTEL_INFO(dev)->gen >= 6)
+		I915_WRITE(MI_MODE, _MASKED_BIT_ENABLE(ASYNC_FLIP_PERF_DISABLE));
+
+	ret = init_pipe_control(ring);
+	if (ret)
+		return ret;
+
+	if (INTEL_INFO(dev)->gen >= 6)
+		I915_WRITE(INSTPM, _MASKED_BIT_ENABLE(INSTPM_FORCE_ORDERING));
+
+	return 0;
+}
+
 static void render_ring_cleanup(struct intel_engine *ring)
 {
 	struct drm_device *dev = ring->dev;
@@ -1990,14 +2024,17 @@ int intel_init_render_ring(struct drm_device *dev)
 	struct intel_engine *ring = &dev_priv->ring[RCS];
 
 	ring->submit = ring_write_tail;
+	ring->init = init_render_ring;
 	if (INTEL_INFO(dev)->gen >= 6) {
 		ring->add_request = gen6_add_request;
 		ring->flush = gen7_render_ring_flush;
 		if (INTEL_INFO(dev)->gen == 6)
 			ring->flush = gen6_render_ring_flush;
 		if (INTEL_INFO(dev)->gen >= 8) {
-			if (dev_priv->lrc_enabled)
+			if (dev_priv->lrc_enabled) {
 				ring->submit = gen8_submit_ctx;
+				ring->init = init_render_ring_lrc;
+			}
 			ring->flush = gen8_render_ring_flush;
 			ring->irq_get = gen8_ring_get_irq;
 			ring->irq_put = gen8_ring_put_irq;
@@ -2065,7 +2102,6 @@ int intel_init_render_ring(struct drm_device *dev)
 		ring->dispatch_execbuffer = i830_dispatch_execbuffer;
 	else
 		ring->dispatch_execbuffer = i915_dispatch_execbuffer;
-	ring->init = init_render_ring;
 	ring->cleanup = render_ring_cleanup;
 
 	/* Workaround batchbuffer to combat CS tlb bug. */
@@ -2163,6 +2199,7 @@ int intel_init_bsd_ring(struct drm_device *dev)
 	struct intel_engine *ring = &dev_priv->ring[VCS];
 
 	ring->submit = ring_write_tail;
+	ring->init = init_ring_common;
 	if (INTEL_INFO(dev)->gen >= 6) {
 		/* gen6 bsd needs a special wa for tail updates */
 		if (IS_GEN6(dev))
@@ -2172,8 +2209,10 @@ int intel_init_bsd_ring(struct drm_device *dev)
 		ring->get_seqno = gen6_ring_get_seqno;
 		ring->set_seqno = ring_set_seqno;
 		if (INTEL_INFO(dev)->gen >= 8) {
-			if (dev_priv->lrc_enabled)
+			if (dev_priv->lrc_enabled) {
 				ring->submit = gen8_submit_ctx;
+				ring->init = init_ring_common_lrc;
+			}
 			ring->irq_enable_mask =
 				GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT;
 			ring->irq_get = gen8_ring_get_irq;
@@ -2221,7 +2260,6 @@ int intel_init_bsd_ring(struct drm_device *dev)
 		}
 		ring->dispatch_execbuffer = i965_dispatch_execbuffer;
 	}
-	ring->init = init_ring_common;
 
 	return intel_init_ring(dev, ring);
 }
@@ -2240,10 +2278,13 @@ int intel_init_bsd2_ring(struct drm_device *dev)
 		return -EINVAL;
 	}
 
-	if (dev_priv->lrc_enabled)
+	if (dev_priv->lrc_enabled) {
 		ring->submit = gen8_submit_ctx;
-	else
+		ring->init = init_ring_common_lrc;
+	} else {
 		ring->submit = ring_write_tail;
+		ring->init = init_ring_common;
+	}
 	ring->flush = gen6_bsd_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
@@ -2272,8 +2313,6 @@ int intel_init_bsd2_ring(struct drm_device *dev)
 	ring->semaphore.mbox.signal[VECS] = GEN6_NOSYNC;
 	ring->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC;
 
-	ring->init = init_ring_common;
-
 	return intel_init_ring(dev, ring);
 }
 
@@ -2283,13 +2322,16 @@ int intel_init_blt_ring(struct drm_device *dev)
 	struct intel_engine *ring = &dev_priv->ring[BCS];
 
 	ring->submit = ring_write_tail;
+	ring->init = init_ring_common;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
 	ring->set_seqno = ring_set_seqno;
 	if (INTEL_INFO(dev)->gen >= 8) {
-		if (dev_priv->lrc_enabled)
+		if (dev_priv->lrc_enabled) {
 			ring->submit = gen8_submit_ctx;
+			ring->init = init_ring_common_lrc;
+		}
 		ring->irq_enable_mask =
 			GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT;
 		ring->irq_get = gen8_ring_get_irq;
@@ -2319,7 +2361,6 @@ int intel_init_blt_ring(struct drm_device *dev)
 	ring->semaphore.mbox.signal[BCS] = GEN6_NOSYNC;
 	ring->semaphore.mbox.signal[VECS] = GEN6_VEBSYNC;
 	ring->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC;
-	ring->init = init_ring_common;
 
 	return intel_init_ring(dev, ring);
 }
@@ -2330,14 +2371,17 @@ int intel_init_vebox_ring(struct drm_device *dev)
 	struct intel_engine *ring = &dev_priv->ring[VECS];
 
 	ring->submit = ring_write_tail;
+	ring->init = init_ring_common;
 	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
 	ring->set_seqno = ring_set_seqno;
 
 	if (INTEL_INFO(dev)->gen >= 8) {
-		if (dev_priv->lrc_enabled)
+		if (dev_priv->lrc_enabled) {
 			ring->submit = gen8_submit_ctx;
+			ring->init = init_ring_common_lrc;
+		}
 		ring->irq_enable_mask =
 			GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT;
 		ring->irq_get = gen8_ring_get_irq;
@@ -2361,7 +2405,6 @@ int intel_init_vebox_ring(struct drm_device *dev)
 	ring->semaphore.mbox.signal[BCS] = GEN6_BVESYNC;
 	ring->semaphore.mbox.signal[VECS] = GEN6_NOSYNC;
 	ring->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC;
-	ring->init = init_ring_common;
 
 	return intel_init_ring(dev, ring);
 }
Signature · 1 line
1.9.0
#64 lore raw

PATCH 31/50 drm/i915/bdw: Set the request context information correctly in the LRC case

In reply to [email protected]

From: Oscar Mateo <[email protected]>

We need it (at least) to properly update the last retired head.

---
 drivers/gpu/drm/i915/i915_gem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +4 -1
index f8acf3d..f9ed89e 100644
@@ -2224,7 +2224,10 @@ int __i915_add_request(struct intel_engine *ring,
 	/* 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 (dev_priv->lrc_enabled)
+		request->ctx = ctx;
+	else
+		request->ctx = ring->last_context;
 	if (request->ctx)
 		i915_gem_context_reference(request->ctx);
 
Signature · 1 line
1.9.0
#65 lore raw

PATCH 32/50 drm/i915/bdw: GEN8 new ring flush

In reply to [email protected]

From: Ben Widawsky <[email protected]>

The BSD invalidate bit is no longer present, and we can consolidate the blt and bsd ring flushes into one. This helps prep the code to more easily handle logical ring contexts.

This partially reverts:
commit 65ea32ce040a0a9a907362e9a362a842fd18cb21

Author: Ben Widawsky <[email protected]>
Date:   Thu Dec 13 14:57:32 2012 -0800

drm/i915/bdw: Update MI_FLUSH_DW

v2: Several rebases. Do not forget the VEBOX.

v3: Due to a reorder of the patch series, make it ctx aware now.

---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 60 +++++++++++++++++++++------------
 1 file changed, 38 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +38 -22
index 35e89c9..5e4e3f7 100644
@@ -1870,6 +1870,31 @@ static void gen6_bsd_ring_write_tail(struct intel_engine *ring,
 		   _MASKED_BIT_DISABLE(GEN6_BSD_SLEEP_MSG_DISABLE));
 }
 
+static int gen8_ring_flush(struct intel_engine *ring,
+			   struct i915_hw_context *ctx,
+			   u32 invalidate, u32 flush)
+{
+	uint32_t cmd;
+	struct intel_ringbuffer *ringbuf;
+
+	ringbuf = intel_ringbuffer_begin(ring, ctx, 4);
+	if (IS_ERR_OR_NULL(ringbuf))
+		return (PTR_ERR(ringbuf));
+
+	cmd = MI_FLUSH_DW + 1;
+
+	if (invalidate & I915_GEM_GPU_DOMAINS)
+		cmd |= MI_INVALIDATE_TLB | MI_FLUSH_DW_STORE_INDEX |
+			MI_FLUSH_DW_OP_STOREDW;
+	intel_ringbuffer_emit(ringbuf, cmd);
+	intel_ringbuffer_emit(ringbuf, I915_GEM_HWS_SCRATCH_ADDR | MI_FLUSH_DW_USE_GTT);
+	intel_ringbuffer_emit(ringbuf, 0); /* upper addr */
+	intel_ringbuffer_emit(ringbuf, 0); /* value */
+	intel_ringbuffer_advance(ringbuf);
+
+	return 0;
+}
+
 static int gen6_bsd_ring_flush(struct intel_engine *ring,
 			       struct i915_hw_context *ctx,
 			       u32 invalidate, u32 flush)
@@ -1882,8 +1907,7 @@ static int gen6_bsd_ring_flush(struct intel_engine *ring,
 		return ret;
 
 	cmd = MI_FLUSH_DW;
-	if (INTEL_INFO(ring->dev)->gen >= 8)
-		cmd += 1;
+
 	/*
 	 * Bspec vol 1c.5 - video engine command streamer:
 	 * "If ENABLED, all TLBs will be invalidated once the flush
@@ -1895,13 +1919,9 @@ static int gen6_bsd_ring_flush(struct intel_engine *ring,
 			MI_FLUSH_DW_STORE_INDEX | MI_FLUSH_DW_OP_STOREDW;
 	intel_ring_emit(ring, cmd);
 	intel_ring_emit(ring, I915_GEM_HWS_SCRATCH_ADDR | MI_FLUSH_DW_USE_GTT);
-	if (INTEL_INFO(ring->dev)->gen >= 8) {
-		intel_ring_emit(ring, 0); /* upper addr */
-		intel_ring_emit(ring, 0); /* value */
-	} else  {
-		intel_ring_emit(ring, 0);
-		intel_ring_emit(ring, MI_NOOP);
-	}
+	intel_ring_emit(ring, 0);
+	intel_ring_emit(ring, MI_NOOP);
+
 	intel_ring_advance(ring);
 	return 0;
 }
@@ -1990,8 +2010,7 @@ static int gen6_ring_flush(struct intel_engine *ring,
 		return ret;
 
 	cmd = MI_FLUSH_DW;
-	if (INTEL_INFO(ring->dev)->gen >= 8)
-		cmd += 1;
+
 	/*
 	 * Bspec vol 1c.3 - blitter engine command streamer:
 	 * "If ENABLED, all TLBs will be invalidated once the flush
@@ -2003,13 +2022,7 @@ static int gen6_ring_flush(struct intel_engine *ring,
 			MI_FLUSH_DW_OP_STOREDW;
 	intel_ring_emit(ring, cmd);
 	intel_ring_emit(ring, I915_GEM_HWS_SCRATCH_ADDR | MI_FLUSH_DW_USE_GTT);
-	if (INTEL_INFO(ring->dev)->gen >= 8) {
-		intel_ring_emit(ring, 0); /* upper addr */
-		intel_ring_emit(ring, 0); /* value */
-	} else  {
-		intel_ring_emit(ring, 0);
-		intel_ring_emit(ring, MI_NOOP);
-	}
+	intel_ring_emit(ring, MI_NOOP);
 	intel_ring_advance(ring);
 
 	if (IS_GEN7(dev) && !invalidate && flush)
@@ -2204,7 +2217,6 @@ int intel_init_bsd_ring(struct drm_device *dev)
 		/* gen6 bsd needs a special wa for tail updates */
 		if (IS_GEN6(dev))
 			ring->submit = gen6_bsd_ring_write_tail;
-		ring->flush = gen6_bsd_ring_flush;
 		ring->add_request = gen6_add_request;
 		ring->get_seqno = gen6_ring_get_seqno;
 		ring->set_seqno = ring_set_seqno;
@@ -2213,6 +2225,7 @@ int intel_init_bsd_ring(struct drm_device *dev)
 				ring->submit = gen8_submit_ctx;
 				ring->init = init_ring_common_lrc;
 			}
+			ring->flush = gen8_ring_flush;
 			ring->irq_enable_mask =
 				GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT;
 			ring->irq_get = gen8_ring_get_irq;
@@ -2220,6 +2233,7 @@ int intel_init_bsd_ring(struct drm_device *dev)
 			ring->dispatch_execbuffer =
 				gen8_ring_dispatch_execbuffer;
 		} else {
+			ring->flush = gen6_bsd_ring_flush;
 			ring->irq_enable_mask = GT_BSD_USER_INTERRUPT;
 			ring->irq_get = gen6_ring_get_irq;
 			ring->irq_put = gen6_ring_put_irq;
@@ -2285,7 +2299,7 @@ int intel_init_bsd2_ring(struct drm_device *dev)
 		ring->submit = ring_write_tail;
 		ring->init = init_ring_common;
 	}
-	ring->flush = gen6_bsd_ring_flush;
+	ring->flush = gen8_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
 	ring->set_seqno = ring_set_seqno;
@@ -2323,7 +2337,6 @@ int intel_init_blt_ring(struct drm_device *dev)
 
 	ring->submit = ring_write_tail;
 	ring->init = init_ring_common;
-	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
 	ring->set_seqno = ring_set_seqno;
@@ -2332,12 +2345,14 @@ int intel_init_blt_ring(struct drm_device *dev)
 			ring->submit = gen8_submit_ctx;
 			ring->init = init_ring_common_lrc;
 		}
+		ring->flush = gen8_ring_flush;
 		ring->irq_enable_mask =
 			GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT;
 		ring->irq_get = gen8_ring_get_irq;
 		ring->irq_put = gen8_ring_put_irq;
 		ring->dispatch_execbuffer = gen8_ring_dispatch_execbuffer;
 	} else {
+		ring->flush = gen6_ring_flush;
 		ring->irq_enable_mask = GT_BLT_USER_INTERRUPT;
 		ring->irq_get = gen6_ring_get_irq;
 		ring->irq_put = gen6_ring_put_irq;
@@ -2372,7 +2387,6 @@ int intel_init_vebox_ring(struct drm_device *dev)
 
 	ring->submit = ring_write_tail;
 	ring->init = init_ring_common;
-	ring->flush = gen6_ring_flush;
 	ring->add_request = gen6_add_request;
 	ring->get_seqno = gen6_ring_get_seqno;
 	ring->set_seqno = ring_set_seqno;
@@ -2382,12 +2396,14 @@ int intel_init_vebox_ring(struct drm_device *dev)
 			ring->submit = gen8_submit_ctx;
 			ring->init = init_ring_common_lrc;
 		}
+		ring->flush = gen8_ring_flush;
 		ring->irq_enable_mask =
 			GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT;
 		ring->irq_get = gen8_ring_get_irq;
 		ring->irq_put = gen8_ring_put_irq;
 		ring->dispatch_execbuffer = gen8_ring_dispatch_execbuffer;
 	} else {
+		ring->flush = gen6_ring_flush;
 		ring->irq_enable_mask = PM_VEBOX_USER_INTERRUPT;
 		ring->irq_get = hsw_vebox_get_irq;
 		ring->irq_put = hsw_vebox_put_irq;
Signature · 1 line
1.9.0
#66 lore raw

PATCH 33/50 drm/i915/bdw: Always write seqno to default context

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Even though we have one Hardware Status Page per context, we are still managing the seqnos per engine. Therefore, the sequence number must be written to a consistent place for all contexts: one of the global default contexts.

v2: Since get_seqno and set_seqno now look for the seqno in the engine's status page, they don't need to be changed.

---
 drivers/gpu/drm/i915/i915_reg.h         |  1 +
 drivers/gpu/drm/i915/intel_ringbuffer.c | 67 ++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +1 -0
index 33d007d..2e76ec0 100644
@@ -259,6 +259,7 @@
 #define   MI_FORCE_RESTORE		(1<<1)
 #define   MI_RESTORE_INHIBIT		(1<<0)
 #define MI_STORE_DWORD_IMM	MI_INSTR(0x20, 1)
+#define MI_STORE_DWORD_IMM_GEN8	MI_INSTR(0x20, 2)
 #define   MI_MEM_VIRTUAL	(1 << 22) /* 965+ only */
 #define MI_STORE_DWORD_INDEX	MI_INSTR(0x21, 1)
 #define   MI_STORE_DWORD_INDEX_SHIFT 2
drivers/gpu/drm/i915/intel_ringbuffer.c +66 -1

109 lines not on this page · raw message

Signature · 1 line
1.9.0
#67 lore raw

PATCH 34/50 drm/i915/bdw: Implement context switching (somewhat)

In reply to [email protected]

From: Ben Widawsky <[email protected]>

A context switch occurs by submitting a context descriptor to the ExecList Submission Port. Given that we can now initialize a context, it's possible to begin implementing the context switch by creating the descriptor and submitting it to ELSP (actually two, since the ELSP has two ports).

The context object must be mapped in the GGTT, which means it must exist in the 0-4GB graphics VA range.

v2: This code has changed quite a lot in various rebases. Of particular importance is that now we use the globally unique Submission ID to send to the hardware. Also, context pages are now pinned unconditionally to GGTT, so there is no need to bind them.

v3: Use LRCA[31:11] as hwCtxId[18:0]. This guarantees that the HW context ID we submit to the ELSP is globally unique and != 0 (Bspec requirements of the software use-only bits of the Context ID in the Context Descriptor Format) without the hassle of the previous submission Id construction. Also, re-add the ELSP porting read (it was dropped somewhere during the rebases).

---
 drivers/gpu/drm/i915/i915_drv.h  |  9 ++++
 drivers/gpu/drm/i915/intel_lrc.c | 95 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +9 -0
index 7d06a66..208a4bd 100644
@@ -2434,6 +2434,15 @@ int gen8_create_lr_context(struct i915_hw_context *ctx,
 struct i915_hw_context *
 gen8_gem_validate_context(struct drm_device *dev, struct drm_file *file,
 			  struct intel_engine *ring, const u32 ctx_id);
+static inline u32 intel_get_lr_contextid(struct drm_i915_gem_object *ctx_obj)
+{
+	u32 lrca = i915_gem_obj_ggtt_offset(ctx_obj);
+
+	/* LRCA is required to be 4K aligned and LRCA context image is always at
+	 * least 2 pages, so the more significant 19 bits are globally unique
+	 * (which leaves one HwCtxId bit free) */
+	return lrca >> 13;
+}
 
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
drivers/gpu/drm/i915/intel_lrc.c +95 -0

107 lines not on this page · raw message

Signature · 1 line
1.9.0
#68 lore raw

PATCH 35/50 drm/i915/bdw: Add forcewake lock around ELSP writes

In reply to [email protected]

From: Thomas Daniel <[email protected]>

BSPEC says: SW must set Force Wakeup bit to prevent GT from entering C6 while ELSP writes are in progress.

---
 drivers/gpu/drm/i915/i915_drv.h  |  1 +
 drivers/gpu/drm/i915/intel_lrc.c | 15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 208a4bd..6b39fed 100644
@@ -2694,6 +2694,7 @@ int vlv_freq_opcode(struct drm_i915_private *dev_priv, int val);
 
 #define I915_READ(reg)		dev_priv->uncore.funcs.mmio_readl(dev_priv, (reg), true)
 #define I915_WRITE(reg, val)	dev_priv->uncore.funcs.mmio_writel(dev_priv, (reg), (val), true)
+#define I915_RAW_WRITE(reg, val)	writel(val, dev_priv->regs + reg)
 #define I915_READ_NOTRACE(reg)		dev_priv->uncore.funcs.mmio_readl(dev_priv, (reg), false)
 #define I915_WRITE_NOTRACE(reg, val)	dev_priv->uncore.funcs.mmio_writel(dev_priv, (reg), (val), false)
 
drivers/gpu/drm/i915/intel_lrc.c +11 -4
index 2eb1c28..54cbb4b 100644
@@ -141,14 +141,21 @@ static void submit_execlist(struct intel_engine *ring,
 	desc[3] = (u32)(temp >> 32);
 	desc[2] = (u32)temp;
 
-	I915_WRITE(RING_ELSP(ring), desc[1]);
-	I915_WRITE(RING_ELSP(ring), desc[0]);
-	I915_WRITE(RING_ELSP(ring), desc[3]);
+	/* Set Force Wakeup bit to prevent GT from entering C6 while
+	 * ELSP writes are in progress */
+	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+
+	I915_RAW_WRITE(RING_ELSP(ring), desc[1]);
+	I915_RAW_WRITE(RING_ELSP(ring), desc[0]);
+	I915_RAW_WRITE(RING_ELSP(ring), desc[3]);
 	/* The context is automatically loaded after the following */
-	I915_WRITE(RING_ELSP(ring), desc[2]);
+	I915_RAW_WRITE(RING_ELSP(ring), desc[2]);
 
 	/* ELSP is a write only register, so this serves as a posting read */
 	POSTING_READ(RING_EXECLIST_STATUS(ring));
+
+	/* Release Force Wakeup */
+	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
 }
 
 static int gen8_switch_context(struct intel_engine *ring,
Signature · 1 line
1.9.0
#69 lore raw

PATCH 36/50 drm/i915/bdw: Write the tail pointer, LRC style

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Each logical ring context has the tail pointer in the context object, so update it before submission.

---
 drivers/gpu/drm/i915/intel_lrc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/gpu/drm/i915/intel_lrc.c +19 -0
index 54cbb4b..b06098e 100644
@@ -158,6 +158,21 @@ static void submit_execlist(struct intel_engine *ring,
 	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
 }
 
+static int lr_context_write_tail(struct drm_i915_gem_object *ctx_obj, u32 tail)
+{
+	struct page *page;
+	uint32_t *reg_state;
+
+	page = i915_gem_object_get_page(ctx_obj, 1);
+	reg_state = kmap_atomic(page);
+
+	reg_state[CTX_RING_TAIL+1] = tail;
+
+	kunmap_atomic(reg_state);
+
+	return 0;
+}
+
 static int gen8_switch_context(struct intel_engine *ring,
 		struct i915_hw_context *to0, u32 tail0,
 		struct i915_hw_context *to1, u32 tail1)
@@ -169,10 +184,14 @@ static int gen8_switch_context(struct intel_engine *ring,
 	BUG_ON(!ctx_obj0);
 	BUG_ON(!i915_gem_obj_is_pinned(ctx_obj0));
 
+	lr_context_write_tail(ctx_obj0, tail0);
+
 	if (to1) {
 		ctx_obj1 = to1->engine[ring->id].obj;
 		BUG_ON(!ctx_obj1);
 		BUG_ON(!i915_gem_obj_is_pinned(ctx_obj1));
+
+		lr_context_write_tail(ctx_obj1, tail1);
 	}
 
 	submit_execlist(ring, ctx_obj0, ctx_obj1);
Signature · 1 line
1.9.0
#70 lore raw

PATCH 37/50 drm/i915/bdw: Don't write PDP in the legacy way when using LRCs

In reply to [email protected]

From: Oscar Mateo <[email protected]>

This is mostly for correctness so that we know we are running the LR context correctly (this is, the PDPs are contained inside the context object).

---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +4 -0
index a0993c0..de4a982 100644
@@ -240,11 +240,15 @@ static int gen8_mm_switch(struct i915_hw_ppgtt *ppgtt,
 			  struct intel_engine *ring,
 			  bool synchronous)
 {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	int i, ret;
 
 	/* bit of a hack to find the actual last used pd */
 	int used_pd = ppgtt->num_pd_entries / GEN8_PDES_PER_PAGE;
 
+	if (dev_priv->lrc_enabled)
+		return 0;
+
 	for (i = used_pd - 1; i >= 0; i--) {
 		dma_addr_t addr = ppgtt->pd_dma_addr[i];
 		ret = gen8_write_pdp(ring, i, addr, synchronous);
Signature · 1 line
1.9.0
#71 lore raw

PATCH 38/50 drm/i915/bdw: LR context switch interrupts

In reply to [email protected]

From: Thomas Daniel <[email protected]>

We need to attend context switch interrupts from all rings. Also, fixed writing IMR/IER and added HWSTAM at ring init time.

Notice that, if added to irq_enable_mask, the context switch interrupts would be incorrectly masked out when the user interrupts are due to no users waiting on a sequence number. Therefore, this commit adds a bitmask of interrupts to be kept unmasked at all times.

v2: Disable HWSTAM, as suggested by Damien (nobody listens to these interrupts, anyway).

---
 drivers/gpu/drm/i915/i915_irq.c         | 27 ++++++++++++++++++-------
 drivers/gpu/drm/i915/i915_reg.h         |  2 ++
 drivers/gpu/drm/i915/intel_ringbuffer.c | 36 ++++++++++++++++++++-------------
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 4 files changed, 45 insertions(+), 21 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +20 -7
index 873ae50..a28cf6c 100644
@@ -1300,7 +1300,7 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 				       struct drm_i915_private *dev_priv,
 				       u32 master_ctl)
 {
-	u32 rcs, bcs, vcs;
+	u32 rcs, bcs, vcs, vecs;
 	uint32_t tmp = 0;
 	irqreturn_t ret = IRQ_NONE;
 
@@ -1314,6 +1314,8 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 				notify_ring(dev, &dev_priv->ring[RCS]);
 			if (bcs & GT_RENDER_USER_INTERRUPT)
 				notify_ring(dev, &dev_priv->ring[BCS]);
+			if ((rcs | bcs) & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
 			I915_WRITE(GEN8_GT_IIR(0), tmp);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT0)!\n");
@@ -1326,9 +1328,13 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 			vcs = tmp >> GEN8_VCS1_IRQ_SHIFT;
 			if (vcs & GT_RENDER_USER_INTERRUPT)
 				notify_ring(dev, &dev_priv->ring[VCS]);
+			if (vcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
 			vcs = tmp >> GEN8_VCS2_IRQ_SHIFT;
 			if (vcs & GT_RENDER_USER_INTERRUPT)
 				notify_ring(dev, &dev_priv->ring[VCS2]);
+			if (vcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
 			I915_WRITE(GEN8_GT_IIR(1), tmp);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT1)!\n");
@@ -1338,9 +1344,11 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 		tmp = I915_READ(GEN8_GT_IIR(3));
 		if (tmp) {
 			ret = IRQ_HANDLED;
-			vcs = tmp >> GEN8_VECS_IRQ_SHIFT;
-			if (vcs & GT_RENDER_USER_INTERRUPT)
+			vecs = tmp >> GEN8_VECS_IRQ_SHIFT;
+			if (vecs & GT_RENDER_USER_INTERRUPT)
 				notify_ring(dev, &dev_priv->ring[VECS]);
+			if (vecs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
 			I915_WRITE(GEN8_GT_IIR(3), tmp);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT3)!\n");
@@ -3243,12 +3251,17 @@ static void gen8_gt_irq_postinstall(struct drm_i915_private *dev_priv)
 	/* These are interrupts we'll toggle with the ring mask register */
 	uint32_t gt_interrupts[] = {
 		GT_RENDER_USER_INTERRUPT << GEN8_RCS_IRQ_SHIFT |
-			GT_RENDER_L3_PARITY_ERROR_INTERRUPT |
-			GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT,
+		GT_RENDER_L3_PARITY_ERROR_INTERRUPT |
+		GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_RCS_IRQ_SHIFT |
+		GT_RENDER_USER_INTERRUPT << GEN8_BCS_IRQ_SHIFT |
+		GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_BCS_IRQ_SHIFT,
 		GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT |
-			GT_RENDER_USER_INTERRUPT << GEN8_VCS2_IRQ_SHIFT,
+		GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS1_IRQ_SHIFT |
+		GT_RENDER_USER_INTERRUPT << GEN8_VCS2_IRQ_SHIFT |
+		GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS2_IRQ_SHIFT,
 		0,
-		GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT
+		GT_RENDER_USER_INTERRUPT << GEN8_VECS_IRQ_SHIFT |
+		GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VECS_IRQ_SHIFT,
 		};
 
 	for (i = 0; i < ARRAY_SIZE(gt_interrupts); i++)
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 2e76ec0..97a51f8 100644
@@ -823,6 +823,7 @@ enum punit_power_well {
 #define RING_ACTHD_UDW(base)	((base)+0x5c)
 #define RING_NOPID(base)	((base)+0x94)
 #define RING_IMR(base)		((base)+0xa8)
+#define RING_HWSTAM(base)	((base)+0x98)
 #define RING_TIMESTAMP(base)	((base)+0x358)
 #define   TAIL_ADDR		0x001FFFF8
 #define   HEAD_WRAP_COUNT	0xFFE00000
@@ -4269,6 +4270,7 @@ enum punit_power_well {
 #define GEN8_GT_IMR(which) (0x44304 + (0x10 * (which)))
 #define GEN8_GT_IIR(which) (0x44308 + (0x10 * (which)))
 #define GEN8_GT_IER(which) (0x4430c + (0x10 * (which)))
+#define   GEN8_GT_CONTEXT_SWITCH_INTERRUPT	(1<<8)
 
 #define GEN8_BCS_IRQ_SHIFT 16
 #define GEN8_RCS_IRQ_SHIFT 0
drivers/gpu/drm/i915/intel_ringbuffer.c +22 -14
index d38d824..847fec5 100644
@@ -567,6 +567,12 @@ out:
 
 static int init_ring_common_lrc(struct intel_engine *ring)
 {
+	struct drm_device *dev = ring->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	I915_WRITE_IMR(ring, ~(ring->irq_enable_mask | ring->irq_keep_mask));
+	I915_WRITE(RING_HWSTAM(ring->mmio_base), 0xffffffff);
+
 	return 0;
 }
 
@@ -1288,13 +1294,7 @@ gen8_ring_get_irq(struct intel_engine *ring)
 
 	spin_lock_irqsave(&dev_priv->irq_lock, flags);
 	if (ring->irq_refcount++ == 0) {
-		if (HAS_L3_DPF(dev) && ring->id == RCS) {
-			I915_WRITE_IMR(ring,
-				       ~(ring->irq_enable_mask |
-					 GT_RENDER_L3_PARITY_ERROR_INTERRUPT));
-		} else {
-			I915_WRITE_IMR(ring, ~ring->irq_enable_mask);
-		}
+		I915_WRITE_IMR(ring, ~(ring->irq_enable_mask | ring->irq_keep_mask));
 		POSTING_READ(RING_IMR(ring->mmio_base));
 	}
 	spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
@@ -1311,12 +1311,7 @@ gen8_ring_put_irq(struct intel_engine *ring)
 
 	spin_lock_irqsave(&dev_priv->irq_lock, flags);
 	if (--ring->irq_refcount == 0) {
-		if (HAS_L3_DPF(dev) && ring->id == RCS) {
-			I915_WRITE_IMR(ring,
-				       ~GT_RENDER_L3_PARITY_ERROR_INTERRUPT);
-		} else {
-			I915_WRITE_IMR(ring, ~0);
-		}
+		I915_WRITE_IMR(ring, ~ring->irq_keep_mask);
 		POSTING_READ(RING_IMR(ring->mmio_base));
 	}
 	spin_unlock_irqrestore(&dev_priv->irq_lock, flags);
@@ -2108,15 +2103,20 @@ int intel_init_render_ring(struct drm_device *dev)
 				ring->submit = gen8_submit_ctx;
 				ring->init = init_render_ring_lrc;
 				ring->add_request = gen8_add_request_lrc;
+				ring->irq_keep_mask =
+					GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_RCS_IRQ_SHIFT;
 			}
 			ring->flush = gen8_render_ring_flush;
 			ring->irq_get = gen8_ring_get_irq;
 			ring->irq_put = gen8_ring_put_irq;
+			if (HAS_L3_DPF(dev))
+				ring->irq_keep_mask |= GT_RENDER_L3_PARITY_ERROR_INTERRUPT;
 		} else {
 			ring->irq_get = gen6_ring_get_irq;
 			ring->irq_put = gen6_ring_put_irq;
 		}
-		ring->irq_enable_mask = GT_RENDER_USER_INTERRUPT;
+		ring->irq_enable_mask =
+			GT_RENDER_USER_INTERRUPT << GEN8_RCS_IRQ_SHIFT;
 		ring->get_seqno = gen6_ring_get_seqno;
 		ring->set_seqno = ring_set_seqno;
 		ring->semaphore.sync_to = gen6_ring_sync;
@@ -2286,6 +2286,8 @@ int intel_init_bsd_ring(struct drm_device *dev)
 				ring->submit = gen8_submit_ctx;
 				ring->init = init_ring_common_lrc;
 				ring->add_request = gen8_nonrender_add_request_lrc;
+				ring->irq_keep_mask =
+					GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS1_IRQ_SHIFT;
 			}
 			ring->flush = gen8_ring_flush;
 			ring->irq_enable_mask =
@@ -2358,6 +2360,8 @@ int intel_init_bsd2_ring(struct drm_device *dev)
 		ring->submit = gen8_submit_ctx;
 		ring->add_request = gen8_nonrender_add_request_lrc;
 		ring->init = init_ring_common_lrc;
+		ring->irq_keep_mask =
+			GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VCS2_IRQ_SHIFT;
 	} else {
 		ring->submit = ring_write_tail;
 		ring->add_request = gen6_add_request;
@@ -2408,6 +2412,8 @@ int intel_init_blt_ring(struct drm_device *dev)
 			ring->submit = gen8_submit_ctx;
 			ring->init = init_ring_common_lrc;
 			ring->add_request = gen8_nonrender_add_request_lrc;
+			ring->irq_keep_mask =
+				GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_BCS_IRQ_SHIFT;
 		}
 		ring->flush = gen8_ring_flush;
 		ring->irq_enable_mask =
@@ -2460,6 +2466,8 @@ int intel_init_vebox_ring(struct drm_device *dev)
 			ring->submit = gen8_submit_ctx;
 			ring->init = init_ring_common_lrc;
 			ring->add_request = gen8_nonrender_add_request_lrc;
+			ring->irq_keep_mask =
+				GEN8_GT_CONTEXT_SWITCH_INTERRUPT << GEN8_VECS_IRQ_SHIFT;
 		}
 		ring->flush = gen8_ring_flush;
 		ring->irq_enable_mask =
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index c224fdc..709b1f1 100644
@@ -96,6 +96,7 @@ struct intel_engine {
 
 	unsigned irq_refcount; /* protected by dev_priv->irq_lock */
 	u32		irq_enable_mask;	/* bitmask to enable ring interrupt */
+	u32		irq_keep_mask;		/* bitmask for interrupts that should not be masked */
 	u32		trace_irq_seqno;
 	bool __must_check (*irq_get)(struct intel_engine *ring);
 	void		(*irq_put)(struct intel_engine *ring);
Signature · 1 line
1.9.0
#72 lore raw

PATCH 39/50 drm/i915/bdw: Get prepared for a two-stage execlist submit process

In reply to [email protected]

From: Michel Thierry <[email protected]>

Context switch (and execlist submission) should happen only when other contexts are not active, otherwise pre-emption occurs.

To assure this, we place context switch requests in a queue and those request are later consumed when the right context switch interrupt is received.

v2: Use a spinlock, do not remove the requests on unqueue (wait for context switch completion).

v3: Several rebases and code changes. Use unique ID.

v4:
- Move the queue/lock init to the late ring initialization.
- Damien's kmalloc review comments: check return, use sizeof(*req), do not cast.

---
 drivers/gpu/drm/i915/i915_drv.h         |  6 ++++
 drivers/gpu/drm/i915/intel_lrc.c        | 57 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_ringbuffer.c |  3 ++
 drivers/gpu/drm/i915/intel_ringbuffer.h |  3 ++
 4 files changed, 69 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +6 -0
index 6b39fed..f2aae6a 100644
@@ -1745,6 +1745,9 @@ struct drm_i915_gem_request {
 	struct drm_i915_file_private *file_priv;
 	/** file_priv list entry for this request */
 	struct list_head client_list;
+
+	/** execlist queue entry for this request */
+	struct list_head execlist_link;
 };
 
 struct drm_i915_file_private {
@@ -2443,6 +2446,9 @@ static inline u32 intel_get_lr_contextid(struct drm_i915_gem_object *ctx_obj)
 	 * (which leaves one HwCtxId bit free) */
 	return lrca >> 13;
 }
+int gen8_switch_context_queue(struct intel_engine *ring,
+			      struct i915_hw_context *to,
+			      u32 tail);
 
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
drivers/gpu/drm/i915/intel_lrc.c +57 -0

63 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.c +3 -0
index 847fec5..35ced7c 100644
@@ -1554,6 +1554,9 @@ static int intel_init_ring(struct drm_device *dev,
 
 	init_waitqueue_head(&ring->irq_queue);
 
+	INIT_LIST_HEAD(&ring->execlist_queue);
+	spin_lock_init(&ring->execlist_lock);
+
 	if (dev_priv->lrc_enabled) {
 		struct drm_i915_gem_object *obj;
 
drivers/gpu/drm/i915/intel_ringbuffer.h +3 -0
index 709b1f1..daf91de 100644
@@ -176,6 +176,9 @@ struct intel_engine {
 
 	wait_queue_head_t irq_queue;
 
+	spinlock_t execlist_lock;
+	struct list_head execlist_queue;
+
 	struct i915_hw_context *default_context;
 	struct i915_hw_context *last_context;
 
Signature · 1 line
1.9.0
#73 lore raw

PATCH 40/50 drm/i915/bdw: Handle context switch events

In reply to [email protected]

From: Thomas Daniel <[email protected]>

Handle all context status events in the context status buffer on every context switch interrupt. We only remove work from the execlist queue after a context status buffer reports that it has completed and we only attempt to schedule new contexts on interrupt when a previously submitted context completes (unless no contexts are queued, which means the GPU is free).

v2: Unreferencing the context when we are freeing the request might free the backing bo, which requires the struct_mutex to be grabbed, so defer unreferencing and freeing to a bottom half.

v3:
- Ack the interrupt inmediately, before trying to handle it (fix for missing interrupts by Bob Beckett <[email protected]>).
- Update the Context Status Buffer Read Pointer, just in case (spotted by Damien Lespiau).

---
 drivers/gpu/drm/i915/i915_drv.h         |   3 +
 drivers/gpu/drm/i915/i915_irq.c         |  38 +++++++-----
 drivers/gpu/drm/i915/intel_lrc.c        | 102 +++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_ringbuffer.c |   1 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |   1 +
 5 files changed, 129 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index f2aae6a..07b8bdc 100644
@@ -1748,6 +1748,8 @@ struct drm_i915_gem_request {
 
 	/** execlist queue entry for this request */
 	struct list_head execlist_link;
+	/** Struct to handle this request in the bottom half of an interrupt */
+	struct work_struct work;
 };
 
 struct drm_i915_file_private {
@@ -2449,6 +2451,7 @@ static inline u32 intel_get_lr_contextid(struct drm_i915_gem_object *ctx_obj)
 int gen8_switch_context_queue(struct intel_engine *ring,
 			      struct i915_hw_context *to,
 			      u32 tail);
+void gen8_handle_context_events(struct intel_engine *ring);
 
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
drivers/gpu/drm/i915/i915_irq.c +24 -14
index a28cf6c..fbffead 100644
@@ -1300,6 +1300,7 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 				       struct drm_i915_private *dev_priv,
 				       u32 master_ctl)
 {
+	struct intel_engine *ring;
 	u32 rcs, bcs, vcs, vecs;
 	uint32_t tmp = 0;
 	irqreturn_t ret = IRQ_NONE;
@@ -1307,16 +1308,22 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 	if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) {
 		tmp = I915_READ(GEN8_GT_IIR(0));
 		if (tmp) {
+			I915_WRITE(GEN8_GT_IIR(0), tmp);
 			ret = IRQ_HANDLED;
+
 			rcs = tmp >> GEN8_RCS_IRQ_SHIFT;
-			bcs = tmp >> GEN8_BCS_IRQ_SHIFT;
+			ring = &dev_priv->ring[RCS];
 			if (rcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[RCS]);
+				notify_ring(dev, ring);
+			if (rcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+				gen8_handle_context_events(ring);
+
+			bcs = tmp >> GEN8_BCS_IRQ_SHIFT;
+			ring = &dev_priv->ring[BCS];
 			if (bcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[BCS]);
-			if ((rcs | bcs) & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
-			I915_WRITE(GEN8_GT_IIR(0), tmp);
+				notify_ring(dev, ring);
+			if (bcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+				gen8_handle_context_events(ring);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT0)!\n");
 	}
@@ -1324,18 +1331,20 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 	if (master_ctl & (GEN8_GT_VCS1_IRQ | GEN8_GT_VCS2_IRQ)) {
 		tmp = I915_READ(GEN8_GT_IIR(1));
 		if (tmp) {
+			I915_WRITE(GEN8_GT_IIR(1), tmp);
 			ret = IRQ_HANDLED;
 			vcs = tmp >> GEN8_VCS1_IRQ_SHIFT;
+			ring = &dev_priv->ring[VCS];
 			if (vcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[VCS]);
+				notify_ring(dev, ring);
 			if (vcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
+			     gen8_handle_context_events(ring);
 			vcs = tmp >> GEN8_VCS2_IRQ_SHIFT;
+			ring = &dev_priv->ring[VCS2];
 			if (vcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[VCS2]);
+				notify_ring(dev, ring);
 			if (vcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
-			I915_WRITE(GEN8_GT_IIR(1), tmp);
+			     gen8_handle_context_events(ring);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT1)!\n");
 	}
@@ -1343,13 +1352,14 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 	if (master_ctl & GEN8_GT_VECS_IRQ) {
 		tmp = I915_READ(GEN8_GT_IIR(3));
 		if (tmp) {
+			I915_WRITE(GEN8_GT_IIR(3), tmp);
 			ret = IRQ_HANDLED;
 			vecs = tmp >> GEN8_VECS_IRQ_SHIFT;
+			ring = &dev_priv->ring[VECS];
 			if (vecs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[VECS]);
+				notify_ring(dev, ring);
 			if (vecs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
-			I915_WRITE(GEN8_GT_IIR(3), tmp);
+				gen8_handle_context_events(ring);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT3)!\n");
 	}
drivers/gpu/drm/i915/intel_lrc.c +100 -2

132 lines not on this page · raw message

drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
index 35ced7c..9cd6ee8 100644
@@ -1573,6 +1573,7 @@ static int intel_init_ring(struct drm_device *dev,
 		if (ring->status_page.page_addr == NULL)
 			return -ENOMEM;
 		ring->status_page.obj = obj;
+		ring->next_context_status_buffer = 0;
 	} else if (I915_NEED_GFX_HWS(dev)) {
 		ret = init_status_page(ring);
 		if (ret)
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index daf91de..f3ae547 100644
@@ -178,6 +178,7 @@ struct intel_engine {
 
 	spinlock_t execlist_lock;
 	struct list_head execlist_queue;
+	u8 next_context_status_buffer;
 
 	struct i915_hw_context *default_context;
 	struct i915_hw_context *last_context;
Signature · 1 line
1.9.0
#74 lore raw

Re: [PATCH 40/50] drm/i915/bdw: Handle context switch events

Quoted 11 lines · On Fri, May 09, 2014 at 01:09:10PM +0100, [email protected] wrote:

From: Thomas Daniel <[email protected]>

Handle all context status events in the context status buffer on every context switch interrupt. We only remove work from the execlist queue after a context status buffer reports that it has completed and we only attempt to schedule new contexts on interrupt when a previously submitted context completes (unless no contexts are queued, which means the GPU is free).

Quoted 7 lines

v2: Unreferencing the context when we are freeing the request might free the backing bo, which requires the struct_mutex to be grabbed, so defer unreferencing and freeing to a bottom half.

v3:
- Ack the interrupt inmediately, before trying to handle it (fix for missing interrupts by Bob Beckett <[email protected]>).

This interrupt handling change is interesting since it might explain our irq handling woes on gen5+ with the two-level GT interrupt handling scheme. Can you please roll this out as a prep patch for all the existing gt interrupt sources we handle already for gen5+?

Thanks, Daniel

Quoted 290 lines

- Update the Context Status Buffer Read Pointer, just in case (spotted by Damien Lespiau).

---
 drivers/gpu/drm/i915/i915_drv.h         |   3 +
 drivers/gpu/drm/i915/i915_irq.c         |  38 +++++++-----
 drivers/gpu/drm/i915/intel_lrc.c        | 102 +++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_ringbuffer.c |   1 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |   1 +
 5 files changed, 129 insertions(+), 16 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index f2aae6a..07b8bdc 100644
@@ -1748,6 +1748,8 @@ struct drm_i915_gem_request {
 
 	/** execlist queue entry for this request */
 	struct list_head execlist_link;
+	/** Struct to handle this request in the bottom half of an interrupt */
+	struct work_struct work;
 };
 
 struct drm_i915_file_private {
@@ -2449,6 +2451,7 @@ static inline u32 intel_get_lr_contextid(struct drm_i915_gem_object *ctx_obj)
 int gen8_switch_context_queue(struct intel_engine *ring,
 			      struct i915_hw_context *to,
 			      u32 tail);
+void gen8_handle_context_events(struct intel_engine *ring);
 
 /* i915_gem_evict.c */
 int __must_check i915_gem_evict_something(struct drm_device *dev,
drivers/gpu/drm/i915/i915_irq.c +24 -14
index a28cf6c..fbffead 100644
@@ -1300,6 +1300,7 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 				       struct drm_i915_private *dev_priv,
 				       u32 master_ctl)
 {
+	struct intel_engine *ring;
 	u32 rcs, bcs, vcs, vecs;
 	uint32_t tmp = 0;
 	irqreturn_t ret = IRQ_NONE;
@@ -1307,16 +1308,22 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 	if (master_ctl & (GEN8_GT_RCS_IRQ | GEN8_GT_BCS_IRQ)) {
 		tmp = I915_READ(GEN8_GT_IIR(0));
 		if (tmp) {
+			I915_WRITE(GEN8_GT_IIR(0), tmp);
 			ret = IRQ_HANDLED;
+
 			rcs = tmp >> GEN8_RCS_IRQ_SHIFT;
-			bcs = tmp >> GEN8_BCS_IRQ_SHIFT;
+			ring = &dev_priv->ring[RCS];
 			if (rcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[RCS]);
+				notify_ring(dev, ring);
+			if (rcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+				gen8_handle_context_events(ring);
+
+			bcs = tmp >> GEN8_BCS_IRQ_SHIFT;
+			ring = &dev_priv->ring[BCS];
 			if (bcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[BCS]);
-			if ((rcs | bcs) & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
-			I915_WRITE(GEN8_GT_IIR(0), tmp);
+				notify_ring(dev, ring);
+			if (bcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
+				gen8_handle_context_events(ring);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT0)!\n");
 	}
@@ -1324,18 +1331,20 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 	if (master_ctl & (GEN8_GT_VCS1_IRQ | GEN8_GT_VCS2_IRQ)) {
 		tmp = I915_READ(GEN8_GT_IIR(1));
 		if (tmp) {
+			I915_WRITE(GEN8_GT_IIR(1), tmp);
 			ret = IRQ_HANDLED;
 			vcs = tmp >> GEN8_VCS1_IRQ_SHIFT;
+			ring = &dev_priv->ring[VCS];
 			if (vcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[VCS]);
+				notify_ring(dev, ring);
 			if (vcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
+			     gen8_handle_context_events(ring);
 			vcs = tmp >> GEN8_VCS2_IRQ_SHIFT;
+			ring = &dev_priv->ring[VCS2];
 			if (vcs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[VCS2]);
+				notify_ring(dev, ring);
 			if (vcs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
-			I915_WRITE(GEN8_GT_IIR(1), tmp);
+			     gen8_handle_context_events(ring);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT1)!\n");
 	}
@@ -1343,13 +1352,14 @@ static irqreturn_t gen8_gt_irq_handler(struct drm_device *dev,
 	if (master_ctl & GEN8_GT_VECS_IRQ) {
 		tmp = I915_READ(GEN8_GT_IIR(3));
 		if (tmp) {
+			I915_WRITE(GEN8_GT_IIR(3), tmp);
 			ret = IRQ_HANDLED;
 			vecs = tmp >> GEN8_VECS_IRQ_SHIFT;
+			ring = &dev_priv->ring[VECS];
 			if (vecs & GT_RENDER_USER_INTERRUPT)
-				notify_ring(dev, &dev_priv->ring[VECS]);
+				notify_ring(dev, ring);
 			if (vecs & GEN8_GT_CONTEXT_SWITCH_INTERRUPT)
-			     DRM_DEBUG_DRIVER("TODO: Context switch\n");
-			I915_WRITE(GEN8_GT_IIR(3), tmp);
+				gen8_handle_context_events(ring);
 		} else
 			DRM_ERROR("The master control interrupt lied (GT3)!\n");
 	}
drivers/gpu/drm/i915/intel_lrc.c +100 -2
index 6da7db9..1ff493a 100644
@@ -49,6 +49,22 @@
 #define RING_ELSP(ring)			((ring)->mmio_base+0x230)
 #define RING_EXECLIST_STATUS(ring)	((ring)->mmio_base+0x234)
 #define RING_CONTEXT_CONTROL(ring)	((ring)->mmio_base+0x244)
+#define RING_CONTEXT_STATUS_BUF(ring)	((ring)->mmio_base+0x370)
+#define RING_CONTEXT_STATUS_PTR(ring)	((ring)->mmio_base+0x3a0)
+
+#define RING_EXECLIST_QFULL		(1 << 0x2)
+#define RING_EXECLIST1_VALID		(1 << 0x3)
+#define RING_EXECLIST0_VALID		(1 << 0x4)
+#define RING_EXECLIST_ACTIVE_STATUS	(3 << 0xE)
+#define RING_EXECLIST1_ACTIVE		(1 << 0x11)
+#define RING_EXECLIST0_ACTIVE		(1 << 0x12)
+
+#define GEN8_CTX_STATUS_IDLE_ACTIVE	(1 << 0)
+#define GEN8_CTX_STATUS_PREEMPTED	(1 << 1)
+#define GEN8_CTX_STATUS_ELEMENT_SWITCH	(1 << 2)
+#define GEN8_CTX_STATUS_ACTIVE_IDLE	(1 << 3)
+#define GEN8_CTX_STATUS_COMPLETE	(1 << 4)
+#define GEN8_CTX_STATUS_LITE_RESTORE	(1 << 15)
 
 #define CTX_LRI_HEADER_0		0x01
 #define CTX_CONTEXT_CONTROL		0x02
@@ -203,6 +219,9 @@ static void gen8_switch_context_unqueue(struct intel_engine *ring)
 {
 	struct drm_i915_gem_request *req0 = NULL, *req1 = NULL;
 	struct drm_i915_gem_request *cursor = NULL, *tmp = NULL;
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+
+	assert_spin_locked(&ring->execlist_lock);
 
 	if (list_empty(&ring->execlist_queue))
 		return;
@@ -215,8 +234,7 @@ static void gen8_switch_context_unqueue(struct intel_engine *ring)
 			/* Same ctx: ignore first request, as second request
 			 * will update tail past first request's workload */
 			list_del(&req0->execlist_link);
-			i915_gem_context_unreference(req0->ctx);
-			kfree(req0);
+			queue_work(dev_priv->wq, &req0->work);
 			req0 = cursor;
 		} else {
 			req1 = cursor;
@@ -228,6 +246,85 @@ static void gen8_switch_context_unqueue(struct intel_engine *ring)
 			req1? req1->ctx : NULL, req1? req1->tail : 0));
 }
 
+static bool check_remove_request(struct intel_engine *ring, u32 request_id)
+{
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	struct drm_i915_gem_request *head_req;
+
+	assert_spin_locked(&ring->execlist_lock);
+
+	head_req = list_first_entry_or_null(&ring->execlist_queue,
+			struct drm_i915_gem_request, execlist_link);
+	if (head_req != NULL) {
+		struct drm_i915_gem_object *ctx_obj =
+				head_req->ctx->engine[ring->id].obj;
+		if (intel_get_lr_contextid(ctx_obj) == request_id) {
+			list_del(&head_req->execlist_link);
+			queue_work(dev_priv->wq, &head_req->work);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+void gen8_handle_context_events(struct intel_engine *ring)
+{
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
+	u32 status_pointer;
+	u8 read_pointer;
+	u8 write_pointer;
+	u32 status;
+	u32 status_id;
+	u32 submit_contexts = 0;
+
+	status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(ring));
+
+	read_pointer = ring->next_context_status_buffer;
+	write_pointer = status_pointer & 0x07;
+	if (read_pointer > write_pointer)
+		write_pointer += 6;
+
+	spin_lock(&ring->execlist_lock);
+
+	while (read_pointer < write_pointer) {
+		read_pointer++;
+		status = I915_READ(RING_CONTEXT_STATUS_BUF(ring) +
+				(read_pointer % 6) * 8);
+		status_id = I915_READ(RING_CONTEXT_STATUS_BUF(ring) +
+				(read_pointer % 6) * 8 + 4);
+
+		if (status & GEN8_CTX_STATUS_COMPLETE) {
+			if (check_remove_request(ring, status_id))
+				submit_contexts++;
+		}
+	}
+
+	if (submit_contexts != 0)
+		gen8_switch_context_unqueue(ring);
+
+	spin_unlock(&ring->execlist_lock);
+
+	WARN(submit_contexts > 2, "More than two context complete events?\n");
+	ring->next_context_status_buffer = write_pointer % 6;
+
+	I915_WRITE(RING_CONTEXT_STATUS_PTR(ring),
+			((u32)ring->next_context_status_buffer & 0x07) << 8);
+}
+
+static void free_request_task(struct work_struct *work)
+{
+	struct drm_i915_gem_request *req =
+			container_of(work, struct drm_i915_gem_request, work);
+	struct drm_device *dev = req->ring->dev;
+
+	mutex_lock(&dev->struct_mutex);
+	i915_gem_context_unreference(req->ctx);
+	mutex_unlock(&dev->struct_mutex);
+
+	kfree(req);
+}
+
 int gen8_switch_context_queue(struct intel_engine *ring,
 			      struct i915_hw_context *to,
 			      u32 tail)
@@ -243,6 +340,7 @@ int gen8_switch_context_queue(struct intel_engine *ring,
 	req->ctx = to;
 	i915_gem_context_reference(req->ctx);
 	req->tail = tail;
+	INIT_WORK(&req->work, free_request_task);
 
 	spin_lock_irqsave(&ring->execlist_lock, flags);
 
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
index 35ced7c..9cd6ee8 100644
@@ -1573,6 +1573,7 @@ static int intel_init_ring(struct drm_device *dev,
 		if (ring->status_page.page_addr == NULL)
 			return -ENOMEM;
 		ring->status_page.obj = obj;
+		ring->next_context_status_buffer = 0;
 	} else if (I915_NEED_GFX_HWS(dev)) {
 		ret = init_status_page(ring);
 		if (ret)
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index daf91de..f3ae547 100644
@@ -178,6 +178,7 @@ struct intel_engine {
 
 	spinlock_t execlist_lock;
 	struct list_head execlist_queue;
+	u8 next_context_status_buffer;
 
 	struct i915_hw_context *default_context;
 	struct i915_hw_context *last_context;
Signature · 6 lines
1.9.0

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

Re: [PATCH 40/50] drm/i915/bdw: Handle context switch events

Quoted 29 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, June 11, 2014 12:52 PM
To: Mateo Lozano, Oscar
Cc: [email protected]; Daniel, Thomas
Subject: Re: [Intel-gfx] [PATCH 40/50] drm/i915/bdw: Handle context switch events

Quoted 11 lines · On Fri, May 09, 2014 at 01:09:10PM +0100, [email protected] wrote:

From: Thomas Daniel <[email protected]>

Handle all context status events in the context status buffer on every context switch interrupt. We only remove work from the execlist queue after a context status buffer reports that it has completed and we only attempt to schedule new contexts on interrupt when a previously submitted context completes (unless no contexts are queued, which means the GPU is free).

Quoted 7 lines

v2: Unreferencing the context when we are freeing the request might free the backing bo, which requires the struct_mutex to be grabbed, so defer unreferencing and freeing to a bottom half.

v3:
- Ack the interrupt inmediately, before trying to handle it (fix for missing interrupts by Bob Beckett <[email protected]>).

Quoted 6 lines

This interrupt handling change is interesting since it might explain our irq handling woes on gen5+ with the two-level GT interrupt handling scheme. Can you please roll this out as a prep patch for all the existing gt interrupt sources we handle already for gen5+?

Thanks, Daniel

Can do.

#76 lore raw

Re: [PATCH 40/50] drm/i915/bdw: Handle context switch events

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

- Ack the interrupt inmediately, before trying to handle it (fix for missing interrupts by Bob Beckett <[email protected]>).

This interrupt handling change is interesting since it might explain our irq handling woes on gen5+ with the two-level GT interrupt handling

Quoted 7 lines

scheme.

Quoted 4 lines

Can you please roll this out as a prep patch for all the existing gt interrupt sources we handle already for gen5+?

Thanks, Daniel

Can do.

One question, though: why only the GT interrupts? what about DE, PM, etc...?

It looks like the BSpec is pretty clear on this:

1 - Disable Master Interrupt Control
2 - Find the category of interrupt that is pending
3 - Find the source(s) of the interrupt and ***clear the Interrupt Identity bits (IIR)*** 4 - Process the interrupt(s) that had bits set in the IIRs
5 - Re-enable Master Interrupt Control

#77 lore raw

Re: [PATCH 40/50] drm/i915/bdw: Handle context switch events

Quoted 15 lines · Oscar
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

- Ack the interrupt inmediately, before trying to handle it (fix for missing interrupts by Bob Beckett <[email protected]>).

This interrupt handling change is interesting since it might explain our irq handling woes on gen5+ with the two-level GT interrupt handling

Quoted 7 lines

scheme.

Quoted 4 lines

Can you please roll this out as a prep patch for all the existing gt interrupt sources we handle already for gen5+?

Thanks, Daniel

Can do.

One question, though: why only the GT interrupts? what about DE, PM, etc...?

Quoted 7 lines

It looks like the BSpec is pretty clear on this:

1 - Disable Master Interrupt Control
2 - Find the category of interrupt that is pending
3 - Find the source(s) of the interrupt and ***clear the Interrupt Identity bits (IIR)*** 4 - Process the interrupt(s) that had bits set in the IIRs
5 - Re-enable Master Interrupt Control

Yeah, makes sense to do it for all. When I've looked at it the funky part are the SDE interrupts where we (at least on pre-bdw) have this crazy hack. I guess at least that one we should leave in since apparently it works.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#78 lore raw

PATCH 41/50 drm/i915/bdw: Start queueing contexts to be submitted

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Finally, start queueing request on ring->submit. Also, remove remaining legacy context switches.

---
 drivers/gpu/drm/i915/i915_gem.c            |  9 ++++++---
 drivers/gpu/drm/i915/i915_gem_context.c    | 10 ++++++----
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  8 +++++---
 drivers/gpu/drm/i915/intel_ringbuffer.c    |  5 ++++-
 4 files changed, 21 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +6 -3
index f9ed89e..e2d2edb 100644
@@ -2813,9 +2813,12 @@ int i915_gpu_idle(struct drm_device *dev)
 
 	/* Flush everything onto the inactive list. */
 	for_each_active_ring(ring, dev_priv, i) {
-		ret = i915_switch_context(ring, ring->default_context);
-		if (ret)
-			return ret;
+		if (!dev_priv->lrc_enabled) {
+			ret = i915_switch_context(ring,
+					ring->default_context);
+			if (ret)
+				return ret;
+		}
 
 		ret = intel_ring_idle(ring);
 		if (ret)
drivers/gpu/drm/i915/i915_gem_context.c +6 -4
index d4c6863..bf6264a 100644
@@ -532,10 +532,12 @@ int i915_gem_context_enable(struct drm_i915_private *dev_priv)
 
 	BUG_ON(!dev_priv->ring[RCS].default_context);
 
-	for_each_active_ring(ring, dev_priv, i) {
-		ret = i915_switch_context(ring, ring->default_context);
-		if (ret)
-			return ret;
+	if (!dev_priv->lrc_enabled) {
+		for_each_active_ring(ring, dev_priv, i) {
+			ret = i915_switch_context(ring, ring->default_context);
+			if (ret)
+				return ret;
+		}
 	}
 
 	return 0;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +5 -3
index f7dad8c..9d17bd8 100644
@@ -1288,9 +1288,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	if (ret)
 		goto err;
 
-	ret = i915_switch_context(ring, ctx);
-	if (ret)
-		goto err;
+	if (!dev_priv->lrc_enabled) {
+		ret = i915_switch_context(ring, ctx);
+		if (ret)
+			goto err;
+	}
 
 	if (ring == &dev_priv->ring[RCS] &&
 	    mode != dev_priv->relative_constants_mode) {
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -1
index 9cd6ee8..94c1716 100644
@@ -433,7 +433,10 @@ static void ring_write_tail(struct intel_engine *ring,
 static void gen8_submit_ctx(struct intel_engine *ring,
 			    struct i915_hw_context *ctx, u32 value)
 {
-	DRM_ERROR("Execlists still not ready!\n");
+	if (WARN_ON(ctx == NULL))
+		ctx = ring->default_context;
+
+	gen8_switch_context_queue(ring, ctx, value);
 }
 
 u64 intel_ring_get_active_head(struct intel_engine *ring)
Signature · 1 line
1.9.0
#79 lore raw

PATCH 42/50 drm/i915/bdw: Display execlists info in debugfs

In reply to [email protected]

From: Oscar Mateo <[email protected]>

v2: Warn and return if LRCs are not enabled.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 74 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_reg.h     |  7 ++++
 drivers/gpu/drm/i915/intel_lrc.c    |  6 ---
 3 files changed, 81 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +74 -0
index 204b432..cc212df 100644
@@ -1716,6 +1716,79 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	return 0;
 }
 
+static int i915_execlists(struct seq_file *m, void *data)
+{
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_engine *ring;
+	u32 status_pointer;
+	u8 read_pointer;
+	u8 write_pointer;
+	u32 status;
+	u32 ctx_id;
+	struct list_head *cursor;
+	struct drm_i915_gem_request *head_req;
+	int ring_id, i;
+
+	if (!dev_priv->lrc_enabled) {
+		seq_printf(m, "Logical Ring Contexts are disabled\n");
+		return 0;
+	}
+
+	for_each_active_ring(ring, dev_priv, ring_id) {
+		int count = 0;
+
+		seq_printf(m, "%s\n", ring->name);
+
+		status = I915_READ(RING_EXECLIST_STATUS(ring));
+		ctx_id = I915_READ(RING_EXECLIST_STATUS(ring) + 4);
+		seq_printf(m, "\tExeclist status: 0x%08X, context: %u\n",
+				status, ctx_id);
+
+		status_pointer = I915_READ(RING_CONTEXT_STATUS_PTR(ring));
+		seq_printf(m, "\tStatus pointer: 0x%08X\n", status_pointer);
+
+		read_pointer = ring->next_context_status_buffer;
+		write_pointer = status_pointer & 0x07;
+		if (read_pointer > write_pointer)
+			write_pointer += 6;
+		seq_printf(m, "\tRead pointer: 0x%08X, write pointer 0x%08X\n",
+				read_pointer, write_pointer);
+
+		for (i = 0; i < 6; i++) {
+			status = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i);
+			ctx_id = I915_READ(RING_CONTEXT_STATUS_BUF(ring) + 8*i + 4);
+
+			seq_printf(m, "\tStatus buffer %d: 0x%08X, context: %u\n",
+					i, status, ctx_id);
+		}
+
+		list_for_each(cursor, &ring->execlist_queue) {
+			count++;
+		}
+		seq_printf(m, "\t%d requests in queue\n", count);
+
+		if (count > 0) {
+			struct drm_i915_gem_object *ctx_obj;
+
+			head_req = list_first_entry(&ring->execlist_queue,
+					struct drm_i915_gem_request, execlist_link);
+
+			ctx_obj = head_req->ctx->engine[ring_id].obj;
+			seq_printf(m, "\tHead request id: %u\n",
+					intel_get_lr_contextid(ctx_obj));
+			seq_printf(m, "\tHead request seqno: %u\n", head_req->seqno);
+			seq_printf(m, "\tHead request tail: %u\n", head_req->tail);
+
+		}
+
+		seq_putc(m, '\n');
+	}
+
+	return 0;
+}
+
 static int i915_gen6_forcewake_count_info(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -3771,6 +3844,7 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_opregion", i915_opregion, 0},
 	{"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
 	{"i915_context_status", i915_context_status, 0},
+	{"i915_execlists", i915_execlists, 0},
 	{"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
 	{"i915_swizzle_info", i915_swizzle_info, 0},
 	{"i915_ppgtt_info", i915_ppgtt_info, 0},
drivers/gpu/drm/i915/i915_reg.h +7 -0
index 97a51f8..ab3a650 100644
@@ -116,6 +116,13 @@
 #define GEN8_RING_PDP_UDW(ring, n)	((ring)->mmio_base+0x270 + ((n) * 8 + 4))
 #define GEN8_RING_PDP_LDW(ring, n)	((ring)->mmio_base+0x270 + (n) * 8)
 
+/* Execlists regs */
+#define RING_ELSP(ring)			((ring)->mmio_base+0x230)
+#define RING_EXECLIST_STATUS(ring)	((ring)->mmio_base+0x234)
+#define RING_CONTEXT_CONTROL(ring)	((ring)->mmio_base+0x244)
+#define RING_CONTEXT_STATUS_BUF(ring)	((ring)->mmio_base+0x370)
+#define RING_CONTEXT_STATUS_PTR(ring)	((ring)->mmio_base+0x3a0)
+
 #define GAM_ECOCHK			0x4090
 #define   ECOCHK_SNB_BIT		(1<<10)
 #define   HSW_ECOCHK_ARB_PRIO_SOL	(1<<6)
drivers/gpu/drm/i915/intel_lrc.c +0 -6
index 1ff493a..dc1ab25 100644
@@ -46,12 +46,6 @@
 
 #define GEN8_LR_CONTEXT_ALIGN 4096
 
-#define RING_ELSP(ring)			((ring)->mmio_base+0x230)
-#define RING_EXECLIST_STATUS(ring)	((ring)->mmio_base+0x234)
-#define RING_CONTEXT_CONTROL(ring)	((ring)->mmio_base+0x244)
-#define RING_CONTEXT_STATUS_BUF(ring)	((ring)->mmio_base+0x370)
-#define RING_CONTEXT_STATUS_PTR(ring)	((ring)->mmio_base+0x3a0)
-
 #define RING_EXECLIST_QFULL		(1 << 0x2)
 #define RING_EXECLIST1_VALID		(1 << 0x3)
 #define RING_EXECLIST0_VALID		(1 << 0x4)
Signature · 1 line
1.9.0
#80 lore raw

PATCH 43/50 drm/i915/bdw: Display context backing obj & ringbuffer info in debugfs

In reply to [email protected]

From: Oscar Mateo <[email protected]>

---
 drivers/gpu/drm/i915/i915_debugfs.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +24 -2
index cc212df..c99a872 100644
@@ -1671,6 +1671,12 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
 
 	return 0;
 }
+static void describe_ctx_ringbuf(struct seq_file *m, struct intel_ringbuffer *ringbuf)
+{
+	seq_printf(m, " (ringbuffer, space: %d, head: %u, tail: %u, last head: %d)",
+			ringbuf->space, ringbuf->head, ringbuf->tail,
+			ringbuf->last_retired_head);
+}
 
 static int i915_context_status(struct seq_file *m, void *unused)
 {
@@ -1698,7 +1704,7 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	}
 
 	list_for_each_entry(ctx, &dev_priv->context_list, link) {
-		if (ctx->engine[RCS].obj == NULL)
+		if (!dev_priv->lrc_enabled && ctx->engine[RCS].obj == NULL)
 			continue;
 
 		seq_puts(m, "HW context ");
@@ -1707,7 +1713,23 @@ static int i915_context_status(struct seq_file *m, void *unused)
 			if (ring->default_context == ctx)
 				seq_printf(m, "(default context %s) ", ring->name);
 
-		describe_obj(m, ctx->engine[RCS].obj);
+		if (dev_priv->lrc_enabled) {
+			seq_putc(m, '\n');
+			for_each_active_ring(ring, dev_priv, i) {
+				struct drm_i915_gem_object *ctx_obj = ctx->engine[i].obj;
+				struct intel_ringbuffer *ringbuf = ctx->engine[i].ringbuf;
+
+				seq_printf(m, "%s: ", ring->name);
+				if (ctx_obj)
+					describe_obj(m, ctx_obj);
+				if (ringbuf)
+					describe_ctx_ringbuf(m, ringbuf);
+				seq_putc(m, '\n');
+			}
+		} else {
+			describe_obj(m, ctx->engine[RCS].obj);
+		}
+
 		seq_putc(m, '\n');
 	}
 
Signature · 1 line
1.9.0
#81 lore raw

PATCH 44/50 drm/i915/bdw: Print context state in debugfs

In reply to [email protected]

From: Ben Widawsky <[email protected]>

This has turned out to be really handy in debug so far.

Update:
Since writing this patch, I've gotten similar code upstream for error state. I've used it quite a bit in debugfs however, and I'd like to keep it here at least until preemption is working.

This patch was accidentally dropped in the first Execlists version, and it has been very useful indeed. Put it back again, but as a standalone debugfs file.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 52 +++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
drivers/gpu/drm/i915/i915_debugfs.c +52 -0
index c99a872..7f661bf 100644
@@ -1738,6 +1738,57 @@ static int i915_context_status(struct seq_file *m, void *unused)
 	return 0;
 }
 
+static int i915_dump_lrc(struct seq_file *m, void *unused)
+{
+	struct drm_info_node *node = (struct drm_info_node *) m->private;
+	struct drm_device *dev = node->minor->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_engine *ring;
+	struct i915_hw_context *ctx;
+	int ret, i;
+
+	if (!dev_priv->lrc_enabled) {
+		seq_printf(m, "Logical Ring Contexts are disabled\n");
+		return 0;
+	}
+
+	ret = mutex_lock_interruptible(&dev->mode_config.mutex);
+	if (ret)
+		return ret;
+
+	list_for_each_entry(ctx, &dev_priv->context_list, link) {
+		for_each_active_ring(ring, dev_priv, i) {
+			struct drm_i915_gem_object *ctx_obj = ctx->engine[i].obj;
+
+			if (ring->default_context == ctx)
+				continue;
+
+			if (ctx_obj) {
+				struct page *page = i915_gem_object_get_page(ctx_obj, 1);
+				uint32_t *reg_state = kmap_atomic(page);
+				int j;
+
+				seq_printf(m, "CONTEXT: %s %u\n", ring->name,
+						intel_get_lr_contextid(ctx_obj));
+
+				for (j = 0; j < 0x600 / sizeof(u32) / 4; j += 4) {
+					seq_printf(m, "\t[0x%08lx] 0x%08x 0x%08x 0x%08x 0x%08x\n",
+					i915_gem_obj_ggtt_offset(ctx_obj) + 4096 + (j * 4),
+					reg_state[j], reg_state[j + 1],
+					reg_state[j + 2], reg_state[j + 3]);
+				}
+				kunmap_atomic(reg_state);
+
+				seq_putc(m, '\n');
+			}
+		}
+	}
+
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return 0;
+}
+
 static int i915_execlists(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -3866,6 +3917,7 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_opregion", i915_opregion, 0},
 	{"i915_gem_framebuffer", i915_gem_framebuffer_info, 0},
 	{"i915_context_status", i915_context_status, 0},
+	{"i915_dump_lrc", i915_dump_lrc, 0},
 	{"i915_execlists", i915_execlists, 0},
 	{"i915_gen6_forcewake_count", i915_gen6_forcewake_count_info, 0},
 	{"i915_swizzle_info", i915_swizzle_info, 0},
Signature · 1 line
1.9.0
#82 lore raw

PATCH 45/50 drm/i915/bdw: Document execlists and logical ring contexts

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Explain intel_lrc.c with some execlists notes

v2: Add notes on logical ring context creation.

---
 drivers/gpu/drm/i915/intel_lrc.c | 67 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
drivers/gpu/drm/i915/intel_lrc.c +67 -0
index dc1ab25..49f6c9d 100644
@@ -33,8 +33,75 @@
  * These expanded contexts enable a number of new abilities, especially
  * "Execlists" (also implemented in this file).
  *
+ * One of the main differences with the legacy HW contexts is that logical
+ * ring contexts incorporate many more things to the context's state, like
+ * PDPs or ringbuffer control registers.
+ *
+ * Regarding the creation of contexts, we have:
+ *
+ * - One global default context.
+ * - One local default context for each opened fd.
+ * - One local extra context for each context create ioctl call.
+ *
+ * Now that ringbuffers belong per-context (and not per-engine, like before)
+ * and that contexts are uniquely tied to a given engine (and not reusable,
+ * like before) we need:
+ *
+ * - One ringbuffer per-engine inside each context.
+ * - One backing object per-engine inside each context.
+ *
+ * The global default context starts its life with these new objects fully
+ * allocated and populated. Regarding non-global contexts, we don't know
+ * at creation time which engine is going to use them, so we have implemented
+ * a deferred creation of LR contexts: the local context starts its life as a
+ * hollow or blank holder, that gets populated for a given engine once we receive
+ * an execbuffer. If later on we receive another execbuffer ioctl for the same
+ * context but a different engine, we allocate/populate a new ringbuffer and
+ * context backing object and so on.
+ *
  * Execlists are the new method by which, on gen8+ hardware, workloads are
  * submitted for execution (as opposed to the legacy, ringbuffer-based, method).
+ * This method works as follows:
+ *
+ * When a request is committed, its commands (the BB start and any leading or
+ * trailing commands, like the seqno breadcrumbs) are placed in the ringbuffer
+ * for the appropriate context. The tail pointer in the hardware context is not
+ * updated at this time, but instead, kept by the driver in the ringbuffer
+ * structure. A structure representing this request is added to a request queue
+ * for the appropriate engine: this structure contains a copy of the context's
+ * tail after the request was written to the ring buffer and a pointer to the
+ * context itself.
+ *
+ * If the engine's request queue was empty before the request was added, the
+ * queue is processed immediately. Otherwise the queue will be processed during
+ * a context switch interrupt. In any case, elements on the queue will get sent
+ * (in pairs) to the GPU's ExecLists Submit Port (ELSP, for short) with a
+ * globally unique 20-bits submission ID.
+ *
+ * When execution of a request completes, the GPU updates the context status
+ * buffer with a context complete event and generates a context switch interrupt.
+ * During the interrupt handling, the driver examines the events in the buffer:
+ * for each context complete event, if the announced ID matches that on the head
+ * of the request queue then that request is retired and removed from the queue.
+ *
+ * After processing, if any requests were retired and the queue is not empty
+ * then a new execution list can be submitted. The two requests at the front of
+ * the queue are next to be submitted but since a context may not occur twice in
+ * an execution list, if subsequent requests have the same ID as the first then
+ * the two requests must be combined. This is done simply by discarding requests
+ * at the head of the queue until either only one requests is left (in which case
+ * we use a NULL second context) or the first two requests have unique IDs.
+ *
+ * By always executing the first two requests in the queue the driver ensures
+ * that the GPU is kept as busy as possible. In the case where a single context
+ * completes but a second context is still executing, the request for the second
+ * context will be at the head of the queue when we remove the first one. This
+ * request will then be resubmitted along with a new request for a different context,
+ * which will cause the hardware to continue executing the second request and queue
+ * the new request (the GPU detects the condition of a context getting preempted
+ * with the same context and optimizes the context switch flow by not doing
+ * preemption, but just sampling the new tail pointer).
+ *
  */
 
 #include <drm/drmP.h>
Signature · 1 line
1.9.0
#83 lore raw

PATCH 46/50 drm/i915/bdw: Avoid non-lite-restore preemptions

In reply to [email protected]

From: Oscar Mateo <[email protected]>

In the current Execlists feeding mechanism, full preemption is not supported yet: only lite-restores are allowed (this is: the GPU simply samples a new tail pointer for the context currently in execution).

But we have identified an scenario in which a full preemption occurs:
1) We submit two contexts for execution (A & B).
2) The GPU finishes with the first one (A), switches to the second one
(B) and informs us.
3) We submit B again (hoping to cause a lite restore) together with C, but in the time we spend writing to the ELSP, the GPU finishes B.
4) The GPU start executing B again (since we told it so).
5) We receive a B finished interrupt and, mistakenly, we submit C (again) and D, causing a full preemption of B.

By keeping a better track of our submissions, we can avoid the scenario described above.

---
 drivers/gpu/drm/i915/i915_drv.h  |  3 +++
 drivers/gpu/drm/i915/intel_lrc.c | 28 ++++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
index 07b8bdc..c797e63 100644
@@ -1750,6 +1750,9 @@ struct drm_i915_gem_request {
 	struct list_head execlist_link;
 	/** Struct to handle this request in the bottom half of an interrupt */
 	struct work_struct work;
+
+	/** No. of times this request has been sent to the ELSP */
+	int elsp_submitted;
 };
 
 struct drm_i915_file_private {
drivers/gpu/drm/i915/intel_lrc.c +24 -4
index 49f6c9d..a13a570 100644
@@ -294,6 +294,7 @@ static void gen8_switch_context_unqueue(struct intel_engine *ring)
 		else if (req0->ctx == cursor->ctx) {
 			/* Same ctx: ignore first request, as second request
 			 * will update tail past first request's workload */
+			cursor->elsp_submitted = req0->elsp_submitted;
 			list_del(&req0->execlist_link);
 			queue_work(dev_priv->wq, &req0->work);
 			req0 = cursor;
@@ -303,8 +304,14 @@ static void gen8_switch_context_unqueue(struct intel_engine *ring)
 		}
 	}
 
+	WARN_ON(req1 && req1->elsp_submitted);
+
 	BUG_ON(gen8_switch_context(ring, req0->ctx, req0->tail,
 			req1? req1->ctx : NULL, req1? req1->tail : 0));
+
+	req0->elsp_submitted++;
+	if (req1)
+		req1->elsp_submitted++;
 }
 
 static bool check_remove_request(struct intel_engine *ring, u32 request_id)
@@ -320,9 +327,13 @@ static bool check_remove_request(struct intel_engine *ring, u32 request_id)
 		struct drm_i915_gem_object *ctx_obj =
 				head_req->ctx->engine[ring->id].obj;
 		if (intel_get_lr_contextid(ctx_obj) == request_id) {
-			list_del(&head_req->execlist_link);
-			queue_work(dev_priv->wq, &head_req->work);
-			return true;
+			WARN(head_req->elsp_submitted == 0,
+					"Never submitted head request\n");
+			if (--head_req->elsp_submitted <= 0) {
+				list_del(&head_req->execlist_link);
+				queue_work(dev_priv->wq, &head_req->work);
+				return true;
+			}
 		}
 	}
 
@@ -355,7 +366,16 @@ void gen8_handle_context_events(struct intel_engine *ring)
 		status_id = I915_READ(RING_CONTEXT_STATUS_BUF(ring) +
 				(read_pointer % 6) * 8 + 4);
 
-		if (status & GEN8_CTX_STATUS_COMPLETE) {
+		if (status & GEN8_CTX_STATUS_PREEMPTED) {
+			if (status & GEN8_CTX_STATUS_LITE_RESTORE) {
+				if (check_remove_request(ring, status_id))
+					WARN(1, "Lite Restored request removed from queue\n");
+			} else
+				WARN(1, "Preemption without Lite Restore\n");
+		}
+
+		 if ((status & GEN8_CTX_STATUS_ACTIVE_IDLE) ||
+		     (status & GEN8_CTX_STATUS_ELEMENT_SWITCH)) {
 			if (check_remove_request(ring, status_id))
 				submit_contexts++;
 		}
Signature · 1 line
1.9.0
#84 lore raw

PATCH 47/50 drm/i915/bdw: Make sure gpu reset still works with Execlists

In reply to [email protected]

From: Oscar Mateo <[email protected]>

If we reset a ring after a hang, we have to make sure that we clear out all queued Execlists requests and that we re-program the ring for execution. Also, reset the hangcheck counters.

---
 drivers/gpu/drm/i915/i915_gem.c         | 13 +++++++++++++
 drivers/gpu/drm/i915/intel_lrc.c        | 10 +---------
 drivers/gpu/drm/i915/intel_ringbuffer.c |  8 ++++++++
 3 files changed, 22 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +13 -0
index e2d2edb..4f1bb46 100644
@@ -2400,6 +2400,19 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
 		i915_gem_free_request(request);
 	}
 
+	if (dev_priv->lrc_enabled) {
+		while (!list_empty(&ring->execlist_queue)) {
+			struct drm_i915_gem_request *request;
+
+			request = list_first_entry(&ring->execlist_queue,
+						   struct drm_i915_gem_request,
+						   execlist_link);
+			list_del(&request->execlist_link);
+			i915_gem_context_unreference(request->ctx);
+			kfree(request);
+		}
+	}
+
 	/* These may not have been flush before the reset, do so now */
 	kfree(ring->preallocated_lazy_request);
 	ring->preallocated_lazy_request = NULL;
drivers/gpu/drm/i915/intel_lrc.c +1 -9
index a13a570..d9edd10 100644
@@ -700,17 +700,9 @@ int gen8_gem_context_init(struct drm_device *dev)
 		goto err_out;
 	}
 
-	for_each_ring(ring, dev_priv, ring_id) {
+	for_each_ring(ring, dev_priv, ring_id)
 		ring->default_context = ctx;
 
-		I915_WRITE(RING_MODE_GEN7(ring),
-			_MASKED_BIT_DISABLE(GFX_REPLAY_MODE) |
-			_MASKED_BIT_ENABLE(GFX_RUN_LIST_ENABLE));
-		POSTING_READ(RING_MODE_GEN7(ring));
-		DRM_DEBUG_DRIVER("Execlists enabled for %s\n",
-				ring->name);
-	}
-
 	DRM_DEBUG_DRIVER("LR context support initialized\n");
 	return 0;
 
drivers/gpu/drm/i915/intel_ringbuffer.c +8 -0
index 94c1716..9c0deb2 100644
@@ -573,6 +573,14 @@ static int init_ring_common_lrc(struct intel_engine *ring)
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
+	I915_WRITE(RING_MODE_GEN7(ring),
+		_MASKED_BIT_DISABLE(GFX_REPLAY_MODE) |
+		_MASKED_BIT_ENABLE(GFX_RUN_LIST_ENABLE));
+	POSTING_READ(RING_MODE_GEN7(ring));
+	DRM_DEBUG_DRIVER("Execlists enabled for %s\n", ring->name);
+
+	memset(&ring->hangcheck, 0, sizeof(ring->hangcheck));
+
 	I915_WRITE_IMR(ring, ~(ring->irq_enable_mask | ring->irq_keep_mask));
 	I915_WRITE(RING_HWSTAM(ring->mmio_base), 0xffffffff);
 
Signature · 1 line
1.9.0
#85 lore raw

PATCH 48/50 drm/i915/bdw: Make sure error capture keeps working with Execlists

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Since the ringbuffer does not belong per engine anymore, we have to make sure that we are always recording the correct ringbuffer.

TODO: This is only a small fix to keep basic error capture working, but we need to add more information for it to be useful (e.g. dump the context being executed).

---
 drivers/gpu/drm/i915/i915_gpu_error.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +7 -4
index 6724e32..31ff7e1 100644
@@ -823,9 +823,6 @@ static void i915_record_ring_state(struct drm_device *dev,
 		ering->hws = I915_READ(mmio);
 	}
 
-	ering->cpu_ring_head = ring->default_ringbuf.head;
-	ering->cpu_ring_tail = ring->default_ringbuf.tail;
-
 	ering->hangcheck_score = ring->hangcheck.score;
 	ering->hangcheck_action = ring->hangcheck.action;
 
@@ -881,6 +878,7 @@ static void i915_gem_record_rings(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_request *request;
+	struct intel_ringbuffer *ringbuf;
 	int i, count;
 
 	for (i = 0; i < I915_NUM_RINGS; i++) {
@@ -927,8 +925,13 @@ static void i915_gem_record_rings(struct drm_device *dev,
 			}
 		}
 
+		ringbuf = intel_ringbuffer_get(ring,
+				request ? request->ctx : ring->default_context);
+		error->ring[i].cpu_ring_head = ringbuf->head;
+		error->ring[i].cpu_ring_tail = ringbuf->tail;
+
 		error->ring[i].ringbuffer =
-			i915_error_ggtt_object_create(dev_priv, ring->default_ringbuf.obj);
+			i915_error_ggtt_object_create(dev_priv, ringbuf->obj);
 
 		if (ring->status_page.obj)
 			error->ring[i].hws_page =
Signature · 1 line
1.9.0
#86 lore raw

PATCH 49/50 drm/i915/bdw: Help out the ctx switch interrupt handler

In reply to [email protected]

From: Oscar Mateo <[email protected]>

If we receive a storm of requests for the same context (see gem_storedw_loop_*) we might end up iterating over too many elements in interrupt time, looking for contexts to squash together. Instead, share the burden by giving more intelligence to the queue function. At most, the interrupt will iterate over three elements.

---
 drivers/gpu/drm/i915/intel_lrc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +20 -3
index d9edd10..0aad721 100644
@@ -410,9 +410,11 @@ int gen8_switch_context_queue(struct intel_engine *ring,
 			      struct i915_hw_context *to,
 			      u32 tail)
 {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	struct drm_i915_gem_request *req = NULL;
 	unsigned long flags;
-	bool was_empty;
+	struct drm_i915_gem_request *cursor;
+	int num_elements = 0;
 
 	req = kzalloc(sizeof(*req), GFP_KERNEL);
 	if (req == NULL)
@@ -425,9 +427,24 @@ int gen8_switch_context_queue(struct intel_engine *ring,
 
 	spin_lock_irqsave(&ring->execlist_lock, flags);
 
-	was_empty = list_empty(&ring->execlist_queue);
+	list_for_each_entry(cursor, &ring->execlist_queue, execlist_link)
+		if (++num_elements > 2)
+			break;
+
+	if (num_elements > 2) {
+		struct drm_i915_gem_request *tail_req =
+				list_last_entry(&ring->execlist_queue,
+					struct drm_i915_gem_request, execlist_link);
+		if (to == tail_req->ctx) {
+			WARN(tail_req->elsp_submitted != 0,
+					"More than 2 already-submitted reqs queued\n");
+			list_del(&tail_req->execlist_link);
+			queue_work(dev_priv->wq, &tail_req->work);
+		}
+	}
+
 	list_add_tail(&req->execlist_link, &ring->execlist_queue);
-	if (was_empty)
+	if (num_elements == 0)
 		gen8_switch_context_unqueue(ring);
 
 	spin_unlock_irqrestore(&ring->execlist_lock, flags);
Signature · 1 line
1.9.0
#87 lore raw

Re: [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

Quoted 40 lines · On Fri, May 09, 2014 at 01:09:19PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

If we receive a storm of requests for the same context (see gem_storedw_loop_*) we might end up iterating over too many elements in interrupt time, looking for contexts to squash together. Instead, share the burden by giving more intelligence to the queue function. At most, the interrupt will iterate over three elements.

---
 drivers/gpu/drm/i915/intel_lrc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +8 -2
index d9edd10..0aad721 100644
@@ -410,9 +410,11 @@ int gen8_switch_context_queue(struct intel_engine *ring,
 			      struct i915_hw_context *to,
 			      u32 tail)
 {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	struct drm_i915_gem_request *req = NULL;
 	unsigned long flags;
-	bool was_empty;
+	struct drm_i915_gem_request *cursor;
+	int num_elements = 0;
 
 	req = kzalloc(sizeof(*req), GFP_KERNEL);
 	if (req == NULL)
@@ -425,9 +427,24 @@ int gen8_switch_context_queue(struct intel_engine *ring,
 
 	spin_lock_irqsave(&ring->execlist_lock, flags);
 
-	was_empty = list_empty(&ring->execlist_queue);
+	list_for_each_entry(cursor, &ring->execlist_queue, execlist_link)
+		if (++num_elements > 2)
+			break;
+
+	if (num_elements > 2) {

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring, · line 444

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +10 -0
+		struct drm_i915_gem_request *tail_req =
+				list_last_entry(&ring->execlist_queue,
+					struct drm_i915_gem_request, execlist_link);
+		if (to == tail_req->ctx) {
+			WARN(tail_req->elsp_submitted != 0,
+					"More than 2 already-submitted reqs queued\n");
+			list_del(&tail_req->execlist_link);
+			queue_work(dev_priv->wq, &tail_req->work);
+		}
+	}

Completely forgotten to mention this: Chris&I discussed this on irc and I guess this issue will disappear if we track contexts instead of requests in the scheduler. I guess this is an artifact of the gen7 scheduler you've based this on, but even for that I think scheduling contexts (with preempt point after each batch) is the right approach. But I haven't dug out the scheduler patches again so might be wrong with that.
-Daniel

Quoted 14 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -1
+
 	list_add_tail(&req->execlist_link, &ring->execlist_queue);
-	if (was_empty)
+	if (num_elements == 0)
 		gen8_switch_context_unqueue(ring);
 
 	spin_unlock_irqrestore(&ring->execlist_lock, flags);
Signature · 6 lines
1.9.0

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

Re: [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

Quoted 62 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, June 11, 2014 12:50 PM
To: Mateo Lozano, Oscar
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct

Quoted 19 lines · On Fri, May 09, 2014 at 01:09:19PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

If we receive a storm of requests for the same context (see gem_storedw_loop_*) we might end up iterating over too many elements in interrupt time, looking for contexts to squash together. Instead, share the burden by giving more intelligence to the queue function. At most, the interrupt will iterate over three elements.

---
 drivers/gpu/drm/i915/intel_lrc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index d9edd10..0aad721 100644
@@ -410,9 +410,11 @@ int gen8_switch_context_queue(struct

intel_engine *ring,

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct

Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -1
 			      struct i915_hw_context *to,
 			      u32 tail)
 {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	struct drm_i915_gem_request *req = NULL;
 	unsigned long flags;
-	bool was_empty;
+	struct drm_i915_gem_request *cursor;
+	int num_elements = 0;
 
 	req = kzalloc(sizeof(*req), GFP_KERNEL);
 	if (req == NULL)
@@ -425,9 +427,24 @@ int gen8_switch_context_queue(struct

intel_engine

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring,

Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +8 -1
 *ring,
 
 	spin_lock_irqsave(&ring->execlist_lock, flags);
 
-	was_empty = list_empty(&ring->execlist_queue);
+	list_for_each_entry(cursor, &ring->execlist_queue, execlist_link)
+		if (++num_elements > 2)
+			break;
+
+	if (num_elements > 2) {
+		struct drm_i915_gem_request *tail_req =
+				list_last_entry(&ring->execlist_queue,
+					struct drm_i915_gem_request,

execlist_link);

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring,

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+		if (to == tail_req->ctx) {
+			WARN(tail_req->elsp_submitted != 0,
+					"More than 2 already-submitted reqs

queued\n");

Quoted 12 lines

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring, · line 444

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +4 -0
+			list_del(&tail_req->execlist_link);
+			queue_work(dev_priv->wq, &tail_req->work);
+		}
+	}

Completely forgotten to mention this: Chris&I discussed this on irc and I guess this issue will disappear if we track contexts instead of requests in the scheduler. I guess this is an artifact of the gen7 scheduler you've based this on, but even for that I think scheduling contexts (with preempt point after each batch) is the right approach. But I haven't dug out the scheduler patches again so might be wrong with that.
-Daniel

Hmmmm... I didn´t really base this on the scheduler. Some kind of queue to hold context submissions until the hardware was ready was needed, and queuing drm_i915_gem_requests seemed like a good choice at the time (by the way, in the next version I am using a new struct intel_ctx_submit_request, since I don´t need most of the fields in drm_i915_gem_requests, and I have to add a couple of new ones anyway).

What do you mean by "scheduling contexts"? Notice that the requests I am queuing basically just contain the context and the tail at the point it was submitted for execution...

#89 lore raw

Re: [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

Quoted 82 lines · Oscar
Quoted 62 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, June 11, 2014 12:50 PM
To: Mateo Lozano, Oscar
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct

Quoted 19 lines · On Fri, May 09, 2014 at 01:09:19PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

If we receive a storm of requests for the same context (see gem_storedw_loop_*) we might end up iterating over too many elements in interrupt time, looking for contexts to squash together. Instead, share the burden by giving more intelligence to the queue function. At most, the interrupt will iterate over three elements.

---
 drivers/gpu/drm/i915/intel_lrc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index d9edd10..0aad721 100644
@@ -410,9 +410,11 @@ int gen8_switch_context_queue(struct

intel_engine *ring,

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct

Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -1
 			      struct i915_hw_context *to,
 			      u32 tail)
 {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	struct drm_i915_gem_request *req = NULL;
 	unsigned long flags;
-	bool was_empty;
+	struct drm_i915_gem_request *cursor;
+	int num_elements = 0;
 
 	req = kzalloc(sizeof(*req), GFP_KERNEL);
 	if (req == NULL)
@@ -425,9 +427,24 @@ int gen8_switch_context_queue(struct

intel_engine

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring,

Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +8 -1
 *ring,
 
 	spin_lock_irqsave(&ring->execlist_lock, flags);
 
-	was_empty = list_empty(&ring->execlist_queue);
+	list_for_each_entry(cursor, &ring->execlist_queue, execlist_link)
+		if (++num_elements > 2)
+			break;
+
+	if (num_elements > 2) {
+		struct drm_i915_gem_request *tail_req =
+				list_last_entry(&ring->execlist_queue,
+					struct drm_i915_gem_request,

execlist_link);

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring,

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+		if (to == tail_req->ctx) {
+			WARN(tail_req->elsp_submitted != 0,
+					"More than 2 already-submitted reqs

queued\n");

Quoted 12 lines

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring, · line 444

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +4 -0
+			list_del(&tail_req->execlist_link);
+			queue_work(dev_priv->wq, &tail_req->work);
+		}
+	}

Completely forgotten to mention this: Chris&I discussed this on irc and I guess this issue will disappear if we track contexts instead of requests in the scheduler. I guess this is an artifact of the gen7 scheduler you've based this on, but even for that I think scheduling contexts (with preempt point after each batch) is the right approach. But I haven't dug out the scheduler patches again so might be wrong with that.
-Daniel

Hmmmm... I didn´t really base this on the scheduler. Some kind of queue to hold context submissions until the hardware was ready was needed, and queuing drm_i915_gem_requests seemed like a good choice at the time (by the way, in the next version I am using a new struct intel_ctx_submit_request, since I don´t need most of the fields in drm_i915_gem_requests, and I have to add a couple of new ones anyway).

Quoted 3 lines

What do you mean by "scheduling contexts"? Notice that the requests I am queuing basically just contain the context and the tail at the point it was submitted for execution...

Well I've thought we could just throw contexts at the hardware and throw new ones at it when the old ones get stuck/are completed. But now I've realized that since we do the cross-engine/ctx depency tracking in software it's not quite that easy and we can't unconditionally update the tail-pointer.

Still for the degenerate case of one ctx submitting batches exclusively I've hoped just updating the tail pointer in the context and telling the hw to reload the current context should have been enough. Or at least I've hoped so, and that should take (mostly) care of the insane request overload case your patch here addresses.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#90 lore raw

Re: [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

Quoted 96 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, June 11, 2014 2:58 PM
To: Mateo Lozano, Oscar
Cc: Daniel Vetter; [email protected]
Subject: Re: [Intel-gfx] [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

Quoted 10 lines · Oscar
Quoted 10 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, June 11, 2014 12:50 PM
To: Mateo Lozano, Oscar
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH 49/50] drm/i915/bdw: Help out the ctx switch interrupt handler

On Fri, May 09, 2014 at 01:09:19PM +0100, [email protected]

Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines

From: Oscar Mateo <[email protected]>

If we receive a storm of requests for the same context (see gem_storedw_loop_*) we might end up iterating over too many elements in interrupt time, looking for contexts to squash together. Instead, share the burden by giving more intelligence to the queue function. At most, the interrupt will iterate over three

elements.

Quoted 45 lines
Quoted 45 lines

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct

Quoted 12 lines
---
 drivers/gpu/drm/i915/intel_lrc.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +0 -0
index d9edd10..0aad721 100644
@@ -410,9 +410,11 @@ int gen8_switch_context_queue(struct

intel_engine *ring,

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct

Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -1
 			      struct i915_hw_context *to,
 			      u32 tail)
 {
+	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	struct drm_i915_gem_request *req = NULL;
 	unsigned long flags;
-	bool was_empty;
+	struct drm_i915_gem_request *cursor;
+	int num_elements = 0;
 
 	req = kzalloc(sizeof(*req), GFP_KERNEL);
 	if (req == NULL)
@@ -425,9 +427,24 @@ int gen8_switch_context_queue(struct

intel_engine

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring,

Quoted 13 lines
drivers/gpu/drm/i915/intel_lrc.c +8 -1
 *ring,
 
 	spin_lock_irqsave(&ring->execlist_lock, flags);
 
-	was_empty = list_empty(&ring->execlist_queue);
+	list_for_each_entry(cursor, &ring->execlist_queue, execlist_link)
+		if (++num_elements > 2)
+			break;
+
+	if (num_elements > 2) {
+		struct drm_i915_gem_request *tail_req =
+				list_last_entry(&ring->execlist_queue,
+					struct drm_i915_gem_request,

execlist_link);

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring,

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+		if (to == tail_req->ctx) {
+			WARN(tail_req->elsp_submitted != 0,
+					"More than 2 already-submitted reqs

queued\n");

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/i915/intel_lrc.c int gen8_switch_context_queue(struct intel_engine *ring, · line 444

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +4 -0
+			list_del(&tail_req->execlist_link);
+			queue_work(dev_priv->wq, &tail_req->work);
+		}
+	}

Completely forgotten to mention this: Chris&I discussed this on irc and I guess this issue will disappear if we track contexts instead of requests in the scheduler. I guess this is an artifact of the gen7 scheduler you've based this on, but even for that I think scheduling contexts (with preempt point after each batch) is the right approach. But I haven't dug out the scheduler patches again so

might be wrong with that.

Quoted 5 lines
Quoted 1 line

-Daniel

Hmmmm... I didn´t really base this on the scheduler. Some kind of queue to hold context submissions until the hardware was ready was needed, and queuing drm_i915_gem_requests seemed like a good choice

at

Quoted 4 lines

the time (by the way, in the next version I am using a new struct intel_ctx_submit_request, since I don´t need most of the fields in drm_i915_gem_requests, and I have to add a couple of new ones anyway).

Quoted 8 lines
Quoted 3 lines

What do you mean by "scheduling contexts"? Notice that the requests I am queuing basically just contain the context and the tail at the point it was submitted for execution...

Well I've thought we could just throw contexts at the hardware and throw new ones at it when the old ones get stuck/are completed. But now I've realized that since we do the cross-engine/ctx depency tracking in software it's not quite that easy and we can't unconditionally update the tail-pointer.

Exactly: unconditionally updating the tail-pointer also means the seqnos might get executed out of order, which is not nice (at least until there is a scheduler keeping track of the dependencies).

Quoted 5 lines

Still for the degenerate case of one ctx submitting batches exclusively I've hoped just updating the tail pointer in the context and telling the hw to reload the current context should have been enough. Or at least I've hoped so, and that should take (mostly) care of the insane request overload case your patch here addresses.

What we had before this patch:

A) The submitter places one request per new batch received in the queue, regardless.
B) The interrupt handler traverses the queue backwards, squashing together all requests for the same context that come in a row. Notice that the first one in the queue might be already in execution, in which case the squashing will end up doing exactly what you said: updating the tail pointer.
C) When the ELSP is written to, if the same context was already in execution, the GPU performs a Lite Restore (the new tail is sampled and execution continues).

After this patch:

A) The submitter places one request per new batch received in the queue. But, if the last request in the queue belongs to the same context, and it´s not suspicious of being in-execution (which means it occupies the 3rd position or higher) then squash the two requests together (the old and the new).
B) The interrupt handler traverses the queue backwards, squashing together all requests for the same context that come in a row (maximum of two: one in execution, and the pending one).
C) When the ELSP is written to, if the same context was already in execution, the GPU performs a Lite Restore (the new tail is sampled and execution continues).

In a graphical form, if A and B are contexts and (*) means they are in execution:

B3 -> B2 B1* A1* (the submitter wants to queue B with tail 3)
B3 B1* A1*(as B2 is redundant, the submitter drops it and queues B3 in place)
B3 B1* (the interrupt informs us that A is complete, so we remove it from the head of the queue) -> B3 (since B1 is redundant, we submit B3, causing a Lite Restore)

(* context in execution)

#91 lore raw

PATCH 50/50 drm/i915/bdw: Enable logical ring contexts

In reply to [email protected]

From: Oscar Mateo <[email protected]>

The time has come, the Walrus said, to talk of many things.

---
 drivers/gpu/drm/i915/i915_drv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
index c797e63..969962c 100644
@@ -1937,7 +1937,7 @@ struct drm_i915_cmd_table {
 #define I915_NEED_GFX_HWS(dev)	(INTEL_INFO(dev)->need_gfx_hws)
 
 #define HAS_HW_CONTEXTS(dev)	(INTEL_INFO(dev)->gen >= 6)
-#define HAS_LOGICAL_RING_CONTEXTS(dev)	0
+#define HAS_LOGICAL_RING_CONTEXTS(dev)	(INTEL_INFO(dev)->gen >= 8)
 #define HAS_ALIASING_PPGTT(dev)	(INTEL_INFO(dev)->gen >= 6 && \
 				 (!IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)))
 #define HAS_PPGTT(dev)		(INTEL_INFO(dev)->gen >= 7 \
Signature · 1 line
1.9.0
#92 lore raw

PATCH 1/1 drm/i915/bdw: Do not call intel_runtime_pm_get() in an interrupt

In reply to [email protected]

From: Oscar Mateo <[email protected]>

Or with a spinlock grabbed, because it might sleep, which is not a nice thing to do. Instead, do the runtime_pm get/put together with the create/destroy request, and handle the forcewake get/put directly.

This can be squashed with:

[PATCH 35/50] drm/i915/bdw: Add forcewake lock around ELSP writes

but it needs some patch reordering, so I will leave it for the next patchset version.

---
 drivers/gpu/drm/i915/intel_lrc.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +21 -5
index e624580..55255e8 100644
@@ -205,6 +205,7 @@ static void submit_execlist(struct intel_engine *ring,
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	uint64_t temp = 0;
 	uint32_t desc[4];
+	unsigned long flags;
 
 	/* XXX: You must always write both descriptors in the order below. */
 	if (ctx_obj1)
@@ -218,9 +219,17 @@ static void submit_execlist(struct intel_engine *ring,
 	desc[3] = (u32)(temp >> 32);
 	desc[2] = (u32)temp;
 
-	/* Set Force Wakeup bit to prevent GT from entering C6 while
-	 * ELSP writes are in progress */
-	gen6_gt_force_wake_get(dev_priv, FORCEWAKE_ALL);
+	/* Set Force Wakeup bit to prevent GT from entering C6 while ELSP writes
+	 * are in progress.
+	 *
+	 * The other problem is that we can't just call gen6_gt_force_wake_get()
+	 * because that function calls intel_runtime_pm_get(), which might sleep.
+	 * Instead, we do the runtime_pm_get/put when creating/destroying requests.
+	 */
+	spin_lock_irqsave(&dev_priv->uncore.lock, flags);
+	if (dev_priv->uncore.forcewake_count++ == 0)
+		dev_priv->uncore.funcs.force_wake_get(dev_priv, FORCEWAKE_ALL);
+	spin_unlock_irqrestore(&dev_priv->uncore.lock, flags);
 
 	I915_RAW_WRITE(RING_ELSP(ring), desc[1]);
 	I915_RAW_WRITE(RING_ELSP(ring), desc[0]);
@@ -231,8 +240,11 @@ static void submit_execlist(struct intel_engine *ring,
 	/* ELSP is a write only register, so this serves as a posting read */
 	POSTING_READ(RING_EXECLIST_STATUS(ring));
 
-	/* Release Force Wakeup */
-	gen6_gt_force_wake_put(dev_priv, FORCEWAKE_ALL);
+	/* Release Force Wakeup (see the big comment above). */
+	spin_lock_irqsave(&dev_priv->uncore.lock, flags);
+	if (--dev_priv->uncore.forcewake_count == 0)
+		dev_priv->uncore.funcs.force_wake_put(dev_priv, FORCEWAKE_ALL);
+	spin_unlock_irqrestore(&dev_priv->uncore.lock, flags);
 }
 
 static int lr_context_write_tail(struct drm_i915_gem_object *ctx_obj, u32 tail)
@@ -398,6 +410,9 @@ static void free_request_task(struct work_struct *work)
 	struct drm_i915_gem_request *req =
 			container_of(work, struct drm_i915_gem_request, work);
 	struct drm_device *dev = req->ring->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	intel_runtime_pm_put(dev_priv);
 
 	mutex_lock(&dev->struct_mutex);
 	i915_gem_context_unreference(req->ctx);
@@ -424,6 +439,7 @@ int gen8_switch_context_queue(struct intel_engine *ring,
 	i915_gem_context_reference(req->ctx);
 	req->tail = tail;
 	INIT_WORK(&req->work, free_request_task);
+	intel_runtime_pm_get(dev_priv);
 
 	spin_lock_irqsave(&ring->execlist_lock, flags);
 
Signature · 1 line
1.9.0
#93 lore raw
In reply to [email protected]
Quoted 37 lines · On Fri, May 09, 2014 at 01:08:30PM +0100, [email protected] wrote:

From: Oscar Mateo <[email protected]>

For a description of this patchset, please check the previous cover letter [1].

Together with this patchset, I'm also submitting an IGT test: gem_execlist [2].

v2:
- Use the same context struct for all the different engines (suggested by Brad Volkin).
- Rename write_tail to submit (suggested by Brad).
- Simplify hardware submission id creation by using LRCA[31:11] as hwCtxId[18:0].
- Non-render contexts are only two pages long (suggested by Damien Lespiau).
- Disable HWSTAM, as no one listens to it anyway (suggested by Damien).
- Do not write PDPs in the context every time, doing it at context creation time is enough.
- Various kmalloc changes in gen8_switch_context_queue (suggested by Damien).
- Module parameter to disable Execlists (as per Damien's patches).
- Update the HW read pointer in CONTEXT_STATUS_PTR (suggested by Damien).
- Fixed gpu reset and basic error reporting (verified by the new gem_error_capture test).
- Fix for unexpected full preemption in some scenarios (instead of lite restore).
- Ack the context switch interrupts as soon as possible (fix by Bob Beckett).
- Move default context backing object creation to intel_init_ring.
- Take into account the second BSD ring.
- Help out the ctx switch interrupt handler by sharing the burden of squashing requests together.

What I haven't done in this release:

- Get the context sizes from the CXT_SIZE registers, as suggested by Damien: the BSpec is full of holes with regards to the various CXT_SIZE registers, but the hardcoded values seem pretty clear.
- Allocate the ringbuffer together with the context, as suggested by Damien: now that every context has NUM_RINGS ringbuffers on it, the advantage of this is not clear anymore.
- Damien pointed out that we are missing the RS context restore, but I don't see any RS values that are needed on the first execution (the first save should take care of these).
- I have added a comment to clarify how the context population takes place (MI_LOAD_REGISTER_IMM plus <reg,value> pairs) but I haven't provided names for each position (as Jeff Mcgee suggested) or created an OUT_BATCH_REG_WRITE(reg, value) (as Daniel Vetter suggested).

Quoted 4 lines

[1]
http://lists.freedesktop.org/archives/intel-gfx/2014-March/042563.html
[2]
http://lists.freedesktop.org/archives/intel-gfx/2014-May/044846.html

I've done a very cursory read of this, and my original comment from my original high-level review on the internal list still stands: I'm freaked out by how invasive this is into the existing ring code. All the changes in i915_dma.c look very suspicious, since that code is for the legacy ums crap and will _never_ run on bdw. Nor even on anything more modern than g4x platforms (gen4).

Apparently that review has been lost/ignored, so I'll quote it in full:

"In reading through your patches the big thing which jumped out is how the new execlist code is intermingled with the old legacy gen8 framebuffer stuff. Imo those two modes don't match at all, and we need to resolve this mismatch with another abstraction layer ;-)

"I'm thinking of dev_priv->gt.do_execbuf which takes care of all the lower-level request tracking and command submission. Feel free to massively bikeshed the name. I'm thinking that we should move everything from i915_gem_execbuffer_move_to_gpu to i915_gem_execbuffer_retire_commands into that callback. With the current code that'd include the active list tracking, maybe we should move that part out again. Otoh if we go wild with scheduling and preemption, active bo tracking _will_ be rather different from previous platforms. To support execlist we might need some more vfuncs in the ringbuffer struct to support execlist specific stuff (submit execlist, enable context switch interrupts), but a lot of the existing stuff will be redudant. At the end (once things settles) we should then document which kind of do_execbuf uses which kinds of low-level ring interfaces.

"With that abstraction:
- We can separate gen8 execlist from legacy gen8 code, and so should avoid regressions (and so blocking mesa).
- Play around with different execlist approaches (guc, deferred execution, whatever, ...) since it'll just be differen copy&pasta.

"Maybe we also need a similar abstraction for a wait_seqno/request interface. But since has/fulsim can't simulate interrupts properly that discussion is a bit moot for now.

"Finally I think our immediate focus for execlist enabling should be to get multi-context execlists going, so that we can validate whether that'll work together with mesa/hw contexts. If it doesn't, not much point in bothering. The simplest way is to just block in the ->do_execbuf callback if we can't submit the new context right away. It'll suck a bit perf-wise, but will get the hw going.

"In summary execlists looks like a big&invasive feature. My aim here with those ideas is purely risk mitigation: I want to avoid committing resources for a (potentially) dead-end design, while still giving us enough flexibility to do the necessary prototyping to figure out the right answers."

That mail was from Mar 25th, 2013.

So essentially what I'd prefer is we keep all the existing ringbuffer code as-is, and throw in a complete new set (with fairly new datastructures) in for execlists. Then only interaction points would be:
- Ring init either calls into legacy ring init or new fancy execlist ring init.
- Execbuf calls ring->do_submit with ring/engine, ctx object, batch state and otherwise doesn't care one bit how it will all get submitted.
- Context state needs to be frobbed a bit so that we create the correct backing object (i.e. legacy hw state or execlist ring+ctx). To make this feasible it's probably best to switch the implicit per-fd ctx to be per-ring. That way we still have the fixed hw-contxt->ring/engine relationship and don't need to play tricks with lazy context allocation (because those beats are so big with execlists).

Yes this means that a bunch of things like e.g. seqno emission and flusing in intel_ringbuffer.c will be duplicated into intel_lrc.c. But imo that's a feature, not a bug - I would be massively suprised if there's not subtile differences here we need to be able to cope with.

Cheers, Daniel

Quoted 98 lines

Ben Widawsky (13):
drm/i915: s/for_each_ring/for_each_active_ring drm/i915: for_each_ring
drm/i915: Extract trivial parts of ring init (early init) drm/i915/bdw: Macro and module parameter for LRCs (Logical Ring
Contexts)
drm/i915/bdw: Rework init code for Logical Ring Contexts drm/i915/bdw: A bit more advanced context init/fini drm/i915/bdw: Populate LR contexts (somewhat) drm/i915/bdw: Status page for LR contexts drm/i915/bdw: Enable execlists in the hardware drm/i915/bdw: LR context ring init
drm/i915/bdw: GEN8 new ring flush
drm/i915/bdw: Implement context switching (somewhat) drm/i915/bdw: Print context state in debugfs

Michel Thierry (1):
drm/i915/bdw: Get prepared for a two-stage execlist submit process

Oscar Mateo (33):
drm/i915: Simplify a couple of functions thanks to for_each_ring drm/i915: Extract ringbuffer destroy, make destroy & alloc outside
accesible
drm/i915: s/intel_ring_buffer/intel_engine
drm/i915: Split the ringbuffers and the rings
drm/i915: Rename functions that mention ringbuffers (meaning rings) drm/i915: Plumb the context everywhere in the execbuffer path drm/i915: s/__intel_ring_advance/intel_ringbuffer_advance_and_submit drm/i915: Write a new set of context-aware ringbuffer management
functions
drm/i915: Final touches to ringbuffer and context plumbing and
refactoring
drm/i915: s/write_tail/submit
drm/i915: Introduce one context backing object per engine drm/i915: Make i915_gem_create_context outside accessible drm/i915: Option to skip backing object allocation during context
creation
drm/i915: Extract context backing object allocation drm/i915/bdw: New file for Logical Ring Contexts and Execlists drm/i915/bdw: Allocate ringbuffer backing objects for default global
LRC
drm/i915/bdw: Allocate ringbuffer for user-created LRCs drm/i915/bdw: Deferred creation of user-created LRCs drm/i915/bdw: Allow non-default, non-render, user-created LRCs drm/i915/bdw: Execlists ring tail writing
drm/i915/bdw: Set the request context information correctly in the LRC
case
drm/i915/bdw: Always write seqno to default context drm/i915/bdw: Write the tail pointer, LRC style drm/i915/bdw: Don't write PDP in the legacy way when using LRCs drm/i915/bdw: Start queueing contexts to be submitted drm/i915/bdw: Display execlists info in debugfs drm/i915/bdw: Display context backing obj & ringbuffer info in debugfs drm/i915/bdw: Document execlists and logical ring contexts drm/i915/bdw: Avoid non-lite-restore preemptions drm/i915/bdw: Make sure gpu reset still works with Execlists drm/i915/bdw: Make sure error capture keeps working with Execlists drm/i915/bdw: Help out the ctx switch interrupt handler drm/i915/bdw: Enable logical ring contexts

Thomas Daniel (3):
drm/i915/bdw: Add forcewake lock around ELSP writes drm/i915/bdw: LR context switch interrupts drm/i915/bdw: Handle context switch events

 drivers/gpu/drm/i915/Makefile              |   1 +
 drivers/gpu/drm/i915/i915_cmd_parser.c     |  16 +-
 drivers/gpu/drm/i915/i915_debugfs.c        | 180 ++++++-
 drivers/gpu/drm/i915/i915_dma.c            |  48 +-
 drivers/gpu/drm/i915/i915_drv.h            |  97 +++-
 drivers/gpu/drm/i915/i915_gem.c            | 172 ++++---
 drivers/gpu/drm/i915/i915_gem_context.c    | 220 +++++---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  85 ++--
 drivers/gpu/drm/i915/i915_gem_gtt.c        |  41 +-
 drivers/gpu/drm/i915/i915_gem_gtt.h        |   2 +-
 drivers/gpu/drm/i915/i915_gpu_error.c      |  19 +-
 drivers/gpu/drm/i915/i915_irq.c            | 102 ++--
 drivers/gpu/drm/i915/i915_params.c         |   6 +
 drivers/gpu/drm/i915/i915_reg.h            |  11 +
 drivers/gpu/drm/i915/i915_trace.h          |  26 +-
 drivers/gpu/drm/i915/intel_display.c       |  26 +-
 drivers/gpu/drm/i915/intel_drv.h           |   4 +-
 drivers/gpu/drm/i915/intel_lrc.c           | 729 ++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_overlay.c       |  12 +-
 drivers/gpu/drm/i915/intel_pm.c            |  18 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c    | 792 +++++++++++++++++++----------
 drivers/gpu/drm/i915/intel_ringbuffer.h    | 196 ++++---
 22 files changed, 2107 insertions(+), 696 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_lrc.c
Signature · 6 lines
1.9.0

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