Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

John Allen and committed by
Borislav Petkov (AMD)
1233aa3f efdbe82a

+26 -13
+5 -13
drivers/ras/amd/atl/core.c
··· 51 51 52 52 static int add_legacy_hole(struct addr_ctx *ctx) 53 53 { 54 - u32 dram_hole_base; 55 - u8 func = 0; 56 - 57 54 if (!legacy_hole_en(ctx)) 58 55 return 0; 59 56 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); 70 59 71 60 return 0; 72 61 } ··· 113 124 ctx.inputs.socket_id = socket_id; 114 125 ctx.inputs.die_id = die_id; 115 126 ctx.inputs.coh_st_inst_id = coh_st_inst_id; 127 + 128 + if (legacy_hole_en(&ctx) && !df_cfg.dram_hole_base) 129 + return -EINVAL; 116 130 117 131 if (determine_node_id(&ctx, socket_id, die_id)) 118 132 return -EINVAL;
+2
drivers/ras/amd/atl/internal.h
··· 135 135 /* Number of DRAM Address maps visible in a Coherent Station. */ 136 136 u8 num_coh_st_maps; 137 137 138 + u32 dram_hole_base; 139 + 138 140 /* Global flags to handle special cases. */ 139 141 struct df_flags flags; 140 142 };
+19
drivers/ras/amd/atl/system.c
··· 223 223 return -EINVAL; 224 224 } 225 225 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 + 226 241 static void get_num_maps(void) 227 242 { 228 243 switch (df_cfg.rev) { ··· 281 266 282 267 pr_debug("num_coh_st_maps=%u", df_cfg.num_coh_st_maps); 283 268 269 + pr_debug("dram_hole_base=0x%x", df_cfg.dram_hole_base); 284 270 pr_debug("flags.legacy_ficaa=%u", df_cfg.flags.legacy_ficaa); 285 271 pr_debug("flags.socket_id_shift_quirk=%u", df_cfg.flags.socket_id_shift_quirk); 286 272 } ··· 297 281 apply_node_id_shift(); 298 282 299 283 get_num_maps(); 284 + 285 + if (get_dram_hole_base()) 286 + pr_warn("Failed to read DRAM hole base"); 300 287 301 288 dump_df_cfg(); 302 289