Commit 50f33737 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] add readX_relaxed() interface

From: jbarnes@sgi.com (Jesse Barnes)

Here's the patch to add the new _relaxed variants for PIO read accesses.
It's been ack'd by gregkh and Grant Grundler, and I think it's ready to
go.

PCI ordering rules also guarantee that PIO read responses arrive after any
outstanding DMA writes on that bus, since for some devices the result of a
readb() call may signal to the driver that a DMA transaction is complete.  In
many cases, however, the driver may want to indicate that the next readb()
call has no relation to any previous DMA writes performed by the device.  The
driver can use the readb_relaxed() for these cases, although only some
platforms will honor the relaxed semantics.
parent 9829f0a5
......@@ -126,7 +126,9 @@
<para>
The functions are named <function>readb</function>,
<function>readw</function>, <function>readl</function>,
<function>readq</function>, <function>writeb</function>,
<function>readq</function>, <function>readb_relaxed</function>,
<function>readw_relaxed</function>, <function>readl_relaxed</function>,
<function>readq_relaxed</function>, <function>writeb</function>,
<function>writew</function>, <function>writel</function> and
<function>writeq</function>.
</para>
......@@ -159,6 +161,18 @@
author cares. This kind of property cannot be hidden from driver
writers in the API.
</para>
<para>
PCI ordering rules also guarantee that PIO read responses arrive
after any outstanding DMA writes on that bus, since for some devices
the result of a <function>readb</function> call may signal to the
driver that a DMA transaction is complete. In many cases, however,
the driver may want to indicate that the next
<function>readb</function> call has no relation to any previous DMA
writes performed by the device. The driver can use
<function>readb_relaxed</function> for these cases, although only
some platforms will honor the relaxed semantics.
</para>
</sect1>
<sect1>
......
......@@ -23,6 +23,10 @@
#undef __sn_readw
#undef __sn_readl
#undef __sn_readq
#undef __sn_readb_relaxed
#undef __sn_readw_relaxed
#undef __sn_readl_relaxed
#undef __sn_readq_relaxed
unsigned int
__sn_inb (unsigned long port)
......@@ -84,4 +88,28 @@ __sn_readq (void *addr)
return ___sn_readq (addr);
}
unsigned char
__sn_readb_relaxed (void *addr)
{
return ___sn_readb_relaxed (addr);
}
unsigned short
__sn_readw_relaxed (void *addr)
{
return ___sn_readw_relaxed (addr);
}
unsigned int
__sn_readl_relaxed (void *addr)
{
return ___sn_readl_relaxed (addr);
}
unsigned long
__sn_readq_relaxed (void *addr)
{
return ___sn_readq_relaxed (addr);
}
#endif
......@@ -412,6 +412,11 @@ extern void ___raw_writeq(u64 b, unsigned long addr);
# define readq(a) _readq((unsigned long)(a))
#endif
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define readq_relaxed(addr) readq(addr)
#ifndef writeb
# define writeb(v,a) _writeb((v),(unsigned long)(a))
#endif
......
......@@ -38,6 +38,9 @@ u32 __readl(void *addr);
#define readb(b) __readb(b)
#define readw(b) __readw(b)
#define readl(b) __readl(b)
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
void __writeb(u8 val, void *addr);
void __writew(u16 val, void *addr);
......
......@@ -149,6 +149,9 @@ extern void _memset_io(unsigned long, int, size_t);
#define readb(c) ({ unsigned int __v = __raw_readb(__mem_pci(c)); __v; })
#define readw(c) ({ unsigned int __v = le16_to_cpu(__raw_readw(__mem_pci(c))); __v; })
#define readl(c) ({ unsigned int __v = le32_to_cpu(__raw_readl(__mem_pci(c))); __v; })
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define readsb(p,d,l) __raw_readsb((unsigned int)__mem_pci(p),d,l)
#define readsw(p,d,l) __raw_readsw((unsigned int)__mem_pci(p),d,l)
......
......@@ -308,6 +308,9 @@ DECLARE_IO(int,l,"")
#define readb(c) (__readwrite_bug("readb"),0)
#define readw(c) (__readwrite_bug("readw"),0)
#define readl(c) (__readwrite_bug("readl"),0)
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define writeb(v,c) __readwrite_bug("writeb")
#define writew(v,c) __readwrite_bug("writew")
#define writel(v,c) __readwrite_bug("writel")
......
......@@ -42,6 +42,9 @@ extern void iounmap(void *addr);
#define readb(addr) (*(volatile unsigned char *) (addr))
#define readw(addr) (*(volatile unsigned short *) (addr))
#define readl(addr) (*(volatile unsigned int *) (addr))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define __raw_readb readb
#define __raw_readw readw
#define __raw_readl readl
......
......@@ -47,6 +47,10 @@ static inline unsigned int _swapl(volatile unsigned long v)
#define readl(addr) \
({ unsigned int __v = (*(volatile unsigned int *) (addr & 0x00ffffff)); __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 & 0x00ffffff)) = (b))
#define writew(b,addr) (void)((*(volatile unsigned short *) (addr & 0x00ffffff)) = (b))
#define writel(b,addr) (void)((*(volatile unsigned int *) (addr & 0x00ffffff)) = (b))
......
......@@ -153,6 +153,9 @@ extern void bt_iounmap(void *addr, unsigned long size);
#define readb(addr) (*(volatile unsigned char *) __io_virt(addr))
#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define __raw_readb readb
#define __raw_readw readw
#define __raw_readl readl
......
......@@ -125,6 +125,10 @@ __ia64_mk_io_addr (unsigned long port)
#define __ia64_readw ___ia64_readw
#define __ia64_readl ___ia64_readl
#define __ia64_readq ___ia64_readq
#define __ia64_readb_relaxed ___ia64_readb
#define __ia64_readw_relaxed ___ia64_readw
#define __ia64_readl_relaxed ___ia64_readl
#define __ia64_readq_relaxed ___ia64_readq
#define __ia64_writeb ___ia64_writeb
#define __ia64_writew ___ia64_writew
#define __ia64_writel ___ia64_writel
......@@ -337,15 +341,27 @@ __writeq (unsigned long val, void *addr)
#define __readw platform_readw
#define __readl platform_readl
#define __readq platform_readq
#define __readb_relaxed platform_readb_relaxed
#define __readw_relaxed platform_readw_relaxed
#define __readl_relaxed platform_readl_relaxed
#define __readq_relaxed platform_readq_relaxed
#define readb(a) __readb((void *)(a))
#define readw(a) __readw((void *)(a))
#define readl(a) __readl((void *)(a))
#define readq(a) __readq((void *)(a))
#define readb_relaxed(a) __readb_relaxed((void *)(a))
#define readw_relaxed(a) __readw_relaxed((void *)(a))
#define readl_relaxed(a) __readl_relaxed((void *)(a))
#define readq_relaxed(a) __readq_relaxed((void *)(a))
#define __raw_readb readb
#define __raw_readw readw
#define __raw_readl readl
#define __raw_readq readq
#define __raw_readb_relaxed readb_relaxed
#define __raw_readw_relaxed readw_relaxed
#define __raw_readl_relaxed readl_relaxed
#define __raw_readq_relaxed readq_relaxed
#define writeb(v,a) __writeb((v), (void *) (a))
#define writew(v,a) __writew((v), (void *) (a))
#define writel(v,a) __writel((v), (void *) (a))
......
......@@ -65,6 +65,10 @@ typedef unsigned char ia64_mv_readb_t (void *);
typedef unsigned short ia64_mv_readw_t (void *);
typedef unsigned int ia64_mv_readl_t (void *);
typedef unsigned long ia64_mv_readq_t (void *);
typedef unsigned char ia64_mv_readb_relaxed_t (void *);
typedef unsigned short ia64_mv_readw_relaxed_t (void *);
typedef unsigned int ia64_mv_readl_relaxed_t (void *);
typedef unsigned long ia64_mv_readq_relaxed_t (void *);
extern void machvec_noop (void);
extern void machvec_memory_fence (void);
......@@ -116,6 +120,10 @@ extern void machvec_memory_fence (void);
# define platform_readw ia64_mv.readw
# define platform_readl ia64_mv.readl
# define platform_readq ia64_mv.readq
# define platform_readb_relaxed ia64_mv.readb_relaxed
# define platform_readw_relaxed ia64_mv.readw_relaxed
# define platform_readl_relaxed ia64_mv.readl_relaxed
# define platform_readq_relaxed ia64_mv.readq_relaxed
# endif
/* __attribute__((__aligned__(16))) is required to make size of the
......@@ -158,6 +166,10 @@ struct ia64_machine_vector {
ia64_mv_readw_t *readw;
ia64_mv_readl_t *readl;
ia64_mv_readq_t *readq;
ia64_mv_readb_relaxed_t *readb_relaxed;
ia64_mv_readw_relaxed_t *readw_relaxed;
ia64_mv_readl_relaxed_t *readl_relaxed;
ia64_mv_readq_relaxed_t *readq_relaxed;
} __attribute__((__aligned__(16))); /* align attrib? see above comment */
#define MACHVEC_INIT(name) \
......@@ -196,6 +208,10 @@ struct ia64_machine_vector {
platform_readw, \
platform_readl, \
platform_readq, \
platform_readb_relaxed, \
platform_readw_relaxed, \
platform_readl_relaxed, \
platform_readq_relaxed, \
}
extern struct ia64_machine_vector ia64_mv;
......@@ -322,5 +338,17 @@ extern ia64_mv_dma_supported swiotlb_dma_supported;
#ifndef platform_readq
# define platform_readq __ia64_readq
#endif
#ifndef platform_readb_relaxed
# define platform_readb_relaxed __ia64_readb_relaxed
#endif
#ifndef platform_readw_relaxed
# define platform_readw_relaxed __ia64_readw_relaxed
#endif
#ifndef platform_readl_relaxed
# define platform_readl_relaxed __ia64_readl_relaxed
#endif
#ifndef platform_readq_relaxed
# define platform_readq_relaxed __ia64_readq_relaxed
#endif
#endif /* _ASM_IA64_MACHVEC_H */
......@@ -52,6 +52,10 @@ extern ia64_mv_readb_t __sn_readb;
extern ia64_mv_readw_t __sn_readw;
extern ia64_mv_readl_t __sn_readl;
extern ia64_mv_readq_t __sn_readq;
extern ia64_mv_readb_t __sn_readb_relaxed;
extern ia64_mv_readw_t __sn_readw_relaxed;
extern ia64_mv_readl_t __sn_readl_relaxed;
extern ia64_mv_readq_t __sn_readq_relaxed;
extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent;
extern ia64_mv_dma_free_coherent sn_dma_free_coherent;
extern ia64_mv_dma_map_single sn_dma_map_single;
......@@ -87,6 +91,10 @@ extern ia64_mv_dma_supported sn_dma_supported;
#define platform_readw __sn_readw
#define platform_readl __sn_readl
#define platform_readq __sn_readq
#define platform_readb_relaxed __sn_readb_relaxed
#define platform_readw_relaxed __sn_readw_relaxed
#define platform_readl_relaxed __sn_readl_relaxed
#define platform_readq_relaxed __sn_readq_relaxed
#define platform_irq_desc sn_irq_desc
#define platform_irq_to_vector sn_irq_to_vector
#define platform_local_vector_to_irq sn_local_vector_to_irq
......
......@@ -27,6 +27,10 @@ extern void sn_dma_flush(unsigned long);
#define __sn_readw ___sn_readw
#define __sn_readl ___sn_readl
#define __sn_readq ___sn_readq
#define __sn_readb_relaxed ___sn_readb_relaxed
#define __sn_readw_relaxed ___sn_readw_relaxed
#define __sn_readl_relaxed ___sn_readl_relaxed
#define __sn_readq_relaxed ___sn_readq_relaxed
/*
* The following routines are SN Platform specific, called when
......@@ -208,25 +212,25 @@ sn_inl_fast (unsigned long port)
}
static inline unsigned char
sn_readb_fast (void *addr)
___sn_readb_relaxed (void *addr)
{
return *(volatile unsigned char *)addr;
}
static inline unsigned short
sn_readw_fast (void *addr)
___sn_readw_relaxed (void *addr)
{
return *(volatile unsigned short *)addr;
}
static inline unsigned int
sn_readl_fast (void *addr)
___sn_readl_relaxed (void *addr)
{
return *(volatile unsigned int *) addr;
}
static inline unsigned long
sn_readq_fast (void *addr)
___sn_readq_relaxed (void *addr)
{
return *(volatile unsigned long *) addr;
}
......
......@@ -261,6 +261,10 @@ static inline void isa_delay(void)
#define writeb(val,addr) out_8((addr),(val))
#define writew(val,addr) out_le16((addr),(val))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#ifndef CONFIG_ISA
#define inb(port) in_8(port)
#define outb(val,port) out_8((port),(val))
......
......@@ -39,6 +39,10 @@ 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))
......
......@@ -264,6 +264,10 @@ extern void iounmap(void *addr);
#define readw(addr) __ioswab16(__raw_readw(addr))
#define readl(addr) __ioswab32(__raw_readl(addr))
#define readq(addr) __ioswab64(__raw_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 __raw_writeb(b,addr) ((*(volatile unsigned char *)(addr)) = (b))
#define __raw_writew(w,addr) ((*(volatile unsigned short *)(addr)) = (w))
......
......@@ -171,6 +171,11 @@ extern __inline__ void ___raw_writeq(unsigned long long val, unsigned long addr)
#define writeq(b,addr) __raw_writeq(cpu_to_le64(b),addr)
#endif /* !USE_HPPA_IOREMAP */
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define readq_relaxed(addr) readq(addr)
extern void __memcpy_fromio(unsigned long dest, unsigned long src, int count);
extern void __memcpy_toio(unsigned long dest, unsigned long src, int count);
extern void __memset_io(unsigned long dest, char fill, int count);
......
......@@ -58,6 +58,9 @@ extern unsigned long pci_dram_offset;
#define writel(b,addr) out_le32((volatile u32 *)(addr),(b))
#endif /* CONFIG_APUS */
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define __raw_readb(addr) (*(volatile unsigned char *)(addr))
#define __raw_readw(addr) (*(volatile unsigned short *)(addr))
......
......@@ -79,6 +79,10 @@ extern unsigned long pci_io_base;
#define outsl(port, buf, nl) _outsl_ns((u32 *)((port)+pci_io_base), (buf), (nl))
#endif
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
extern void _insb(volatile u8 *port, void *buf, int ns);
extern void _outsb(volatile u8 *port, const void *buf, int ns);
extern void _insw(volatile u16 *port, void *buf, int ns);
......
......@@ -87,6 +87,10 @@ extern void iounmap(void *addr);
#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define writeb(b,addr) (*(volatile unsigned char *) __io_virt(addr) = (b))
#define writew(b,addr) (*(volatile unsigned short *) __io_virt(addr) = (b))
#define writel(b,addr) (*(volatile unsigned int *) __io_virt(addr) = (b))
......
......@@ -130,6 +130,10 @@
# define writel(v,a) ({ __raw_writel((v),(unsigned long)(a)); mb(); })
#endif
#define readb_relaxed(a) readb(a)
#define readw_relaxed(a) readw(a)
#define readl_relaxed(a) readl(a)
/*
* If the platform has PC-like I/O, this function converts the offset into
* an address.
......
......@@ -99,6 +99,9 @@ static inline void __writel(u32 b, unsigned long addr)
#define readb(addr) __readb((unsigned long)(addr))
#define readw(addr) __readw((unsigned long)(addr))
#define readl(addr) __readl((unsigned long)(addr))
#define readb_relaxed(addr) readb(addr)
#define readw_relaxed(addr) readw(addr)
#define readl_relaxed(addr) readl(addr)
#define writeb(b, addr) __writeb((b),(unsigned long)(addr))
#define writew(b, addr) __writew((b),(unsigned long)(addr))
......
......@@ -176,6 +176,10 @@ static __inline__ void _writeq(u64 q, unsigned long addr)
#define readw(__addr) (_readw((unsigned long)(__addr)))
#define readl(__addr) (_readl((unsigned long)(__addr)))
#define readq(__addr) (_readq((unsigned long)(__addr)))
#define readb_relaxed(a) readb(a)
#define readw_relaxed(a) readw(a)
#define readl_relaxed(a) readl(a)
#define readq_relaxed(a) readq(a)
#define writeb(__b, __addr) (_writeb((u8)(__b), (unsigned long)(__addr)))
#define writew(__w, __addr) (_writew((u16)(__w), (unsigned long)(__addr)))
#define writel(__l, __addr) (_writel((u32)(__l), (unsigned long)(__addr)))
......
......@@ -23,6 +23,10 @@
#define readl(addr) \
({ unsigned long __v = (*(volatile unsigned long *) (addr)); __v; })
#define readb_relaxed(a) readb(a)
#define readw_relaxed(a) readw(a)
#define readl_relaxed(a) readl(a)
#define writeb(b, addr) \
(void)((*(volatile unsigned char *) (addr)) = (b))
#define writew(b, addr) \
......
......@@ -188,6 +188,10 @@ extern void iounmap(void *addr);
#define readw(addr) (*(volatile unsigned short *) __io_virt(addr))
#define readl(addr) (*(volatile unsigned int *) __io_virt(addr))
#define readq(addr) (*(volatile unsigned long *) __io_virt(addr))
#define readb_relaxed(a) readb(a)
#define readw_relaxed(a) readw(a)
#define readl_relaxed(a) readl(a)
#define readq_relaxed(a) readq(a)
#define __raw_readb readb
#define __raw_readw readw
#define __raw_readl readl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment