Patchwork [U-Boot,v2] powerpc: fix implementation of out_8 to match the other out_XX functions

login
register
mail settings
Submitter Timur Tabi
Date April 4, 2011, 9:21 p.m.
Message ID <1301952064-1418-1-git-send-email-timur@freescale.com>
Download mbox | patch
Permalink /patch/89713/
State Accepted
Delegated to: Wolfgang Denk
Headers show

Comments

Timur Tabi - April 4, 2011, 9:21 p.m.
For some reason, the implementation of out_8() does not match the other
output accessors, nor does it match equivalent Linux accessor.  This can
cause a problem in a situation like this:

	__raw_readb(p1);
	out_8(p2, x);

In this case, there is no barrier between the read and the write.
If the out_8() is changed to out_be16(), then there is a barrier.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 arch/powerpc/include/asm/io.h |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
Wolfgang Denk - April 27, 2011, 10:56 p.m.
Dear Timur Tabi,

In message <1301952064-1418-1-git-send-email-timur@freescale.com> you wrote:
> For some reason, the implementation of out_8() does not match the other
> output accessors, nor does it match equivalent Linux accessor.  This can
> cause a problem in a situation like this:
> 
> 	__raw_readb(p1);
> 	out_8(p2, x);
> 
> In this case, there is no barrier between the read and the write.
> If the out_8() is changed to out_be16(), then there is a barrier.
> 
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
>  arch/powerpc/include/asm/io.h |    5 ++++-
>  1 files changed, 4 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 4ddad26..56ac9fe 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -175,7 +175,10 @@  extern inline int in_8(const volatile unsigned char __iomem *addr)
 
 extern inline void out_8(volatile unsigned char __iomem *addr, int val)
 {
-	__asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
+	__asm__ __volatile__("sync;\n"
+			     "stb%U0%X0 %1,%0;\n"
+			     : "=m" (*addr)
+			     : "r" (val));
 }
 
 extern inline int in_le16(const volatile unsigned short __iomem *addr)