[PATCH 15/25] x86/MCE/AMD: Define function to get number of interleaved dies

From: Yazen Ghannam
Date: Fri May 07 2021 - 15:02:58 EST


From: Yazen Ghannam <yazen.ghannam@xxxxxxx>

Move parsing of the number of interleaved dies to a separate helper
function. This will be expanded for future DF versions. Also, drop an
unneeded assert to match the reference code.

Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
arch/x86/kernel/cpu/mce/amd.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 0c24bdc346a3..de59fa6cf540 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -730,6 +730,7 @@ struct addr_ctx {
u8 map_num;
u8 intlv_addr_bit;
u8 intlv_num_chan;
+ u8 intlv_num_dies;
u8 cs_id;
bool hash_enabled;
};
@@ -848,12 +849,17 @@ static void get_intlv_num_chan(struct addr_ctx *ctx)
}
}

+static void get_intlv_num_dies(struct addr_ctx *ctx)
+{
+ ctx->intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3;
+}
+
static int denormalize_addr(struct addr_ctx *ctx)
{
u32 tmp;

u8 die_id_shift, die_id_mask, socket_id_shift, socket_id_mask;
- u8 intlv_num_dies, intlv_num_sockets;
+ u8 intlv_num_sockets;
u8 num_intlv_bits, cs_mask = 0;

/* Return early if no interleaving. */
@@ -864,19 +870,12 @@ static int denormalize_addr(struct addr_ctx *ctx)
return -EINVAL;

intlv_num_sockets = (ctx->reg_limit_addr >> 8) & 0x1;
- intlv_num_dies = (ctx->reg_limit_addr >> 10) & 0x3;

get_intlv_num_chan(ctx);
+ get_intlv_num_dies(ctx);

num_intlv_bits = ctx->intlv_num_chan;
-
- if (intlv_num_dies > 2) {
- pr_err("%s: Invalid number of interleaved nodes/dies %d.\n",
- __func__, intlv_num_dies);
- return -EINVAL;
- }
-
- num_intlv_bits += intlv_num_dies;
+ num_intlv_bits += ctx->intlv_num_dies;

/* Add a bit if sockets are interleaved. */
num_intlv_bits += intlv_num_sockets;
@@ -913,14 +912,14 @@ static int denormalize_addr(struct addr_ctx *ctx)

sock_id_bit = die_id_bit;

- if (intlv_num_dies || intlv_num_sockets)
+ if (ctx->intlv_num_dies || intlv_num_sockets)
if (amd_df_indirect_read(ctx->nid, df_regs[SYS_FAB_ID_MASK],
ctx->umc, &tmp))
return -EINVAL;

/* If interleaved over more than 1 die. */
- if (intlv_num_dies) {
- sock_id_bit = die_id_bit + intlv_num_dies;
+ if (ctx->intlv_num_dies) {
+ sock_id_bit = die_id_bit + ctx->intlv_num_dies;
die_id_shift = (tmp >> 24) & 0xF;
die_id_mask = (tmp >> 8) & 0xFF;

--
2.25.1