drm/i915: Implement CS stall workaround on Broadwell.
Subsystems (2)
PATCH 1/5 drm/i915: Implement CS stall workaround on Broadwell.
According to the latest documentation, any PIPE_CONTROL with the "Command Streamer Stall" bit set must also have another bit set, with five different options. I chose "Stall at Pixel Scoreboard" since we've used it effectively in the past, but the choice is fairly arbitrary.
--- drivers/gpu/drm/i915/intel_ringbuffer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +8 -1
@@ -370,7 +370,14 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring,u32 scratch_addr = ring->scratch.gtt_offset +128 ;int ret; - flags |=PIPE_CONTROL_CS_STALL ; +/* For CS stalls, one of the following must also be set: +* - Render Target Cache Flush +* - Depth Cache Flush +* - Stall at Pixel Scoreboard +* - Post-Sync Operation +* We arbitrarily choose "Stall at Scoreboard". +*/ + flags |=PIPE_CONTROL_CS_STALL |PIPE_CONTROL_STALL_AT_SCOREBOARD ;if (flush_domains) { flags |=PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH ;
Signature · 1 line
1.8.5.2
PATCH 2/5 drm/i915: Refactor Broadwell PIPE_CONTROL emission into a helper.
We'll want to reuse this for a workaround.
--- drivers/gpu/drm/i915/intel_ringbuffer.c | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.c +22 -15
@@ -363,12 +363,32 @@ gen7_render_ring_flush(struct intel_ring_buffer *ring, }static int +gen8_emit_pipe_control (struct intel_ring_buffer *ring, +u32 flags,u32 scratch_addr) +{ +int ret; + + ret =intel_ring_begin (ring,6 ); +if (ret) +return ret; + +intel_ring_emit (ring,GFX_OP_PIPE_CONTROL (6 )); +intel_ring_emit (ring, flags); +intel_ring_emit (ring, scratch_addr); +intel_ring_emit (ring,0 ); +intel_ring_emit (ring,0 ); +intel_ring_emit (ring,0 ); +intel_ring_advance (ring); + +return 0 ; +} + +static int gen8_render_ring_flush (struct intel_ring_buffer *ring,u32 invalidate_domains,u32 flush_domains) {u32 flags =0 ;u32 scratch_addr = ring->scratch.gtt_offset +128 ; -int ret;/* For CS stalls, one of the following must also be set: * - Render Target Cache Flush
@@ -394,20 +414,7 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring, flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; } - ret =intel_ring_begin (ring,6 ); -if (ret) -return ret; - -intel_ring_emit (ring,GFX_OP_PIPE_CONTROL (6 )); -intel_ring_emit (ring, flags); -intel_ring_emit (ring, scratch_addr); -intel_ring_emit (ring,0 ); -intel_ring_emit (ring,0 ); -intel_ring_emit (ring,0 ); -intel_ring_advance (ring); - -return 0 ; - +return gen8_emit_pipe_control (ring, flags, scratch_addr); } static void ring_write_tail(struct intel_ring_buffer *ring,
Signature · 1 line
1.8.5.2
PATCH 3/5 drm/i915: Add the WaCsStallBeforeStateCacheInvalidate:bdw workaround.
In reply to Kenneth GraunkeOn Broadwell, any PIPE_CONTROL with the "State Cache Invalidate" bit set must be preceded by a PIPE_CONTROL with the "CS Stall" bit set.
Documented on the BSpec 3D workarounds page.
--- drivers/gpu/drm/i915/intel_ringbuffer.c | 9 +++++++++ 1 file changed, 9 insertions(+)
The Gen7 code doesn't check ret on the state cache workaround, but it seems like we ought to.
At this point, gen7_render_ring_flush and gen8_render_ring_flush look pretty darn similar. We could probably merge them, if people are interested in that...
drivers/gpu/drm/i915/intel_ringbuffer.c +9 -0
@@ -389,6 +389,7 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring, {u32 flags =0 ;u32 scratch_addr = ring->scratch.gtt_offset +128 ; +int ret;/* For CS stalls, one of the following must also be set: * - Render Target Cache Flush
@@ -412,6 +413,14 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring, flags |=PIPE_CONTROL_STATE_CACHE_INVALIDATE ; flags |=PIPE_CONTROL_QW_WRITE ; flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; + +/* WaCsStallBeforeStateCacheInvalidate:bdw */ + ret =gen8_emit_pipe_control (ring, +PIPE_CONTROL_CS_STALL | +PIPE_CONTROL_STALL_AT_SCOREBOARD , +0 ); +if (ret) +return ret; }return gen8_emit_pipe_control (ring, flags, scratch_addr);
Signature · 1 line
1.8.5.2
Re: [PATCH 3/5] drm/i915: Add the WaCsStallBeforeStateCacheInvalidate:bdw workaround.
Quoted 4 lines · Kenneth Graunke
On Broadwell, any
PIPE_CONTROLwith the "State Cache Invalidate" bit set must be preceded by aPIPE_CONTROLwith the "CS Stall" bit set.Documented on the BSpec 3D workarounds page.
FWIW, I am not clear this is actually needed. If it is, we need/should file a bspec bug, since it is missing there. What I am afraid happened is Windows carried it over from gen7, and that's how it ended up in the w/a db.
As I am too lazy to check the performance implications (or whether it's really needed) - I say just ship it.
Quoted 47 lines
Signed-off-by Kenneth Graunke <[email protected]>--- drivers/gpu/drm/i915/intel_ringbuffer.c | 9 +++++++++ 1 file changed, 9 insertions(+)The Gen7 code doesn't check ret on the state cache workaround, but it seems like we ought to.
At this point,
gen7_render_ring_flushandgen8_render_ring_flushlook pretty darn similar. We could probably merge them, if people are interested in that...drivers/gpu/drm/i915/intel_ringbuffer.c +9
-0@@ -389,6 +389,7 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring, {u32 flags =0 ;u32 scratch_addr = ring->scratch.gtt_offset +128 ; +int ret;/* For CS stalls, one of the following must also be set: * - Render Target Cache Flush @@ -412,6 +413,14 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring, flags |=PIPE_CONTROL_STATE_CACHE_INVALIDATE ; flags |=PIPE_CONTROL_QW_WRITE ; flags |=PIPE_CONTROL_GLOBAL_GTT_IVB ; + +/* WaCsStallBeforeStateCacheInvalidate:bdw */ + ret =gen8_emit_pipe_control (ring, +PIPE_CONTROL_CS_STALL | +PIPE_CONTROL_STALL_AT_SCOREBOARD , +0 ); +if (ret) +return ret; }return gen8_emit_pipe_control (ring, flags, scratch_addr);Signature · 6 lines
1.8.5.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
PATCH 4/5 drm/i915: Add a partial instruction shootdown workaround on Broadwell.
In reply to Kenneth GraunkeThis should apply even for production hardware.
--- drivers/gpu/drm/i915/i915_reg.h | 4 ++++ drivers/gpu/drm/i915/intel_pm.c | 4 ++++ 2 files changed, 8 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -5007,6 +5007,10 @@#define GEN7_SINGLE_SUBSCAN_DISPATCH_ENABLE (1<<10)#define GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE (1<<3) +#define GEN8_ROW_CHICKEN 0xe4f0 +#define PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE (1<<8) +#define STALL_DOP_GATING_DISABLE (1<<5) +#define GEN7_ROW_CHICKEN2 0xe4f4#define GEN7_ROW_CHICKEN2_GT2 0xf4f4#define DOP_CLOCK_GATING_DISABLE (1<<0)
drivers/gpu/drm/i915/intel_pm.c +4 -0
@@ -4713,6 +4713,10 @@ static void gen8_init_clock_gating(struct drm_device *dev)/* FIXME(BDW): Check all the w/a, some might only apply to * pre-production hw. */ +/* WaDisablePartialInstShootdown */ +I915_WRITE (GEN8_ROW_CHICKEN , +_MASKED_BIT_ENABLE (PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE )); +/* * This GEN8_CENTROID_PIXEL_OPT_DIS W/A is only needed for * pre-production hardware
Signature · 1 line
1.8.5.2
PATCH 5/5 drm/i915: Implement more Broadwell workarounds.
In reply to Kenneth GraunkeThese should only be necessary on pre-production hardware.
--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_pm.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -5008,6 +5008,7 @@#define GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE (1<<3)#define GEN8_ROW_CHICKEN 0xe4f0 +#define INSTRUCTION_SHOOTDOWN_DISABLE (1<<9)#define PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE (1<<8)#define STALL_DOP_GATING_DISABLE (1<<5)
drivers/gpu/drm/i915/intel_pm.c +12 -0
@@ -4717,6 +4717,18 @@ static void gen8_init_clock_gating(struct drm_device *dev)I915_WRITE (GEN8_ROW_CHICKEN ,_MASKED_BIT_ENABLE (PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE )); +/* WaDisableInstructionShootdown:bdw - pre-production only */ +I915_WRITE (GEN8_ROW_CHICKEN , +_MASKED_BIT_ENABLE (INSTRUCTION_SHOOTDOWN_DISABLE )); + +/* WaDisableThreadStallDopClockGating:bdw - pre-production only */ +I915_WRITE (GEN8_ROW_CHICKEN , +_MASKED_BIT_ENABLE (STALL_DOP_GATING_DISABLE )); + +/* WaDisableRowChickenDopClockGating:bdw - pre-production only */ +I915_WRITE (GEN7_ROW_CHICKEN2 , +_MASKED_BIT_ENABLE (DOP_CLOCK_GATING_DISABLE )); +/* * This GEN8_CENTROID_PIXEL_OPT_DIS W/A is only needed for * pre-production hardware
Signature · 1 line
1.8.5.2
Re: [PATCH 5/5] drm/i915: Implement more Broadwell workarounds.
Quoted 25 lines · Kenneth Graunke
These should only be necessary on pre-production hardware.
Signed-off-by Kenneth Graunke <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_pm.c | 12 ++++++++++++ 2 files changed, 13 insertions(+)drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -5008,6 +5008,7 @@#define GEN7_PSD_SINGLE_PORT_DISPATCH_ENABLE (1<<3)#define GEN8_ROW_CHICKEN 0xe4f0 +#define INSTRUCTION_SHOOTDOWN_DISABLE (1<<9)#define PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE (1<<8)#define STALL_DOP_GATING_DISABLE (1<<5)drivers/gpu/drm/i915/intel_pm.c +0
-0
drivers/gpu/drm/i915/intel_pm.c static void gen8_init_clock_gating(struct drm_device *dev) · line 4726
Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +7
-0@@ -4717,6 +4717,18 @@ static void gen8_init_clock_gating(struct drm_device *dev)I915_WRITE (GEN8_ROW_CHICKEN ,_MASKED_BIT_ENABLE (PARTIAL_INSTRUCTION_SHOOTDOWN_DISABLE )); +/* WaDisableInstructionShootdown:bdw - pre-production only */ +I915_WRITE (GEN8_ROW_CHICKEN , +_MASKED_BIT_ENABLE (INSTRUCTION_SHOOTDOWN_DISABLE )); + +/* WaDisableThreadStallDopClockGating:bdw - pre-production only */ +I915_WRITE (GEN8_ROW_CHICKEN , +_MASKED_BIT_ENABLE (STALL_DOP_GATING_DISABLE ));
bspec leads me to believe this one is not pre-production only.
drivers/gpu/drm/i915/intel_pm.c static void gen8_init_clock_gating(struct drm_device *dev) · line 4734
Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +5
-0+ +/* WaDisableRowChickenDopClockGating:bdw - pre-production only */ +I915_WRITE (GEN7_ROW_CHICKEN2 , +_MASKED_BIT_ENABLE (DOP_CLOCK_GATING_DISABLE )); +/* * This GEN8_CENTROID_PIXEL_OPT_DIS W/A is only needed for * pre-production hardware
Other than the two minor nitpicks, lgtm in patch 1, and here:
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 21 lines · Kenneth Graunke
According to the latest documentation, any
PIPE_CONTROLwith the "Command Streamer Stall" bit set must also have another bit set, with five different options. I chose "Stall at Pixel Scoreboard" since we've used it effectively in the past, but the choice is fairly arbitrary.Signed-off-by Kenneth Graunke <[email protected]>--- drivers/gpu/drm/i915/intel_ringbuffer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_ringbuffer.c +1
-1@@ -370,7 +370,14 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring,u32 scratch_addr = ring->scratch.gtt_offset +128 ;int ret; - flags |=PIPE_CONTROL_CS_STALL ; +/* For CS stalls, one of the following must also be set:
drivers/gpu/drm/i915/intel_ringbuffer.c gen8_render_ring_flush(struct intel_ring_buffer *ring, · line 383
Quoted 10 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +7
-0+* - Render Target Cache Flush +* - Depth Cache Flush +* - Stall at Pixel Scoreboard +* - Post-Sync Operation +* We arbitrarily choose "Stall at Scoreboard". +*/ + flags |=PIPE_CONTROL_CS_STALL |PIPE_CONTROL_STALL_AT_SCOREBOARD ;if (flush_domains) { flags |=PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH ;
If I am reading the same workaround as you, we only need to do this when !flush_domains, since we satisfy the requisite in the flush_domains case.
But I can live with it whether or not you change it.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 30 lines · Ben Widawsky
Quoted 29 lines · Kenneth Graunke
According to the latest documentation, any
PIPE_CONTROLwith the "Command Streamer Stall" bit set must also have another bit set, with five different options. I chose "Stall at Pixel Scoreboard" since we've used it effectively in the past, but the choice is fairly arbitrary.Signed-off-by Kenneth Graunke <[email protected]>--- drivers/gpu/drm/i915/intel_ringbuffer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_ringbuffer.c +8
-1@@ -370,7 +370,14 @@ gen8_render_ring_flush(struct intel_ring_buffer *ring,u32 scratch_addr = ring->scratch.gtt_offset +128 ;int ret; - flags |=PIPE_CONTROL_CS_STALL ; +/* For CS stalls, one of the following must also be set: +* - Render Target Cache Flush +* - Depth Cache Flush +* - Stall at Pixel Scoreboard +* - Post-Sync Operation +* We arbitrarily choose "Stall at Scoreboard". +*/ + flags |=PIPE_CONTROL_CS_STALL |PIPE_CONTROL_STALL_AT_SCOREBOARD ;
Quoted 6 lines
drivers/gpu/drm/i915/intel_ringbuffer.c gen8_render_ring_flush(struct intel_ring_buffer *ring, · line 383
Quoted 2 lines
drivers/gpu/drm/i915/intel_ringbuffer.c +0
-0if (flush_domains) { flags |=PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH ;If I am reading the same workaround as you, we only need to do this when !flush_domains, since we satisfy the requisite in the
flush_domainscase.
And we satisfy them for !flush_domains as well since we do a post-sync operation (since it must be an invalidate_domains).
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre