From 7499b913b340c56f9d566cc13300d305385eea96 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 3 Mar 2016 11:51:18 +0000 Subject: [PATCH] lib/igt_gt: Replace asm clflush/mfence with __builtin_ia32 variants Signed-off-by: Chris Wilson --- lib/igt_gt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/igt_gt.c b/lib/igt_gt.c index 72355191..c7e16e35 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -481,6 +481,11 @@ int igt_setup_clflush(void) int first_stanza = 1; int has_clflush = 0; +#if !defined(__x86_64__) && !defined(__SSE2__) + /* requires mfence + clflush, both SSE2 instructions */ + return 0; +#endif + if (clflush_size) return 1; @@ -514,16 +519,16 @@ int igt_setup_clflush(void) void igt_clflush_range(void *addr, int size) { -#if defined(__i386__) || defined(__x86_64__) +#if defined(__x86_64__) || defined(__SSE2__) char *p, *end; end = (char *)addr + size; p = (char *)((uintptr_t)addr & ~((uintptr_t)clflush_size - 1)); - asm volatile("mfence" ::: "memory"); + __builtin_ia32_mfence(); for (; p < end; p += clflush_size) - asm volatile("clflush %0" : "+m" (*(volatile char *)p)); - asm volatile("mfence" ::: "memory"); + __builtin_ia32_clflush(p); + __builtin_ia32_mfence(); #else fprintf(stderr, "igt_clflush_range() unsupported\n"); #endif