From 42155abdd7265efd32ea4678fb9698c2ac4ee18a Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 12 Feb 2016 11:00:08 -0800 Subject: [PATCH] anv: Add a clfush_range helper function --- src/vulkan/anv_private.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 6da714ad8b2..22df64c5825 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -418,14 +418,11 @@ struct anv_state_stream { #define CACHELINE_SIZE 64 #define CACHELINE_MASK 63 -static void inline -anv_state_clflush(struct anv_state state) +static inline void +anv_clflush_range(void *start, size_t size) { - /* state.map may not be cacheline aligned, so round down the start pointer - * to a cacheline boundary so we flush all pages that contain the state. - */ - void *end = state.map + state.alloc_size; - void *p = (void *) (((uintptr_t) state.map) & ~CACHELINE_MASK); + void *p = (void *) (((uintptr_t) start) & ~CACHELINE_MASK); + void *end = start + size; __builtin_ia32_mfence(); while (p < end) { @@ -434,6 +431,12 @@ anv_state_clflush(struct anv_state state) } } +static void inline +anv_state_clflush(struct anv_state state) +{ + anv_clflush_range(state.map, state.alloc_size); +} + void anv_block_pool_init(struct anv_block_pool *pool, struct anv_device *device, uint32_t block_size); void anv_block_pool_finish(struct anv_block_pool *pool);