From: Ganesh Goudar <ganeshgr@linux.ibm.com>
To: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org
Cc: mahesh@linux.vnet.ibm.com, Ganesh Goudar <ganeshgr@linux.ibm.com>
Subject: [PATCH 1/2] powerpc/mce: Add helper functions to remove duplicate code
Date: Mon, 27 Apr 2020 11:43:07 +0530 [thread overview]
Message-ID: <20200427061308.26204-1-ganeshgr@linux.ibm.com> (raw)
mce_handle_ierror() and mce_handle_derror() has some duplicate
code to recover from the recoverable MCE errors and to get the
MCE error sub-type while generating MCE error info, Add helper
functions to remove it.
Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
---
arch/powerpc/kernel/mce_power.c | 136 +++++++++++++-------------------
1 file changed, 56 insertions(+), 80 deletions(-)
diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
index 067b094bfeff..143e79450e93 100644
--- a/arch/powerpc/kernel/mce_power.c
+++ b/arch/powerpc/kernel/mce_power.c
@@ -391,6 +391,56 @@ static int mce_find_instr_ea_and_phys(struct pt_regs *regs, uint64_t *addr,
return -1;
}
+static int mce_correct_err(unsigned int err_type)
+{
+ int handled = 0;
+
+ /* attempt to correct the error */
+ switch (err_type) {
+ case MCE_ERROR_TYPE_SLB:
+ if (local_paca->in_mce == 1)
+ slb_save_contents(local_paca->mce_faulty_slbs);
+ handled = mce_flush(MCE_FLUSH_SLB);
+ break;
+ case MCE_ERROR_TYPE_ERAT:
+ handled = mce_flush(MCE_FLUSH_ERAT);
+ break;
+ case MCE_ERROR_TYPE_TLB:
+ handled = mce_flush(MCE_FLUSH_TLB);
+ break;
+ }
+ return handled;
+}
+
+static void mce_err_get_sub_type(struct mce_error_info *mce_err,
+ unsigned int err_type,
+ unsigned int err_sub_type)
+{
+ switch (err_type) {
+ case MCE_ERROR_TYPE_UE:
+ mce_err->u.ue_error_type = err_sub_type;
+ break;
+ case MCE_ERROR_TYPE_SLB:
+ mce_err->u.slb_error_type = err_sub_type;
+ break;
+ case MCE_ERROR_TYPE_ERAT:
+ mce_err->u.erat_error_type = err_sub_type;
+ break;
+ case MCE_ERROR_TYPE_TLB:
+ mce_err->u.tlb_error_type = err_sub_type;
+ break;
+ case MCE_ERROR_TYPE_USER:
+ mce_err->u.user_error_type = err_sub_type;
+ break;
+ case MCE_ERROR_TYPE_RA:
+ mce_err->u.ra_error_type = err_sub_type;
+ break;
+ case MCE_ERROR_TYPE_LINK:
+ mce_err->u.link_error_type = err_sub_type;
+ break;
+ }
+}
+
static int mce_handle_ierror(struct pt_regs *regs,
const struct mce_ierror_table table[],
struct mce_error_info *mce_err, uint64_t *addr,
@@ -405,48 +455,13 @@ static int mce_handle_ierror(struct pt_regs *regs,
for (i = 0; table[i].srr1_mask; i++) {
if ((srr1 & table[i].srr1_mask) != table[i].srr1_value)
continue;
-
- /* attempt to correct the error */
- switch (table[i].error_type) {
- case MCE_ERROR_TYPE_SLB:
- if (local_paca->in_mce == 1)
- slb_save_contents(local_paca->mce_faulty_slbs);
- handled = mce_flush(MCE_FLUSH_SLB);
- break;
- case MCE_ERROR_TYPE_ERAT:
- handled = mce_flush(MCE_FLUSH_ERAT);
- break;
- case MCE_ERROR_TYPE_TLB:
- handled = mce_flush(MCE_FLUSH_TLB);
- break;
- }
+ handled = mce_correct_err(table[i].error_type);
/* now fill in mce_error_info */
mce_err->error_type = table[i].error_type;
mce_err->error_class = table[i].error_class;
- switch (table[i].error_type) {
- case MCE_ERROR_TYPE_UE:
- mce_err->u.ue_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_SLB:
- mce_err->u.slb_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_ERAT:
- mce_err->u.erat_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_TLB:
- mce_err->u.tlb_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_USER:
- mce_err->u.user_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_RA:
- mce_err->u.ra_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_LINK:
- mce_err->u.link_error_type = table[i].error_subtype;
- break;
- }
+ mce_err_get_sub_type(mce_err, table[i].error_type,
+ table[i].error_subtype);
mce_err->sync_error = table[i].sync_error;
mce_err->severity = table[i].severity;
mce_err->initiator = table[i].initiator;
@@ -492,25 +507,7 @@ static int mce_handle_derror(struct pt_regs *regs,
for (i = 0; table[i].dsisr_value; i++) {
if (!(dsisr & table[i].dsisr_value))
continue;
-
- /* attempt to correct the error */
- switch (table[i].error_type) {
- case MCE_ERROR_TYPE_SLB:
- if (local_paca->in_mce == 1)
- slb_save_contents(local_paca->mce_faulty_slbs);
- if (mce_flush(MCE_FLUSH_SLB))
- handled = 1;
- break;
- case MCE_ERROR_TYPE_ERAT:
- if (mce_flush(MCE_FLUSH_ERAT))
- handled = 1;
- break;
- case MCE_ERROR_TYPE_TLB:
- if (mce_flush(MCE_FLUSH_TLB))
- handled = 1;
- break;
- }
-
+ handled = mce_correct_err(table[i].error_type);
/*
* Attempt to handle multiple conditions, but only return
* one. Ensure uncorrectable errors are first in the table
@@ -522,29 +519,8 @@ static int mce_handle_derror(struct pt_regs *regs,
/* now fill in mce_error_info */
mce_err->error_type = table[i].error_type;
mce_err->error_class = table[i].error_class;
- switch (table[i].error_type) {
- case MCE_ERROR_TYPE_UE:
- mce_err->u.ue_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_SLB:
- mce_err->u.slb_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_ERAT:
- mce_err->u.erat_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_TLB:
- mce_err->u.tlb_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_USER:
- mce_err->u.user_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_RA:
- mce_err->u.ra_error_type = table[i].error_subtype;
- break;
- case MCE_ERROR_TYPE_LINK:
- mce_err->u.link_error_type = table[i].error_subtype;
- break;
- }
+ mce_err_get_sub_type(mce_err, table[i].error_type,
+ table[i].error_subtype);
mce_err->sync_error = table[i].sync_error;
mce_err->severity = table[i].severity;
mce_err->initiator = table[i].initiator;
--
2.17.2
next reply other threads:[~2020-04-27 6:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 6:13 Ganesh Goudar [this message]
2020-04-27 6:13 ` [PATCH 2/2] powerpc/mce: Do not poison the memory using guest effective addr Ganesh Goudar
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=20200427061308.26204-1-ganeshgr@linux.ibm.com \
--to=ganeshgr@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mahesh@linux.vnet.ibm.com \
--cc=mpe@ellerman.id.au \
/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).