radv: report the last GPUVM fault when a device lost is detected
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 10 Oct 2023 08:44:00 +0000 (10:44 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 25 Oct 2023 15:29:23 +0000 (15:29 +0000)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23238>

src/amd/vulkan/radv_debug.c
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c

index cda92da..e27235d 100644 (file)
@@ -694,7 +694,7 @@ radv_gpu_hang_occurred(struct radv_queue *queue, enum amd_ip_type ring)
    return false;
 }
 
-static bool
+bool
 radv_vm_fault_occurred(struct radv_device *device, struct radv_winsys_gpuvm_fault_info *fault_info)
 {
    if (!device->physical_device->rad_info.has_gpuvm_fault_query)
index caa22e6..fb18bf0 100644 (file)
@@ -103,4 +103,6 @@ bool radv_trap_handler_init(struct radv_device *device);
 void radv_trap_handler_finish(struct radv_device *device);
 void radv_check_trap_handler(struct radv_queue *queue);
 
+bool radv_vm_fault_occurred(struct radv_device *device, struct radv_winsys_gpuvm_fault_info *fault_info);
+
 #endif
index d13035b..4aa4b93 100644 (file)
@@ -598,6 +598,17 @@ init_dispatch_tables(struct radv_device *device, struct radv_physical_device *ph
    add_entrypoints(&b, &vk_common_device_entrypoints, RADV_DISPATCH_TABLE_COUNT);
 }
 
+static void
+radv_report_gpuvm_fault(struct radv_device *device)
+{
+   struct radv_winsys_gpuvm_fault_info fault_info = {0};
+
+   if (!radv_vm_fault_occurred(device, &fault_info))
+      return;
+
+   fprintf(stderr, "radv: GPUVM fault detected at address 0x%08" PRIx64 ".\n", fault_info.addr);
+}
+
 static VkResult
 radv_check_status(struct vk_device *vk_device)
 {
@@ -612,15 +623,20 @@ radv_check_status(struct vk_device *vk_device)
       if (device->hw_ctx[i]) {
          status = device->ws->ctx_query_reset_status(device->hw_ctx[i]);
 
-         if (status == RADV_GUILTY_CONTEXT_RESET)
+         if (status == RADV_GUILTY_CONTEXT_RESET) {
+            radv_report_gpuvm_fault(device);
             return vk_device_set_lost(&device->vk, "GPU hung detected in this process");
-         else if (status == RADV_INNOCENT_CONTEXT_RESET)
+         } else if (status == RADV_INNOCENT_CONTEXT_RESET) {
             context_reset = true;
+         }
       }
    }
 
-   if (context_reset)
+   if (context_reset) {
+      radv_report_gpuvm_fault(device);
       return vk_device_set_lost(&device->vk, "GPU hung triggered by other process");
+   }
+
    return VK_SUCCESS;
 }