summaryrefslogtreecommitdiff
path: root/arch/arc
diff options
context:
space:
mode:
authorEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>2020-03-30 22:44:43 +0300
committerAlexey Brodkin <abrodkin@synopsys.com>2020-03-31 18:25:16 +0300
commit7e5702282374138507ab3c08dfc1b28dd9ec2bd7 (patch)
treed9ff13574d147cf24f029bdff6bf01cad04fbec7 /arch/arc
parent93330d4ce416208fe202e304e5a18166c57ac569 (diff)
downloadu-boot-7e5702282374138507ab3c08dfc1b28dd9ec2bd7.tar.gz
u-boot-7e5702282374138507ab3c08dfc1b28dd9ec2bd7.tar.bz2
u-boot-7e5702282374138507ab3c08dfc1b28dd9ec2bd7.zip
ARC: IO: add volatile to accessors
We must use 'volatile' in C-version read/write IO accessors implementation to avoid merging several reads (writes) into one read (write), or optimizing them out by compiler. Fixes commit 07906b3dad15 ("ARC: Switch to generic accessors") Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Diffstat (limited to 'arch/arc')
-rw-r--r--arch/arc/include/asm/io.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h
index 70d050590d..1f1ae889f3 100644
--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -54,15 +54,21 @@ static inline void sync(void)
/* Not yet implemented */
}
-#define __arch_getb(a) (*(unsigned char *)(a))
-#define __arch_getw(a) (*(unsigned short *)(a))
-#define __arch_getl(a) (*(unsigned int *)(a))
-#define __arch_getq(a) (*(unsigned long long *)(a))
-
-#define __arch_putb(v, a) (*(unsigned char *)(a) = (v))
-#define __arch_putw(v, a) (*(unsigned short *)(a) = (v))
-#define __arch_putl(v, a) (*(unsigned int *)(a) = (v))
-#define __arch_putq(v, a) (*(unsigned long long *)(a) = (v))
+/*
+ * We must use 'volatile' in C-version read/write IO accessors implementation
+ * to avoid merging several reads (writes) into one read (write), or optimizing
+ * them out by compiler.
+ */
+#define __arch_getb(a) (*(volatile u8 *)(a))
+#define __arch_getw(a) (*(volatile u16 *)(a))
+#define __arch_getl(a) (*(volatile u32 *)(a))
+#define __arch_getq(a) (*(volatile u64 *)(a))
+
+#define __arch_putb(v, a) (*(volatile u8 *)(a) = (v))
+#define __arch_putw(v, a) (*(volatile u16 *)(a) = (v))
+#define __arch_putl(v, a) (*(volatile u32 *)(a) = (v))
+#define __arch_putq(v, a) (*(volatile u64 *)(a) = (v))
+
#define __raw_writeb(v, a) __arch_putb(v, a)
#define __raw_writew(v, a) __arch_putw(v, a)