Address Translation support for MI200 and MI300 models
v2 cover Address Translation support for MI200 and MI300 models
From: Muralidhara M K <[email protected]>
This patchset adds support for MI200 heterogeneous address translation support and MI300A address translation support, Few fixups on HBM3 memory address maps to convert on-die(MCA decoded) address to Normalized address.
The patch set depends on the Yazen's patches submitted "AMD Address Translation Library"
https://lore.kernel.org/r/[email protected]
The patchset does the following
Patch 1:
MI200 heterogeneous address translation support.
Patch 2:
MI300 heterogeneous address translation support.
Patch 3:
Convert HBM3 MCA Decoded address to Normalized address.
Patch 4:
lookup table to get the correct cs instance id for HBM3.
Patch 5:
Convert physical cs id to logical cs id by static lookup table.
Patch 6:
Identify all 8 column system physical addresses from each HBM3 row and retire all column addresses when the error is injected to avoid future errors.
Muralidhara M K (6):
RAS: Add Address Translation support for MI200
RAS: Add Address Translation support for MI300
RAS: Add MCA Error address conversion for UMC
RAS: Add static lookup table to get CS physical ID
RAS: Add fixed Physical to logical CS ID mapping table
RAS: EDAC/amd64: Retire all system physical address from HBM3 row
drivers/edac/amd64_edac.c | 3 + drivers/ras/amd/atl/core.c | 5 +- drivers/ras/amd/atl/dehash.c | 149 ++++++++++++++++ drivers/ras/amd/atl/denormalize.c | 110 +++++++++++- drivers/ras/amd/atl/internal.h | 27 ++- drivers/ras/amd/atl/map.c | 158 ++++++++++++++--- drivers/ras/amd/atl/reg_fields.h | 34 ++++ drivers/ras/amd/atl/system.c | 4 + drivers/ras/amd/atl/umc.c | 284 +++++++++++++++++++++++++++++- include/linux/amd-atl.h | 2 + 10 files changed, 747 insertions(+), 29 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/6 RAS: Add Address Translation support for MI200
From: Muralidhara M K <[email protected]>
Add support for address translation on Data Fabric version 3.5 Add new interleaving modes for heterogeneous model support and adjust how the DRAM address maps are found early in the translation for certain cases.
---
Changes:
v1 -> v2 : None
drivers/ras/amd/atl/dehash.c | 60 +++++++++++++++++ drivers/ras/amd/atl/denormalize.c | 11 +++- drivers/ras/amd/atl/internal.h | 15 ++++- drivers/ras/amd/atl/map.c | 105 +++++++++++++++++++++++++++++- drivers/ras/amd/atl/reg_fields.h | 29 +++++++++ drivers/ras/amd/atl/system.c | 1 + 6 files changed, 217 insertions(+), 4 deletions(-)
drivers/ras/amd/atl/dehash.c +60 -0
@@ -395,6 +395,61 @@ static int df4p5_dehash_addr(struct addr_ctx *ctx)return 0 ; } +/* +* MI200 hash bits +* 64K 2M 1G +* CSSelect[0] = XOR of addr{8, 16, 21, 30}; +* CSSelect[1] = XOR of addr{9, 17, 22, 31}; +* CSSelect[2] = XOR of addr{10, 18, 23, 32}; +* CSSelect[3] = XOR of addr{11, 19, 24, 33}; - 16 and 32 channel only +* CSSelect[4] = XOR of addr{12, 20, 25, 34}; - 32 channel only +*/ +static int mi200_dehash_addr (struct addr_ctx *ctx) +{ +u8 num_intlv_bits = ctx->map.total_intlv_bits; +bool hash_ctl_64k, hash_ctl_2M, hash_ctl_1G; +u8 hashed_bit, intlv_bit, i; + +/* Assert that interleave bit is 8. */ +if (ctx->map.intlv_bit_pos !=8 ) { +pr_warn ("%s: Invalid interleave bit: %u" , + __func__, ctx->map.intlv_bit_pos); +return -EINVAL ; + } + +/* Assert that die interleaving is disabled. */ +if (ctx->map.num_intlv_dies >1 ) { +pr_warn ("%s: Invalid number of interleave dies: %u" , + __func__, ctx->map.num_intlv_dies); +return -EINVAL ; + } + +/* Assert that socket interleaving is disabled. */ +if (ctx->map.num_intlv_sockets >1 ) { +pr_warn ("%s: Invalid number of interleave sockets: %u" , + __func__, ctx->map.num_intlv_sockets); +return -EINVAL ; + } + + hash_ctl_64k =FIELD_GET (DF3_HASH_CTL_64K , ctx->map.ctl); + hash_ctl_2M =FIELD_GET (DF3_HASH_CTL_2M , ctx->map.ctl); + hash_ctl_1G =FIELD_GET (DF3_HASH_CTL_1G , ctx->map.ctl); + +for (i =0 ; i < num_intlv_bits; i++) { + intlv_bit =atl_get_bit (8 + i, ctx->ret_addr); + + hashed_bit = intlv_bit; + hashed_bit ^=atl_get_bit (8 + i, ctx->ret_addr); + hashed_bit ^=atl_get_bit (16 + i, ctx->ret_addr) & hash_ctl_64k; + hashed_bit ^=atl_get_bit (21 + i, ctx->ret_addr) & hash_ctl_2M; + hashed_bit ^=atl_get_bit (30 + i, ctx->ret_addr) & hash_ctl_1G; + +if (hashed_bit != intlv_bit) + ctx->ret_addr ^=BIT_ULL (8 + i); + } +return 0 ; +} +int dehash_address (struct addr_ctx *ctx) {switch (ctx->map.intlv_mode) {
@@ -452,6 +507,11 @@ int dehash_address(struct addr_ctx *ctx)case DF4p5_NPS1_16CHAN_2K_HASH:return df4p5_dehash_addr (ctx); +case MI2_HASH_8CHAN : +case MI2_HASH_16CHAN : +case MI2_HASH_32CHAN : +return mi200_dehash_addr (ctx); +default :ATL_BAD_INTLV_MODE (ctx->map.intlv_mode);return -EINVAL ;
drivers/ras/amd/atl/denormalize.c +10 -1
@@ -16,7 +16,7 @@* Returns the Destination Fabric ID. This is the first (lowest) * CS Fabric ID used within a DRAM Address map. */ -static u16 get_dst_fabric_id (struct addr_ctx *ctx) +u16 get_dst_fabric_id (struct addr_ctx *ctx) {switch (df_cfg.rev) {case DF2 :
@@ -97,6 +97,9 @@ static u64 make_space_for_cs_id(struct addr_ctx *ctx)case NOHASH_8CHAN :case NOHASH_16CHAN :case NOHASH_32CHAN : +case MI2_HASH_8CHAN : +case MI2_HASH_16CHAN : +case MI2_HASH_32CHAN :case DF2_2CHAN_HASH :return make_space_for_cs_id_at_intlv_bit (ctx);
@@ -233,6 +236,9 @@ static u16 calculate_cs_id(struct addr_ctx *ctx)case DF3_COD4_2CHAN_HASH :case DF3_COD2_4CHAN_HASH :case DF3_COD1_8CHAN_HASH : +case MI2_HASH_8CHAN : +case MI2_HASH_16CHAN : +case MI2_HASH_32CHAN :case DF2_2CHAN_HASH :return get_cs_id_df2 (ctx);
@@ -296,6 +302,9 @@ static u64 insert_cs_id(struct addr_ctx *ctx, u64 denorm_addr, u16 cs_id)case NOHASH_8CHAN :case NOHASH_16CHAN :case NOHASH_32CHAN : +case MI2_HASH_8CHAN : +case MI2_HASH_16CHAN : +case MI2_HASH_32CHAN :case DF2_2CHAN_HASH :return insert_cs_id_at_intlv_bit (ctx, denorm_addr, cs_id);
drivers/ras/amd/atl/internal.h +14 -1
@@ -30,6 +30,12 @@/* Shift needed for adjusting register values to true values. */ #define DF_DRAM_BASE_LIMIT_LSB 28 +/* Cache Coherent Moderator Instance Type value on register */ +#define DF_INST_TYPE_CCM 0 + +/* Maximum possible number of DRAM maps within a Data Fabric. */ +#define DF_NUM_DRAM_MAPS_AVAILABLE 16 +/* * Glossary of acronyms used in address translation for Zen-based systems *
@@ -68,6 +74,9 @@ enum intlv_modes {DF4_NPS1_12CHAN_HASH =0x15 ,DF4_NPS2_5CHAN_HASH =0x16 ,DF4_NPS1_10CHAN_HASH =0x17 , +MI2_HASH_8CHAN =0x1C , +MI2_HASH_16CHAN =0x1D , +MI2_HASH_32CHAN =0x1E ,DF2_2CHAN_HASH =0x21 ,/* DF4.5 modes are all IntLvNumChan + 0x20 */ DF4p5_NPS1_16CHAN_1K_HASH = 0x2C,
@@ -94,8 +103,9 @@ enum intlv_modes {struct df_flags {__u8 legacy_ficaa :1 , + heterogeneous :1 , genoa_quirk :1 , - __reserved_0 :6 ; + __reserved_0 :5 ; };struct df_config {
@@ -220,6 +230,9 @@ int determine_node_id(struct addr_ctx *ctx, u8 socket_num, u8 die_num);int get_address_map (struct addr_ctx *ctx);int denormalize_address (struct addr_ctx *ctx); + +u16 get_dst_fabric_id (struct addr_ctx *ctx); +int dehash_address (struct addr_ctx *ctx);int norm_to_sys_addr (u8 socket_id,u8 die_id,u8 cs_inst_id,u64 *addr);
drivers/ras/amd/atl/map.c +103 -2
135 lines not on this page · raw message
drivers/ras/amd/atl/reg_fields.h +29 -0
@@ -601,3 +601,32 @@#define DF2_SOCKET_ID_SHIFT GENMASK(31, 28)#define DF3_SOCKET_ID_SHIFT GENMASK(9, 8)#define DF4_SOCKET_ID_SHIFT GENMASK(11, 8) + +/* +* Total number of instances of all the blocks in DF +* +* Access type: Broadcast +* +* Register +* Rev Fieldname Bits +* +* D18F0x040 [Fabric Block Instance Count] +* DF3 BlkInstCount [7:0] +* DF3p5 BlkInstCount [7:0] +* DF4 BlkInstCount [7:0] +* DF4p5 BlkInstCount [9:0] +*/ +#define DF_BLOCK_INSTANCE_COUNT GENMASK(9, 0) + +/* +* Information on the block capabilities +* +* Access type: Broadcast +* +* Register +* Rev Fieldname Bits +* +* D18F0x044 [Fabric Block Instance Information 0] +* DF3p5 BlkInstCount [3:0] +*/ +#define DF_INSTANCE_TYPE GENMASK(3, 0)
drivers/ras/amd/atl/system.c +1 -0
@@ -144,6 +144,7 @@ static int determine_df_rev_legacy(void)if (FIELD_GET (DF4_COMPONENT_ID_MASK , fabric_id_mask0)) { df_cfg.rev = DF3p5; + df_cfg.flags.heterogeneous =1 ;/* Read D18F1x154 (SystemFabricIdMask1) */ if (df_indirect_read_broadcast (0 ,1 ,0x154 , &fabric_id_mask1))
Signature · 1 line
2.25.1
PATCH v2 2/6 RAS: Add Address Translation support for MI300
In reply to Muralidhara M KFrom: Muralidhara M K <[email protected]>
Add support for address translation on Data Fabric version 4.5 for MI300 systems.
Add new interleaving modes for APU model support and adjust how the DRAM address maps are found early in the translation for certain cases.
---
Changes:
v1 -> v2 : None
drivers/ras/amd/atl/core.c | 5 +- drivers/ras/amd/atl/dehash.c | 89 +++++++++++++++++++++++++++++++ drivers/ras/amd/atl/denormalize.c | 79 +++++++++++++++++++++++++++ drivers/ras/amd/atl/internal.h | 12 ++++- drivers/ras/amd/atl/map.c | 53 +++++++++++------- drivers/ras/amd/atl/reg_fields.h | 5 ++ drivers/ras/amd/atl/system.c | 3 ++ drivers/ras/amd/atl/umc.c | 28 +++++++++- 8 files changed, 250 insertions(+), 24 deletions(-)
drivers/ras/amd/atl/core.c +3 -2
@@ -56,7 +56,7 @@ static int add_legacy_hole(struct addr_ctx *ctx)if (df_cfg.rev >=DF4 ) func =7 ; -if (df_indirect_read_broadcast (ctx->node_id, func,0x104 , &dram_hole_base)) +if (df_indirect_read_broadcast (ctx->df_acc_id, func,0x104 , &dram_hole_base))return -EINVAL ; dram_hole_base &=DF_DRAM_HOLE_BASE_MASK ;
@@ -103,7 +103,7 @@ static bool late_hole_remove(struct addr_ctx *ctx)return false; } -int norm_to_sys_addr (u8 socket_id,u8 die_id,u8 cs_inst_id,u64 *addr) +int norm_to_sys_addr (u16 df_acc_id,u8 socket_id,u8 die_id,u8 cs_inst_id,u64 *addr) {struct addr_ctx ctx;
@@ -115,6 +115,7 @@ int norm_to_sys_addr(u8 socket_id, u8 die_id, u8 cs_inst_id, u64 *addr)/* We start from the normalized address */ ctx.ret_addr = *addr; ctx.inst_id = cs_inst_id; + ctx.df_acc_id = df_acc_id;if (determine_node_id (&ctx, socket_id, die_id)) {pr_warn ("Failed to determine Node ID" );
drivers/ras/amd/atl/dehash.c +89 -0
101 lines not on this page · raw message
drivers/ras/amd/atl/denormalize.c +79 -0
109 lines not on this page · raw message
drivers/ras/amd/atl/internal.h +11 -1
@@ -27,8 +27,12 @@/* PCI IDs for Genoa DF Function 0. */ #define DF_FUNC0_ID_GENOA 0x14AD1022 +/* PCI IDs for MI300 DF Function 0. */ +#define DF_FUNC0_ID_MI300 0x15281022 +/* Shift needed for adjusting register values to true values. */ #define DF_DRAM_BASE_LIMIT_LSB 28 +#define MI300_DRAM_LIMIT_LSB 20/* Cache Coherent Moderator Instance Type value on register */ #define DF_INST_TYPE_CCM 0
@@ -74,6 +78,9 @@ enum intlv_modes {DF4_NPS1_12CHAN_HASH =0x15 ,DF4_NPS2_5CHAN_HASH =0x16 ,DF4_NPS1_10CHAN_HASH =0x17 , +MI3_HASH_8CHAN =0x18 , +MI3_HASH_16CHAN =0x19 , +MI3_HASH_32CHAN =0x1A ,MI2_HASH_8CHAN =0x1C ,MI2_HASH_16CHAN =0x1D , MI2_HASH_32CHAN = 0x1E,
@@ -219,6 +226,9 @@ struct addr_ctx {* System-wide ID that includes 'node' bits. */ u16 cs_fabric_id; + +/* ID calculated from topology */ +u16 df_acc_id; };int df_indirect_read_instance (u16 node,u8 func,u16 reg,u8 instance_id,u32 *lo);
@@ -235,7 +245,7 @@ u16 get_dst_fabric_id(struct addr_ctx *ctx);int dehash_address (struct addr_ctx *ctx); -int norm_to_sys_addr (u8 socket_id,u8 die_id,u8 cs_inst_id,u64 *addr); +int norm_to_sys_addr (u16 df_acc_id,u8 socket_id,u8 die_id,u8 cs_inst_id,u64 *addr);/* * Helper to use test_bit() without needing to do
drivers/ras/amd/atl/map.c +33 -20
194 lines not on this page · raw message
drivers/ras/amd/atl/reg_fields.h +5 -0
@@ -251,6 +251,11 @@#define DF4_HASH_CTL_2M BIT(9)#define DF4_HASH_CTL_1G BIT(10)#define DF4_HASH_CTL_1T BIT(15) +#define DF4p5_HASH_CTL_4K BIT(7) +#define DF4p5_HASH_CTL_64K BIT(8) +#define DF4p5_HASH_CTL_2M BIT(9) +#define DF4p5_HASH_CTL_1G BIT(10) +#define DF4p5_HASH_CTL_1T BIT(15)/* * High Address Offset
drivers/ras/amd/atl/system.c +3 -0
@@ -124,6 +124,9 @@ static int df4_determine_df_rev(u32 reg)if (reg ==DF_FUNC0_ID_GENOA ) df_cfg.flags.genoa_quirk =1 ; +if (reg ==DF_FUNC0_ID_MI300 ) + df_cfg.flags.heterogeneous =1 ; +return df4_get_fabric_id_mask_registers (); }
drivers/ras/amd/atl/umc.c +27 -1
@@ -17,8 +17,16 @@ static u8 get_socket_id(struct mce *m)return m->socketid; } +#define MCA_IPID_INST_ID_HI GENMASK_ULL(47, 44)static u8 get_die_id (struct mce *m) { +/* The "AMD Node ID" is provided in MCA_IPID[InstanceIdHi] */ +if (df_cfg.rev == DF4p5 && df_cfg.flags.heterogeneous) { +u8 node_id =FIELD_GET (MCA_IPID_INST_ID_HI , m->ipid); + +return node_id /4 ; + } +/* * For CPUs, this is the AMD Node ID modulo the number * of AMD Nodes per socket.
@@ -37,14 +45,32 @@ static u8 get_cs_inst_id(struct mce *m)return FIELD_GET (UMC_CHANNEL_NUM , m->ipid); } +/* +* Use CPU's AMD Node ID for all cases. +* +* This is needed to read DF registers which can only be +* done on CPU-attached DFs even in heterogeneous cases. +* +* Future systems may report MCA errors across AMD Nodes. +* For example, errors from CPU socket 1 are reported to a +* CPU on socket 0. When this happens, the assumption below +* will break. But the AMD Node ID will be reported in +* MCA_IPID[InstanceIdHi] at that time. +*/ +static u16 get_df_acc_id (struct mce *m) +{ +return topology_die_id (m->extcpu); +} +int umc_mca_addr_to_sys_addr (struct mce *m,u64 *sys_addr) {u8 cs_inst_id =get_cs_inst_id (m);u8 socket_id =get_socket_id (m);u64 addr =get_norm_addr (m);u8 die_id =get_die_id (m); +u16 df_acc_id =get_df_acc_id (m); -if (norm_to_sys_addr (socket_id, die_id, cs_inst_id, &addr)) +if (norm_to_sys_addr (df_acc_id, socket_id, die_id, cs_inst_id, &addr))return -EINVAL ; *sys_addr = addr;
Signature · 1 line
2.25.1
PATCH v2 3/6 RAS: Add MCA Error address conversion for UMC
In reply to Muralidhara M KFrom: Muralidhara M K <[email protected]>
On AMD systems with HBM3 memory, The reported MCA address is DRAM address which needs to be converted to normalized address before the data fabric address translation.
MI300A models have on-chip HBM3 memory capable of On-Die ECC support. On-Die ECC error address to MCA is a encoded address reported with a DRAM address (PC/SID/Bank/ROW/COL) instead of normalized address unlike MI200s UMC ECC, as the implementation difference between HBM3 On-Die ECC and HBM2 host ECC.
Because On-Die ECC address reporting is done in the back-end of UMC and it no longer has normalized address at that point.
So software needs to convert the reported MCA Error Address back to normalized address.
---
Changes:
v1 -> v2 : None
drivers/ras/amd/atl/umc.c | 145 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+)
drivers/ras/amd/atl/umc.c +145 -0
@@ -12,6 +12,147 @@#include "internal.h" +static bool internal_bit_wise_xor (u32 inp) +{ +bool tmp =0 ; +int i; + +for (i =0 ; i <32 ; i++) + tmp = tmp ^ ((inp >> i) &0x1 ); + +return tmp; +} + +/* +* Mapping of MCA decoded error address bit location to +* normalized address on MI300A systems. +*/ +static const u8 umc_mca2na_mapping[] = { +0 ,5 ,6 ,8 ,9 ,14 ,12 ,13 , +10 ,11 ,15 ,16 ,17 ,18 ,19 ,20 , +21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 , +7 ,29 ,30 , +}; + +/* AddrHashBank and AddrHashPC/PC2 umc register bit fields */ +static struct { +u32 xor_enable :1 ; +u32 col_xor :13 ; +u32 row_xor :18 ; +} addr_hash_pc, addr_hash_bank[4 ]; + +static struct { +u32 bank_xor :6 ; +} addr_hash_pc2; + +#define COLUMN_LOCATION GENMASK(5, 1) +#define ROW_LOCATION GENMASK(23, 10) +/* +* The location of bank, column and row are fixed. +* location of column bit must be NA[5]. +* Row bits are always placed in a contiguous stretch of NA above the +* column and bank bits. +* Bits below the row bits can be either column or bank in any order, +* with the exception that NA[5] must be a column bit. +* Stack ID(SID) bits are placed in the MSB position of the NA. +*/ +static int umc_ondie_addr_to_normaddr (u64 mca_addr,u16 nid) +{ +u32 bank[4 ], bank_hash[4 ], pc_hash; +u32 col, row, rawbank =0 , pc; +int i, temp =0 , err; +u64 mca2na; + +/* Default umc base address on MI300A systems */ +u32 gpu_umc_base =0x90000 ; + +/* +* Error address logged on MI300A systems is ondie MCA address +* in the format MCA_Addr[27:0] = +* {SID[1:0],PC[0],row[14:0],bank[3:0],col[4:0],1'b0} +* The bit locations are calculated as per umc_mca2na_mapping[] +* to find normalized address. +* Refer F19 M90h BKDG Section 20.3.1.3 for clarifications +* +* XORs need to be applied based on the hash settings below. +*/ + +/* Calculate column and row */ + col =FIELD_GET (COLUMN_LOCATION , mca_addr); + row =FIELD_GET (ROW_LOCATION , mca_addr); + +/* Apply hashing on below banks for bank calculation */ +for (i =0 ; i <4 ; i++) + bank_hash[i] = (mca_addr >> (6 + i)) &0x1 ; + +/* bank hash algorithm */ +for (i =0 ; i <4 ; i++) { +/* Read AMD PPR UMC::AddrHashBank register */ + err =amd_smn_read (nid, gpu_umc_base +0xC8 + (i *4 ), &temp); +if (err) +return err; + + addr_hash_bank[i].xor_enable = temp &1 ; + addr_hash_bank[i].col_xor =FIELD_GET (GENMASK (13 ,1 ), temp); + addr_hash_bank[i].row_xor =FIELD_GET (GENMASK (31 ,14 ), temp); +/* bank hash selection */ + bank[i] = bank_hash[i] ^ (addr_hash_bank[i].xor_enable & + (internal_bit_wise_xor (col & addr_hash_bank[i].col_xor) ^ +internal_bit_wise_xor (row & addr_hash_bank[i].row_xor))); + } + +/* To apply hash on pc bit */ + pc_hash = (mca_addr >>25 ) &0x1 ; + +/* Read AMD PPR UMC::CH::AddrHashPC register */ + err =amd_smn_read (nid, gpu_umc_base +0xE0 , &temp); +if (err) +return err; + + addr_hash_pc.xor_enable = temp &1 ; + addr_hash_pc.col_xor =FIELD_GET (GENMASK (13 ,1 ), temp); + addr_hash_pc.row_xor =FIELD_GET (GENMASK (31 ,14 ), temp); + +/* Read AMD PPR UMC::CH::AddrHashPC2 register*/ + err =amd_smn_read (nid, gpu_umc_base +0xE4 , &temp); +if (err) +return err; + + addr_hash_pc2.bank_xor =FIELD_GET (GENMASK (5 ,0 ), temp); + +/* Calculate bank value from bank[0..3], bank[4] and bank[5] */ +for (i =0 ; i <4 ; i++) + rawbank |= (bank[i] &1 ) << i; + + rawbank |= (mca_addr >>22 ) &0x30 ; + +/* pseudochannel(pc) hash selection */ + pc = pc_hash ^ (addr_hash_pc.xor_enable & + (internal_bit_wise_xor (col & addr_hash_pc.col_xor) ^ +internal_bit_wise_xor (row & addr_hash_pc.row_xor) ^ +internal_bit_wise_xor (rawbank & addr_hash_pc2.bank_xor))); + +/* Mask b'25(pc_bit) and b'[9:6](bank) */ + mca_addr &= ~0x20003c0ULL ; + +for (i =0 ; i <4 ; i++) + mca_addr |= (bank[i] << (6 + i)); + + mca_addr |= (pc <<25 ); + +/* NA[4..0] is fixed */ + mca2na =0x0 ; +/* convert mca error address to normalized address */ +for (i =1 ; i <ARRAY_SIZE (umc_mca2na_mapping); i++) + mca2na |= ((mca_addr >> i) &0x1 ) << umc_mca2na_mapping[i]; + + mca_addr = mca2na; +pr_debug ("Error Addr 0x%016llx\n" , mca_addr); +pr_debug ("Error hit on Bank %d Row %d Column %d\n" , rawbank, row, col); + +return mca_addr; +} +static u8 get_socket_id (struct mce *m) {return m->socketid;
@@ -36,6 +177,10 @@ static u8 get_die_id(struct mce *m)static u64 get_norm_addr (struct mce *m) { +/* MI300: DRAM->Normalized translation */ +if (df_cfg.rev == DF4p5 && df_cfg.flags.heterogeneous) +return umc_ondie_addr_to_normaddr (m->addr,get_socket_id (m)); +return m->addr; }
Signature · 1 line
2.25.1
PATCH v2 4/6 RAS: Add static lookup table to get CS physical ID
In reply to Muralidhara M KFrom: Muralidhara M K <[email protected]>
AMD MI300A models have a single Data Fabric (DF) instance per socket. So, all 4 AIDs are not software-visible (using PCI Device 18h, etc.).
The MCA_IPID_UMC[InstanceId] field holds the SMN base address for the UMC instance and SMN address mapping repeated same for each of all 4 AIDs in as socket.
Add a static lookup table by reading the UMC SMN address from the MCA_IPID_UMC[InstanceId] field and use the value to look up the CS physical ID from the table.
---
Changes:
v1 -> v2 : None
drivers/ras/amd/atl/umc.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/ras/amd/atl/umc.c +33 -0
@@ -153,6 +153,35 @@ static int umc_ondie_addr_to_normaddr(u64 mca_addr, u16 nid)return mca_addr; } +/* +* MCA_IPID_UMC[InstanceId] holds the SMN Base Address for a UMC instance. +* MI-300 has a fixed, model-specific mapping between a UMC instance and its +* related Data Fabric CS instance. +* Use the UMC SMN Base Address value to find the appropriate CS instance ID. +*/ +static const u32 csmap[32 ] = { +0x393f00 ,0x293f00 ,0x193f00 ,0x093f00 ,0x392f00 ,0x292f00 , +0x192f00 ,0x092f00 ,0x391f00 ,0x291f00 ,0x191f00 ,0x091f00 , +0x390f00 ,0x290f00 ,0x190f00 ,0x090f00 ,0x793f00 ,0x693f00 , +0x593f00 ,0x493f00 ,0x792f00 ,0x692f00 ,0x592f00 ,0x492f00 , +0x791f00 ,0x691f00 ,0x591f00 ,0x491f00 ,0x790f00 ,0x690f00 , +0x590f00 ,0x490f00 }; + +/* MCA_IPID[InstanceId] give the Instance Number UMC SmnAddr */ +#define UMC_PHY_INSTANCE_NUM GENMASK(31, 0) + +static u8 fixup_cs_inst_id (struct mce *m) +{ +u32 smn_addr =FIELD_GET (UMC_PHY_INSTANCE_NUM , m->ipid); +int i; + +for (i =0 ; i <ARRAY_SIZE (csmap); i++) { +if (smn_addr == csmap[i]) +break ; + } +return i; +} +static u8 get_socket_id (struct mce *m) {return m->socketid;
@@ -187,6 +216,10 @@ static u64 get_norm_addr(struct mce *m)#define UMC_CHANNEL_NUM GENMASK(31, 20)static u8 get_cs_inst_id (struct mce *m) { +/* MI300: static mapping table for MCA_IPID[InstanceId] to CS physical ID. */ +if (df_cfg.rev == DF4p5 && df_cfg.flags.heterogeneous) +return fixup_cs_inst_id (m); +return FIELD_GET (UMC_CHANNEL_NUM , m->ipid); }
Signature · 1 line
2.25.1
PATCH v2 5/6 RAS: Add fixed Physical to logical CS ID mapping table
In reply to Muralidhara M KFrom: Muralidhara M K <[email protected]>
AMD MI300A models have a single Data Fabric (DF) instance per socket. So, only one out of 4 AIDs are software-visible using PCI Device 18h.
Add a static lookup table for converting physical CS ID to logical CS ID for mapping of all 4 respective AIDs in a socket.
---
Changes:
v1 -> v2 : None
drivers/ras/amd/atl/denormalize.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/ras/amd/atl/denormalize.c +19 -1
@@ -442,6 +442,20 @@ static u16 get_logical_cs_fabric_id(struct addr_ctx *ctx)return (phys_cs_fabric_id & df_cfg.node_id_mask) | log_cs_fabric_id; } +/* Physical CS to Logical CS mapping for MI300 AIDs */ +u16 phy_to_logicalcs_mapping_mi300_aid[] = {12 ,13 ,14 ,15 ,8 ,9 ,10 ,11 , +4 ,5 ,6 ,7 ,0 ,1 ,2 ,3 , +28 ,29 ,30 ,31 ,24 ,25 ,26 ,27 , +20 ,21 ,22 ,23 ,16 ,17 ,18 ,19 }; + +static u16 get_logical_cs_fabric_id_mi300_die (struct addr_ctx *ctx) +{ +if (ctx->inst_id >=sizeof (phy_to_logicalcs_mapping_mi300_aid)) +return -EINVAL ; + +return phy_to_logicalcs_mapping_mi300_aid[ctx->inst_id]; +} +static int denorm_addr_common (struct addr_ctx *ctx) {u64 denorm_addr;
@@ -451,7 +465,11 @@ static int denorm_addr_common(struct addr_ctx *ctx)* Convert the original physical CS Fabric ID to a logical value. * This is required for non-power-of-two and other interleaving modes. */ - ctx->cs_fabric_id =get_logical_cs_fabric_id (ctx); +if (df_cfg.rev == DF4p5 && df_cfg.flags.heterogeneous) + ctx->cs_fabric_id = (ctx->cs_fabric_id & df_cfg.node_id_mask) | +get_logical_cs_fabric_id_mi300_die (ctx); +else + ctx->cs_fabric_id =get_logical_cs_fabric_id (ctx); denorm_addr =make_space_for_cs_id (ctx); cs_id =calculate_cs_id (ctx);
Signature · 1 line
2.25.1
PATCH v2 6/6 RAS: EDAC/amd64: Retire all system physical address from HBM3 row
In reply to Muralidhara M KFrom: Muralidhara M K <[email protected]>
AMD systems have HBM memory embedded within the chip, The entire memory is managed by host OS. Error containment needs to be reliable, because HBM memory cannot be replaced.
HBM3 memory has 8 columns in each row and column bits are c2, c3 and c4 which gives 8 possible combination of addresses in each row.
Identify all these system physical addresses in a HBM row and retire all system physical address to get rid of intermittent or recurrent memory errors.
---
Changes:
v1 -> v2 : Rename and modify function amd_umc_retire_column_spa_from_row()
drivers/edac/amd64_edac.c | 3 ++ drivers/ras/amd/atl/umc.c | 77 +++++++++++++++++++++++++++++++++++++++ include/linux/amd-atl.h | 2 + 3 files changed, 82 insertions(+)
drivers/edac/amd64_edac.c +3 -0
@@ -2831,6 +2831,9 @@ static void decode_umc_error(int node_id, struct mce *m)error_address_to_page_and_offset (sys_addr, &err); +if (pvt->fam ==0x19 && (pvt->model >=0x90 && pvt->model <=0x9f )) +amd_umc_retire_column_spa_from_row (m); + log_error:__log_ecc_error (mci, &err, ecc_type); }
drivers/ras/amd/atl/umc.c +77 -0
80 lines not on this page · raw message
include/linux/amd-atl.h +2 -0
@@ -25,4 +25,6 @@ static inline int amd_umc_mca_addr_to_sys_addr(struct mce *m, u64 *sys_addr) return umc_mca_addr_to_sys_addr(m, sys_addr); } +void amd_umc_retire_column_spa_from_row (struct mce *m); +#endif /* _AMD_ATL_H */
Signature · 1 line
2.25.1