[PATCH] xhci: Use readq/writeq when available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the architecture supports 64-bit MMIO accesses, use them.
Saves 320 bytes of text on my build, and probably improves
performance a fair bit.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@xxxxxxxxx>
---
 drivers/usb/host/xhci.h |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index a3be33d..714eaea 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1363,15 +1363,33 @@ static inline void xhci_writel(struct xhci_hcd *xhci,
  * writing the low dword first (ptr[0]), then the high dword (ptr[1]) second.
  * xHCI implementations that do not support 64-bit address pointers will ignore
  * the high dword, and write order is irrelevant.
+ *
+ * NB: we assume that all accesses are appropriately locked by the caller.
  */
+#ifdef readq
+static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
+		__le64 __iomem *regs)
+{
+	return readq(regs);
+}
+#else
 static inline u64 xhci_read_64(const struct xhci_hcd *xhci,
 		__le64 __iomem *regs)
 {
 	__u32 __iomem *ptr = (__u32 __iomem *) regs;
 	u64 val_lo = readl(ptr);
 	u64 val_hi = readl(ptr + 1);
-	return val_lo + (val_hi << 32);
+	return val_lo | (val_hi << 32);
+}
+#endif
+
+#ifdef writeq
+static inline void xhci_write_64(struct xhci_hcd *xhci,
+				 const u64 val, __le64 __iomem *regs)
+{
+	writeq(val, regs);
 }
+#else
 static inline void xhci_write_64(struct xhci_hcd *xhci,
 				 const u64 val, __le64 __iomem *regs)
 {
@@ -1382,6 +1400,7 @@ static inline void xhci_write_64(struct xhci_hcd *xhci,
 	writel(val_lo, ptr);
 	writel(val_hi, ptr + 1);
 }
+#endif
 
 static inline int xhci_link_trb_quirk(struct xhci_hcd *xhci)
 {
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux