LTP GCOV extension - code coverage report
Current view: directory - arch/i386/kernel/cpu/mcheck - non-fatal.c
Test: 2.6.14_rebootonly_gcov.info
Date: 2006-05-22 Instrumented lines: 26
Code covered: 69.2 % Executed lines: 18

       1                 : /*
       2                 :  * Non Fatal Machine Check Exception Reporting
       3                 :  *
       4                 :  * (C) Copyright 2002 Dave Jones. <davej@codemonkey.org.uk>
       5                 :  *
       6                 :  * This file contains routines to check for non-fatal MCEs every 15s
       7                 :  *
       8                 :  */
       9                 : 
      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/workqueue.h>
      16                 : #include <linux/interrupt.h>
      17                 : #include <linux/smp.h>
      18                 : #include <linux/module.h>
      19                 : 
      20                 : #include <asm/processor.h> 
      21                 : #include <asm/system.h>
      22                 : #include <asm/msr.h>
      23                 : 
      24                 : #include "mce.h"
      25                 : 
      26                 : static int firstbank;
      27                 : 
      28                 : #define MCE_RATE        15*HZ   /* timer rate is 15s */
      29                 : 
      30                 : static void mce_checkregs (void *info)
      31              11 : {
      32              11 :         u32 low, high;
      33              11 :         int i;
      34                 : 
      35              66 :         for (i=firstbank; i<nr_mce_banks; i++) {
      36              55 :                 rdmsr (MSR_IA32_MC0_STATUS+i*4, low, high);
      37                 : 
      38              55 :                 if (high & (1<<31)) {
      39               0 :                         printk(KERN_INFO "MCE: The hardware reports a non "
      40                 :                                 "fatal, correctable incident occurred on "
      41                 :                                 "CPU %d.\n",
      42                 :                                 smp_processor_id());
      43               0 :                         printk (KERN_INFO "Bank %d: %08x%08x\n", i, high, low);
      44                 : 
      45                 :                         /* Scrub the error so we don't pick it up in MCE_RATE seconds time. */
      46               0 :                         wrmsr (MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
      47                 : 
      48                 :                         /* Serialize */
      49               0 :                         wmb();
      50               0 :                         add_taint(TAINT_MACHINE_CHECK);
      51                 :                 }
      52                 :         }
      53                 : }
      54                 : 
      55                 : static void mce_work_fn(void *data);
      56                 : static DECLARE_WORK(mce_work, mce_work_fn, NULL);
      57                 : 
      58                 : static void mce_work_fn(void *data)
      59              11 : { 
      60              11 :         on_each_cpu(mce_checkregs, NULL, 1, 1);
      61              11 :         schedule_delayed_work(&mce_work, MCE_RATE);
      62                 : } 
      63                 : 
      64                 : static int __init init_nonfatal_mce_checker(void)
      65               1 : {
      66               1 :         struct cpuinfo_x86 *c = &boot_cpu_data;
      67                 : 
      68                 :         /* Check for MCE support */
      69               1 :         if (!cpu_has(c, X86_FEATURE_MCE))
      70               0 :                 return -ENODEV;
      71                 : 
      72                 :         /* Check for PPro style MCA */
      73               1 :         if (!cpu_has(c, X86_FEATURE_MCA))
      74               0 :                 return -ENODEV;
      75                 : 
      76                 :         /* Some Athlons misbehave when we frob bank 0 */
      77               1 :         if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
      78                 :                 boot_cpu_data.x86 == 6)
      79               0 :                         firstbank = 1;
      80                 :         else
      81               1 :                         firstbank = 0;
      82                 : 
      83                 :         /*
      84                 :          * Check for non-fatal errors every MCE_RATE s
      85                 :          */
      86               1 :         schedule_delayed_work(&mce_work, MCE_RATE);
      87               1 :         printk(KERN_INFO "Machine check exception polling timer started.\n");
      88               1 :         return 0;
      89                 : }
      90                 : module_init(init_nonfatal_mce_checker);
      91                 : 
      92                 : MODULE_LICENSE("GPL");

Generated by: LTP GCOV extension version 1.4