@@ -1074,6 +1074,7 @@ struct addr_ctx {
u8 cs_id;
int (*dehash_addr)(struct addr_ctx *ctx);
void (*make_space_for_cs_id)(struct addr_ctx *ctx);
+ void (*insert_cs_id)(struct addr_ctx *ctx);
};
struct data_fabric_ops {
@@ -1106,6 +1107,11 @@ static void make_space_for_cs_id_simple(struct addr_ctx *ctx)
expand_bits(ctx->intlv_addr_bit, num_intlv_bits, &ctx->ret_addr);
}
+static void insert_cs_id_simple(struct addr_ctx *ctx)
+{
+ ctx->ret_addr |= (ctx->cs_id << ctx->intlv_addr_bit);
+}
+
static u64 get_hi_addr_offset_df2(struct addr_ctx *ctx)
{
return (ctx->reg_dram_offset & GENMASK_ULL(31, 20)) << 8;
@@ -1137,6 +1143,7 @@ static int get_intlv_mode_df2(struct addr_ctx *ctx)
}
ctx->make_space_for_cs_id = make_space_for_cs_id_simple;
+ ctx->insert_cs_id = insert_cs_id_simple;
if (ctx->intlv_mode != NONE &&
ctx->intlv_mode != NOHASH_2CH &&
@@ -1295,8 +1302,6 @@ static int calculate_cs_id(struct addr_ctx *ctx)
static int denormalize_addr(struct addr_ctx *ctx)
{
- u8 num_intlv_bits;
-
/* Return early if no interleaving. */
if (ctx->intlv_mode == NONE)
return 0;
@@ -1313,20 +1318,7 @@ static int denormalize_addr(struct addr_ctx *ctx)
if (calculate_cs_id(ctx))
return -EINVAL;
- if (num_intlv_bits > 0) {
- u64 temp_addr_i;
-
- /*
- * The pre-interleaved address consists of XXXXXXIIIYYYYY
- * where III is the ID for this CS, and XXXXXXYYYYY are the
- * address bits from the post-interleaved address.
- * "num_intlv_bits" has been calculated to tell us how many "I"
- * bits there are. "intlv_addr_bit" tells us how many "Y" bits
- * there are (where "I" starts).
- */
- temp_addr_i = (ctx->cs_id << ctx->intlv_addr_bit);
- ctx->ret_addr |= temp_addr_i;
- }
+ ctx->insert_cs_id(ctx);
return 0;
}
Move the code that inserts the CS ID into the address into a separate helper function. Save the function pointer in the context struct. It will be set based on interleaving mode rather than Data Fabric version. This will be expanded for new interleaving modes added in future Data Fabric versions. Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> --- Link: https://lkml.kernel.org/r/20210623192002.3671647-25-yazen.ghannam@amd.com v2->v3: * Was patch 24 in v2. v1->v2: * Moved from arch/x86 to EDAC. * Added function pointer to ctx struct. drivers/edac/amd64_edac.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-)