lkml.org 
[lkml]   [2021]   [Jun]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 24/31] EDAC/amd64: Define function to insert CS ID into address
Date
Move the code that inserts the CS ID into the address into a separate
helper function. This will be expanded for future DF versions.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
Link:
https://lkml.kernel.org/r/20210507190140.18854-21-Yazen.Ghannam@amd.com

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(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 0270bf4f1f90..d09a17747abd 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -1103,6 +1103,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 {
@@ -1135,6 +1136,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;
@@ -1166,6 +1172,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 &&
@@ -1333,8 +1340,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;
@@ -1351,20 +1356,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;
}
--
2.25.1
\
 
 \ /
  Last update: 2021-06-23 21:22    [W:0.269 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site