radv: dump last 60 lines of dmesg when a hang occured
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 11 Sep 2017 20:02:54 +0000 (22:02 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 14 Sep 2017 08:37:57 +0000 (10:37 +0200)
Copied from dd_dump_dmesg().

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_debug.c

index c93ebf1c77a48e4d1fbea51b23332f5f502aabe0..ec43366de7d75c271478a5174d310887e3413879 100644 (file)
@@ -563,6 +563,24 @@ radv_get_saved_compute_pipeline(struct radv_device *device)
        return (struct radv_pipeline *)ptr[2];
 }
 
+static void
+radv_dump_dmesg(FILE *f)
+{
+       char line[2000];
+       FILE *p;
+
+       p = popen("dmesg | tail -n60", "r");
+       if (!p)
+               return;
+
+       fprintf(f, "\nLast 60 lines of dmesg:\n\n");
+       while (fgets(line, sizeof(line), p))
+               fputs(line, f);
+       fprintf(f, "\n");
+
+       pclose(p);
+}
+
 static bool
 radv_gpu_hang_occured(struct radv_queue *queue, enum ring_type ring)
 {
@@ -595,6 +613,8 @@ radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_winsys_cs *cs)
        graphics_pipeline = radv_get_saved_graphics_pipeline(device);
        compute_pipeline = radv_get_saved_compute_pipeline(device);
 
+       radv_dump_dmesg(stderr);
+
        if (vm_fault_occurred) {
                fprintf(stderr, "VM fault report.\n\n");
                fprintf(stderr, "Failing VM page: 0x%08"PRIx64"\n\n", addr);