From nobody Wed Dec 17 12:21:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7A3AC07CB1 for ; Mon, 27 Nov 2023 11:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233242AbjK0Lb2 (ORCPT ); Mon, 27 Nov 2023 06:31:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233158AbjK0Lb0 (ORCPT ); Mon, 27 Nov 2023 06:31:26 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4CA3C0; Mon, 27 Nov 2023 03:31:31 -0800 (PST) Date: Mon, 27 Nov 2023 11:31:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701084689; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jf9JetOvZH0lMfipFdKAeTki4Ool1/gZmRBNarGOB7Q=; b=qWCiaOSLqUI6MGTe80mmFfj9cl/vcinjPrjGNaQcIvM3HVTdi1mDdhXwrQ1WvRc7zy6l+s BcO2p4eKGpFMJQduNvBeNRCA8+TvWJOilYXn4ewB2Ix/6l85AQkjDH0qtyzqHaFXT+fncf n36V4ClWa4mnqWvPwqu9C5R9l+CLLeaw2k3m3X5y4P/vuPmtXzYRw3buDb1UE3Ek3QjERH 0Q8U9U3dlLUXqnUtACNI10khWQkAeIhTCkkSjaedy5DBWByujgmRLkcZKQW46nZdctaql0 P7GOVgkNdrh1Oh3Nu3s2XgLrXKJIFC33izbbrJiAqAmNPj1pqicxedG4qqtezQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701084689; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jf9JetOvZH0lMfipFdKAeTki4Ool1/gZmRBNarGOB7Q=; b=rJkj7PCFMWccsTziuWRymWOZfgSPOY9et+RNvBVoJX/hdONTVqAbA4dd8lwnSyf+Owqmxh iN9mtNm39wDvSaCw== From: "tip-bot2 for Yazen Ghannam" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: ras/core] x86/mce/amd, EDAC/mce_amd: Move long names to decoder module Cc: Yazen Ghannam , "Borislav Petkov (AMD)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231118193248.1296798-5-yazen.ghannam@amd.com> References: <20231118193248.1296798-5-yazen.ghannam@amd.com> MIME-Version: 1.0 Message-ID: <170108468829.398.11053786865426002698.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the ras/core branch of tip: Commit-ID: ff03ff328fbd0a2b3a43e8b9bbc2a1d84265e77e Gitweb: https://git.kernel.org/tip/ff03ff328fbd0a2b3a43e8b9bbc2a1d84= 265e77e Author: Yazen Ghannam AuthorDate: Sat, 18 Nov 2023 13:32:32 -06:00 Committer: Borislav Petkov (AMD) CommitterDate: Mon, 27 Nov 2023 12:16:51 +01:00 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 Signed-off-by: Borislav Petkov (AMD) Link: https://lore.kernel.org/r/20231118193248.1296798-5-yazen.ghannam@amd.= com --- arch/x86/include/asm/mce.h | 1 +- arch/x86/kernel/cpu/mce/amd.c | 74 +++++++++++++--------------------- drivers/edac/mce_amd.c | 46 +++++++++++++++++++-- 3 files changed, 72 insertions(+), 49 deletions(-) diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h index 6de6e1d..4ad49af 100644 --- a/arch/x86/include/asm/mce.h +++ b/arch/x86/include/asm/mce.h @@ -333,7 +333,6 @@ enum smca_bank_types { N_SMCA_BANK_TYPES }; =20 -extern const char *smca_get_long_name(enum smca_bank_types t); extern bool amd_mce_is_memory_error(struct mce *m); =20 extern int mce_threshold_create_device(unsigned int cpu); diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index f3517b8..f6c6c1e 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -87,42 +87,37 @@ struct smca_bank { static DEFINE_PER_CPU_READ_MOSTLY(struct smca_bank[MAX_NR_BANKS], smca_ban= ks); static DEFINE_PER_CPU_READ_MOSTLY(u8[N_SMCA_BANK_TYPES], smca_bank_counts); =20 -struct smca_bank_name { - const char *name; /* Short name for sysfs */ - const char *long_name; /* Long name for pretty-printing */ -}; - -static struct smca_bank_name smca_names[] =3D { - [SMCA_LS ... SMCA_LS_V2] =3D { "load_store", "Load Store Unit" }, - [SMCA_IF] =3D { "insn_fetch", "Instruction Fetch Unit" }, - [SMCA_L2_CACHE] =3D { "l2_cache", "L2 Cache" }, - [SMCA_DE] =3D { "decode_unit", "Decode Unit" }, - [SMCA_RESERVED] =3D { "reserved", "Reserved" }, - [SMCA_EX] =3D { "execution_unit", "Execution Unit" }, - [SMCA_FP] =3D { "floating_point", "Floating Point Unit" }, - [SMCA_L3_CACHE] =3D { "l3_cache", "L3 Cache" }, - [SMCA_CS ... SMCA_CS_V2] =3D { "coherent_slave", "Coherent Slave" }, - [SMCA_PIE] =3D { "pie", "Power, Interrupts, etc." }, +static const char * const smca_names[] =3D { + [SMCA_LS ... SMCA_LS_V2] =3D "load_store", + [SMCA_IF] =3D "insn_fetch", + [SMCA_L2_CACHE] =3D "l2_cache", + [SMCA_DE] =3D "decode_unit", + [SMCA_RESERVED] =3D "reserved", + [SMCA_EX] =3D "execution_unit", + [SMCA_FP] =3D "floating_point", + [SMCA_L3_CACHE] =3D "l3_cache", + [SMCA_CS ... SMCA_CS_V2] =3D "coherent_slave", + [SMCA_PIE] =3D "pie", =20 /* UMC v2 is separate because both of them can exist in a single system. = */ - [SMCA_UMC] =3D { "umc", "Unified Memory Controller" }, - [SMCA_UMC_V2] =3D { "umc_v2", "Unified Memory Controller v2" }, - [SMCA_PB] =3D { "param_block", "Parameter Block" }, - [SMCA_PSP ... SMCA_PSP_V2] =3D { "psp", "Platform Security Processor" }, - [SMCA_SMU ... SMCA_SMU_V2] =3D { "smu", "System Management Unit" }, - [SMCA_MP5] =3D { "mp5", "Microprocessor 5 Unit" }, - [SMCA_MPDMA] =3D { "mpdma", "MPDMA Unit" }, - [SMCA_NBIO] =3D { "nbio", "Northbridge IO Unit" }, - [SMCA_PCIE ... SMCA_PCIE_V2] =3D { "pcie", "PCI Express Unit" }, - [SMCA_XGMI_PCS] =3D { "xgmi_pcs", "Ext Global Memory Interconnect PCS = Unit" }, - [SMCA_NBIF] =3D { "nbif", "NBIF Unit" }, - [SMCA_SHUB] =3D { "shub", "System Hub Unit" }, - [SMCA_SATA] =3D { "sata", "SATA Unit" }, - [SMCA_USB] =3D { "usb", "USB Unit" }, - [SMCA_GMI_PCS] =3D { "gmi_pcs", "Global Memory Interconnect PCS Unit" = }, - [SMCA_XGMI_PHY] =3D { "xgmi_phy", "Ext Global Memory Interconnect PHY = Unit" }, - [SMCA_WAFL_PHY] =3D { "wafl_phy", "WAFL PHY Unit" }, - [SMCA_GMI_PHY] =3D { "gmi_phy", "Global Memory Interconnect PHY Unit" = }, + [SMCA_UMC] =3D "umc", + [SMCA_UMC_V2] =3D "umc_v2", + [SMCA_PB] =3D "param_block", + [SMCA_PSP ... SMCA_PSP_V2] =3D "psp", + [SMCA_SMU ... SMCA_SMU_V2] =3D "smu", + [SMCA_MP5] =3D "mp5", + [SMCA_MPDMA] =3D "mpdma", + [SMCA_NBIO] =3D "nbio", + [SMCA_PCIE ... SMCA_PCIE_V2] =3D "pcie", + [SMCA_XGMI_PCS] =3D "xgmi_pcs", + [SMCA_NBIF] =3D "nbif", + [SMCA_SHUB] =3D "shub", + [SMCA_SATA] =3D "sata", + [SMCA_USB] =3D "usb", + [SMCA_GMI_PCS] =3D "gmi_pcs", + [SMCA_XGMI_PHY] =3D "xgmi_phy", + [SMCA_WAFL_PHY] =3D "wafl_phy", + [SMCA_GMI_PHY] =3D "gmi_phy", }; =20 static const char *smca_get_name(enum smca_bank_types t) @@ -130,17 +125,8 @@ static const char *smca_get_name(enum smca_bank_types = t) if (t >=3D N_SMCA_BANK_TYPES) return NULL; =20 - return smca_names[t].name; -} - -const char *smca_get_long_name(enum smca_bank_types t) -{ - if (t >=3D N_SMCA_BANK_TYPES) - return NULL; - - return smca_names[t].long_name; + return smca_names[t]; } -EXPORT_SYMBOL_GPL(smca_get_long_name); =20 enum smca_bank_types smca_get_bank_type(unsigned int cpu, unsigned int ban= k) { diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c index 9215c06..28363eb 100644 --- a/drivers/edac/mce_amd.c +++ b/drivers/edac/mce_amd.c @@ -1163,11 +1163,51 @@ static void decode_mc6_mce(struct mce *m) pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n"); } =20 +static const char * const smca_long_names[] =3D { + [SMCA_LS ... SMCA_LS_V2] =3D "Load Store Unit", + [SMCA_IF] =3D "Instruction Fetch Unit", + [SMCA_L2_CACHE] =3D "L2 Cache", + [SMCA_DE] =3D "Decode Unit", + [SMCA_RESERVED] =3D "Reserved", + [SMCA_EX] =3D "Execution Unit", + [SMCA_FP] =3D "Floating Point Unit", + [SMCA_L3_CACHE] =3D "L3 Cache", + [SMCA_CS ... SMCA_CS_V2] =3D "Coherent Slave", + [SMCA_PIE] =3D "Power, Interrupts, etc.", + + /* UMC v2 is separate because both of them can exist in a single system. = */ + [SMCA_UMC] =3D "Unified Memory Controller", + [SMCA_UMC_V2] =3D "Unified Memory Controller v2", + [SMCA_PB] =3D "Parameter Block", + [SMCA_PSP ... SMCA_PSP_V2] =3D "Platform Security Processor", + [SMCA_SMU ... SMCA_SMU_V2] =3D "System Management Unit", + [SMCA_MP5] =3D "Microprocessor 5 Unit", + [SMCA_MPDMA] =3D "MPDMA Unit", + [SMCA_NBIO] =3D "Northbridge IO Unit", + [SMCA_PCIE ... SMCA_PCIE_V2] =3D "PCI Express Unit", + [SMCA_XGMI_PCS] =3D "Ext Global Memory Interconnect PCS Unit", + [SMCA_NBIF] =3D "NBIF Unit", + [SMCA_SHUB] =3D "System Hub Unit", + [SMCA_SATA] =3D "SATA Unit", + [SMCA_USB] =3D "USB Unit", + [SMCA_GMI_PCS] =3D "Global Memory Interconnect PCS Unit", + [SMCA_XGMI_PHY] =3D "Ext Global Memory Interconnect PHY Unit", + [SMCA_WAFL_PHY] =3D "WAFL PHY Unit", + [SMCA_GMI_PHY] =3D "Global Memory Interconnect PHY Unit", +}; + +static const char *smca_get_long_name(enum smca_bank_types t) +{ + if (t >=3D N_SMCA_BANK_TYPES) + return NULL; + + return smca_long_names[t]; +} + /* Decode errors according to Scalable MCA specification */ static void decode_smca_error(struct mce *m) { enum smca_bank_types bank_type =3D smca_get_bank_type(m->extcpu, m->bank); - const char *ip_name; u8 xec =3D XEC(m->status, xec_mask); =20 if (bank_type >=3D N_SMCA_BANK_TYPES) @@ -1178,9 +1218,7 @@ static void decode_smca_error(struct mce *m) return; } =20 - ip_name =3D smca_get_long_name(bank_type); - - pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec); + pr_emerg(HW_ERR "%s Ext. Error Code: %d", smca_get_long_name(bank_type), = xec); =20 /* Only print the decode of valid error codes */ if (xec < smca_mce_descs[bank_type].num_descs)