Skip to content

Commit

Permalink
Merge branch 'io' of git://git.kernel.org/pub/scm/linux/kernel/git/wi…
Browse files Browse the repository at this point in the history
…ll/linux into asm-generic

* 'io' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux:
  documentation: memory-barriers: clarify relaxed io accessor semantics
  x86: io: implement dummy relaxed accessor macros for writes
  tile: io: implement dummy relaxed accessor macros for writes
  sparc: io: implement dummy relaxed accessor macros for writes
  powerpc: io: implement dummy relaxed accessor macros for writes
  parisc: io: implement dummy relaxed accessor macros for writes
  mn10300: io: implement dummy relaxed accessor macros for writes
  m68k: io: implement dummy relaxed accessor macros for writes
  m32r: io: implement dummy relaxed accessor macros for writes
  ia64: io: implement dummy relaxed accessor macros for writes
  cris: io: implement dummy relaxed accessor macros for writes
  frv: io: implement dummy relaxed accessor macros for writes
  xtensa: io: remove dummy relaxed accessor macros for reads
  s390: io: remove dummy relaxed accessor macros for reads
  microblaze: io: remove dummy relaxed accessor macros
  asm-generic: io: implement relaxed accessor macros as conditional wrappers

Conflicts:
	include/asm-generic/io.h

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  • Loading branch information
Arnd Bergmann committed Nov 11, 2014
2 parents 3ba5acf + a8e0aea commit 1c8d296
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 46 deletions.
13 changes: 9 additions & 4 deletions Documentation/memory-barriers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2465,10 +2465,15 @@ functions:
Please refer to the PCI specification for more information on interactions
between PCI transactions.

(*) readX_relaxed()

These are similar to readX(), but are not guaranteed to be ordered in any
way. Be aware that there is no I/O read barrier available.
(*) readX_relaxed(), writeX_relaxed()

These are similar to readX() and writeX(), but provide weaker memory
ordering guarantees. Specifically, they do not guarantee ordering with
respect to normal memory accesses (e.g. DMA buffers) nor do they guarantee
ordering with respect to LOCK or UNLOCK operations. If the latter is
required, an mmiowb() barrier can be used. Note that relaxed accesses to
the same peripheral are guaranteed to be ordered with respect to each
other.

(*) ioreadX(), iowriteX()

Expand Down
3 changes: 3 additions & 0 deletions arch/cris/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ static inline void writel(unsigned int b, volatile void __iomem *addr)
else
*(volatile unsigned int __force *) addr = b;
}
#define writeb_relaxed(b, addr) writeb(b, addr)
#define writew_relaxed(b, addr) writew(b, addr)
#define writel_relaxed(b, addr) writel(b, addr)
#define __raw_writeb writeb
#define __raw_writew writew
#define __raw_writel writel
Expand Down
3 changes: 3 additions & 0 deletions arch/frv/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ static inline void writel(uint32_t datum, volatile void __iomem *addr)
__flush_PCI_writes();
}

#define writeb_relaxed writeb
#define writew_relaxed writew
#define writel_relaxed writel

/* Values for nocacheflag and cmode */
#define IOMAP_FULL_CACHING 0
Expand Down
4 changes: 4 additions & 0 deletions arch/ia64/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ __writeq (unsigned long val, volatile void __iomem *addr)
#define writew(v,a) __writew((v), (a))
#define writel(v,a) __writel((v), (a))
#define writeq(v,a) __writeq((v), (a))
#define writeb_relaxed(v,a) __writeb((v), (a))
#define writew_relaxed(v,a) __writew((v), (a))
#define writel_relaxed(v,a) __writel((v), (a))
#define writeq_relaxed(v,a) __writeq((v), (a))
#define __raw_writeb writeb
#define __raw_writew writew
#define __raw_writel writel
Expand Down
3 changes: 3 additions & 0 deletions arch/m32r/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ static inline void _writel(unsigned long l, unsigned long addr)
#define __raw_writeb writeb
#define __raw_writew writew
#define __raw_writel writel
#define writeb_relaxed writeb
#define writew_relaxed writew
#define writel_relaxed writel

#define ioread8 read
#define ioread16 readw
Expand Down
8 changes: 8 additions & 0 deletions arch/m68k/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
#else
#include <asm/io_mm.h>
#endif

