anv: Avoid unnecessary intel_flush calls

Batch bos are always allocated with ANV_BO_ALLOC_HOST_CACHED_COHERENT
so there is no need to do cflush calls.
But if we ever decide to change that anv_bo_needs_host_cache_flush()
will make sure cflush is called.

Outside of batch bos, this patch is also removing the
intel_flush_range() call from anv_QueuePresentKHR because
device->debug_frame_desc is offset of workaround_bo that is also
allocated as ANV_BO_ALLOC_HOST_COHERENT.

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26457>
This commit is contained in:
José Roberto de Souza
2023-12-01 09:32:18 -08:00
committed by Marge Bot
parent 9aea879342
commit 5560835fbe
6 changed files with 23 additions and 14 deletions
+6 -3
View File
@@ -361,7 +361,8 @@ anv_batch_bo_link(struct anv_cmd_buffer *cmd_buffer,
*map = intel_canonical_address(next_bbo->bo->offset + next_bbo_offset);
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (cmd_buffer->device->physical->memory.need_flush)
if (cmd_buffer->device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(prev_bbo->bo->alloc_flags))
intel_flush_range(map, sizeof(uint64_t));
#endif
}
@@ -1673,7 +1674,8 @@ anv_queue_submit_simple_batch(struct anv_queue *queue,
memcpy(batch_bo->map, batch->start, batch_size);
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush)
if (device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(batch_bo->alloc_flags))
intel_flush_range(batch_bo->map, batch_size);
#endif
@@ -1713,7 +1715,8 @@ anv_queue_submit_trtt_batch(struct anv_sparse_submission *submit,
memcpy(trtt_bbo->bo->map, batch->start, trtt_bbo->size);
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush)
if (device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(trtt_bbo->bo->alloc_flags))
intel_flush_range(trtt_bbo->bo->map, trtt_bbo->size);
#endif
+7
View File
@@ -512,6 +512,13 @@ anv_bo_ref(struct anv_bo *bo)
enum intel_device_info_mmap_mode
anv_bo_get_mmap_mode(struct anv_device *device, struct anv_bo *bo);
static inline bool
anv_bo_needs_host_cache_flush(enum anv_bo_alloc_flags alloc_flags)
{
return (alloc_flags & (ANV_BO_ALLOC_HOST_CACHED | ANV_BO_ALLOC_HOST_COHERENT)) ==
ANV_BO_ALLOC_HOST_CACHED;
}
struct anv_address {
struct anv_bo *bo;
int64_t offset;
+2 -1
View File
@@ -366,7 +366,8 @@ anv_utrace_create_ts_buffer(struct u_trace_context *utctx, uint32_t size_b)
memset(bo->map, 0, bo->size);
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush)
if (device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(bo->alloc_flags))
intel_flush_range(bo->map, bo->size);
#endif
-6
View File
@@ -113,12 +113,6 @@ VkResult anv_QueuePresentKHR(
if (device->debug_frame_desc) {
device->debug_frame_desc->frame_id++;
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush) {
intel_flush_range(device->debug_frame_desc,
sizeof(*device->debug_frame_desc));
}
#endif
}
if (u_trace_should_process(&device->ds.trace_context))
+4 -2
View File
@@ -481,7 +481,8 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf,
}
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush)
if (device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(device->batch_bo_pool.bo_alloc_flags))
anv_cmd_buffer_clflush(cmd_buffers, num_cmd_buffers);
#endif
@@ -561,7 +562,8 @@ setup_utrace_execbuf(struct anv_execbuf *execbuf, struct anv_queue *queue,
return result;
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush)
if (device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(bo->alloc_flags))
intel_flush_range(bo->map, bo->size);
#endif
}
+4 -2
View File
@@ -244,7 +244,8 @@ xe_queue_exec_utrace_locked(struct anv_queue *queue,
xe_exec_fill_sync(&xe_sync, utrace_submit->sync, 0, TYPE_SIGNAL);
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush) {
if (device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(device->utrace_bo_pool.bo_alloc_flags)) {
util_dynarray_foreach(&utrace_submit->batch_bos, struct anv_bo *, bo)
intel_flush_range((*bo)->map, (*bo)->size);
}
@@ -362,7 +363,8 @@ xe_queue_exec_locked(struct anv_queue *queue,
anv_cmd_buffer_chain_command_buffers(cmd_buffers, cmd_buffer_count);
#ifdef SUPPORT_INTEL_INTEGRATED_GPUS
if (device->physical->memory.need_flush)
if (device->physical->memory.need_flush &&
anv_bo_needs_host_cache_flush(device->batch_bo_pool.bo_alloc_flags))
anv_cmd_buffer_clflush(cmd_buffers, cmd_buffer_count);
#endif