From 8582ab2d6eff1d8fc1964ba0f353037af212bdfe Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 20 Feb 2017 10:18:57 -0800 Subject: [PATCH] anv: Add an invalidate_range helper This is similar to clflush_range except that it puts the mfence on the other side to ensure caches are flushed prior to reading. Reviewed-by: Lionel Landwerlin Cc: "13.0 17.0" --- src/intel/vulkan/anv_private.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index cd35eba..c36fdcf 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -448,6 +448,19 @@ anv_clflush_range(void *start, size_t size) } } +static inline void +anv_invalidate_range(void *start, size_t size) +{ + void *p = (void *) (((uintptr_t) start) & ~CACHELINE_MASK); + void *end = start + size; + + while (p < end) { + __builtin_ia32_clflush(p); + p += CACHELINE_SIZE; + } + __builtin_ia32_mfence(); +} + static void inline anv_state_clflush(struct anv_state state) { -- 2.7.4