]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Prevent compiler from optimizing mmio_read64 to single 64b read
authorAdam Judge <ajudge@iol.unh.edu>
Tue, 9 Jun 2020 19:58:49 +0000 (15:58 -0400)
committerKeith Busch <kbusch@kernel.org>
Thu, 18 Jun 2020 16:14:55 +0000 (10:14 -0600)
nvme-print.c

index fc8f99d085a33c7cb7377333a37b7cad4575bbed..c0de9283afead194eeaf34ac83889f9ec081a63c 100644 (file)
@@ -1311,9 +1311,13 @@ static inline uint32_t mmio_read32(void *addr)
 /* Access 64-bit registers as 2 32-bit; Some devices fail 64-bit MMIO. */
 static inline __u64 mmio_read64(void *addr)
 {
-       __le32 *p = addr;
+       const volatile __u32 *p = addr;
+       __u32 low, high;
+
+       low = le32_to_cpu(*p);
+       high = le32_to_cpu(*(p + 1));
 
-       return le32_to_cpu(*p) | ((uint64_t)le32_to_cpu(*(p + 1)) << 32);
+       return ((__u64) high << 32) | low;
 }
 
 static void json_ctrl_registers(void *bar)