io: define stronger ordering for the default writeX() implementation
authorSinan Kaya <okaya@codeaurora.org>
Thu, 5 Apr 2018 13:09:11 +0000 (09:09 -0400)
committerArnd Bergmann <arnd@arndb.de>
Fri, 6 Apr 2018 10:01:56 +0000 (12:01 +0200)
The default implementation of mapping writeX() to __raw_writeX() is wrong.
writeX() has stronger ordering semantics. Compiler is allowed to reorder
memory writes against __raw_writeX().

Use the previously defined __io_aw() and __io_bw() macros to harden
code generation according to architecture support.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
include/asm-generic/io.h

index d27e8af9dd5a67f754aa62ff84cc6b7183b00412..964725e4f459b97bedec445fd0a14855bf938c27 100644 (file)
@@ -208,7 +208,9 @@ static inline u64 readq(const volatile void __iomem *addr)
 #define writeb writeb
 static inline void writeb(u8 value, volatile void __iomem *addr)
 {
+       __io_bw();
        __raw_writeb(value, addr);
+       __io_aw();
 }
 #endif
 
@@ -216,7 +218,9 @@ static inline void writeb(u8 value, volatile void __iomem *addr)
 #define writew writew
 static inline void writew(u16 value, volatile void __iomem *addr)
 {
+       __io_bw();
        __raw_writew(cpu_to_le16(value), addr);
+       __io_aw();
 }
 #endif
 
@@ -224,7 +228,9 @@ static inline void writew(u16 value, volatile void __iomem *addr)
 #define writel writel
 static inline void writel(u32 value, volatile void __iomem *addr)
 {
+       __io_bw();
        __raw_writel(__cpu_to_le32(value), addr);
+       __io_aw();
 }
 #endif
 
@@ -233,7 +239,9 @@ static inline void writel(u32 value, volatile void __iomem *addr)
 #define writeq writeq
 static inline void writeq(u64 value, volatile void __iomem *addr)
 {
+       __io_bw();
        __raw_writeq(__cpu_to_le64(value), addr);
+       __io_aw();
 }
 #endif
 #endif /* CONFIG_64BIT */