diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-03 11:51:18 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-03-03 12:11:01 +0000 |
commit | 7499b913b340c56f9d566cc13300d305385eea96 (patch) | |
tree | 822b29e09d8161cb87ececa7190a65ec0e402de9 /lib/igt_gt.c | |
parent | 4133c7f85bbb89684c326b0ab178c7c11b09df22 (diff) |
lib/igt_gt: Replace asm clflush/mfence with __builtin_ia32 variants
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_gt.c')
-rw-r--r-- | lib/igt_gt.c | 13 |
1 files 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 |