From 91ee00a7417f9ab90901eb4e062e9abe57728894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Roberto=20de=20Souza?= Date: Wed, 29 Mar 2023 09:08:33 -0700 Subject: [PATCH] anv: Move to a function code to clflush batch buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also need to be executed in Xe kmd, so moving it to a function. No changes in behavior intended here. Signed-off-by: José Roberto de Souza Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_batch_chain.c | 18 ++++++++++++++++++ src/intel/vulkan/anv_private.h | 3 +++ src/intel/vulkan/i915/anv_batch_chain.c | 12 ++---------- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index d32212ab4bd..88254a0ab9c 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1398,3 +1398,21 @@ anv_queue_submit_simple_batch(struct anv_queue *queue, return result; } + +void +anv_cmd_buffer_clflush(struct anv_cmd_buffer **cmd_buffers, + uint32_t num_cmd_buffers) +{ +#ifdef SUPPORT_INTEL_INTEGRATED_GPUS + struct anv_batch_bo **bbo; + + __builtin_ia32_mfence(); + + for (uint32_t i = 0; i < num_cmd_buffers; i++) { + u_vector_foreach(bbo, &cmd_buffers[i]->seen_bbos) { + for (uint32_t l = 0; l < (*bbo)->length; l += CACHELINE_SIZE) + __builtin_ia32_clflush((*bbo)->bo->map + l); + } + } +#endif +} diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 7082bfc7f23..e9b9a2a7817 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -2878,6 +2878,9 @@ anv_cmd_buffer_exec_batch_debug(struct anv_queue *queue, struct anv_cmd_buffer **cmd_buffers, struct anv_query_pool *perf_query_pool, uint32_t perf_query_pass); +void +anv_cmd_buffer_clflush(struct anv_cmd_buffer **cmd_buffers, + uint32_t num_cmd_buffers); /** * A allocation tied to a command buffer. diff --git a/src/intel/vulkan/i915/anv_batch_chain.c b/src/intel/vulkan/i915/anv_batch_chain.c index ffe3ca07945..ab3497b2053 100644 --- a/src/intel/vulkan/i915/anv_batch_chain.c +++ b/src/intel/vulkan/i915/anv_batch_chain.c @@ -403,16 +403,8 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, } #ifdef SUPPORT_INTEL_INTEGRATED_GPUS - if (device->physical->memory.need_clflush) { - __builtin_ia32_mfence(); - struct anv_batch_bo **bbo; - for (uint32_t i = 0; i < num_cmd_buffers; i++) { - u_vector_foreach(bbo, &cmd_buffers[i]->seen_bbos) { - for (uint32_t l = 0; l < (*bbo)->length; l += CACHELINE_SIZE) - __builtin_ia32_clflush((*bbo)->bo->map + l); - } - } - } + if (device->physical->memory.need_clflush) + anv_cmd_buffer_clflush(cmd_buffers, num_cmd_buffers); #endif execbuf->execbuf = (struct drm_i915_gem_execbuffer2) {