Skip to contentSkip to conversation

drm/i915: Fix PIPE_CONTROL command on Sandybridge

PATCH In review Zhenyu Wang 2 participants 3 messages May 27, 2010 – May 28, 2010

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

PATCH 1/2 drm/i915: Fix PIPE_CONTROL command on Sandybridge

Sandybridge(Gen6) has new format for PIPE_CONTROL command, the flush and post-op control are in dword 1 now. This changes command length field for difference between Ironlake and Sandybridge.

I tried to test this with noop request and issue PIPE_CONTROL command for each sequence and track notify interrupts, which seems work fine. Hopefully we don't need workaround like on Ironlake for Sandybridge.

---
 drivers/gpu/drm/i915/i915_gem.c |   77 +++++++++++++++++++++++----------------
 drivers/gpu/drm/i915/i915_reg.h |   11 +++++-
 2 files changed, 55 insertions(+), 33 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +44 -31
index 112699f..aad41b7 100644
@@ -1595,7 +1595,7 @@ i915_gem_process_flushing_list(struct drm_device *dev,
 
 #define PIPE_CONTROL_FLUSH(addr)					\
 	OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE |		\
-		 PIPE_CONTROL_DEPTH_STALL);				\
+		 PIPE_CONTROL_DEPTH_STALL | 2);				\
 	OUT_RING(addr | PIPE_CONTROL_GLOBAL_GTT);			\
 	OUT_RING(0);							\
 	OUT_RING(0);							\
@@ -1635,37 +1635,50 @@ i915_add_request(struct drm_device *dev, struct drm_file *file_priv,
 		dev_priv->mm.next_gem_seqno++;
 
 	if (HAS_PIPE_CONTROL(dev)) {
-		u32 scratch_addr = dev_priv->seqno_gfx_addr + 128;
+		if (IS_GEN6(dev)) {
+			BEGIN_LP_RING(6);
+			OUT_RING(GFX_OP_PIPE_CONTROL | 3);
+			OUT_RING(PIPE_CONTROL_QW_WRITE |
+				 PIPE_CONTROL_WC_FLUSH | PIPE_CONTROL_IS_FLUSH |
+				 PIPE_CONTROL_NOTIFY);
+			OUT_RING(dev_priv->seqno_gfx_addr | PIPE_CONTROL_GLOBAL_GTT);
+			OUT_RING(seqno);
+			OUT_RING(0);
+			OUT_RING(0);
+			ADVANCE_LP_RING();
+		} else {
+			u32 scratch_addr = dev_priv->seqno_gfx_addr + 128;
 
-		/*
-		 * Workaround qword write incoherence by flushing the
-		 * PIPE_NOTIFY buffers out to memory before requesting
-		 * an interrupt.
-		 */
-		BEGIN_LP_RING(32);
-		OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE |
-			 PIPE_CONTROL_WC_FLUSH | PIPE_CONTROL_TC_FLUSH);
-		OUT_RING(dev_priv->seqno_gfx_addr | PIPE_CONTROL_GLOBAL_GTT);
-		OUT_RING(seqno);
-		OUT_RING(0);
-		PIPE_CONTROL_FLUSH(scratch_addr);
-		scratch_addr += 128; /* write to separate cachelines */
-		PIPE_CONTROL_FLUSH(scratch_addr);
-		scratch_addr += 128;
-		PIPE_CONTROL_FLUSH(scratch_addr);
-		scratch_addr += 128;
-		PIPE_CONTROL_FLUSH(scratch_addr);
-		scratch_addr += 128;
-		PIPE_CONTROL_FLUSH(scratch_addr);
-		scratch_addr += 128;
-		PIPE_CONTROL_FLUSH(scratch_addr);
-		OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE |
-			 PIPE_CONTROL_WC_FLUSH | PIPE_CONTROL_TC_FLUSH |
-			 PIPE_CONTROL_NOTIFY);
-		OUT_RING(dev_priv->seqno_gfx_addr | PIPE_CONTROL_GLOBAL_GTT);
-		OUT_RING(seqno);
-		OUT_RING(0);
-		ADVANCE_LP_RING();
+			/*
+			 * Workaround qword write incoherence by flushing the
+			 * PIPE_NOTIFY buffers out to memory before requesting
+			 * an interrupt.
+			 */
+			BEGIN_LP_RING(32);
+			OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE |
+				 PIPE_CONTROL_WC_FLUSH | PIPE_CONTROL_TC_FLUSH | 2);
+			OUT_RING(dev_priv->seqno_gfx_addr | PIPE_CONTROL_GLOBAL_GTT);
+			OUT_RING(seqno);
+			OUT_RING(0);
+			PIPE_CONTROL_FLUSH(scratch_addr);
+			scratch_addr += 128; /* write to separate cachelines */
+			PIPE_CONTROL_FLUSH(scratch_addr);
+			scratch_addr += 128;
+			PIPE_CONTROL_FLUSH(scratch_addr);
+			scratch_addr += 128;
+			PIPE_CONTROL_FLUSH(scratch_addr);
+			scratch_addr += 128;
+			PIPE_CONTROL_FLUSH(scratch_addr);
+			scratch_addr += 128;
+			PIPE_CONTROL_FLUSH(scratch_addr);
+			OUT_RING(GFX_OP_PIPE_CONTROL | PIPE_CONTROL_QW_WRITE |
+				 PIPE_CONTROL_WC_FLUSH | PIPE_CONTROL_TC_FLUSH |
+				 PIPE_CONTROL_NOTIFY);
+			OUT_RING(dev_priv->seqno_gfx_addr | PIPE_CONTROL_GLOBAL_GTT);
+			OUT_RING(seqno);
+			OUT_RING(0);
+			ADVANCE_LP_RING();
+		}
 	} else {
 		BEGIN_LP_RING(4);
 		OUT_RING(MI_STORE_DWORD_INDEX);
drivers/gpu/drm/i915/i915_reg.h +10 -1
index f3e39cc..2740f09 100644
@@ -230,7 +230,12 @@
 #define   ASYNC_FLIP                (1<<22)
 #define   DISPLAY_PLANE_A           (0<<20)
 #define   DISPLAY_PLANE_B           (1<<20)
-#define GFX_OP_PIPE_CONTROL	((0x3<<29)|(0x3<<27)|(0x2<<24)|2)
+#define GFX_OP_PIPE_CONTROL	((0x3<<29)|(0x3<<27)|(0x2<<24))
+#define   PIPE_CONTROL_CS_STALL	(1<<20)
+#define   PIPE_CONTROL_GLOBAL_SNAPSHOT_COUNT_RESET	(1<<19)
+#define   PIPE_CONTROL_TLB_INVALIDATE	(1<<18)
+#define   PIPE_CONTROL_SYNC_GFDT	(1<<17)
+#define   PIPE_CONTROL_MEDIA_STATE_CLEAR	(1<<16)
 #define   PIPE_CONTROL_QW_WRITE	(1<<14)
 #define   PIPE_CONTROL_DEPTH_STALL (1<<13)
 #define   PIPE_CONTROL_WC_FLUSH	(1<<12)
@@ -238,6 +243,10 @@
 #define   PIPE_CONTROL_TC_FLUSH (1<<10) /* GM45+ only */
 #define   PIPE_CONTROL_ISP_DIS	(1<<9)
 #define   PIPE_CONTROL_NOTIFY	(1<<8)
+#define   PIPE_CONTROL_VF_CACHE_INVALIDATE	(1<<4)
+#define   PIPE_CONTROL_CONST_CACHE_INVALIDATE	(1<<3)
+#define   PIPE_CONTROL_STATE_CACHE_INVALIDATE	(1<<2)
+#define   PIPE_CONTROL_DEPTH_CACHE_FLUSH	(1<<0)
 #define   PIPE_CONTROL_GLOBAL_GTT (1<<2) /* in addr dword */
 #define   PIPE_CONTROL_STALL_EN	(1<<1) /* in addr word, Ironlake+ only */
 
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 2/2 drm/i915: Unmask interrupt for render engine on Sandybridge

With splitted engines on Sandybridge, each engine has its own interrupt control as well. This unmasks the interrupt to properly enable pipe control notify event for render engine.

---
 drivers/gpu/drm/i915/i915_debugfs.c |    4 ++++
 drivers/gpu/drm/i915/i915_irq.c     |    2 ++
 drivers/gpu/drm/i915/i915_reg.h     |   19 +++++++++++++++++++
 3 files changed, 25 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -0
index 322070c..8818577 100644
@@ -192,6 +192,10 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
 			   I915_READ(GTIIR));
 		seq_printf(m, "Graphics Interrupt mask:		%08x\n",
 			   I915_READ(GTIMR));
