[Mesa-dev] [PATCH 1/3] radv: add radv_check_gpu_hangs() helper function

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Aug 31 09:43:58 UTC 2017


That way, most of the debug code will be at the same place.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/amd/vulkan/radv_debug.c  | 26 +++++++++++++++++++++++++-
 src/amd/vulkan/radv_debug.h  |  3 ++-
 src/amd/vulkan/radv_device.c | 11 +----------
 3 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/amd/vulkan/radv_debug.c b/src/amd/vulkan/radv_debug.c
index 9913c06ec2..4024f75da8 100644
--- a/src/amd/vulkan/radv_debug.c
+++ b/src/amd/vulkan/radv_debug.c
@@ -47,7 +47,7 @@ radv_init_trace(struct radv_device *device)
 	return true;
 }
 
-void
+static void
 radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs)
 {
 	const char *filename = getenv("RADV_TRACE_FILE");
@@ -63,6 +63,30 @@ radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs)
 	fclose(f);
 }
 
+static bool
+radv_gpu_hang_occured(struct radv_queue *queue)
+{
+	struct radeon_winsys *ws = queue->device->ws;
+	enum ring_type ring;
+
+	ring = radv_queue_family_to_ring(queue->queue_family_index);
+
+	if (!ws->ctx_wait_idle(queue->hw_ctx, ring, queue->queue_idx))
+		return true;
+
+	return false;
+}
+
+void
+radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_winsys_cs *cs)
+{
+	if (!radv_gpu_hang_occured(queue))
+		return;
+
+	radv_dump_trace(queue->device, cs);
+	abort();
+}
+
 void
 radv_print_spirv(struct radv_shader_module *module, FILE *fp)
 {
diff --git a/src/amd/vulkan/radv_debug.h b/src/amd/vulkan/radv_debug.h
index d2fbe695fc..cafb0ee20f 100644
--- a/src/amd/vulkan/radv_debug.h
+++ b/src/amd/vulkan/radv_debug.h
@@ -47,7 +47,8 @@ enum {
 
 bool radv_init_trace(struct radv_device *device);
 
-void radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs);
+void
+radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_winsys_cs *cs);
 
 void radv_print_spirv(struct radv_shader_module *module, FILE *fp);
 
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index cbba04a5d6..a5898691df 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -2129,16 +2129,7 @@ VkResult radv_QueueSubmit(
 			}
 			fence_emitted = true;
 			if (queue->device->trace_bo) {
-				bool success = queue->device->ws->ctx_wait_idle(
-							queue->hw_ctx,
-							radv_queue_family_to_ring(
-								queue->queue_family_index),
-							queue->queue_idx);
-
-				if (!success) { /* Hang */
-					radv_dump_trace(queue->device, cs_array[j]);
-					abort();
-				}
+				radv_check_gpu_hangs(queue, cs_array[j]);
 			}
 		}
 
-- 
2.14.1



More information about the mesa-dev mailing list