From: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
To: <tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
<tony.luck@intel.com>, <linux-kernel@vger.kernel.org>,
<linux-edac@vger.kernel.org>, <qiuxu.zhuo@intel.com>
Cc: <CobeChen@zhaoxin.com>, <TimGuo@zhaoxin.com>,
<LeoLiu-oc@zhaoxin.com>, Lyle Li <LyleLi@zhaoxin.com>
Subject: [PATCH v5 3/4] x86/mce: Add zhaoxin.c to support Zhaoxin MCA
Date: Mon, 14 Oct 2024 15:53:17 +0800 [thread overview]
Message-ID: <20241014075318.1936-4-TonyWWang-oc@zhaoxin.com> (raw)
In-Reply-To: <20241014075318.1936-1-TonyWWang-oc@zhaoxin.com>
From: Lyle Li <LyleLi@zhaoxin.com>
For the sake of code standardization, add zhaoxin.c to
override the Zhaoxin MCA code.
Signed-off-by: Lyle Li <LyleLi@zhaoxin.com>
Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
---
arch/x86/Kconfig | 8 ++++
arch/x86/kernel/cpu/mce/Makefile | 1 +
arch/x86/kernel/cpu/mce/core.c | 57 --------------------------
arch/x86/kernel/cpu/mce/internal.h | 7 ++++
arch/x86/kernel/cpu/mce/zhaoxin.c | 64 ++++++++++++++++++++++++++++++
5 files changed, 80 insertions(+), 57 deletions(-)
create mode 100644 arch/x86/kernel/cpu/mce/zhaoxin.c
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 1ea18662942c..a7993835f460 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1183,6 +1183,14 @@ config X86_MCE_INTEL
Additional support for intel specific MCE features such as
the thermal monitor.
+config X86_MCE_ZHAOXIN
+ def_bool y
+ prompt "Zhaoxin MCE features"
+ depends on X86_MCE_INTEL
+ help
+ Additional support for Zhaoxin specific MCE features such as
+ the corrected machine check interrupt.
+
config X86_MCE_AMD
def_bool y
prompt "AMD MCE features"
diff --git a/arch/x86/kernel/cpu/mce/Makefile b/arch/x86/kernel/cpu/mce/Makefile
index 015856abdbb1..7b52c8f2f08e 100644
--- a/arch/x86/kernel/cpu/mce/Makefile
+++ b/arch/x86/kernel/cpu/mce/Makefile
@@ -4,6 +4,7 @@ obj-y = core.o severity.o genpool.o
obj-$(CONFIG_X86_ANCIENT_MCE) += winchip.o p5.o
obj-$(CONFIG_X86_MCE_INTEL) += intel.o
obj-$(CONFIG_X86_MCE_AMD) += amd.o
+obj-$(CONFIG_X86_MCE_ZHAOXIN) += zhaoxin.o
obj-$(CONFIG_X86_MCE_THRESHOLD) += threshold.o
mce-inject-y := inject.o
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index f71b33b96b5b..a1684b73b349 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -1970,17 +1970,6 @@ static int __mcheck_cpu_apply_quirks(struct cpuinfo_x86 *c)
mce_flags.skx_repmov_quirk = 1;
}
- if (c->x86_vendor == X86_VENDOR_ZHAOXIN) {
- /*
- * All newer Zhaoxin CPUs support MCE broadcasting. Enable
- * synchronization with a one second timeout.
- */
- if (c->x86 > 6 || (c->x86_model == 0x19 || c->x86_model == 0x1f)) {
- if (cfg->monarch_timeout < 0)
- cfg->monarch_timeout = USEC_PER_SEC;
- }
- }
-
if (cfg->monarch_timeout < 0)
cfg->monarch_timeout = 0;
if (cfg->bootlog != 0)
@@ -2023,49 +2012,6 @@ static void __mcheck_cpu_init_early(struct cpuinfo_x86 *c)
}
}
-static void mce_centaur_feature_init(struct cpuinfo_x86 *c)
-{
- struct mca_config *cfg = &mca_cfg;
-
- /*
- * All newer Centaur CPUs support MCE broadcasting. Enable
- * synchronization with a one second timeout.
- */
- if ((c->x86 == 6 && c->x86_model == 0xf && c->x86_stepping >= 0xe) ||
- c->x86 > 6) {
- if (cfg->monarch_timeout < 0)
- cfg->monarch_timeout = USEC_PER_SEC;
- }
-}
-
-static void mce_zhaoxin_feature_init(struct cpuinfo_x86 *c)
-{
- struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array);
-
- /*
- * These CPUs have MCA bank 8 which reports only one error type called
- * SVAD (System View Address Decoder). The reporting of that error is
- * controlled by IA32_MC8.CTL.0.
- *
- * If enabled, prefetching on these CPUs will cause SVAD MCE when
- * virtual machines start and result in a system panic. Always disable
- * bank 8 SVAD error by default.
- */
- if ((c->x86 == 7 && c->x86_model == 0x1b) ||
- (c->x86_model == 0x19 || c->x86_model == 0x1f)) {
- if (this_cpu_read(mce_num_banks) > 8)
- mce_banks[8].ctl = 0;
- }
-
- intel_init_cmci();
- intel_init_lmce();
-}
-
-static void mce_zhaoxin_feature_clear(struct cpuinfo_x86 *c)
-{
- intel_clear_lmce();
-}
-
static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
{
switch (c->x86_vendor) {
@@ -2083,9 +2029,6 @@ static void __mcheck_cpu_init_vendor(struct cpuinfo_x86 *c)
break;
case X86_VENDOR_CENTAUR:
- mce_centaur_feature_init(c);
- break;
-
case X86_VENDOR_ZHAOXIN:
mce_zhaoxin_feature_init(c);
break;
diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h
index 43c7f3b71df5..fb9d8b5b3b75 100644
--- a/arch/x86/kernel/cpu/mce/internal.h
+++ b/arch/x86/kernel/cpu/mce/internal.h
@@ -336,4 +336,11 @@ static __always_inline u32 mca_msr_reg(int bank, enum mca_msr reg)
}
extern void (*mc_poll_banks)(void);
+#ifdef CONFIG_X86_MCE_ZHAOXIN
+void mce_zhaoxin_feature_init(struct cpuinfo_x86 *c);
+void mce_zhaoxin_feature_clear(struct cpuinfo_x86 *c);
+#else
+static inline void mce_zhaoxin_feature_init(struct cpuinfo_x86 *c) { }
+static inline void mce_zhaoxin_feature_clear(struct cpuinfo_x86 *c) { }
+#endif
#endif /* __X86_MCE_INTERNAL_H__ */
diff --git a/arch/x86/kernel/cpu/mce/zhaoxin.c b/arch/x86/kernel/cpu/mce/zhaoxin.c
new file mode 100644
index 000000000000..6fdef2d24f31
--- /dev/null
+++ b/arch/x86/kernel/cpu/mce/zhaoxin.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Zhaoxin specific MCE features
+ * Author: Lyle Li
+ */
+#include <asm/msr.h>
+#include "internal.h"
+
+static void mce_zhaoxin_apply_mce_broadcast(struct cpuinfo_x86 *c)
+{
+ struct mca_config *cfg = &mca_cfg;
+
+ /* Older CPUs do not do MCE broadcast: */
+ if (c->x86 < 6)
+ return;
+
+ /* All newer ones do: */
+ if (c->x86 > 6)
+ goto mce_broadcast;
+
+ /* Family 6 is mixed: */
+ if (c->x86_vendor == X86_VENDOR_CENTAUR) {
+ if (c->x86_model == 0xf && c->x86_stepping >= 0xe)
+ goto mce_broadcast;
+ } else if (c->x86_vendor == X86_VENDOR_ZHAOXIN) {
+ if (c->x86_model == 0x19 || c->x86_model == 0x1f)
+ goto mce_broadcast;
+ }
+
+ return;
+
+mce_broadcast:
+ if (cfg->monarch_timeout <= 0)
+ cfg->monarch_timeout = USEC_PER_SEC;
+}
+
+void mce_zhaoxin_feature_init(struct cpuinfo_x86 *c)
+{
+ struct mce_bank *mce_banks = this_cpu_ptr(mce_banks_array);
+
+ /*
+ * These CPUs have MCA bank 8 which reports only one error type called
+ * SVAD (System View Address Decoder). The reporting of that error is
+ * controlled by IA32_MC8.CTL.0.
+ *
+ * If enabled, prefetching on these CPUs will cause SVAD MCE when
+ * virtual machines start and result in a system panic. Always disable
+ * bank 8 SVAD error by default.
+ */
+ if ((c->x86 == 7 && c->x86_model == 0x1b) ||
+ (c->x86_model == 0x19 || c->x86_model == 0x1f)) {
+ if (this_cpu_read(mce_num_banks) > 8)
+ mce_banks[8].ctl = 0;
+ }
+
+ mce_zhaoxin_apply_mce_broadcast(c);
+ intel_init_cmci();
+ intel_init_lmce();
+}
+
+void mce_zhaoxin_feature_clear(struct cpuinfo_x86 *c)
+{
+ intel_clear_lmce();
+}
--
2.34.1
next prev parent reply other threads:[~2024-10-14 8:09 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2024090910439.3349-1-TonyWWang-oc@zhaoxin.com>
2024-09-10 9:26 ` [PATCH v2 0/3] x86/mce: Add Zhaoxin MCE support Tony W Wang-oc
2024-09-10 9:26 ` [PATCH v2 1/3] x86/mce: Add centaur vendor to support Zhaoxin MCA Tony W Wang-oc
2024-09-10 9:26 ` [PATCH v2 2/3] x86/mce: Add zhaoxin.c " Tony W Wang-oc
2024-09-10 9:26 ` [PATCH v2 3/3] x86/mce: Add CMCI storm switching support for Zhaoxin Tony W Wang-oc
2024-09-18 5:54 ` [PATCH v3 0/3] x86/mce: Add Zhaoxin MCE support Tony W Wang-oc
2024-09-18 5:54 ` [PATCH v3 1/3] x86/mce: Add centaur vendor to support Zhaoxin MCA Tony W Wang-oc
2024-09-19 13:55 ` Yazen Ghannam
2024-09-20 10:41 ` Tony W Wang-oc
2024-09-18 5:54 ` [PATCH v3 2/3] x86/mce: Add zhaoxin.c " Tony W Wang-oc
2024-09-18 5:54 ` [PATCH v3 3/3] x86/mce: Add CMCI storm switching support for Zhaoxin Tony W Wang-oc
2024-09-19 14:06 ` Yazen Ghannam
2024-09-20 10:42 ` Tony W Wang-oc
2024-09-20 13:23 ` Yazen Ghannam
2024-09-20 9:17 ` Zhuo, Qiuxu
2024-09-20 10:42 ` Tony W Wang-oc
2024-09-20 11:44 ` Zhuo, Qiuxu
2024-09-20 13:36 ` Yazen Ghannam
2024-09-21 5:39 ` Zhuo, Qiuxu
[not found] ` <acf35354-ab97-4441-828f-daf7affa20ac@zhaoxin.com>
2024-09-23 3:23 ` Tony W Wang-oc
2024-09-23 7:33 ` [PATCH v4 0/4] x86/mce: Add Zhaoxin MCE support and remove Tony W Wang-oc
2024-09-23 7:33 ` [PATCH v4 1/4] x86/mce: Add centaur vendor to support Zhaoxin MCA Tony W Wang-oc
2024-10-12 3:34 ` Zhuo, Qiuxu
2024-09-23 7:33 ` [PATCH v4 2/4] x86/mce: Remove functions that disable error reporting Tony W Wang-oc
2024-10-12 5:37 ` Zhuo, Qiuxu
2024-09-23 7:33 ` [PATCH v4 3/4] x86/mce: Add zhaoxin.c to support Zhaoxin MCA Tony W Wang-oc
2024-10-12 6:41 ` Zhuo, Qiuxu
2024-10-12 9:06 ` Tony W Wang-oc
2024-10-12 11:27 ` Zhuo, Qiuxu
2024-09-23 7:33 ` [PATCH v4 4/4] x86/mce: Add CMCI storm switching support for Zhaoxin Tony W Wang-oc
2024-10-12 7:13 ` Zhuo, Qiuxu
2024-10-12 7:56 ` Tony W Wang-oc
2024-10-14 7:53 ` [PATCH v5 0/4] x86/mce: Add Zhaoxin MCE support and remove functions that disable error reporting Tony W Wang-oc
2024-10-14 7:53 ` [PATCH v5 1/4] x86/mce: Add Centaur vendor to support Zhaoxin MCA Tony W Wang-oc
2024-10-14 7:53 ` [PATCH v5 2/4] x86/mce: Remove functions that disable error reporting Tony W Wang-oc
2024-10-14 7:53 ` Tony W Wang-oc [this message]
2024-10-14 7:53 ` [PATCH v5 4/4] x86/mce: Add CMCI storm switching support for Zhaoxin Tony W Wang-oc
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=20241014075318.1936-4-TonyWWang-oc@zhaoxin.com \
--to=tonywwang-oc@zhaoxin.com \
--cc=CobeChen@zhaoxin.com \
--cc=LeoLiu-oc@zhaoxin.com \
--cc=LyleLi@zhaoxin.com \
--cc=TimGuo@zhaoxin.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=qiuxu.zhuo@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.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