aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2015-09-11 03:34:52 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2015-09-11 11:08:18 -0400
commit6e8f580d1fcc18e290713984c379cb97131c015a (patch)
treef4dc7a3e4310c64cacacae02d8c20476bc6f4c37
parent716ff1921a86c637b8875c7bb312fc6755fa9300 (diff)
ARM: domains: add memory dependencies to get_domain/set_domain
We need to have memory dependencies on get_domain/set_domain to avoid the compiler over-optimising these inline assembly instructions. Loads/stores must not be reordered across a set_domain(), so introduce a compiler barrier for that assembly. The value of get_domain() must not be cached across a set_domain(), but we still want to allow the compiler to optimise it away. Introduce a dependency on current_thread_info()->cpu_domain to avoid this; the new memory clobber in set_domain() should therefore cause the compiler to re-load this. The other advantage of using this is we should have its address in the register set already, or very soon after at most call sites. Tested-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/include/asm/domain.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
index e878129f2fee..fc8ba1663601 100644
--- a/arch/arm/include/asm/domain.h
+++ b/arch/arm/include/asm/domain.h
@@ -12,6 +12,7 @@
12 12
13#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
14#include <asm/barrier.h> 14#include <asm/barrier.h>
15#include <asm/thread_info.h>
15#endif 16#endif
16 17
17/* 18/*
@@ -89,7 +90,8 @@ static inline unsigned int get_domain(void)
89 90
90 asm( 91 asm(
91 "mrc p15, 0, %0, c3, c0 @ get domain" 92 "mrc p15, 0, %0, c3, c0 @ get domain"
92 : "=r" (domain)); 93 : "=r" (domain)
94 : "m" (current_thread_info()->cpu_domain));
93 95
94 return domain; 96 return domain;
95} 97}
@@ -98,7 +100,7 @@ static inline void set_domain(unsigned val)
98{ 100{
99 asm volatile( 101 asm volatile(
100 "mcr p15, 0, %0, c3, c0 @ set domain" 102 "mcr p15, 0, %0, c3, c0 @ set domain"
101 : : "r" (val)); 103 : : "r" (val) : "memory");
102 isb(); 104 isb();
103} 105}
104 106