Skip to content

Commit ff03ff3

Browse files
yghannambp3tk0v
authored andcommitted
x86/mce/amd, EDAC/mce_amd: Move long names to decoder module
The long names of the SMCA banks are only used by the MCE decoder module. Move them out of the arch code and into the decoder module. [ bp: Name the long names array "smca_long_names", drop local ptr in decode_smca_error(), constify arrays. ] Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20231118193248.1296798-5-yazen.ghannam@amd.com
1 parent 6175b40 commit ff03ff3

3 files changed

Lines changed: 72 additions & 49 deletions

File tree

arch/x86/include/asm/mce.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ enum smca_bank_types {
333333
N_SMCA_BANK_TYPES
334334
};
335335

336-
extern const char *smca_get_long_name(enum smca_bank_types t);
337336
extern bool amd_mce_is_memory_error(struct mce *m);
338337

339338
extern int mce_threshold_create_device(unsigned int cpu);

arch/x86/kernel/cpu/mce/amd.c

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -87,60 +87,46 @@ struct smca_bank {
8787
static DEFINE_PER_CPU_READ_MOSTLY(struct smca_bank[MAX_NR_BANKS], smca_banks);
8888
static DEFINE_PER_CPU_READ_MOSTLY(u8[N_SMCA_BANK_TYPES], smca_bank_counts);
8989

90-
struct smca_bank_name {
91-
const char *name; /* Short name for sysfs */
92-
const char *long_name; /* Long name for pretty-printing */
93-
};
94-
95-
static struct smca_bank_name smca_names[] = {
96-
[SMCA_LS ... SMCA_LS_V2] = { "load_store", "Load Store Unit" },
97-
[SMCA_IF] = { "insn_fetch", "Instruction Fetch Unit" },
98-
[SMCA_L2_CACHE] = { "l2_cache", "L2 Cache" },
99-
[SMCA_DE] = { "decode_unit", "Decode Unit" },
100-
[SMCA_RESERVED] = { "reserved", "Reserved" },
101-
[SMCA_EX] = { "execution_unit", "Execution Unit" },
102-
[SMCA_FP] = { "floating_point", "Floating Point Unit" },
103-
[SMCA_L3_CACHE] = { "l3_cache", "L3 Cache" },
104-
[SMCA_CS ... SMCA_CS_V2] = { "coherent_slave", "Coherent Slave" },
105-
[SMCA_PIE] = { "pie", "Power, Interrupts, etc." },
90+
static const char * const smca_names[] = {
91+
[SMCA_LS ... SMCA_LS_V2] = "load_store",
92+
[SMCA_IF] = "insn_fetch",
93+
[SMCA_L2_CACHE] = "l2_cache",
94+
[SMCA_DE] = "decode_unit",
95+
[SMCA_RESERVED] = "reserved",
96+
[SMCA_EX] = "execution_unit",
97+
[SMCA_FP] = "floating_point",
98+
[SMCA_L3_CACHE] = "l3_cache",
99+
[SMCA_CS ... SMCA_CS_V2] = "coherent_slave",
100+
[SMCA_PIE] = "pie",
106101

107102
/* UMC v2 is separate because both of them can exist in a single system. */
108-
[SMCA_UMC] = { "umc", "Unified Memory Controller" },
109-
[SMCA_UMC_V2] = { "umc_v2", "Unified Memory Controller v2" },
110-
[SMCA_PB] = { "param_block", "Parameter Block" },
111-
[SMCA_PSP ... SMCA_PSP_V2] = { "psp", "Platform Security Processor" },
112-
[SMCA_SMU ... SMCA_SMU_V2] = { "smu", "System Management Unit" },
113-
[SMCA_MP5] = { "mp5", "Microprocessor 5 Unit" },
114-
[SMCA_MPDMA] = { "mpdma", "MPDMA Unit" },
115-
[SMCA_NBIO] = { "nbio", "Northbridge IO Unit" },
116-
[SMCA_PCIE ... SMCA_PCIE_V2] = { "pcie", "PCI Express Unit" },
117-
[SMCA_XGMI_PCS] = { "xgmi_pcs", "Ext Global Memory Interconnect PCS Unit" },
118-
[SMCA_NBIF] = { "nbif", "NBIF Unit" },
119-
[SMCA_SHUB] = { "shub", "System Hub Unit" },
120-
[SMCA_SATA] = { "sata", "SATA Unit" },
121-
[SMCA_USB] = { "usb", "USB Unit" },
122-
[SMCA_GMI_PCS] = { "gmi_pcs", "Global Memory Interconnect PCS Unit" },
123-
[SMCA_XGMI_PHY] = { "xgmi_phy", "Ext Global Memory Interconnect PHY Unit" },
124-
[SMCA_WAFL_PHY] = { "wafl_phy", "WAFL PHY Unit" },
125-
[SMCA_GMI_PHY] = { "gmi_phy", "Global Memory Interconnect PHY Unit" },
103+
[SMCA_UMC] = "umc",
104+
[SMCA_UMC_V2] = "umc_v2",
105+
[SMCA_PB] = "param_block",
106+
[SMCA_PSP ... SMCA_PSP_V2] = "psp",
107+
[SMCA_SMU ... SMCA_SMU_V2] = "smu",
108+
[SMCA_MP5] = "mp5",
109+
[SMCA_MPDMA] = "mpdma",
110+
[SMCA_NBIO] = "nbio",
111+
[SMCA_PCIE ... SMCA_PCIE_V2] = "pcie",
112+
[SMCA_XGMI_PCS] = "xgmi_pcs",
113+
[SMCA_NBIF] = "nbif",
114+
[SMCA_SHUB] = "shub",
115+
[SMCA_SATA] = "sata",
116+
[SMCA_USB] = "usb",
117+
[SMCA_GMI_PCS] = "gmi_pcs",
118+
[SMCA_XGMI_PHY] = "xgmi_phy",
119+
[SMCA_WAFL_PHY] = "wafl_phy",
120+
[SMCA_GMI_PHY] = "gmi_phy",
126121
};
127122

128123
static const char *smca_get_name(enum smca_bank_types t)
129124
{
130125
if (t >= N_SMCA_BANK_TYPES)
131126
return NULL;
132127

133-
return smca_names[t].name;
134-
}
135-
136-
const char *smca_get_long_name(enum smca_bank_types t)
137-
{
138-
if (t >= N_SMCA_BANK_TYPES)
139-
return NULL;
140-
141-
return smca_names[t].long_name;
128+
return smca_names[t];
142129
}
143-
EXPORT_SYMBOL_GPL(smca_get_long_name);
144130

145131
enum smca_bank_types smca_get_bank_type(unsigned int cpu, unsigned int bank)
146132
{

drivers/edac/mce_amd.c

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,11 +1163,51 @@ static void decode_mc6_mce(struct mce *m)
11631163
pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n");
11641164
}
11651165

1166+
static const char * const smca_long_names[] = {
1167+
[SMCA_LS ... SMCA_LS_V2] = "Load Store Unit",
1168+
[SMCA_IF] = "Instruction Fetch Unit",
1169+
[SMCA_L2_CACHE] = "L2 Cache",
1170+
[SMCA_DE] = "Decode Unit",
1171+
[SMCA_RESERVED] = "Reserved",
1172+
[SMCA_EX] = "Execution Unit",
1173+
[SMCA_FP] = "Floating Point Unit",
1174+
[SMCA_L3_CACHE] = "L3 Cache",
1175+
[SMCA_CS ... SMCA_CS_V2] = "Coherent Slave",
1176+
[SMCA_PIE] = "Power, Interrupts, etc.",
1177+
1178+
/* UMC v2 is separate because both of them can exist in a single system. */
1179+
[SMCA_UMC] = "Unified Memory Controller",
1180+
[SMCA_UMC_V2] = "Unified Memory Controller v2",
1181+
[SMCA_PB] = "Parameter Block",
1182+
[SMCA_PSP ... SMCA_PSP_V2] = "Platform Security Processor",
1183+
[SMCA_SMU ... SMCA_SMU_V2] = "System Management Unit",
1184+
[SMCA_MP5] = "Microprocessor 5 Unit",
1185+
[SMCA_MPDMA] = "MPDMA Unit",
1186+
[SMCA_NBIO] = "Northbridge IO Unit",
1187+
[SMCA_PCIE ... SMCA_PCIE_V2] = "PCI Express Unit",
1188+
[SMCA_XGMI_PCS] = "Ext Global Memory Interconnect PCS Unit",
1189+
[SMCA_NBIF] = "NBIF Unit",
1190+
[SMCA_SHUB] = "System Hub Unit",
1191+
[SMCA_SATA] = "SATA Unit",
1192+
[SMCA_USB] = "USB Unit",
1193+
[SMCA_GMI_PCS] = "Global Memory Interconnect PCS Unit",
1194+
[SMCA_XGMI_PHY] = "Ext Global Memory Interconnect PHY Unit",
1195+
[SMCA_WAFL_PHY] = "WAFL PHY Unit",
1196+
[SMCA_GMI_PHY] = "Global Memory Interconnect PHY Unit",
1197+
};
1198+
1199+
static const char *smca_get_long_name(enum smca_bank_types t)
1200+
{
1201+
if (t >= N_SMCA_BANK_TYPES)
1202+
return NULL;
1203+
1204+
return smca_long_names[t];
1205+
}
1206+
11661207
/* Decode errors according to Scalable MCA specification */
11671208
static void decode_smca_error(struct mce *m)
11681209
{
11691210
enum smca_bank_types bank_type = smca_get_bank_type(m->extcpu, m->bank);
1170-
const char *ip_name;
11711211
u8 xec = XEC(m->status, xec_mask);
11721212

11731213
if (bank_type >= N_SMCA_BANK_TYPES)
@@ -1178,9 +1218,7 @@ static void decode_smca_error(struct mce *m)
11781218
return;
11791219
}
11801220

1181-
ip_name = smca_get_long_name(bank_type);
1182-
1183-
pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec);
1221+
pr_emerg(HW_ERR "%s Ext. Error Code: %d", smca_get_long_name(bank_type), xec);
11841222

11851223
/* Only print the decode of valid error codes */
11861224
if (xec < smca_mce_descs[bank_type].num_descs)

0 commit comments

Comments
 (0)