Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1396714

[PATCH 4.4 46/67] ARC: Add missing io barriers to io{read,write}{16,32}be()

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 46/67] ARC: Add missing io barriers to io{read,write}{16,32}be()
Date 2016-05-09 09:30 +0200
Message-ID <rwNNI-7J-101@gated-at.bofh.it> (permalink)
References <rwNDY-8jo-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Vineet Gupta <vgupta@synopsys.com>

commit e5bc0478ab6cf565619224536d75ecb2aedca43b upstream.

While reviewing a different change to asm-generic/io.h Arnd spotted that
ARC ioread32 and ioread32be both of which come from asm-generic versions
are not symmetrical in terms of calling the io barriers.

generic ioread32   -> ARC readl()                  [ has barriers]
generic ioread32be -> __be32_to_cpu(__raw_readl()) [ lacks barriers]

While generic ioread32be is being remediated to call readl(), that involves
a swab32(), causing double swaps on ioread32be() on Big Endian systems.

So provide our versions of big endian IO accessors to ensure io barrier
calls while also keeping them optimal

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/arc/include/asm/io.h |   27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

--- a/arch/arc/include/asm/io.h
+++ b/arch/arc/include/asm/io.h
@@ -13,6 +13,15 @@
 #include <asm/byteorder.h>
 #include <asm/page.h>
 
+#ifdef CONFIG_ISA_ARCV2
+#include <asm/barrier.h>
+#define __iormb()		rmb()
+#define __iowmb()		wmb()
+#else
+#define __iormb()		do { } while (0)
+#define __iowmb()		do { } while (0)
+#endif
+
 extern void __iomem *ioremap(unsigned long physaddr, unsigned long size);
 extern void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
 				  unsigned long flags);
@@ -22,6 +31,15 @@ extern void iounmap(const void __iomem *
 #define ioremap_wc(phy, sz)		ioremap(phy, sz)
 #define ioremap_wt(phy, sz)		ioremap(phy, sz)
 
+/*
+ * io{read,write}{16,32}be() macros
+ */
+#define ioread16be(p)		({ u16 __v = be16_to_cpu((__force __be16)__raw_readw(p)); __iormb(); __v; })
+#define ioread32be(p)		({ u32 __v = be32_to_cpu((__force __be32)__raw_readl(p)); __iormb(); __v; })
+
+#define iowrite16be(v,p)	({ __iowmb(); __raw_writew((__force u16)cpu_to_be16(v), p); })
+#define iowrite32be(v,p)	({ __iowmb(); __raw_writel((__force u32)cpu_to_be32(v), p); })
+
 /* Change struct page to physical address */
 #define page_to_phys(page)		(page_to_pfn(page) << PAGE_SHIFT)
 
@@ -99,15 +117,6 @@ static inline void __raw_writel(u32 w, v
 
 }
 
-#ifdef CONFIG_ISA_ARCV2
-#include <asm/barrier.h>
-#define __iormb()		rmb()
-#define __iowmb()		wmb()
-#else
-#define __iormb()		do { } while (0)
-#define __iowmb()		do { } while (0)
-#endif
-
 /*
  * MMIO can also get buffered/optimized in micro-arch, so barriers needed
  * Based on ARM model for the typical use case

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 00/67] 4.4.10-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:30 +0200
  [PATCH 4.4 36/67] batman-adv: fix DAT candidate selection (must use vid) Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:30 +0200
  [PATCH 4.4 67/67] drm/i915/skl: Fix DMC load on Skylake J0 and K0 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:30 +0200
  [PATCH 4.4 30/67] xen/evtchn: fix ring resize when binding new events Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:30 +0200
  [PATCH 4.4 41/67] MAINTAINERS: Remove asterisk from EFI directory names Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:30 +0200
  [PATCH 4.4 26/67] ARM: EXYNOS: Properly skip unitialized parent clock in power domain on Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:30 +0200
  [PATCH 4.4 46/67] ARC: Add missing io barriers to io{read,write}{16,32}be() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:30 +0200
  [PATCH 4.4 05/67] ipvs: drop first packet to redirect conntrack Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 09/67] mwifiex: fix corner case association failure Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 20/67] mac80211: fix statistics leak if dev_alloc_name() fails Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 22/67] MD: make bio mergeable Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 44/67] propogate_mnt: Handle the first propogated copy being a slave Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 08/67] ata: ahci_xgene: dereferencing uninitialized pointer in probe Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 06/67] mfd: intel-lpss: Remove clock tree on error path Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 07/67] nbd: ratelimit error msgs after socket close Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 23/67] Minimal fix-up of bad hashing behavior of hash_64() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 29/67] xen/balloon: Fix crash when ballooning on x86 32 bit PAE Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 27/67] ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 25/67] mm/zswap: provide unique zpool name Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 42/67] x86/tsc: Read all ratio bits from MSR_PLATFORM_INFO Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 40/67] writeback: Fix performance regression in wb_over_bg_thresh() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 09:40 +0200
  [PATCH 4.4 12/67] soc: rockchip: power-domain: fix err handle while probing Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 10:00 +0200
  [PATCH 4.4 17/67] clk: qcom: msm8960: Fix ce3_src register offset Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 10:00 +0200
  [PATCH 4.4 15/67] clk: qcom: msm8960: fix ce3_core clk enable register Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 10:00 +0200
  Re: [PATCH 4.4 00/67] 4.4.10-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-05-09 10:10 +0200
  Re: [PATCH 4.4 00/67] 4.4.10-stable review Guenter Roeck <linux@roeck-us.net> - 2016-05-09 15:20 +0200
  Re: [PATCH 4.4 00/67] 4.4.10-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2016-05-09 21:50 +0200

csiph-web