+		if (IS_GEN6(dev)) {
+			seq_printf(m, "Render Interrupt mask:		%08x\n",
+				   I915_READ(GEN6_RENDER_IMR));
+		}
 	}
 	seq_printf(m, "Interrupts received: %d\n",
 		   atomic_read(&dev_priv->irq_received));
drivers/gpu/drm/i915/i915_irq.c +2 -0
index a7e4b1f..5452300 100644
@@ -1330,6 +1330,8 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
 
 	I915_WRITE(GTIIR, I915_READ(GTIIR));
 	I915_WRITE(GTIMR, dev_priv->gt_irq_mask_reg);
+	if (IS_GEN6(dev))
+		I915_WRITE(GEN6_RENDER_IMR, ~GEN6_RENDER_PIPE_CONTROL_NOTIFY_INTERRUPT);
 	I915_WRITE(GTIER, dev_priv->gt_irq_enable_reg);
 	(void) I915_READ(GTIER);
 
drivers/gpu/drm/i915/i915_reg.h +19 -0
index 2740f09..c7bd4ec 100644
@@ -377,6 +377,25 @@
 #define BB_ADDR		0x02140 /* 8 bytes */
 #define GFX_FLSH_CNTL	0x02170 /* 915+ only */
 
+/* GEN6 interrupt control */
+#define GEN6_RENDER_HWSTAM	0x2098
+#define GEN6_RENDER_IMR		0x20a8
+#define   GEN6_RENDER_CONTEXT_SWITCH_INTERRUPT		(1 << 8)
+#define   GEN6_RENDER_PPGTT_PAGE_FAULT			(1 << 7)
+#define   GEN6_RENDER TIMEOUT_COUNTER_EXPIRED		(1 << 6)
+#define   GEN6_RENDER_L3_PARITY_ERROR			(1 << 5)
+#define   GEN6_RENDER_PIPE_CONTROL_NOTIFY_INTERRUPT	(1 << 4)
+#define   GEN6_RENDER_COMMAND_PARSER_MASTER_ERROR	(1 << 3)
+#define   GEN6_RENDER_SYNC_STATUS			(1 << 2)
+#define   GEN6_RENDER_DEBUG_INTERRUPT			(1 << 1)
+#define   GEN6_RENDER_USER_INTERRUPT			(1 << 0)
+
+#define GEN6_BLITTER_HWSTAM	0x22098
+#define GEN6_BLITTER_IMR	0x220a8
+#define   GEN6_BLITTER_MI_FLUSH_DW_NOTIFY_INTERRUPT	(1 << 26)
+#define   GEN6_BLITTER_COMMAND_PARSER_MASTER_ERROR	(1 << 25)
+#define   GEN6_BLITTER_SYNC_STATUS			(1 << 24)
+#define   GEN6_BLITTER_USER_INTERRUPT			(1 << 22)
 
 /*
  * Framebuffer compression (915+ only)
Signature · 1 line
1.7.0.4
#2 lore raw
In reply to Zhenyu Wang
Quoted 11 lines · Zhenyu Wang

Sandybridge(Gen6) has new format for PIPE_CONTROL command, the flush and post-op control are in dword 1 now. This changes command length field for difference between Ironlake and Sandybridge.

I tried to test this with noop request and issue PIPE_CONTROL command for each sequence and track notify interrupts, which seems work fine. Hopefully we don't need workaround like on Ironlake for Sandybridge.

I rebased this to drm-intel-next and just chained the if statements instead of nesting the ironlake code farther down.

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