Commit 0a6d80c7 authored by Suravee Suthikulpanit's avatar Suravee Suthikulpanit Committed by Ingo Molnar

drivers/iommu/amd: Clean up iommu_pc_get_set_reg()

Clean up coding style and fix a bug in the 64-bit register read logic
since it overwrites the upper 32-bit when reading the lower 32-bit.
Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Jörg Rödel <joro@8bytes.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: iommu@lists.linux-foundation.org
Link: http://lkml.kernel.org/r/1487926102-13073-5-git-send-email-Suravee.Suthikulpanit@amd.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent dc6ca5e4
...@@ -2763,22 +2763,25 @@ static int iommu_pc_get_set_reg_val(struct amd_iommu *iommu, ...@@ -2763,22 +2763,25 @@ static int iommu_pc_get_set_reg_val(struct amd_iommu *iommu,
if (WARN_ON((fxn > 0x28) || (fxn & 7))) if (WARN_ON((fxn > 0x28) || (fxn & 7)))
return -ENODEV; return -ENODEV;
offset = (u32)(((0x40|bank) << 12) | (cntr << 8) | fxn); offset = (u32)(((0x40 | bank) << 12) | (cntr << 8) | fxn);
/* Limit the offset to the hw defined mmio region aperture */ /* Limit the offset to the hw defined mmio region aperture */
max_offset_lim = (u32)(((0x40|iommu->max_banks) << 12) | max_offset_lim = (u32)(((0x40 | iommu->max_banks) << 12) |
(iommu->max_counters << 8) | 0x28); (iommu->max_counters << 8) | 0x28);
if ((offset < MMIO_CNTR_REG_OFFSET) || if ((offset < MMIO_CNTR_REG_OFFSET) ||
(offset > max_offset_lim)) (offset > max_offset_lim))
return -EINVAL; return -EINVAL;
if (is_write) { if (is_write) {
writel((u32)*value, iommu->mmio_base + offset); u64 val = *value & GENMASK_ULL(47, 0);
writel((*value >> 32), iommu->mmio_base + offset + 4);
writel((u32)val, iommu->mmio_base + offset);
writel((val >> 32), iommu->mmio_base + offset + 4);
} else { } else {
*value = readl(iommu->mmio_base + offset + 4); *value = readl(iommu->mmio_base + offset + 4);
*value <<= 32; *value <<= 32;
*value = readl(iommu->mmio_base + offset); *value |= readl(iommu->mmio_base + offset);
*value &= GENMASK_ULL(47, 0);
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment