[Mesa-dev] [PATCH 3/3] anv: implement WaCsStallAtEveryFourthPipecontrol for gen7
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Wed Feb 22 12:12:05 UTC 2017
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
src/intel/vulkan/anv_batch_chain.c | 5 +++++
src/intel/vulkan/anv_pipeline.c | 2 ++
src/intel/vulkan/anv_private.h | 4 ++++
src/intel/vulkan/genX_cmd_buffer.c | 21 +++++++++++++++++++--
4 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c
index 3f6039e816..07921d1d12 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -235,6 +235,9 @@ anv_batch_emit_batch(struct anv_batch *batch, struct anv_batch *other)
other->relocs, offset);
batch->next += size;
+
+ batch->gen7.pipe_controls_since_last_cs_stall +=
+ other->gen7.pipe_controls_since_last_cs_stall;
}
/*-----------------------------------------------------------------------*
@@ -657,6 +660,8 @@ anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer)
struct anv_batch_bo *batch_bo;
VkResult result;
+ memset(&cmd_buffer->batch, 0, sizeof(cmd_buffer->batch));
+
list_inithead(&cmd_buffer->batch_bos);
result = anv_batch_bo_create(cmd_buffer, &batch_bo);
diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 4410103835..5dee943fe9 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1187,6 +1187,8 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
if (result != VK_SUCCESS)
return result;
+ memset(&pipeline->batch, 0, sizeof(pipeline->batch));
+
pipeline->batch.alloc = alloc;
pipeline->batch.next = pipeline->batch.start = pipeline->batch_data;
pipeline->batch.end = pipeline->batch.start + sizeof(pipeline->batch_data);
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index ac121c833e..167a486d83 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -707,6 +707,10 @@ struct anv_batch {
*/
VkResult (*extend_cb)(struct anv_batch *, void *);
void * user_data;
+
+ struct {
+ uint32_t pipe_controls_since_last_cs_stall;
+ } gen7;
};
void *anv_batch_emit_dwords(struct anv_batch *batch, int num_dwords);
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 856b58412a..14998251bb 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -34,10 +34,27 @@
void
genX(emit_pipe_control)(struct anv_device *device,
struct anv_batch *batch,
- const struct GENX(PIPE_CONTROL) *pc)
+ const struct GENX(PIPE_CONTROL) *_pc)
{
+ struct GENX(PIPE_CONTROL) pc = *_pc;
+
+ /* Implement the WaCsStallAtEveryFourthPipecontrol workaround on IVB, BYT:
+ *
+ * "Every 4th PIPE_CONTROL command, not counting the PIPE_CONTROL with
+ * only read-cache-invalidate bit(s) set, must have a CS_STALL bit set."
+ *
+ * Note that the kernel does CS stalls between batches, so we only need
+ * to count them within a batch.
+ */
+ if (device->info.gen == 7 && !device->info.is_haswell) {
+ if (pc.CommandStreamerStallEnable)
+ batch->gen7.pipe_controls_since_last_cs_stall = 0;
+ else if (batch->gen7.pipe_controls_since_last_cs_stall > 4)
+ pc.CommandStreamerStallEnable = true;
+ }
+
void *batch_pc = anv_batch_emit_dwords(batch, GENX(PIPE_CONTROL_length));
- GENX(PIPE_CONTROL_pack)(batch, batch_pc, pc);
+ GENX(PIPE_CONTROL_pack)(batch, batch_pc, &pc);
}
static void
--
2.11.0
More information about the mesa-dev
mailing list