[PATCH 6/9] Use proper membar instructions on SPARC

Matt Turner mattst88 at gmail.com
Wed Aug 12 22:45:39 PDT 2009


Cc: David S. Miller <davem at davemloft.net>
Cc: Alan Coopersmith <alan.coopersmith at sun.com>
Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
 hw/xfree86/common/compiler.h |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 2fc1e6a..157769a 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -195,9 +195,17 @@ extern unsigned short ldw_brx(volatile unsigned char *, int);
 
 #   elif defined __sparc__
 
-#    define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
-#    define mem_barrier()         /* XXX: nop for now */
-#    define write_mem_barrier()   /* XXX: nop for now */
+#    define mem_barrier()				\
+	__asm__ __volatile__("ba,pt %%xcc, 1f\n\t"	\
+		"membar #Lookaside\n"			\
+		"1:\n"					\
+		: : : "memory")
+#    define write_mem_barrier()				\
+	__asm__ __volatile__("ba,pt %%xcc, 1f\n\t"	\
+		"membar #StoreStore\n"			\
+		"1:\n"					\
+		: : : "memory")
+
 #   endif
 #  endif /* __GNUC__ */
 # endif /* NO_INLINE */
@@ -605,7 +613,7 @@ outb(unsigned long port, unsigned char val)
 	__asm__ __volatile__("stba %0, [%1] %2"
 			     : /* No outputs */
 			     : "r" (val), "r" (port), "i" (ASI_PL));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ void
@@ -614,7 +622,7 @@ outw(unsigned long port, unsigned short val)
 	__asm__ __volatile__("stha %0, [%1] %2"
 			     : /* No outputs */
 			     : "r" (val), "r" (port), "i" (ASI_PL));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ void
@@ -623,7 +631,7 @@ outl(unsigned long port, unsigned int val)
 	__asm__ __volatile__("sta %0, [%1] %2"
 			     : /* No outputs */
 			     : "r" (val), "r" (port), "i" (ASI_PL));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ unsigned int
@@ -725,7 +733,7 @@ xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
 	__asm__ __volatile__("stba %0, [%1] %2"
 			     : /* No outputs */
 			     : "r" (val), "r" (addr), "i" (ASI_PL));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ void
@@ -737,7 +745,7 @@ xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
 	__asm__ __volatile__("sth %0, [%1]"
 			     : /* No outputs */
 			     : "r" (val), "r" (addr));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ void
@@ -749,7 +757,7 @@ xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
 	__asm__ __volatile__("stha %0, [%1] %2"
 			     : /* No outputs */
 			     : "r" (val), "r" (addr), "i" (ASI_PL));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ void
@@ -761,7 +769,7 @@ xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
 	__asm__ __volatile__("st %0, [%1]"
 			     : /* No outputs */
 			     : "r" (val), "r" (addr));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ void
@@ -773,7 +781,7 @@ xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
 	__asm__ __volatile__("sta %0, [%1] %2"
 			     : /* No outputs */
 			     : "r" (val), "r" (addr), "i" (ASI_PL));
-	barrier();
+	write_mem_barrier();
 }
 
 static __inline__ void
-- 
1.6.3.3



More information about the xorg-devel mailing list