radv: acquire pstate on-demand when capturing with RGP

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>
This commit is contained in:
Samuel Pitoiset 2022-09-20 08:37:10 +02:00 committed by Marge Bot
parent f1566ad500
commit 923a864d94
2 changed files with 6 additions and 4 deletions

View 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 > "

View 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);