From: Avadhut Naik <avadnaik@amd.com>
To: <linux-edac@vger.kernel.org>, <x86@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <bp@alien8.de>,
<tony.luck@intel.com>, <yazen.ghannam@amd.com>,
<avadnaik@amd.com>
Subject: [PATCH v1 2/3] x86/MCE/AMD: Add HWID Fixup for PCS_XGMI SMCA
Date: Mon, 16 Jan 2023 19:11:01 +0000 [thread overview]
Message-ID: <20230116191102.4226-3-avadnaik@amd.com> (raw)
In-Reply-To: <20230116191102.4226-1-avadnaik@amd.com>
On AMD systems, during Scalable MCA (SMCA) initialization, the HWID and
McaType tuple, read from MCA_IPID register of a SMCA bank type, is used
by the kernel for populating the per-CPU smca_banks array. This very array
is, in turn being utilized by the edac_mce_amd module for determining the
SMCA bank type while decoding a machine check error.
However, on some AMD CPUs, the HWID read from the MCA_IPID register
for XGMI Controller SMCA bank type does not match the value expected by
the kernel. Consequently, the smca_banks array is not populated for the
bank type resulting in the machine check errors on the bank type not being
decoded.
As a solution, set the HWID, obtained from the MCA_IPID register, of the
XGMI Controller SMCA bank type on affected CPUs, to the value expected by
the kernel to ensure that the machine check errors on the bank type are
correctly decoded.
Signed-off-by: Avadhut Naik <avadnaik@amd.com>
---
arch/x86/kernel/cpu/mce/amd.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 23c5072fbbb7..b0cce0ce056c 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -249,6 +249,30 @@ static void default_deferred_error_interrupt(void)
}
void (*deferred_error_int_vector)(void) = default_deferred_error_interrupt;
+/*
+ * Errata encountered on AMD CPUs for some SMCA bank types requires fixup
+ * of HWID, read from MCA_IPID register, for accurate SMCA error decoding.
+ */
+static inline void fixup_hwid(unsigned int *hwid_mcatype)
+{
+ struct cpuinfo_x86 *c = &boot_cpu_data;
+
+ if (c->x86 == 0x19) {
+ switch (c->x86_model) {
+ /*
+ * Handle discrepancy in HWID of kernel and MCA_IPID register
+ * for XGMI Controller SMCA bank type
+ */
+ case 0x30 ... 0x3F:
+ if (*hwid_mcatype == HWID_MCATYPE(0x80, 0x0))
+ *hwid_mcatype = HWID_MCATYPE(0x50, 0x0);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
static void smca_set_misc_banks_map(unsigned int bank, unsigned int cpu)
{
u32 low, high;
@@ -321,6 +345,8 @@ static void smca_configure(unsigned int bank, unsigned int cpu)
hwid_mcatype = HWID_MCATYPE(high & MCI_IPID_HWID,
(high & MCI_IPID_MCATYPE) >> 16);
+ fixup_hwid(&hwid_mcatype);
+
for (i = 0; i < ARRAY_SIZE(smca_hwid_mcatypes); i++) {
s_hwid = &smca_hwid_mcatypes[i];
--
2.34.1
next prev parent reply other threads:[~2023-01-16 19:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-16 19:10 [PATCH v1 0/3] Update SMCA Error Decoding for AMD EPYC Processors Avadhut Naik
2023-01-16 19:11 ` [PATCH v1 1/3] EDAC/mce_amd: Update SMCA bank error descriptions Avadhut Naik
2023-01-16 19:11 ` Avadhut Naik [this message]
2023-01-16 19:11 ` [PATCH v1 3/3] x86/MCE/AMD: Handle reassigned bit definitions for CS SMCA Avadhut Naik
2023-01-17 9:23 ` Ingo Molnar
2023-01-18 18:31 ` Yazen Ghannam
2023-02-07 19:07 ` Avadhut Naik
2023-03-17 14:33 ` 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=20230116191102.4226-3-avadnaik@amd.com \
--to=avadnaik@amd.com \
--cc=bp@alien8.de \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=yazen.ghannam@amd.com \
/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