Skip to contentSkip to conversation

drm/i915: Use PIPE_CONTROL for flushing on gen6+.

PATCH In review Kenneth Graunke 6 participants 14 messages Sep 26, 2011 – Oct 3, 2011

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

PATCH 1/1 drm/i915: Use PIPE_CONTROL for flushing on gen6+.

From: Jesse Barnes <[email protected]>

---
 drivers/gpu/drm/i915/i915_reg.h         |    7 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |  131 ++++++++++++++++++++++++++++---
 2 files changed, 124 insertions(+), 14 deletions(-)

I've been using this patch on my Ivybridge system for a while; it seems to work just fine. The difference between this and Jesse's earlier patch is that we added the VFC bit.

drivers/gpu/drm/i915/i915_reg.h +5 -2
index 138eae1..9ef448a 100644
@@ -243,6 +243,8 @@
 #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_GEN6 ((0x3<<29)|(0x3<<27)|(0x2<<24)|3)
+#define   PIPE_CONTROL_CS_STALL (1<<20)
 #define   PIPE_CONTROL_QW_WRITE	(1<<14)
 #define   PIPE_CONTROL_DEPTH_STALL (1<<13)
 #define   PIPE_CONTROL_WC_FLUSH	(1<<12)
@@ -250,9 +252,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_VFC	(1<<4)
 #define   PIPE_CONTROL_GLOBAL_GTT (1<<2) /* in addr dword */
-#define   PIPE_CONTROL_STALL_EN	(1<<1) /* in addr word, Ironlake+ only */
-
+#define   PIPE_CONTROL_STALL_AT_SCOREBOARD (1<<1) /* in addr word, Ironlake+ only */
+#define   PIPE_CONTROL_DEPTH_FLUSH (1<<0)
 
 /*
  * Reset registers
drivers/gpu/drm/i915/intel_ringbuffer.c +119 -12

161 lines not on this page · raw message

Signature · 1 line
1.7.6.1
#1 lore raw
Quoted 3 lines · Kenneth Graunke

From: Jesse Barnes <[email protected]>

From the school of "If ain't broke, don't fix it" there needs to be a real

explanation of why this change is required here.

PIPE_CONTROL and its workarounds is a very bitter pill to swallow if MI_FLUSH continues to function.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 8 lines · Chris Wilson
Quoted 1 line · Kenneth Graunke

From: Jesse Barnes <[email protected]>

From the school of "If ain't broke, don't fix it" there needs to be a real explanation of why this change is required here.

PIPE_CONTROL and its workarounds is a very bitter pill to swallow if MI_FLUSH continues to function.

Lazy tlb flush, gfdt flush, seperate depth cache flush. In short, I want this ;-)
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#3 lore raw
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Chris Wilson
Quoted 1 line · Kenneth Graunke

From: Jesse Barnes <[email protected]>

Quoted 8 lines
Quoted 5 lines

From the school of "If ain't broke, don't fix it" there needs to be a real explanation of why this change is required here.

PIPE_CONTROL and its workarounds is a very bitter pill to swallow if MI_FLUSH continues to function.

Lazy tlb flush, gfdt flush, seperate depth cache flush. In short, I want this ;-)

I feel jaded, I could have swore you just said "bug, bugs, bugs." ;-) -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw
In reply to Chris Wilson
Quoted 2 lines · Chris Wilson

PIPE_CONTROL and its workarounds is a very bitter pill to swallow if MI_FLUSH continues to function.

If you look at the simulator source code, you'll see that it implements MI_FLUSH as a specific kind of PIPE_CONTROL. And that MI_FLUSH isn't being validated anymore. If this is all true, then this isn't a huge change, other than exposing which PIPE_CONTROL workarounds we're supposed to be using in the MI_FLUSH paths...

Signature · 1 line
[email protected]

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

#5 lore raw
In reply to Chris Wilson
Quoted 9 lines · Chris Wilson
Quoted 1 line · Kenneth Graunke

From: Jesse Barnes <[email protected]>

From the school of "If ain't broke, don't fix it" there needs to be a real explanation of why this change is required here.

PIPE_CONTROL and its workarounds is a very bitter pill to swallow if MI_FLUSH continues to function.
-Chris

I hear you.

The issue is that (from Eric's reading of the simulator) MI_FLUSH seems to be equivalent to PIPE_CONTROL with some unknown set of bits enabled...which means we likely do need workarounds. It's just not clear which ones.

Also, according to the BSpec, MI_FLUSH is no longer validated or guaranteed to work on Ivybridge. I heard they said that about Sandybridge as well but later recanted...I don't know if they will this time, though.

I suspect that it actually is broke, and we do need to fix it. This seems like a first step.

--Kenneth

#6 lore raw
In reply to Kenneth Graunke
Quoted 8 lines · Kenneth Graunke
drivers/gpu/drm/i915/intel_ringbuffer.c +8 -0
+static int
+gen6_render_ring_flush(struct intel_ring_buffer *ring,
+                         u32 invalidate_domains, u32 flush_domains)
+{
+	u32 flags = 0;
+	struct pipe_control *pc = ring->private;
+	u32 scratch_addr = pc->gtt_offset + 128;
+	int ret;

drivers/gpu/drm/i915/intel_ringbuffer.c render_ring_flush(struct intel_ring_buffer *ring, · line 226

Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +10 -0
+
+	/* Force SNB workarounds for PIPE_CONTROL flushes */
+	intel_emit_post_sync_nonzero_flush(ring);
+
+	/* Just flush everything for now */
+	flags |= PIPE_CONTROL_WC_FLUSH;
+	flags |= PIPE_CONTROL_IS_FLUSH;
+	flags |= PIPE_CONTROL_TC_FLUSH;
+	flags |= PIPE_CONTROL_DEPTH_FLUSH;
+	flags |= PIPE_CONTROL_VFC;

