radv: acquire pstate on-demand when capturing with RGP
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 20 Sep 2022 06:37:10 +0000 (08:37 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 21 Sep 2022 09:50:18 +0000 (09:50 +0000)
AMDGPU pstate is per-device, not per Vulkan logical devices. The same
AMDGPU device is shared accross logical devices because the driver
creates only one winsys per fd. The kernel only allows one context
at a time per AMDGPU device, otherwise it returns -EBUSY.

Fixes this by acquiring pstate on-demand to avoid this multiple
logical device problem.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17712>

src/amd/vulkan/layers/radv_sqtt_layer.c
src/amd/vulkan/radv_sqtt.c

index 3945a17..1553ae3 100644 (file)
@@ -349,6 +349,10 @@ radv_handle_thread_trace(VkQueue _queue)
       radv_end_thread_trace(queue);
       thread_trace_enabled = false;
 
+      if (!radv_device_set_pstate(queue->device, false)) {
+         fprintf(stderr, "radv: Failed to restore previous pstate, ignoring.\n");
+      }
+
       /* TODO: Do something better than this whole sync. */
       queue->device->vk.dispatch_table.QueueWaitIdle(_queue);
 
@@ -384,7 +388,8 @@ radv_handle_thread_trace(VkQueue _queue)
 #endif
 
       if (frame_trigger || file_trigger || resize_trigger) {
-         if (ac_check_profile_state(&queue->device->physical_device->rad_info)) {
+         if (!radv_device_set_pstate(queue->device, true) ||
+             ac_check_profile_state(&queue->device->physical_device->rad_info)) {
             fprintf(stderr, "radv: Canceling RGP trace request as a hang condition has been "
                             "detected. Force the GPU into a profiling mode with e.g. "
                             "\"echo profile_peak  > "
index 3961f72..a49a750 100644 (file)
@@ -465,9 +465,6 @@ radv_thread_trace_init(struct radv_device *device)
    if (!radv_thread_trace_init_bo(device))
       return false;
 
-   if (!radv_device_acquire_performance_counters(device))
-      return false;
-
    list_inithead(&thread_trace_data->rgp_pso_correlation.record);
    simple_mtx_init(&thread_trace_data->rgp_pso_correlation.lock, mtx_plain);