[PATCH] x86: MCE: Fix for mce_panic_timeout

Hidetoshi Seto
2009-05-27T04:31:42Z

This fixes:

- In case of panic_timeout == 0 and mce_bootlog != 0:
System should reboot after mce panic, but it doesn't because current
mce code doesn't overwrite small panic_timeout even if it is 0.

- In case of panic_timeout > 0 and mce_bootlog == 0.
System should reboot after panic, but it doesn't on mce panic because
current mce code overwrite panic_timeout to 0.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
arch/x86/kernel/cpu/mcheck/mce.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 0b87fb4..40fedb2 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -82,7 +82,7 @@ static unsigned long notify_user;
static int rip_msr;
static int mce_bootlog = -1;
static int monarch_timeout = -1;
-static int mce_panic_timeout;
+static int mce_panic_timeout = 30;

static char trigger[128];
static char *trigger_argv[2] = { trigger, NULL };
@@ -196,6 +196,15 @@ static void print_mce(struct mce *m)

static atomic_t mce_paniced;

+/* Let system panic to reboot for logging the fatal machine check */
+static void mce_set_panic_timeout(void)
+{
+ if (!mce_bootlog)
+ return;
+ if (!panic_timeout || mce_panic_timeout < panic_timeout)
+ panic_timeout = mce_panic_timeout;
+}
+
/* Panic in progress. Enable interrupts and wait for final IPI */
static void wait_for_panic(void)
{
@@ -204,8 +213,7 @@ static void wait_for_panic(void)
local_irq_enable();
while (timeout-- > 0)
udelay(1);
- if (mce_panic_timeout < panic_timeout)
- panic_timeout = mce_panic_timeout;
+ mce_set_panic_timeout();
panic("Panicing machine check CPU died");
}

@@ -243,8 +251,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
printk(KERN_EMERG "Some CPUs didn't answer in synchronization\n");
if (exp)
printk(KERN_EMERG "Machine check: %s\n", exp);
- if (mce_panic_timeout < panic_timeout)
- panic_timeout = mce_panic_timeout;
+ mce_set_panic_timeout();
panic(msg);
}

@@ -1109,8 +1116,6 @@ static void mce_cpu_quirks(struct cpuinfo_x86 *c)
}
if (monarch_timeout < 0)
monarch_timeout = 0;
- if (mce_bootlog != 0)
- mce_panic_timeout = 30;
}

static void __cpuinit mce_ancient_init(struct cpuinfo_x86 *c)
--
1.6.3