initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / i386 / kernel / cpu / mcheck / non-fatal.c
bloba1664bb1577e6af40732d056833c7e5e87ac77cb
1 /*
2 * Non Fatal Machine Check Exception Reporting
4 * (C) Copyright 2002 Dave Jones. <davej@codemonkey.org.uk>
6 * This file contains routines to check for non-fatal MCEs every 15s
8 */
10 #include <linux/init.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/jiffies.h>
14 #include <linux/config.h>
15 #include <linux/irq.h>
16 #include <linux/workqueue.h>
17 #include <linux/interrupt.h>
18 #include <linux/smp.h>
19 #include <linux/module.h>
21 #include <asm/processor.h>
22 #include <asm/system.h>
23 #include <asm/msr.h>
25 #include "mce.h"
27 static int firstbank;
29 #define MCE_RATE 15*HZ /* timer rate is 15s */
31 static void mce_checkregs (void *info)
33 u32 low, high;
34 int i;
36 for (i=firstbank; i<nr_mce_banks; i++) {
37 rdmsr (MSR_IA32_MC0_STATUS+i*4, low, high);
39 if (high & (1<<31)) {
40 printk(KERN_INFO "MCE: The hardware reports a non "
41 "fatal, correctable incident occurred on "
42 "CPU %d.\n",
43 smp_processor_id());
44 printk (KERN_INFO "Bank %d: %08x%08x\n", i, high, low);
46 /* Scrub the error so we don't pick it up in MCE_RATE seconds time. */
47 wrmsr (MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
49 /* Serialize */
50 wmb();
55 static void mce_work_fn(void *data);
56 static DECLARE_WORK(mce_work, mce_work_fn, NULL);
58 static void mce_work_fn(void *data)
60 on_each_cpu(mce_checkregs, NULL, 1, 1);
61 schedule_delayed_work(&mce_work, MCE_RATE);
64 static int __init init_nonfatal_mce_checker(void)
66 struct cpuinfo_x86 *c = &boot_cpu_data;
68 /* Check for MCE support */
69 if (!cpu_has(c, X86_FEATURE_MCE))
70 return -ENODEV;
72 /* Check for PPro style MCA */
73 if (!cpu_has(c, X86_FEATURE_MCA))
74 return -ENODEV;
76 /* Some Athlons misbehave when we frob bank 0 */
77 if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
78 boot_cpu_data.x86 == 6)
79 firstbank = 1;
80 else
81 firstbank = 0;
84 * Check for non-fatal errors every MCE_RATE s
86 schedule_delayed_work(&mce_work, MCE_RATE);
87 printk(KERN_INFO "Machine check exception polling timer started.\n");
88 return 0;
90 module_init(init_nonfatal_mce_checker);
92 MODULE_LICENSE("GPL");