From: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
To: <tglx@linutronix.de>, <mingo@redhat.com>, <hpa@zytor.com>,
<tony.luck@intel.com>, <bp@alien8.de>, <slaoub@gmail.com>,
<luto@amacapital.net>, <x86@kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-edac@vger.kernel.org>
Cc: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Subject: [PATCH V2 2/2] x86, mce, severities: Define mce_severity function pointer
Date: Fri, 20 Mar 2015 11:31:08 -0500 [thread overview]
Message-ID: <1426869068-4155-3-git-send-email-Aravind.Gopalakrishnan@amd.com> (raw)
In-Reply-To: <1426869068-4155-1-git-send-email-Aravind.Gopalakrishnan@amd.com>
Rename mce_severity() as mce_severity_intel and assign mce_severity
function pointer to either one of mce_severity_intel or
mce_severity_amd during init depending on which processor we are on.
This way, we can avoid a test to call mce_severity_amd every time we
get into mce_severity(). And it's cleaner to do it this way.
Suggested-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
---
arch/x86/include/asm/mce.h | 2 ++
arch/x86/kernel/cpu/mcheck/mce-internal.h | 3 ++-
arch/x86/kernel/cpu/mcheck/mce-severity.c | 35 ++++++++++++++++++++++++++-----
arch/x86/kernel/cpu/mcheck/mce.c | 1 +
4 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index b574fbf..1f5a86d 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -134,9 +134,11 @@ extern int mce_p5_enabled;
#ifdef CONFIG_X86_MCE
int mcheck_init(void);
void mcheck_cpu_init(struct cpuinfo_x86 *c);
+void mcheck_vendor_init_severity(void);
#else
static inline int mcheck_init(void) { return 0; }
static inline void mcheck_cpu_init(struct cpuinfo_x86 *c) {}
+static inline void mcheck_vendor_init_severity(void) {}
#endif
#ifdef CONFIG_X86_ANCIENT_MCE
diff --git a/arch/x86/kernel/cpu/mcheck/mce-internal.h b/arch/x86/kernel/cpu/mcheck/mce-internal.h
index e12f0bf..4758f5f 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-internal.h
+++ b/arch/x86/kernel/cpu/mcheck/mce-internal.h
@@ -24,7 +24,8 @@ struct mce_bank {
char attrname[ATTR_LEN]; /* attribute name */
};
-int mce_severity(struct mce *a, int tolerant, char **msg, bool is_excp);
+extern int (*mce_severity)(struct mce *a, int tolerant,
+ char **msg, bool is_excp);
struct dentry *mce_get_debugfs_dir(void);
extern struct mce_bank *mce_banks;
diff --git a/arch/x86/kernel/cpu/mcheck/mce-severity.c b/arch/x86/kernel/cpu/mcheck/mce-severity.c
index 4f8f87d..683a06f 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-severity.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-severity.c
@@ -187,7 +187,8 @@ static int error_context(struct mce *m)
}
/* keeping mce_severity_amd in sync with AMD error scope heirarchy table */
-static int mce_severity_amd(struct mce *m, enum context ctx)
+static int mce_severity_amd(struct mce *m, int tolerant,
+ char **msg, bool is_excp)
{
enum context ctx = error_context(m);
/* Processor Context Corrupt, no need to fumble too much, die! */
@@ -236,15 +237,13 @@ static int mce_severity_amd(struct mce *m, enum context ctx)
return MCE_KEEP_SEVERITY;
}
-int mce_severity(struct mce *m, int tolerant, char **msg, bool is_excp)
+static int mce_severity_intel(struct mce *m, int tolerant,
+ char **msg, bool is_excp)
{
enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP);
enum context ctx = error_context(m);
struct severity *s;
- if (m->cpuvendor == X86_VENDOR_AMD)
- return mce_severity_amd(m, ctx);
-
for (s = severities;; s++) {
if ((m->status & s->mask) != s->result)
continue;
@@ -269,6 +268,32 @@ int mce_severity(struct mce *m, int tolerant, char **msg, bool is_excp)
}
}
+static int mce_severity_default(struct mce *m, int tolerant,
+ char **msg, bool is_excp)
+{
+ return MCE_PANIC_SEVERITY;
+}
+
+int (*mce_severity)(struct mce *m, int tolerant, char **msg, bool is_excp) =
+ mce_severity_default;
+
+void __init mcheck_vendor_init_severity(void)
+{
+ struct cpuinfo_x86 *c = &boot_cpu_data;
+
+ switch (c->x86_vendor) {
+ case X86_VENDOR_INTEL:
+ mce_severity = mce_severity_intel;
+ break;
+ case X86_VENDOR_AMD:
+ mce_severity = mce_severity_amd;
+ break;
+ default:
+ WARN_ONCE(1, "WTF!?");
+ break;
+ }
+}
+
#ifdef CONFIG_DEBUG_FS
static void *s_start(struct seq_file *f, loff_t *pos)
{
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 680cfb2..f22e76f 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2030,6 +2030,7 @@ __setup("mce", mcheck_enable);
int __init mcheck_init(void)
{
mcheck_intel_therm_init();
+ mcheck_vendor_init_severity();
return 0;
}
--
1.9.1
next prev parent reply other threads:[~2015-03-20 22:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-20 16:31 [PATCH V2 0/2] Rework mce_severity Aravind Gopalakrishnan
2015-03-20 16:31 ` [PATCH V2 1/2] x86, mce, severities: Add AMD severities function Aravind Gopalakrishnan
2015-03-20 16:31 ` Aravind Gopalakrishnan [this message]
2015-03-20 22:31 ` [PATCH V2 2/2] x86, mce, severities: Define mce_severity function pointer Luck, Tony
2015-03-21 2:35 ` Aravind Gopalakrishnan
2015-03-21 6:10 ` Borislav Petkov
2015-03-23 14:20 ` Aravind Gopalakrishnan
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=1426869068-4155-3-git-send-email-Aravind.Gopalakrishnan@amd.com \
--to=aravind.gopalakrishnan@amd.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=slaoub@gmail.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
all inboxes | Powered by JetHome®