Module: Mesa Branch: main Commit: a0f7820fe83d7f0662873a999347cffdbe393964 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a0f7820fe83d7f0662873a999347cffdbe393964
Author: José Roberto de Souza <jose.so...@intel.com> Date: Thu Jan 4 10:05:51 2024 -0800 anv: Simply companion_rcs handling Here dropping is_companion_rcs_cmd_buffer parameter of a few functions that don't need this information, it just need the right anv_cmd_buffer for each case. Signed-off-by: José Roberto de Souza <jose.so...@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwer...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26882> --- src/intel/vulkan/anv_batch_chain.c | 12 +++------ src/intel/vulkan/anv_private.h | 3 +-- src/intel/vulkan/i915/anv_batch_chain.c | 46 ++++++++++++--------------------- src/intel/vulkan/xe/anv_batch_chain.c | 36 ++++++++++++-------------- 4 files changed, 37 insertions(+), 60 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 7aa96bb2984..0dfdd582a4b 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1248,8 +1248,7 @@ anv_cmd_buffer_exec_batch_debug(struct anv_queue *queue, uint32_t cmd_buffer_count, struct anv_cmd_buffer **cmd_buffers, struct anv_query_pool *perf_query_pool, - uint32_t perf_query_pass, - bool is_companion_rcs_cmd_buffer) + uint32_t perf_query_pass) { if (!INTEL_DEBUG(DEBUG_BATCH | DEBUG_BATCH_STATS)) return; @@ -1277,13 +1276,8 @@ anv_cmd_buffer_exec_batch_debug(struct anv_queue *queue, } } - for (uint32_t i = 0; i < cmd_buffer_count; i++) { - struct anv_cmd_buffer *cmd_buffer = - is_companion_rcs_cmd_buffer ? - cmd_buffers[i]->companion_rcs_cmd_buffer : - cmd_buffers[i]; - anv_print_batch(device, queue, cmd_buffer); - } + for (uint32_t i = 0; i < cmd_buffer_count; i++) + anv_print_batch(device, queue, cmd_buffers[i]); } else if (INTEL_DEBUG(DEBUG_BATCH)) { intel_print_batch(queue->decoder, device->trivial_batch_bo->map, device->trivial_batch_bo->size, diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index fcb9b5b6024..d246fa648c9 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -4026,8 +4026,7 @@ anv_cmd_buffer_exec_batch_debug(struct anv_queue *queue, uint32_t cmd_buffer_count, struct anv_cmd_buffer **cmd_buffers, struct anv_query_pool *perf_query_pool, - uint32_t perf_query_pass, - bool is_companion_rcs_cmd_buffer); + uint32_t perf_query_pass); void anv_cmd_buffer_clflush(struct anv_cmd_buffer **cmd_buffers, uint32_t num_cmd_buffers); diff --git a/src/intel/vulkan/i915/anv_batch_chain.c b/src/intel/vulkan/i915/anv_batch_chain.c index 51c99799e0a..c5d791ba77a 100644 --- a/src/intel/vulkan/i915/anv_batch_chain.c +++ b/src/intel/vulkan/i915/anv_batch_chain.c @@ -367,8 +367,7 @@ static VkResult setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, struct anv_queue *queue, struct anv_cmd_buffer **cmd_buffers, - uint32_t num_cmd_buffers, - bool is_companion_rcs_cmd_buffer) + uint32_t num_cmd_buffers) { struct anv_device *device = queue->device; VkResult result; @@ -379,11 +378,8 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, anv_cmd_buffer_chain_command_buffers(cmd_buffers, num_cmd_buffers); for (uint32_t i = 0; i < num_cmd_buffers; i++) { - struct anv_cmd_buffer *cmd_buf = - is_companion_rcs_cmd_buffer ? - cmd_buffers[i]->companion_rcs_cmd_buffer : cmd_buffers[i]; - anv_measure_submit(cmd_buf); - result = setup_execbuf_for_cmd_buffer(execbuf, cmd_buf); + anv_measure_submit(cmd_buffers[i]); + result = setup_execbuf_for_cmd_buffer(execbuf, cmd_buffers[i]); if (result != VK_SUCCESS) return result; } @@ -452,10 +448,7 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, return result; } - struct list_head *batch_bo = - is_companion_rcs_cmd_buffer && cmd_buffers[0]->companion_rcs_cmd_buffer ? - &cmd_buffers[0]->companion_rcs_cmd_buffer->batch_bos : - &cmd_buffers[0]->batch_bos; + struct list_head *batch_bo = &cmd_buffers[0]->batch_bos; struct anv_batch_bo *first_batch_bo = list_first_entry(batch_bo, struct anv_batch_bo, link); @@ -486,11 +479,11 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, anv_cmd_buffer_clflush(cmd_buffers, num_cmd_buffers); #endif - assert(!is_companion_rcs_cmd_buffer || device->physical->has_vm_control); + assert(!cmd_buffers[0]->is_companion_rcs_cmd_buffer || device->physical->has_vm_control); uint64_t exec_flags = 0; uint32_t context_id; - get_context_and_exec_flags(queue, is_companion_rcs_cmd_buffer, &exec_flags, - &context_id); + get_context_and_exec_flags(queue, cmd_buffers[0]->is_companion_rcs_cmd_buffer, + &exec_flags, &context_id); execbuf->execbuf = (struct drm_i915_gem_execbuffer2) { .buffers_ptr = (uintptr_t) execbuf->objects, @@ -702,8 +695,7 @@ setup_execbuf_fence_params(struct anv_execbuf *execbuf) static VkResult i915_companion_rcs_queue_exec_locked(struct anv_queue *queue, - uint32_t cmd_buffer_count, - struct anv_cmd_buffer **cmd_buffers, + struct anv_cmd_buffer *companion_rcs_cmd_buffer, uint32_t wait_count, const struct vk_sync_wait *waits) { @@ -738,17 +730,15 @@ i915_companion_rcs_queue_exec_locked(struct anv_queue *queue, goto error; } - result = setup_execbuf_for_cmd_buffers(&execbuf, queue, cmd_buffers, - cmd_buffer_count, - true /* is_companion_rcs_cmd_buffer */); + result = setup_execbuf_for_cmd_buffers(&execbuf, queue, + &companion_rcs_cmd_buffer, 1); if (result != VK_SUCCESS) goto error; if (INTEL_DEBUG(DEBUG_SUBMIT)) anv_i915_debug_submit(&execbuf); - anv_cmd_buffer_exec_batch_debug(queue, cmd_buffer_count, cmd_buffers, - NULL, 0, true /*is_companion_rcs_cmd_buffer */); + anv_cmd_buffer_exec_batch_debug(queue, 1, &companion_rcs_cmd_buffer, NULL, 0); setup_execbuf_fence_params(&execbuf); @@ -834,10 +824,8 @@ i915_queue_exec_locked(struct anv_queue *queue, } if (cmd_buffer_count) { - result = setup_execbuf_for_cmd_buffers(&execbuf, queue, - cmd_buffers, - cmd_buffer_count, - false /* is_companion_rcs_cmd_buffer */); + result = setup_execbuf_for_cmd_buffers(&execbuf, queue, cmd_buffers, + cmd_buffer_count); } else { result = setup_empty_execbuf(&execbuf, queue); } @@ -852,8 +840,7 @@ i915_queue_exec_locked(struct anv_queue *queue, anv_i915_debug_submit(&execbuf); anv_cmd_buffer_exec_batch_debug(queue, cmd_buffer_count, cmd_buffers, - perf_query_pool, perf_query_pass, - false /* is_companion_rcs_cmd_buffer */); + perf_query_pool, perf_query_pass); setup_execbuf_fence_params(&execbuf); @@ -915,8 +902,9 @@ i915_queue_exec_locked(struct anv_queue *queue, struct anv_cmd_buffer *companion_rcs_cmd_buffer = cmd_buffers[0]->companion_rcs_cmd_buffer; assert(companion_rcs_cmd_buffer->is_companion_rcs_cmd_buffer); - result = i915_companion_rcs_queue_exec_locked(queue, cmd_buffer_count, - cmd_buffers, wait_count, + assert(cmd_buffer_count == 1); + result = i915_companion_rcs_queue_exec_locked(queue, + cmd_buffers[0]->companion_rcs_cmd_buffer, wait_count, waits); } diff --git a/src/intel/vulkan/xe/anv_batch_chain.c b/src/intel/vulkan/xe/anv_batch_chain.c index b5076f3a027..9ef4fa16a16 100644 --- a/src/intel/vulkan/xe/anv_batch_chain.c +++ b/src/intel/vulkan/xe/anv_batch_chain.c @@ -173,16 +173,14 @@ xe_exec_process_syncs(struct anv_queue *queue, static void xe_exec_print_debug(struct anv_queue *queue, uint32_t cmd_buffer_count, struct anv_cmd_buffer **cmd_buffers, struct anv_query_pool *perf_query_pool, - uint32_t perf_query_pass, struct drm_xe_exec *exec, - bool is_companion_rcs_cmd_buffer) + uint32_t perf_query_pass, struct drm_xe_exec *exec) { if (INTEL_DEBUG(DEBUG_SUBMIT)) fprintf(stderr, "Batch offset=0x%016"PRIx64" on queue %u\n", (uint64_t)exec->address, queue->vk.index_in_family); anv_cmd_buffer_exec_batch_debug(queue, cmd_buffer_count, cmd_buffers, - perf_query_pool, perf_query_pass, - is_companion_rcs_cmd_buffer); + perf_query_pool, perf_query_pass); } VkResult @@ -271,8 +269,7 @@ xe_queue_exec_utrace_locked(struct anv_queue *queue, static VkResult xe_companion_rcs_queue_exec_locked(struct anv_queue *queue, - uint32_t cmd_buffer_count, - struct anv_cmd_buffer **cmd_buffers, + struct anv_cmd_buffer *companion_rcs_cmd_buffer, uint32_t wait_count, const struct vk_sync_wait *waits) { @@ -302,15 +299,12 @@ xe_companion_rcs_queue_exec_locked(struct anv_queue *queue, .num_syncs = xe_syncs_count, }; - struct anv_cmd_buffer *first_cmd_buffer = - cmd_buffers[0]->companion_rcs_cmd_buffer; - struct anv_batch_bo *first_batch_bo = - list_first_entry(&first_cmd_buffer->batch_bos, struct anv_batch_bo, - link); - exec.address = first_batch_bo->bo->offset; + struct anv_batch_bo *batch_bo = + list_first_entry(&companion_rcs_cmd_buffer->batch_bos, + struct anv_batch_bo, link); + exec.address = batch_bo->bo->offset; - xe_exec_print_debug(queue, cmd_buffer_count, cmd_buffers, NULL, 0, &exec, - true /* is_companion_rcs_cmd_buffer */); + xe_exec_print_debug(queue, 1, &companion_rcs_cmd_buffer, NULL, 0, &exec); if (!device->info->no_hw) { if (intel_ioctl(device->fd, DRM_IOCTL_XE_EXEC, &exec)) @@ -378,8 +372,7 @@ xe_queue_exec_locked(struct anv_queue *queue, } xe_exec_print_debug(queue, cmd_buffer_count, cmd_buffers, perf_query_pool, - perf_query_pass, &exec, - false /* is_companion_rcs_cmd_buffer */); + perf_query_pass, &exec); /* TODO: add perfetto stuff when Xe supports it */ @@ -389,10 +382,13 @@ xe_queue_exec_locked(struct anv_queue *queue, } vk_free(&device->vk.alloc, xe_syncs); - if (cmd_buffer_count != 0 && cmd_buffers[0]->companion_rcs_cmd_buffer) - result = xe_companion_rcs_queue_exec_locked(queue, cmd_buffer_count, - cmd_buffers, wait_count, - waits); + if (cmd_buffer_count != 0 && cmd_buffers[0]->companion_rcs_cmd_buffer) { + /* not allowed to chain cmd_buffers with companion_rcs_cmd_buffer */ + assert(cmd_buffer_count == 1); + result = xe_companion_rcs_queue_exec_locked(queue, + cmd_buffers[0]->companion_rcs_cmd_buffer, + wait_count, waits); + } if (result == VK_SUCCESS && queue->sync) { result = vk_sync_wait(&device->vk, queue->sync, 0,