From 648731e2bd746a97e94bebf68423c84f6e887844 Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Thu, 14 Jul 2022 21:23:50 +0900 Subject: [PATCH] radv: Only set pstate for the first hw_ctx. We used to do it for every queue, which was duplicate work as pstate is per-device. It could also cause trouble when multiple hw_ctx are created as the call will succeed for only one of them and the rest will return -EBUSY. Simplify and fix this by only setting for the first non-null hw_ctx. Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_device.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index ad0800bc992..6ab6280bf61 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -7150,14 +7150,11 @@ radv_thread_trace_set_pstate(struct radv_device *device, bool enable) enum radeon_ctx_pstate pstate = enable ? RADEON_CTX_PSTATE_PEAK : RADEON_CTX_PSTATE_NONE; if (device->physical_device->rad_info.has_stable_pstate) { - for (unsigned i = 0; i < RADV_MAX_QUEUE_FAMILIES; i++) { - for (unsigned q = 0; q < device->queue_count[i]; q++) { - struct radv_queue *queue = &device->queues[i][q]; - - if (ws->ctx_set_pstate(queue->hw_ctx, pstate) < 0) - return false; - } - } + /* pstate is per-device; setting it for one ctx is sufficient. + * We pick the first initialized one below. */ + for (unsigned i = 0; i < RADV_NUM_HW_CTX; i++) + if (device->hw_ctx[i]) + return ws->ctx_set_pstate(device->hw_ctx[i], pstate) >= 0; } return true;