From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
Michael Ellerman <mpe@ellerman.id.au>,
Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Subject: [PATCH 3/9] powerpc/64s: clean up machine check recovery flushing
Date: Tue, 21 Feb 2017 05:44:24 +1000 [thread overview]
Message-ID: <20170220194430.32602-4-npiggin@gmail.com> (raw)
In-Reply-To: <20170220194430.32602-1-npiggin@gmail.com>
Put the ifdefs into a flush handler call, and have callers ask for
particular type of flushes. Also add an ERAT flush type (although
existing ERAT flushing goes to the SLB flush path).
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/kernel/mce_power.c | 124 +++++++++++++++++++---------------------
1 file changed, 59 insertions(+), 65 deletions(-)
diff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c
index c37fc5fdd433..07af815b5ba1 100644
--- a/arch/powerpc/kernel/mce_power.c
+++ b/arch/powerpc/kernel/mce_power.c
@@ -114,83 +114,74 @@ static void flush_and_reload_slb(void)
asm volatile("slbmte %0,%1" : : "r" (rs), "r" (rb));
}
}
-#endif
-static long mce_handle_derror(uint64_t dsisr, uint64_t slb_error_bits)
+static void flush_erat(void)
{
- long handled = 1;
+ asm volatile(PPC_INVALIDATE_ERAT : : :"memory");
+}
+#endif
- /*
- * flush and reload SLBs for SLB errors and flush TLBs for TLB errors.
- * reset the error bits whenever we handle them so that at the end
- * we can check whether we handled all of them or not.
- * */
+#define MCE_FLUSH_SLB 1
+#define MCE_FLUSH_TLB 2
+#define MCE_FLUSH_ERAT 3
+
+static int mce_flush(int what)
+{
#ifdef CONFIG_PPC_STD_MMU_64
- if (dsisr & slb_error_bits) {
+ if (what == MCE_FLUSH_SLB) {
flush_and_reload_slb();
- /* reset error bits */
- dsisr &= ~(slb_error_bits);
+ return 1;
}
- if (dsisr & P7_DSISR_MC_TLB_MULTIHIT_MFTLB) {
- if (cur_cpu_spec && cur_cpu_spec->flush_tlb)
- cur_cpu_spec->flush_tlb(TLB_INVAL_SCOPE_GLOBAL);
- /* reset error bits */
- dsisr &= ~P7_DSISR_MC_TLB_MULTIHIT_MFTLB;
+ if (what == MCE_FLUSH_ERAT) {
+ flush_erat();
+ return 1;
}
#endif
- /* Any other errors we don't understand? */
- if (dsisr & 0xffffffffUL)
- handled = 0;
+ if (what == MCE_FLUSH_TLB) {
+ if (cur_cpu_spec && cur_cpu_spec->flush_tlb) {
+ cur_cpu_spec->flush_tlb(TLB_INVAL_SCOPE_GLOBAL);
+ return 1;
+ }
+ }
- return handled;
+ return 0;
}
-static long mce_handle_derror_p7(uint64_t dsisr)
+static int mce_handle_flush_derrors(uint64_t dsisr, uint64_t slb, uint64_t tlb, uint64_t erat)
{
- return mce_handle_derror(dsisr, P7_DSISR_MC_SLB_ERRORS);
+ if ((dsisr & slb) && mce_flush(MCE_FLUSH_SLB))
+ dsisr &= ~slb;
+ if ((dsisr & erat) && mce_flush(MCE_FLUSH_ERAT))
+ dsisr &= ~erat;
+ if ((dsisr & tlb) && mce_flush(MCE_FLUSH_TLB))
+ dsisr &= ~tlb;
+ /* Any other errors we don't understand? */
+ if (dsisr)
+ return 0;
+ return 1;
}
-static long mce_handle_common_ierror(uint64_t srr1)
+static long mce_handle_derror_p7(uint64_t dsisr)
{
- long handled = 0;
+ return mce_handle_flush_derrors(dsisr,
+ P7_DSISR_MC_SLB_ERRORS,
+ P7_DSISR_MC_TLB_MULTIHIT_MFTLB,
+ 0);
+}
+static long mce_handle_ierror_p7(uint64_t srr1)
+{
switch (P7_SRR1_MC_IFETCH(srr1)) {
- case 0:
- break;
-#ifdef CONFIG_PPC_STD_MMU_64
case P7_SRR1_MC_IFETCH_SLB_PARITY:
case P7_SRR1_MC_IFETCH_SLB_MULTIHIT:
- /* flush and reload SLBs for SLB errors. */
- flush_and_reload_slb();
- handled = 1;
- break;
+ case P7_SRR1_MC_IFETCH_SLB_BOTH:
+ return mce_flush(MCE_FLUSH_SLB);
+
case P7_SRR1_MC_IFETCH_TLB_MULTIHIT:
- if (cur_cpu_spec && cur_cpu_spec->flush_tlb) {
- cur_cpu_spec->flush_tlb(TLB_INVAL_SCOPE_GLOBAL);
- handled = 1;
- }
- break;
-#endif
+ return mce_flush(MCE_FLUSH_TLB);
default:
- break;
- }
-
- return handled;
-}
-
-static long mce_handle_ierror_p7(uint64_t srr1)
-{
- long handled = 0;
-
- handled = mce_handle_common_ierror(srr1);
-
-#ifdef CONFIG_PPC_STD_MMU_64
- if (P7_SRR1_MC_IFETCH(srr1) == P7_SRR1_MC_IFETCH_SLB_BOTH) {
- flush_and_reload_slb();
- handled = 1;
+ return 0;
}
-#endif
- return handled;
}
static void mce_get_common_ierror(struct mce_error_info *mce_err, uint64_t srr1)
@@ -331,22 +322,25 @@ static void mce_get_derror_p8(struct mce_error_info *mce_err, uint64_t dsisr)
static long mce_handle_ierror_p8(uint64_t srr1)
{
- long handled = 0;
-
- handled = mce_handle_common_ierror(srr1);
+ switch (P7_SRR1_MC_IFETCH(srr1)) {
+ case P7_SRR1_MC_IFETCH_SLB_PARITY:
+ case P7_SRR1_MC_IFETCH_SLB_MULTIHIT:
+ case P8_SRR1_MC_IFETCH_ERAT_MULTIHIT:
+ return mce_flush(MCE_FLUSH_SLB);
-#ifdef CONFIG_PPC_STD_MMU_64
- if (P7_SRR1_MC_IFETCH(srr1) == P8_SRR1_MC_IFETCH_ERAT_MULTIHIT) {
- flush_and_reload_slb();
- handled = 1;
+ case P7_SRR1_MC_IFETCH_TLB_MULTIHIT:
+ return mce_flush(MCE_FLUSH_TLB);
+ default:
+ return 0;
}
-#endif
- return handled;
}
static long mce_handle_derror_p8(uint64_t dsisr)
{
- return mce_handle_derror(dsisr, P8_DSISR_MC_SLB_ERRORS);
+ return mce_handle_flush_derrors(dsisr,
+ P8_DSISR_MC_SLB_ERRORS,
+ P7_DSISR_MC_TLB_MULTIHIT_MFTLB,
+ 0);
}
long __machine_check_early_realmode_p8(struct pt_regs *regs)
--
2.11.0
next prev parent reply other threads:[~2017-02-20 19:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 19:44 [PATCH 0/9] MCE handler for POWER9 Nicholas Piggin
2017-02-20 19:44 ` [PATCH 1/9] powerpc/64s: machine check print NIP Nicholas Piggin
2017-02-20 19:44 ` [PATCH 2/9] powerpc/64s: allow machine check handler to set severity and initiator Nicholas Piggin
2017-02-20 19:44 ` Nicholas Piggin [this message]
2017-02-20 19:44 ` [PATCH 4/9] powerpc/64s: cope with non-synchronous machine checks Nicholas Piggin
2017-02-20 19:44 ` [PATCH 5/9] powerpc/64s: POWER9 machine check handler Nicholas Piggin
2017-02-20 19:44 ` [PATCH 6/9] powerpc/64s: move POWER machine check defines into mce_power.c Nicholas Piggin
2017-02-20 19:44 ` [PATCH 7/9] powerpc/64s: data driven machine check evaluation Nicholas Piggin
2017-02-20 19:44 ` [PATCH 8/9] powerpc/64s: data driven machine check handling Nicholas Piggin
2017-02-20 19:44 ` [PATCH 9/9] powerpc/64s: POWER8 add missing machine check definitions Nicholas Piggin
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=20170220194430.32602-4-npiggin@gmail.com \
--to=npiggin@gmail.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).