Skip to content

Commit 1233aa3

Browse files
jallen-amdbp3tk0v
authored andcommitted
RAS/AMD/ATL: Read DRAM hole base early
Read DRAM hole base when constructing the address map as the value will not change during run time. Signed-off-by: John Allen <john.allen@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com> Link: https://lore.kernel.org/r/20240606203313.51197-3-john.allen@amd.com
1 parent efdbe82 commit 1233aa3

3 files changed

Lines changed: 26 additions & 13 deletions

File tree

drivers/ras/amd/atl/core.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,11 @@ static bool legacy_hole_en(struct addr_ctx *ctx)
5151

5252
static int add_legacy_hole(struct addr_ctx *ctx)
5353
{
54-
u32 dram_hole_base;
55-
u8 func = 0;
56-
5754
if (!legacy_hole_en(ctx))
5855
return 0;
5956

60-
if (df_cfg.rev >= DF4)
61-
func = 7;
62-
63-
if (df_indirect_read_broadcast(ctx->node_id, func, 0x104, &dram_hole_base))
64-
return -EINVAL;
65-
66-
dram_hole_base &= DF_DRAM_HOLE_BASE_MASK;
67-
68-
if (ctx->ret_addr >= dram_hole_base)
69-
ctx->ret_addr += (BIT_ULL(32) - dram_hole_base);
57+
if (ctx->ret_addr >= df_cfg.dram_hole_base)
58+
ctx->ret_addr += (BIT_ULL(32) - df_cfg.dram_hole_base);
7059

7160
return 0;
7261
}
@@ -125,6 +114,9 @@ unsigned long norm_to_sys_addr(u8 socket_id, u8 die_id, u8 coh_st_inst_id, unsig
125114
ctx.inputs.die_id = die_id;
126115
ctx.inputs.coh_st_inst_id = coh_st_inst_id;
127116

117+
if (legacy_hole_en(&ctx) && !df_cfg.dram_hole_base)
118+
return -EINVAL;
119+
128120
if (determine_node_id(&ctx, socket_id, die_id))
129121
return -EINVAL;
130122

drivers/ras/amd/atl/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ struct df_config {
135135
/* Number of DRAM Address maps visible in a Coherent Station. */
136136
u8 num_coh_st_maps;
137137

138+
u32 dram_hole_base;
139+
138140
/* Global flags to handle special cases. */
139141
struct df_flags flags;
140142
};

drivers/ras/amd/atl/system.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,21 @@ static int determine_df_rev(void)
223223
return -EINVAL;
224224
}
225225

226+
static int get_dram_hole_base(void)
227+
{
228+
u8 func = 0;
229+
230+
if (df_cfg.rev >= DF4)
231+
func = 7;
232+
233+
if (df_indirect_read_broadcast(0, func, 0x104, &df_cfg.dram_hole_base))
234+
return -EINVAL;
235+
236+
df_cfg.dram_hole_base &= DF_DRAM_HOLE_BASE_MASK;
237+
238+
return 0;
239+
}
240+
226241
static void get_num_maps(void)
227242
{
228243
switch (df_cfg.rev) {
@@ -266,6 +281,7 @@ static void dump_df_cfg(void)
266281

267282
pr_debug("num_coh_st_maps=%u", df_cfg.num_coh_st_maps);
268283

284+
pr_debug("dram_hole_base=0x%x", df_cfg.dram_hole_base);
269285
pr_debug("flags.legacy_ficaa=%u", df_cfg.flags.legacy_ficaa);
270286
pr_debug("flags.socket_id_shift_quirk=%u", df_cfg.flags.socket_id_shift_quirk);
271287
}
@@ -282,6 +298,9 @@ int get_df_system_info(void)
282298

283299
get_num_maps();
284300

301+
if (get_dram_hole_base())
302+
pr_warn("Failed to read DRAM hole base");
303+
285304
dump_df_cfg();
286305

287306
return 0;

0 commit comments

Comments
 (0)