提交 cfab3bdf 编写于 作者: B Benjamin Herrenschmidt 提交者: Paul Mackerras

[POWERPC] Add "memory" clobber to MMIO accessors

Gcc might re-order MMIO accessors vs. surrounding consistent
memory accesses, which is a "bad thing", and could break drivers.
This fixes it by adding a "memory" clobber to the MMIO accessors,
which should prevent gcc from doing that reordering.
Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: NPaul Mackerras <paulus@samba.org>
上级 732bee4c
...@@ -100,7 +100,7 @@ static inline type name(const volatile type __iomem *addr) \ ...@@ -100,7 +100,7 @@ static inline type name(const volatile type __iomem *addr) \
{ \ { \
type ret; \ type ret; \
__asm__ __volatile__("sync;" insn ";twi 0,%0,0;isync" \ __asm__ __volatile__("sync;" insn ";twi 0,%0,0;isync" \
: "=r" (ret) : "r" (addr), "m" (*addr)); \ : "=r" (ret) : "r" (addr), "m" (*addr) : "memory"); \
return ret; \ return ret; \
} }
...@@ -108,7 +108,7 @@ static inline type name(const volatile type __iomem *addr) \ ...@@ -108,7 +108,7 @@ static inline type name(const volatile type __iomem *addr) \
static inline void name(volatile type __iomem *addr, type val) \ static inline void name(volatile type __iomem *addr, type val) \
{ \ { \
__asm__ __volatile__("sync;" insn \ __asm__ __volatile__("sync;" insn \
: "=m" (*addr) : "r" (val), "r" (addr)); \ : "=m" (*addr) : "r" (val), "r" (addr) : "memory"); \
IO_SET_SYNC_FLAG(); \ IO_SET_SYNC_FLAG(); \
} }
...@@ -333,7 +333,8 @@ static inline unsigned int name(unsigned int port) \ ...@@ -333,7 +333,8 @@ static inline unsigned int name(unsigned int port) \
" .long 3b,5b\n" \ " .long 3b,5b\n" \
".previous" \ ".previous" \
: "=&r" (x) \ : "=&r" (x) \
: "r" (port + _IO_BASE)); \ : "r" (port + _IO_BASE) \
: "memory"); \
return x; \ return x; \
} }
...@@ -350,7 +351,8 @@ static inline void name(unsigned int val, unsigned int port) \ ...@@ -350,7 +351,8 @@ static inline void name(unsigned int val, unsigned int port) \
" .long 0b,2b\n" \ " .long 0b,2b\n" \
" .long 1b,2b\n" \ " .long 1b,2b\n" \
".previous" \ ".previous" \
: : "r" (val), "r" (port + _IO_BASE)); \ : : "r" (val), "r" (port + _IO_BASE) \
: "memory"); \
} }
__do_in_asm(_rec_inb, "lbzx") __do_in_asm(_rec_inb, "lbzx")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册