Any reason you're not also setting the constant cache and state cache invalidate bits?
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#7 lore raw
Quoted 15 lines · Daniel Vetter
Quoted 14 lines · Kenneth Graunke
drivers/gpu/drm/i915/intel_ringbuffer.c +14 -0
+static int
+gen6_render_ring_flush(struct intel_ring_buffer *ring,
+                         u32 invalidate_domains, u32 flush_domains)
+{
+	u32 flags = 0;
+	struct pipe_control *pc = ring->private;
+	u32 scratch_addr = pc->gtt_offset + 128;
+	int ret;
+
+	/* Force SNB workarounds for PIPE_CONTROL flushes */
+	intel_emit_post_sync_nonzero_flush(ring);
+
+	/* Just flush everything for now */
+	flags |= PIPE_CONTROL_WC_FLUSH;
Quoted 8 lines

drivers/gpu/drm/i915/intel_ringbuffer.c render_ring_flush(struct intel_ring_buffer *ring, · line 226

Quoted 4 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -0
+	flags |= PIPE_CONTROL_IS_FLUSH;
+	flags |= PIPE_CONTROL_TC_FLUSH;
+	flags |= PIPE_CONTROL_DEPTH_FLUSH;
+	flags |= PIPE_CONTROL_VFC;

Any reason you're not also setting the constant cache and state cache invalidate bits?
-Daniel

Bits 2 and 3? No particular reason; perhaps they should be.

#8 lore raw
Quoted 25 lines · Kenneth Graunke
Quoted 15 lines · Daniel Vetter
Quoted 14 lines · Kenneth Graunke
drivers/gpu/drm/i915/intel_ringbuffer.c +14 -0
+static int
+gen6_render_ring_flush(struct intel_ring_buffer *ring,
+                         u32 invalidate_domains, u32 flush_domains)
+{
+	u32 flags = 0;
+	struct pipe_control *pc = ring->private;
+	u32 scratch_addr = pc->gtt_offset + 128;
+	int ret;
+
+	/* Force SNB workarounds for PIPE_CONTROL flushes */
+	intel_emit_post_sync_nonzero_flush(ring);
+
+	/* Just flush everything for now */
+	flags |= PIPE_CONTROL_WC_FLUSH;
Quoted 8 lines

drivers/gpu/drm/i915/intel_ringbuffer.c render_ring_flush(struct intel_ring_buffer *ring, · line 226

Quoted 4 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +4 -0
+	flags |= PIPE_CONTROL_IS_FLUSH;
+	flags |= PIPE_CONTROL_TC_FLUSH;
+	flags |= PIPE_CONTROL_DEPTH_FLUSH;
+	flags |= PIPE_CONTROL_VFC;

Any reason you're not also setting the constant cache and state cache invalidate bits?
-Daniel

Quoted 1 line

Bits 2 and 3? No particular reason; perhaps they should be.

IIRC we're not using the constant cache today, but it would be nice to, so let's get it set.

We definitely need state cache invalidate.

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

#9 lore raw
In reply to Kenneth Graunke

drivers/gpu/drm/i915/intel_ringbuffer.c render_ring_flush(struct intel_ring_buffer *ring, · line 226

Quoted 6 lines · On Mon, 26 Sep 2011 11:59:23 -0700 Kenneth Graunke <[email protected]>…
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -0
+	/* Just flush everything for now */
+	flags |= PIPE_CONTROL_WC_FLUSH;
+	flags |= PIPE_CONTROL_IS_FLUSH;
+	flags |= PIPE_CONTROL_TC_FLUSH;
+	flags |= PIPE_CONTROL_DEPTH_FLUSH;
+	flags |= PIPE_CONTROL_VFC;

This is the only bit I'd like to see changed. While we still have the domain tracking code we may as well try to honor it and limit our flushing here like we do with MI_FLUSH.

Unless someone has a "remove all domain tracking" patch already posted that is. :)

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#10 lore raw
Quoted 3 lines · Jesse Barnes

This is the only bit I'd like to see changed. While we still have the domain tracking code we may as well try to honor it and limit our flushing here like we do with MI_FLUSH.

I'd like to see this patch put in place, and then any 'optimization' added afterwards so we can avoid having to revert this change when it breaks.

Signature · 1 line
[email protected]

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

#11 lore raw
Quoted 9 lines · On Mon, 03 Oct 2011 14:14:53 -0700 Keith Packard <[email protected]> wrote:
Quoted 3 lines · Jesse Barnes

This is the only bit I'd like to see changed. While we still have the domain tracking code we may as well try to honor it and limit our flushing here like we do with MI_FLUSH.

I'd like to see this patch put in place, and then any 'optimization' added afterwards so we can avoid having to revert this change when it breaks.

Sounds good. I guess Ken needs to re-post anyway to add the two extra bits...

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#12 lore raw
In reply to Jesse Barnes
Quoted 14 lines · Jesse Barnes

drivers/gpu/drm/i915/intel_ringbuffer.c render_ring_flush(struct intel_ring_buffer *ring, · line 226

Quoted 6 lines · On Mon, 26 Sep 2011 11:59:23 -0700 Kenneth Graunke <[email protected]>…
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -0
+	/* Just flush everything for now */
+	flags |= PIPE_CONTROL_WC_FLUSH;
+	flags |= PIPE_CONTROL_IS_FLUSH;
+	flags |= PIPE_CONTROL_TC_FLUSH;
+	flags |= PIPE_CONTROL_DEPTH_FLUSH;
+	flags |= PIPE_CONTROL_VFC;

This is the only bit I'd like to see changed. While we still have the domain tracking code we may as well try to honor it and limit our flushing here like we do with MI_FLUSH.

Quoted 2 lines

Unless someone has a "remove all domain tracking" patch already posted that is. :)

I don't think we "might as well try to honor it". Working out the workarounds for various combinations is difficult to do even for a fixed set of bits. Let's not make the workarounds more complicated by varying them, when experiments showed no evidence for removing bits improving performance.

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

#13 lore raw
Quoted 15 lines · On Mon, 03 Oct 2011 15:59:29 -0700 Eric Anholt <[email protected]> wrote:
Quoted 14 lines · Jesse Barnes

drivers/gpu/drm/i915/intel_ringbuffer.c render_ring_flush(struct intel_ring_buffer *ring, · line 226

Quoted 6 lines · On Mon, 26 Sep 2011 11:59:23 -0700 Kenneth Graunke <[email protected]>…
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -0
+	/* Just flush everything for now */
+	flags |= PIPE_CONTROL_WC_FLUSH;
+	flags |= PIPE_CONTROL_IS_FLUSH;
+	flags |= PIPE_CONTROL_TC_FLUSH;
+	flags |= PIPE_CONTROL_DEPTH_FLUSH;
+	flags |= PIPE_CONTROL_VFC;

This is the only bit I'd like to see changed. While we still have the domain tracking code we may as well try to honor it and limit our flushing here like we do with MI_FLUSH.

Quoted 8 lines
Quoted 2 lines

Unless someone has a "remove all domain tracking" patch already posted that is. :)

I don't think we "might as well try to honor it". Working out the workarounds for various combinations is difficult to do even for a fixed set of bits. Let's not make the workarounds more complicated by varying them, when experiments showed no evidence for removing bits improving performance.

Oh if you have experiments showing that the individual bits provide no benefit that's fine.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center