Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iomap: Use non-raw io functions for io{read|write}XXbe

Fix an asymmetry in the io{read|write}XXbe functions in that the
big-endian variants make use of the raw io accessors while the
little-endian variants use the regular accessors. Some architectures
implement barriers to order against both spinlocks and DMA accesses
and for these case, the big-endian variant of the API would not be
protected.

Thus, change the mmio_XXXXbe macros to use the appropriate swab() function
wrapping the regular accessor. This is similar to what was done for PIO.

When this code was originally written, barriers in the IO accessors were
not common and the accessors simply wrapped the raw functions in a
conversion to CPU endianness. Since then, barriers have been added in
some architectures and are now missing in the big endian variant of the
API.

This also manages to silence a few sparse warnings that check
for using the correct endian types which the original code did
not annotate correctly.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Link: http://lkml.kernel.org/r/CAK8P3a25zQDxyaY3iVv+JmSSzs7F6ssGc+HdBkGs54ZfViX+Fg@mail.gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Logan Gunthorpe and committed by
Greg Kroah-Hartman
aecc787c dce6d406

+4 -4
+4 -4
lib/iomap.c
··· 65 65 #endif 66 66 67 67 #ifndef mmio_read16be 68 - #define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr)) 69 - #define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr)) 68 + #define mmio_read16be(addr) swab16(readw(addr)) 69 + #define mmio_read32be(addr) swab32(readl(addr)) 70 70 #endif 71 71 72 72 unsigned int ioread8(void __iomem *addr) ··· 106 106 #endif 107 107 108 108 #ifndef mmio_write16be 109 - #define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port) 110 - #define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port) 109 + #define mmio_write16be(val,port) writew(swab16(val),port) 110 + #define mmio_write32be(val,port) writel(swab32(val),port) 111 111 #endif 112 112 113 113 void iowrite8(u8 val, void __iomem *addr)