From: Sinan Kaya <okaya@codeaurora.org>
To: arnd@arndb.de, timur@codeaurora.org, sulrich@codeaurora.org
Cc: linux-arm-msm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Sinan Kaya <okaya@codeaurora.org>,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 1/2] io: prevent compiler reordering on the default writeX() implementation
Date: Fri, 30 Mar 2018 11:58:12 -0400 [thread overview]
Message-ID: <1522425494-2916-1-git-send-email-okaya@codeaurora.org> (raw)
The default implementation of mapping writeX() to __raw_writeX() is wrong.
writeX() has stronger ordering semantics. Compiler is allowed to reorder
__raw_writeX().
In the abscence of a write barrier or when using a strongly ordered
architecture, writeX() should at least have a compiler barrier in
it to prevent commpiler from clobbering the execution order.
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
include/asm-generic/io.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index b4531e3..e8c2078 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -144,6 +144,7 @@ static inline u64 readq(const volatile void __iomem *addr)
#define writeb writeb
static inline void writeb(u8 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writeb(value, addr);
}
#endif
@@ -152,6 +153,7 @@ static inline void writeb(u8 value, volatile void __iomem *addr)
#define writew writew
static inline void writew(u16 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writew(cpu_to_le16(value), addr);
}
#endif
@@ -160,6 +162,7 @@ static inline void writew(u16 value, volatile void __iomem *addr)
#define writel writel
static inline void writel(u32 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writel(__cpu_to_le32(value), addr);
}
#endif
@@ -169,6 +172,7 @@ static inline void writel(u32 value, volatile void __iomem *addr)
#define writeq writeq
static inline void writeq(u64 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writeq(__cpu_to_le64(value), addr);
}
#endif
--
2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: okaya@codeaurora.org (Sinan Kaya)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] io: prevent compiler reordering on the default writeX() implementation
Date: Fri, 30 Mar 2018 11:58:12 -0400 [thread overview]
Message-ID: <1522425494-2916-1-git-send-email-okaya@codeaurora.org> (raw)
The default implementation of mapping writeX() to __raw_writeX() is wrong.
writeX() has stronger ordering semantics. Compiler is allowed to reorder
__raw_writeX().
In the abscence of a write barrier or when using a strongly ordered
architecture, writeX() should at least have a compiler barrier in
it to prevent commpiler from clobbering the execution order.
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
include/asm-generic/io.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index b4531e3..e8c2078 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -144,6 +144,7 @@ static inline u64 readq(const volatile void __iomem *addr)
#define writeb writeb
static inline void writeb(u8 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writeb(value, addr);
}
#endif
@@ -152,6 +153,7 @@ static inline void writeb(u8 value, volatile void __iomem *addr)
#define writew writew
static inline void writew(u16 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writew(cpu_to_le16(value), addr);
}
#endif
@@ -160,6 +162,7 @@ static inline void writew(u16 value, volatile void __iomem *addr)
#define writel writel
static inline void writel(u32 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writel(__cpu_to_le32(value), addr);
}
#endif
@@ -169,6 +172,7 @@ static inline void writel(u32 value, volatile void __iomem *addr)
#define writeq writeq
static inline void writeq(u64 value, volatile void __iomem *addr)
{
+ barrier();
__raw_writeq(__cpu_to_le64(value), addr);
}
#endif
--
2.7.4
next reply other threads:[~2018-03-30 15:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-30 15:58 Sinan Kaya [this message]
2018-03-30 15:58 ` [PATCH v2 1/2] io: prevent compiler reordering on the default writeX() implementation Sinan Kaya
2018-03-30 15:58 ` [PATCH v2 2/2] io: prevent compiler reordering on the default readX() implementation Sinan Kaya
2018-03-30 15:58 ` Sinan Kaya
2018-04-03 10:49 ` Mark Rutland
2018-04-03 10:49 ` Mark Rutland
2018-04-03 11:13 ` Arnd Bergmann
2018-04-03 11:13 ` Arnd Bergmann
2018-04-03 12:44 ` Sinan Kaya
2018-04-03 12:44 ` Sinan Kaya
2018-04-03 12:56 ` Arnd Bergmann
2018-04-03 12:56 ` Arnd Bergmann
2018-04-03 13:06 ` Sinan Kaya
2018-04-03 13:06 ` Sinan Kaya
2018-04-03 22:29 ` Palmer Dabbelt
2018-04-03 22:29 ` Palmer Dabbelt
2018-04-03 22:29 ` Palmer Dabbelt
2018-04-04 15:52 ` Sinan Kaya
2018-04-04 15:52 ` Sinan Kaya
2018-04-04 15:55 ` Arnd Bergmann
2018-04-04 15:55 ` Arnd Bergmann
2018-04-04 15:57 ` Sinan Kaya
2018-04-04 15:57 ` Sinan Kaya
2018-04-04 17:48 ` Sinan Kaya
2018-04-04 17:48 ` Sinan Kaya
2018-04-04 19:50 ` Arnd Bergmann
2018-04-04 19:50 ` Arnd Bergmann
2018-04-05 0:06 ` Sinan Kaya
2018-04-05 0:06 ` Sinan Kaya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1522425494-2916-1-git-send-email-okaya@codeaurora.org \
--to=okaya@codeaurora.org \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sulrich@codeaurora.org \
--cc=timur@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.