Skip to content

Commit

Permalink
Prevent compiler from optimizing mmio_read64 to single 64b read
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Judge authored and keithbusch committed Jun 18, 2020
1 parent b918bc7 commit 33e60ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nvme-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 33e60ff

Please sign in to comment.