#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)

#define writeb_relaxed(b, addr) writeb(b, addr)
#define writew_relaxed(b, addr) writew(b, addr)
#define writel_relaxed(b, addr) writel(b, addr)
4 changes: 0 additions & 4 deletions arch/m68k/include/asm/io_no.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ static inline unsigned int _swapl(volatile unsigned long v)
#define readl(addr) \
({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; })

#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)

#define writeb(b,addr) (void)((*(volatile unsigned char *) (addr)) = (b))
#define writew(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b))
#define writel(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b))
Expand Down
8 changes: 0 additions & 8 deletions arch/microblaze/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,4 @@ extern void __iomem *ioremap(phys_addr_t address, unsigned long size);

#include <asm-generic/io.h>

#define readb_relaxed readb
#define readw_relaxed readw
#define readl_relaxed readl

#define writeb_relaxed writeb
#define writew_relaxed writew
#define writel_relaxed writel

#endif /* _ASM_MICROBLAZE_IO_H */
4 changes: 4 additions & 0 deletions arch/mn10300/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ static inline void writel(u32 b, volatile void __iomem *addr)
#define __raw_writew writew
#define __raw_writel writel

#define writeb_relaxed writeb
#define writew_relaxed writew
#define writel_relaxed writel

/*****************************************************************************/
/*
* traditional input/output functions
Expand Down
12 changes: 8 additions & 4 deletions arch/parisc/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,14 @@ static inline void writeq(unsigned long long q, volatile void __iomem *addr)
#define writel writel
#define writeq writeq

#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define readq_relaxed(addr) readq(addr)
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define readq_relaxed(addr) readq(addr)
#define writeb_relaxed(b, addr) writeb(b, addr)
#define writew_relaxed(w, addr) writew(w, addr)
#define writel_relaxed(l, addr) writel(l, addr)
#define writeq_relaxed(q, addr) writeq(q, addr)

#define mmiowb() do { } while (0)

Expand Down
12 changes: 8 additions & 4 deletions arch/powerpc/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,14 @@ static inline void name at \
/*
* We don't do relaxed operations yet, at least not with this semantic
*/
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define readq_relaxed(addr) readq(addr)
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define readq_relaxed(addr) readq(addr)
#define writeb_relaxed(v, addr) writeb(v, addr)
#define writew_relaxed(v, addr) writew(v, addr)
#define writel_relaxed(v, addr) writel(v, addr)
#define writeq_relaxed(v, addr) writeq(v, addr)

#ifdef CONFIG_PPC32
#define mmiowb()
Expand Down
5 changes: 0 additions & 5 deletions arch/s390/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ static inline void iounmap(volatile void __iomem *addr)
#define __raw_writel zpci_write_u32
#define __raw_writeq zpci_write_u64

#define readb_relaxed readb
#define readw_relaxed readw
#define readl_relaxed readl
#define readq_relaxed readq

#endif /* CONFIG_PCI */

#include <asm-generic/io.h>
Expand Down
9 changes: 9 additions & 0 deletions arch/sparc/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
* Defines used for both SPARC32 and SPARC64
*/

/* Relaxed accessors for MMIO */
#define readb_relaxed(__addr) readb(__addr)
#define readw_relaxed(__addr) readw(__addr)
#define readl_relaxed(__addr) readl(__addr)

#define writeb_relaxed(__b, __addr) writeb(__b, __addr)
#define writew_relaxed(__w, __addr) writew(__w, __addr)
#define writel_relaxed(__l, __addr) writel(__l, __addr)

/* Big endian versions of memory read/write routines */
#define readb_be(__addr) __raw_readb(__addr)
#define readw_be(__addr) __raw_readw(__addr)
Expand Down
4 changes: 0 additions & 4 deletions arch/sparc/include/asm/io_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#include <linux/kernel.h>
#include <linux/ioport.h> /* struct resource */

#define readb_relaxed(__addr) readb(__addr)
#define readw_relaxed(__addr) readw(__addr)
#define readl_relaxed(__addr) readl(__addr)

#define IO_SPACE_LIMIT 0xffffffff

#define memset_io(d,c,sz) _memset_io(d,c,sz)
Expand Down
8 changes: 2 additions & 6 deletions arch/sparc/include/asm/io_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static inline u32 readl(const volatile void __iomem *addr)
}

#define readq readq
#define readq_relaxed readq
static inline u64 readq(const volatile void __iomem *addr)
{ u64 ret;

Expand Down Expand Up @@ -175,6 +176,7 @@ static inline void writel(u32 l, volatile void __iomem *addr)
}

#define writeq writeq
#define writeq_relaxed writeq
static inline void writeq(u64 q, volatile void __iomem *addr)
{
__asm__ __volatile__("stxa\t%r0, [%1] %2\t/* pci_writeq */"
Expand All @@ -183,7 +185,6 @@ static inline void writeq(u64 q, volatile void __iomem *addr)
: "memory");
}


#define inb inb
static inline u8 inb(unsigned long addr)
{
Expand Down Expand Up @@ -264,11 +265,6 @@ static inline void iowrite32_rep(void __iomem *port, const void *buf, unsigned l
outsl((unsigned long __force)port, buf, count);
}

#define readb_relaxed(__addr) readb(__addr)
#define readw_relaxed(__addr) readw(__addr)
#define readl_relaxed(__addr) readl(__addr)
#define readq_relaxed(__addr) readq(__addr)

/* Valid I/O Space regions are anywhere, because each PCI bus supported
* can live in an arbitrary area of the physical address range.
*/
Expand Down
4 changes: 4 additions & 0 deletions arch/tile/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ static inline void writeq(u64 val, unsigned long addr)
#define readw_relaxed readw
#define readl_relaxed readl
#define readq_relaxed readq
#define writeb_relaxed writeb
#define writew_relaxed writew
#define writel_relaxed writel
#define writeq_relaxed writeq

#define ioread8 readb
#define ioread16 readw
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ build_mmio_write(__writel, "l", unsigned int, "r", )
#define __raw_readw __readw
#define __raw_readl __readl

#define writeb_relaxed(v, a) __writeb(v, a)
#define writew_relaxed(v, a) __writew(v, a)
#define writel_relaxed(v, a) __writel(v, a)
#define __raw_writeb __writeb
#define __raw_writew __writew
#define __raw_writel __writel
Expand All @@ -86,6 +89,7 @@ build_mmio_read(readq, "q", unsigned long, "=r", :"memory")
build_mmio_write(writeq, "q", unsigned long, "r", :"memory")

#define readq_relaxed(a) readq(a)
#define writeq_relaxed(v, a) writeq(v, a)

#define __raw_readq(a) readq(a)
#define __raw_writeq(val, addr) writeq(val, addr)
Expand Down
7 changes: 0 additions & 7 deletions arch/xtensa/include/asm/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ static inline void iounmap(volatile void __iomem *addr)

#endif /* CONFIG_MMU */

/*
* Generic I/O
*/
#define readb_relaxed readb
#define readw_relaxed readw
#define readl_relaxed readl

#endif /* __KERNEL__ */

#include <asm-generic/io.h>
Expand Down
37 changes: 37 additions & 0 deletions include/asm-generic/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,43 @@ static inline void writeq(u64 value, volatile void __iomem *addr)
#endif
#endif /* CONFIG_64BIT */

/*
* {read,write}{b,w,l,q}_relaxed() are like the regular version, but
* are not guaranteed to provide ordering against spinlocks or memory
* accesses.
*/
#ifndef readb_relaxed
#define readb_relaxed readb
#endif

#ifndef readw_relaxed
#define readw_relaxed readw
#endif

#ifndef readl_relaxed
#define readl_relaxed readl
#endif

#ifndef readq_relaxed
#define readq_relaxed readq
#endif

#ifndef writeb_relaxed
#define writeb_relaxed writeb
#endif

#ifndef writew_relaxed
#define writew_relaxed writew
#endif

#ifndef writel_relaxed
#define writel_relaxed writel
#endif

#ifndef writeq_relaxed
#define writeq_relaxed writeq
#endif

/*
* {read,write}s{b,w,l,q}() repeatedly access the same memory address in
* native endianness in 8-, 16-, 32- or 64-bit chunks (@count times).
Expand Down

0 comments on commit 1c8d296

Please sign in to comment.