radv: add radv_check_gpu_hangs() helper function
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 1 Sep 2017 07:44:45 +0000 (09:44 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 1 Sep 2017 07:46:00 +0000 (09:46 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_debug.c
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c

index 9913c06ec2375039b1ca324abd0c19efddcf3880..4024f75da884a4052fe8bdce135b24ceab7e5a29 100644 (file)
@@ -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)
 {
index c5e83347279cda877d96362302f67c3ea8d75ab2..0ac1f13c68aee8877a0558574d2866a2fa71228b 100644 (file)
@@ -49,7 +49,7 @@ bool
 radv_init_trace(struct radv_device *device);
 
 void
-radv_dump_trace(struct radv_device *device, struct radeon_winsys_cs *cs);
+radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_winsys_cs *cs);
 
 void
 radv_print_spirv(struct radv_shader_module *module, FILE *fp);
index cbba04a5d6f331bd1b4f490da85844e6814142a8..a5898691df655282968275847edc0b45189e588b 100644 (file)
@@ -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]);
                        }
                }