From 0be9cac742c0daeb4ae5b4456af0d765155746dc Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Wed, 6 Apr 2022 22:56:00 +0300 Subject: [PATCH] anv: limit clflush usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Discrete platforms don't have LLC, but on those, we mmap our buffers with WC. So we shouldn't need to clflush there. Anv already had a boolean field on the physical device to know whether we need to use clflush(), based off the memory heaps available. So use that instead. Signed-off-by: Lionel Landwerlin Reviewed-by: Tapani Pälli Part-of: --- src/intel/vulkan/anv_batch_chain.c | 6 +++--- src/intel/vulkan/anv_device.c | 2 +- src/intel/vulkan/anv_private.h | 2 +- src/intel/vulkan/anv_wsi.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c index 62c526aaaed..7b9faf94e49 100644 --- a/src/intel/vulkan/anv_batch_chain.c +++ b/src/intel/vulkan/anv_batch_chain.c @@ -1911,7 +1911,7 @@ setup_execbuf_for_cmd_buffers(struct anv_execbuf *execbuf, anv_cmd_buffer_process_relocs(cmd_buffers[0], &cmd_buffers[0]->surface_relocs); } - if (!device->info.has_llc) { + if (device->physical->memory.need_clflush) { __builtin_ia32_mfence(); for (uint32_t i = 0; i < num_cmd_buffers; i++) { u_vector_foreach(bbo, &cmd_buffers[i]->seen_bbos) { @@ -1998,7 +1998,7 @@ setup_utrace_execbuf(struct anv_execbuf *execbuf, struct anv_queue *queue, flush->batch_bo->exec_obj_index = last_idx; } - if (!device->info.has_llc) + if (device->physical->memory.need_clflush) intel_flush_range(flush->batch_bo->map, flush->batch_bo->size); execbuf->execbuf = (struct drm_i915_gem_execbuffer2) { @@ -2435,7 +2435,7 @@ anv_queue_submit_simple_batch(struct anv_queue *queue, return result; memcpy(batch_bo->map, batch->start, batch_size); - if (!device->info.has_llc) + if (device->physical->memory.need_clflush) intel_flush_range(batch_bo->map, batch_size); struct anv_execbuf execbuf; diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index c67c57bec16..d67eb0ba3ce 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -2932,7 +2932,7 @@ anv_device_init_trivial_batch(struct anv_device *device) anv_batch_emit(&batch, GFX7_MI_BATCH_BUFFER_END, bbe); anv_batch_emit(&batch, GFX7_MI_NOOP, noop); - if (!device->info.has_llc) + if (device->physical->memory.need_clflush) intel_clflush_range(batch.start, batch.next - batch.start); return VK_SUCCESS; diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index fa4c8662a5c..c67a9d9d68b 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1593,7 +1593,7 @@ write_reloc(const struct anv_device *device, void *p, uint64_t v, bool flush) *(uint32_t *)p = v; } - if (flush && !device->info.has_llc) + if (flush && device->physical->memory.need_clflush) intel_flush_range(p, reloc_size); } diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c index bffa3beca14..d66034a2537 100644 --- a/src/intel/vulkan/anv_wsi.c +++ b/src/intel/vulkan/anv_wsi.c @@ -97,7 +97,7 @@ VkResult anv_QueuePresentKHR( if (device->debug_frame_desc) { device->debug_frame_desc->frame_id++; - if (!device->info.has_llc) { + if (device->physical->memory.need_clflush) { intel_clflush_range(device->debug_frame_desc, sizeof(*device->debug_frame_desc)); }