[PATCH v2 7/8] x86/MCE/AMD: Group register reads in translation code
From: Yazen Ghannam
Date: Thu Sep 03 2020 - 16:02:22 EST
From: Yazen Ghannam <yazen.ghannam@xxxxxxx>
...so that bitfield extraction can be done together to simplify future
patches.
Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
Link:
https://lkml.kernel.org/r/20200814191449.183998-3-Yazen.Ghannam@xxxxxxx
v1 -> v2:
* New patch based on comments for v1 Patch 2.
arch/x86/kernel/cpu/mce/amd.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 5a18937ff7cd..f5440f8000e9 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -729,11 +729,18 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
goto out_err;
}
+ if (amd_df_indirect_read(nid, 0, DF_F0_DRAMLIMITADDR + (8 * base), umc, ®_dram_limit_addr))
+ goto out_err;
+
lgcy_mmio_hole_en = get_bit(reg_dram_base_addr, 1);
intlv_num_chan = get_bits(reg_dram_base_addr, 7, 4);
intlv_addr_sel = get_bits(reg_dram_base_addr, 10, 8);
dram_base_addr = get_bits(reg_dram_base_addr, 31, 12) << 28;
+ intlv_num_sockets = get_bit(reg_dram_limit_addr, 8);
+ intlv_num_dies = get_bits(reg_dram_limit_addr, 11, 10);
+ dram_limit_addr = (get_bits(reg_dram_limit_addr, 31, 12) << 28) | GENMASK_ULL(27, 0);
+
/* {0, 1, 2, 3} map to address bits {8, 9, 10, 11} respectively */
if (intlv_addr_sel > 3) {
pr_err("%s: Invalid interleave address select %d.\n",
@@ -741,13 +748,6 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
goto out_err;
}
- if (amd_df_indirect_read(nid, 0, DF_F0_DRAMLIMITADDR + (8 * base), umc, ®_dram_limit_addr))
- goto out_err;
-
- intlv_num_sockets = get_bit(reg_dram_limit_addr, 8);
- intlv_num_dies = get_bits(reg_dram_limit_addr, 11, 10);
- dram_limit_addr = (get_bits(reg_dram_limit_addr, 31, 12) << 28) | GENMASK_ULL(27, 0);
-
intlv_addr_bit = intlv_addr_sel + 8;
/* Re-use intlv_num_chan by setting it equal to log2(#channels) */
--
2.25.1