]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
powerpc/83xx: handle machine check caused by watchdog timer
authorChristophe Leroy <christophe.leroy@c-s.fr>
Mon, 10 Dec 2018 11:41:29 +0000 (11:41 +0000)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:21:35 +0000 (14:21 -0300)
BugLink: https://bugs.launchpad.net/bugs/1855787
[ Upstream commit 0deae39cec6dab3a66794f3e9e83ca4dc30080f1 ]

When the watchdog timer is set in interrupt mode, it causes a
machine check when it times out. The purpose of this mode is to
ease debugging, not to crash the kernel and reboot the machine.

This patch implements a special handling for that, in order to not
crash the kernel if the watchdog times out while in interrupt or
within the idle task.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
[scottwood: added missing #include]
Signed-off-by: Scott Wood <oss@buserror.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
arch/powerpc/include/asm/cputable.h
arch/powerpc/include/asm/reg.h
arch/powerpc/kernel/cputable.c
arch/powerpc/platforms/83xx/misc.c

index 1cc9e3355c7c18c5898cd37e99f74b0726316f30..23e8752f9d3e235878f182e0347c182d6c352a6f 100644 (file)
@@ -45,6 +45,7 @@ extern int machine_check_e500(struct pt_regs *regs);
 extern int machine_check_e200(struct pt_regs *regs);
 extern int machine_check_47x(struct pt_regs *regs);
 int machine_check_8xx(struct pt_regs *regs);
+int machine_check_83xx(struct pt_regs *regs);
 
 extern void cpu_down_flush_e500v2(void);
 extern void cpu_down_flush_e500mc(void);
index 33feef77aa16907bba98ef806e9d5a7e65159d3e..de27b172b9dd562ae721b4a13a85e1d3f61c03d1 100644 (file)
 #define   SRR1_PROGTRAP                0x00020000 /* Trap */
 #define   SRR1_PROGADDR                0x00010000 /* SRR0 contains subsequent addr */
 
+#define   SRR1_MCE_MCP         0x00080000 /* Machine check signal caused interrupt */
+
 #define SPRN_HSRR0     0x13A   /* Save/Restore Register 0 */
 #define SPRN_HSRR1     0x13B   /* Save/Restore Register 1 */
 #define   HSRR1_DENORM         0x00100000 /* Denorm exception */
index bc2b461e097a9795c2ed1b5bbf0841b9e43eebbd..e8981623e19a1fcd59320e7e7b58d4a6ae495cc4 100644 (file)
@@ -1224,6 +1224,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .machine_check          = machine_check_generic,
                .platform               = "ppc603",
        },
+#ifdef CONFIG_PPC_83xx
        {       /* e300c1 (a 603e core, plus some) on 83xx */
                .pvr_mask               = 0x7fff0000,
                .pvr_value              = 0x00830000,
@@ -1234,7 +1235,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .icache_bsize           = 32,
                .dcache_bsize           = 32,
                .cpu_setup              = __setup_cpu_603,
-               .machine_check          = machine_check_generic,
+               .machine_check          = machine_check_83xx,
                .platform               = "ppc603",
        },
        {       /* e300c2 (an e300c1 core, plus some, minus FPU) on 83xx */
@@ -1248,7 +1249,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .icache_bsize           = 32,
                .dcache_bsize           = 32,
                .cpu_setup              = __setup_cpu_603,
-               .machine_check          = machine_check_generic,
+               .machine_check          = machine_check_83xx,
                .platform               = "ppc603",
        },
        {       /* e300c3 (e300c1, plus one IU, half cache size) on 83xx */
@@ -1262,7 +1263,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .icache_bsize           = 32,
                .dcache_bsize           = 32,
                .cpu_setup              = __setup_cpu_603,
-               .machine_check          = machine_check_generic,
+               .machine_check          = machine_check_83xx,
                .num_pmcs               = 4,
                .oprofile_cpu_type      = "ppc/e300",
                .oprofile_type          = PPC_OPROFILE_FSL_EMB,
@@ -1279,12 +1280,13 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .icache_bsize           = 32,
                .dcache_bsize           = 32,
                .cpu_setup              = __setup_cpu_603,
-               .machine_check          = machine_check_generic,
+               .machine_check          = machine_check_83xx,
                .num_pmcs               = 4,
                .oprofile_cpu_type      = "ppc/e300",
                .oprofile_type          = PPC_OPROFILE_FSL_EMB,
                .platform               = "ppc603",
        },
+#endif
        {       /* default match, we assume split I/D cache & TB (non-601)... */
                .pvr_mask               = 0x00000000,
                .pvr_value              = 0x00000000,
index d75c9816a5c92ad4211d71568e90848ab7fc998a..2b6589fe812dde8746f847e129211802408f4408 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/of_platform.h>
 #include <linux/pci.h>
 
+#include <asm/debug.h>
 #include <asm/io.h>
 #include <asm/hw_irq.h>
 #include <asm/ipic.h>
@@ -150,3 +151,19 @@ void __init mpc83xx_setup_arch(void)
 
        mpc83xx_setup_pci();
 }
+
+int machine_check_83xx(struct pt_regs *regs)
+{
+       u32 mask = 1 << (31 - IPIC_MCP_WDT);
+
+       if (!(regs->msr & SRR1_MCE_MCP) || !(ipic_get_mcp_status() & mask))
+               return machine_check_generic(regs);
+       ipic_clear_mcp_status(mask);
+
+       if (debugger_fault_handler(regs))
+               return 1;
+
+       die("Watchdog NMI Reset", regs, 0);
+
+       return 1;
+}