Skip to contentSkip to conversation

iommu/vt-d: use lo_hi_readq() / lo_hi_writeq()

PATCH In review Andy Shevchenko 1 participant 2 messages Aug 17, 2015 – Sep 17, 2015 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/vt-d: use lo_hi_readq() / lo_hi_writeq()

There is already helper functions to do 64-bit I/O on 32-bit machines or buses, thus we don't need to reinvent the wheel.

---
 include/linux/intel-iommu.h | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
include/linux/intel-iommu.h +5 -14
index a868a0f..5439ea4 100644
@@ -26,6 +26,8 @@
 #include <linux/iova.h>
 #include <linux/io.h>
 #include <linux/dma_remapping.h>
+
+#include <asm-generic/io-64-nonatomic-lo-hi.h>
 #include <asm/cacheflush.h>
 #include <asm/iommu.h>
 
@@ -59,26 +61,15 @@
 #define DMAR_IRTA_REG	0xb8    /* Interrupt remapping table addr register */
 
 #define OFFSET_STRIDE		(9)
-/*
-#define dmar_readl(dmar, reg) readl(dmar + reg)
-#define dmar_readq(dmar, reg) ({ \
-		u32 lo, hi; \
-		lo = readl(dmar + reg); \
-		hi = readl(dmar + reg + 4); \
-		(((u64) hi) << 32) + lo; })
-*/
+
 static inline u64 dmar_readq(void __iomem *addr)
 {
-	u32 lo, hi;
-	lo = readl(addr);
-	hi = readl(addr + 4);
-	return (((u64) hi) << 32) + lo;
+	return lo_hi_readq(addr);
 }
 
 static inline void dmar_writeq(void __iomem *addr, u64 val)
 {
-	writel((u32)val, addr);
-	writel((u32)(val >> 32), addr + 4);
+	lo_hi_writeq(val, addr);
 }
 
 #define DMAR_VER_MAJOR(v)		(((v) & 0xf0) >> 4)
Signature · 1 line
2.5.0

A message that is not in the archive (sent off-list or not yet received): 1439820252-109537-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]

#2 lore raw
Quoted 4 lines · Andy Shevchenko

There is already helper functions to do 64-bit I/O on 32-bit machines or buses,
thus we don't need to reinvent the wheel.

Any comment on this one?

Quoted 50 lines
---
 include/linux/intel-iommu.h | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
include/linux/intel renamed from include/linux/intel-iommu.h +0 -1
-iommu.h

index a868a0f..5439ea4 100644

include/linux/intel-iommu.h +2 -0
@@ -26,6 +26,8 @@
 #include <linux/iova.h>
 #include <linux/io.h>
 #include <linux/dma_remapping.h>
+
+#include <asm-generic/io-64-nonatomic-lo-hi.h>
 #include <asm/cacheflush.h>
 #include <asm/iommu.h>
 
@@ -59,26 +61,15 @@
 #define DMAR_IRTA_REG	0xb8    /* Interrupt remapping table addr 

register */

#define OFFSET_STRIDE (9)

include/linux/intel-iommu.h +3 -14
-/*
-#define dmar_readl(dmar, reg) readl(dmar + reg)
-#define dmar_readq(dmar, reg) ({ \
-		u32 lo, hi; \
-		lo = readl(dmar + reg); \
-		hi = readl(dmar + reg + 4); \
-		(((u64) hi) << 32) + lo; })
-*/
+
 static inline u64 dmar_readq(void __iomem *addr)
 {
-	u32 lo, hi;
-	lo = readl(addr);
-	hi = readl(addr + 4);
-	return (((u64) hi) << 32) + lo;
+	return lo_hi_readq(addr);
 }
 
 static inline void dmar_writeq(void __iomem *addr, u64 val)
 {
-	writel((u32)val, addr);
-	writel((u32)(val >> 32), addr + 4);
+	lo_hi_writeq(val, addr);
 }
 
 #define DMAR_VER_MAJOR(v)		(((v) & 0xf0) >> 4)
Signature · 2 lines
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/[email protected]>
Intel Finland Oy