linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: <linux-edac@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <tony.luck@intel.com>,
	<x86@kernel.org>, <Smita.KoralahalliChannabasappa@amd.com>,
	<mukul.joshi@amd.com>, <alexander.deucher@amd.com>,
	<william.roche@oracle.com>, Yazen Ghannam <yazen.ghannam@amd.com>
Subject: [PATCH 1/3] x86/MCE/AMD: Provide an "Unknown" MCA bank type
Date: Fri, 3 Dec 2021 02:00:15 +0000	[thread overview]
Message-ID: <20211203020017.728440-2-yazen.ghannam@amd.com> (raw)
In-Reply-To: <20211203020017.728440-1-yazen.ghannam@amd.com>

The AMD MCA Thresholding sysfs interface populates directories for each
bank and thresholding block. The name used for each directory is looked
up in a table of known bank types. However, new bank types won't match
in this list and will return NULL for the name. This will cause the
machinecheck sysfs interface to fail to be populated.

Set new and unknown MCA bank types to the "unknown" type. Also,
ensure that the bank's thresholding block directories have unique names.
This will ensure that the machinecheck sysfs interface can be
initialized.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 arch/x86/include/asm/mce.h    |  1 +
 arch/x86/kernel/cpu/mce/amd.c | 34 ++++++++++++++++++++++++++++------
 drivers/edac/mce_amd.c        |  3 +++
 3 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index d58f4f2e006f..7c1c35909946 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -319,6 +319,7 @@ enum smca_bank_types {
 	SMCA_XGMI_PCS,	/* xGMI PCS Unit */
 	SMCA_XGMI_PHY,	/* xGMI PHY Unit */
 	SMCA_WAFL_PHY,	/* WAFL PHY Unit */
+	SMCA_UNKNOWN,	/* Unknown type */
 	N_SMCA_BANK_TYPES
 };
 
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 2f351838d5f7..b9a5a94914a9 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -100,6 +100,7 @@ static struct smca_bank_name smca_names[] = {
 	[SMCA_XGMI_PCS]			= { "xgmi_pcs",		"Ext Global Memory Interconnect PCS Unit" },
 	[SMCA_XGMI_PHY]			= { "xgmi_phy",		"Ext Global Memory Interconnect PHY Unit" },
 	[SMCA_WAFL_PHY]			= { "wafl_phy",		"WAFL PHY Unit" },
+	[SMCA_UNKNOWN]			= { "unknown",		"Unrecognized Bank Type" },
 };
 
 static const char *smca_get_name(enum smca_bank_types t)
@@ -189,6 +190,9 @@ static struct smca_hwid smca_hwid_mcatypes[] = {
 
 	/* WAFL PHY MCA type */
 	{ SMCA_WAFL_PHY, HWID_MCATYPE(0x267, 0x0)	},
+
+	/* Unknown type - this must be last in the list */
+	{ SMCA_UNKNOWN,  HWID_MCATYPE(0xFFF, 0xFFFF)	},
 };
 
 struct smca_bank smca_banks[MAX_NR_BANKS];
@@ -300,7 +304,9 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
 
 	for (i = 0; i < ARRAY_SIZE(smca_hwid_mcatypes); i++) {
 		s_hwid = &smca_hwid_mcatypes[i];
-		if (hwid_mcatype == s_hwid->hwid_mcatype) {
+
+		if (hwid_mcatype == s_hwid->hwid_mcatype ||
+		    s_hwid->bank_type == SMCA_UNKNOWN) {
 			smca_banks[bank].hwid = s_hwid;
 			smca_banks[bank].id = low;
 			smca_banks[bank].sysfs_id = s_hwid->count++;
@@ -1032,12 +1038,28 @@ static const char *get_name(unsigned int bank, struct threshold_block *b)
 		return NULL;
 	}
 
-	if (smca_banks[bank].hwid->count == 1)
-		return smca_get_name(bank_type);
+	if (smca_banks[bank].hwid->count == 1) {
+		if (bank_type == SMCA_UNKNOWN) {
+			snprintf(buf_mcatype, MAX_MCATYPE_NAME_LEN,
+				 "%s_%x", smca_get_name(bank_type),
+					  smca_banks[bank].id);
+
+			return buf_mcatype;
+		} else {
+			return smca_get_name(bank_type);
+		}
+	}
+
+	if (b && bank_type == SMCA_UNKNOWN) {
+		snprintf(buf_mcatype, MAX_MCATYPE_NAME_LEN,
+			 "%s_%x_block_%u", smca_get_name(bank_type),
+			 smca_banks[bank].id, b->block);
+	} else {
+		snprintf(buf_mcatype, MAX_MCATYPE_NAME_LEN,
+			 "%s_%u", smca_get_name(bank_type),
+				  smca_banks[bank].sysfs_id);
+	}
 
-	snprintf(buf_mcatype, MAX_MCATYPE_NAME_LEN,
-		 "%s_%x", smca_get_name(bank_type),
-			  smca_banks[bank].sysfs_id);
 	return buf_mcatype;
 }
 
diff --git a/drivers/edac/mce_amd.c b/drivers/edac/mce_amd.c
index 67dbf4c31271..5ccc09db0a51 100644
--- a/drivers/edac/mce_amd.c
+++ b/drivers/edac/mce_amd.c
@@ -1068,6 +1068,9 @@ static void decode_smca_error(struct mce *m)
 
 	pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec);
 
+	if (bank_type == SMCA_UNKNOWN)
+		return;
+
 	/* Only print the decode of valid error codes */
 	if (xec < smca_mce_descs[bank_type].num_descs)
 		pr_cont(", %s.\n", smca_mce_descs[bank_type].descs[xec]);
-- 
2.25.1


  reply	other threads:[~2021-12-03  2:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03  2:00 [PATCH 0/3] AMD SMCA Updates Yazen Ghannam
2021-12-03  2:00 ` Yazen Ghannam [this message]
2021-12-03 22:17   ` [PATCH 1/3] x86/MCE/AMD: Provide an "Unknown" MCA bank type Borislav Petkov
2021-12-07 16:28     ` Yazen Ghannam
2021-12-11 15:39       ` Borislav Petkov
2021-12-03  2:00 ` [PATCH 2/3] x86/MCE/AMD, EDAC/mce_amd: Add new SMCA Bank Types Yazen Ghannam
2021-12-03  2:00 ` [PATCH 3/3] x86/MCE/AMD, EDAC/mce_amd: Support non-uniform MCA bank type enumeration Yazen Ghannam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211203020017.728440-2-yazen.ghannam@amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=Smita.KoralahalliChannabasappa@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mukul.joshi@amd.com \
    --cc=tony.luck@intel.com \
    --cc=william.roche@oracle.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).