diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-07-29 06:38:05 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-07-29 09:04:37 -0400 |
commit | b92b3612134faff171981fad4f0adb33f485e02e (patch) | |
tree | 90e686709e31ab7523e4ce730b2c85a930384cf7 /arch/arm | |
parent | 79f64dbf68c8a9779a7e9a25e0a9f0217a25b57a (diff) |
ARM: Add barriers to io{read,write}{8,16,32} accessors as well
The ioread/iowrite accessors also need barriers as they're used in
place of readl/writel et.al. in portable drivers. Create __iormb()
and __iowmb() which are conditionally defined to be barriers dependent
on ARM_DMA_MEM_BUFFERABLE, and always use these macros in the accessors.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/include/asm/io.h | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 3c91e7c80c29..1261b1f928d9 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h | |||
@@ -193,23 +193,21 @@ extern void _memset_io(volatile void __iomem *, int, size_t); | |||
193 | cpu_to_le32(v),__mem_pci(c))) | 193 | cpu_to_le32(v),__mem_pci(c))) |
194 | 194 | ||
195 | #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE | 195 | #ifdef CONFIG_ARM_DMA_MEM_BUFFERABLE |
196 | #define readb(c) ({ u8 __v = readb_relaxed(c); rmb(); __v; }) | 196 | #define __iormb() rmb() |
197 | #define readw(c) ({ u16 __v = readw_relaxed(c); rmb(); __v; }) | 197 | #define __iowmb() wmb() |
198 | #define readl(c) ({ u32 __v = readl_relaxed(c); rmb(); __v; }) | ||
199 | |||
200 | #define writeb(v,c) ({ wmb(); writeb_relaxed(v,c); }) | ||
201 | #define writew(v,c) ({ wmb(); writew_relaxed(v,c); }) | ||
202 | #define writel(v,c) ({ wmb(); writel_relaxed(v,c); }) | ||
203 | #else | 198 | #else |
204 | #define readb(c) readb_relaxed(c) | 199 | #define __iormb() do { } while (0) |
205 | #define readw(c) readw_relaxed(c) | 200 | #define __iowmb() do { } while (0) |
206 | #define readl(c) readl_relaxed(c) | ||
207 | |||
208 | #define writeb(v,c) writeb_relaxed(v,c) | ||
209 | #define writew(v,c) writew_relaxed(v,c) | ||
210 | #define writel(v,c) writel_relaxed(v,c) | ||
211 | #endif | 201 | #endif |
212 | 202 | ||
203 | #define readb(c) ({ u8 __v = readb_relaxed(c); __iormb(); __v; }) | ||
204 | #define readw(c) ({ u16 __v = readw_relaxed(c); __iormb(); __v; }) | ||
205 | #define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(); __v; }) | ||
206 | |||
207 | #define writeb(v,c) ({ __iowmb(); writeb_relaxed(v,c); }) | ||
208 | #define writew(v,c) ({ __iowmb(); writew_relaxed(v,c); }) | ||
209 | #define writel(v,c) ({ __iowmb(); writel_relaxed(v,c); }) | ||
210 | |||
213 | #define readsb(p,d,l) __raw_readsb(__mem_pci(p),d,l) | 211 | #define readsb(p,d,l) __raw_readsb(__mem_pci(p),d,l) |
214 | #define readsw(p,d,l) __raw_readsw(__mem_pci(p),d,l) | 212 | #define readsw(p,d,l) __raw_readsw(__mem_pci(p),d,l) |
215 | #define readsl(p,d,l) __raw_readsl(__mem_pci(p),d,l) | 213 | #define readsl(p,d,l) __raw_readsl(__mem_pci(p),d,l) |
@@ -260,13 +258,13 @@ extern void _memset_io(volatile void __iomem *, int, size_t); | |||
260 | * io{read,write}{8,16,32} macros | 258 | * io{read,write}{8,16,32} macros |
261 | */ | 259 | */ |
262 | #ifndef ioread8 | 260 | #ifndef ioread8 |
263 | #define ioread8(p) ({ unsigned int __v = __raw_readb(p); __v; }) | 261 | #define ioread8(p) ({ unsigned int __v = __raw_readb(p); __iormb(); __v; }) |
264 | #define ioread16(p) ({ unsigned int __v = le16_to_cpu((__force __le16)__raw_readw(p)); __v; }) | 262 | #define ioread16(p) ({ unsigned int __v = le16_to_cpu((__force __le16)__raw_readw(p)); __iormb(); __v; }) |
265 | #define ioread32(p) ({ unsigned int __v = le32_to_cpu((__force __le32)__raw_readl(p)); __v; }) | 263 | #define ioread32(p) ({ unsigned int __v = le32_to_cpu((__force __le32)__raw_readl(p)); __iormb(); __v; }) |
266 | 264 | ||
267 | #define iowrite8(v,p) __raw_writeb(v, p) | 265 | #define iowrite8(v,p) ({ __iowmb(); (void)__raw_writeb(v, p); }) |
268 | #define iowrite16(v,p) __raw_writew((__force __u16)cpu_to_le16(v), p) | 266 | #define iowrite16(v,p) ({ __iowmb(); (void)__raw_writew((__force __u16)cpu_to_le16(v), p); }) |
269 | #define iowrite32(v,p) __raw_writel((__force __u32)cpu_to_le32(v), p) | 267 | #define iowrite32(v,p) ({ __iowmb(); (void)__raw_writel((__force __u32)cpu_to_le32(v), p); }) |
270 | 268 | ||
271 | #define ioread8_rep(p,d,c) __raw_readsb(p,d,c) | 269 | #define ioread8_rep(p,d,c) __raw_readsb(p,d,c) |
272 | #define ioread16_rep(p,d,c) __raw_readsw(p,d,c) | 270 | #define ioread16_rep(p,d,c) __raw_readsw(p,d,c) |