radv: report VM faults if detected
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 31 Aug 2017 09:44:00 +0000 (11:44 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 1 Sep 2017 07:46:36 +0000 (09:46 +0200)
It's fairly simple for now, but this might be quite useful.

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_private.h

index 4024f75da884a4052fe8bdce135b24ceab7e5a29..949eeea2f36f6690aaf3dcdab10d187604ea015d 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "ac_debug.h"
 #include "radv_debug.h"
 
 bool
@@ -44,6 +45,9 @@ radv_init_trace(struct radv_device *device)
        if (!device->trace_id_ptr)
                return false;
 
+       ac_vm_fault_occured(device->physical_device->rad_info.chip_class,
+                           &device->dmesg_timestamp, NULL);
+
        return true;
 }
 
@@ -80,9 +84,18 @@ radv_gpu_hang_occured(struct radv_queue *queue)
 void
 radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_winsys_cs *cs)
 {
+       struct radv_device *device = queue->device;
+       uint64_t addr;
+
        if (!radv_gpu_hang_occured(queue))
                return;
 
+       if (ac_vm_fault_occured(device->physical_device->rad_info.chip_class,
+                               &device->dmesg_timestamp, &addr)) {
+               fprintf(stderr, "VM fault report.\n\n");
+               fprintf(stderr, "Failing VM page: 0x%08"PRIx64"\n\n", addr);
+       }
+
        radv_dump_trace(queue->device, cs);
        abort();
 }
index 73f7bdbe8a0ec192a924e0219c7a74965b2c5814..28e70e6915096543a9d4ea4c04375ec22a6a3048 100644 (file)
@@ -555,6 +555,9 @@ struct radv_device {
        uint32_t fmask_mrt_offset_counter;
        struct list_head shader_slabs;
        mtx_t shader_slab_mutex;
+
+       /* For detecting VM faults reported by dmesg. */
+       uint64_t dmesg_timestamp;
 };
 
 struct radv_device_memory {