X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fedac%2Fi5000_edac.c;h=77a9579d716777c70b5dd399a1f40f44cab87e74;hb=f653398c86a1c104f0992bd788dd4bb065449be4;hp=8eb8b6e5b32cdba1f39672e5fa637150d7329a50;hpb=c0d121720220584bba2876b032e58a076b843fa1;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/edac/i5000_edac.c b/drivers/edac/i5000_edac.c index 8eb8b6e..77a9579 100644 --- a/drivers/edac/i5000_edac.c +++ b/drivers/edac/i5000_edac.c @@ -22,12 +22,13 @@ #include #include -#include "edac_mc.h" +#include "edac_core.h" /* * Alter this version for the I5000 module when modifications are made */ -#define I5000_REVISION " Ver: 2.0.11.devel " __DATE__ +#define I5000_REVISION " Ver: 2.0.12 " __DATE__ +#define EDAC_MOD_STR "i5000_edac" #define i5000_printk(level, fmt, arg...) \ edac_printk(level, "i5000", fmt, ##arg) @@ -76,7 +77,7 @@ #define FERR_FAT_M3ERR 0x00000004 #define FERR_FAT_M2ERR 0x00000002 #define FERR_FAT_M1ERR 0x00000001 -#define FERR_FAT_MASK (FERR_FAT_M1ERR | \ +#define FERR_FAT_MASK (FERR_FAT_M1ERR | \ FERR_FAT_M2ERR | \ FERR_FAT_M3ERR) @@ -118,7 +119,8 @@ #define FERR_NF_UNCORRECTABLE (FERR_NF_M12ERR | \ FERR_NF_M11ERR | \ FERR_NF_M10ERR | \ - FERR_NF_M8ERR | \ + FERR_NF_M9ERR | \ + FERR_NF_M8ERR | \ FERR_NF_M7ERR | \ FERR_NF_M6ERR | \ FERR_NF_M5ERR | \ @@ -130,7 +132,7 @@ #define FERR_NF_DIMM_SPARE (FERR_NF_M27ERR | \ FERR_NF_M28ERR) #define FERR_NF_THERMAL (FERR_NF_M26ERR | \ - FERR_NF_M25ERR | \ + FERR_NF_M25ERR | \ FERR_NF_M24ERR | \ FERR_NF_M23ERR) #define FERR_NF_SPD_PROTOCOL (FERR_NF_M22ERR) @@ -278,7 +280,7 @@ #define MTR_DRAM_BANKS(mtr) ((((mtr) >> 5) & 0x1) ? 8 : 4) #define MTR_DRAM_BANKS_ADDR_BITS(mtr) ((MTR_DRAM_BANKS(mtr) == 8) ? 3 : 2) #define MTR_DIMM_RANK(mtr) (((mtr) >> 4) & 0x1) -#define MTR_DIMM_RANK_ADDR_BITS(mtr) (MTR_DIM_RANKS(mtr) ? 2 : 1) +#define MTR_DIMM_RANK_ADDR_BITS(mtr) (MTR_DIMM_RANK(mtr) ? 2 : 1) #define MTR_DIMM_ROWS(mtr) (((mtr) >> 2) & 0x3) #define MTR_DIMM_ROWS_ADDR_BITS(mtr) (MTR_DIMM_ROWS(mtr) + 13) #define MTR_DIMM_COLS(mtr) ((mtr) & 0x3) @@ -300,6 +302,9 @@ static char *numcol_toString[] = { }; #endif +/* enables the report of miscellaneous messages as CE errors - default off */ +static int misc_messages; + /* Enumeration of supported devices */ enum i5000_chips { I5000P = 0, @@ -316,9 +321,9 @@ struct i5000_dev_info { /* Table of devices attributes supported by this driver */ static const struct i5000_dev_info i5000_devs[] = { [I5000P] = { - .ctl_name = "I5000", - .fsb_mapping_errors = PCI_DEVICE_ID_INTEL_I5000_DEV16, - }, + .ctl_name = "I5000", + .fsb_mapping_errors = PCI_DEVICE_ID_INTEL_I5000_DEV16, + }, }; struct i5000_dimm_info { @@ -337,8 +342,6 @@ struct i5000_pvt { struct pci_dev *branch_0; /* 21.0 */ struct pci_dev *branch_1; /* 22.0 */ - int node_id; /* ID of this node */ - u16 tolm; /* top of low memory */ u64 ambase; /* AMB BAR */ @@ -352,7 +355,7 @@ struct i5000_pvt { u16 b1_ambpresent0; /* Branch 1, Channel 8 */ u16 b1_ambpresent1; /* Branch 1, Channel 1 */ - /* DIMM infomation matrix, allocating architecture maximums */ + /* DIMM information matrix, allocating architecture maximums */ struct i5000_dimm_info dimm_info[MAX_CSROWS][MAX_CHANNELS]; /* Actual values for this controller */ @@ -381,18 +384,20 @@ struct i5000_error_info { }; -/****************************************************************************** +static struct edac_pci_ctl_info *i5000_pci; + +/* * i5000_get_error_info Retrieve the hardware error information from * the hardware and cache it in the 'info' * structure */ static void i5000_get_error_info(struct mem_ctl_info *mci, - struct i5000_error_info * info) + struct i5000_error_info *info) { struct i5000_pvt *pvt; u32 value; - pvt = (struct i5000_pvt *)mci->pvt_info; + pvt = mci->pvt_info; /* read in the 1st FATAL error register */ pci_read_config_dword(pvt->branchmap_werrors, FERR_FAT_FBD, &value); @@ -408,15 +413,15 @@ static void i5000_get_error_info(struct mem_ctl_info *mci, /* harvest the various error data we need */ pci_read_config_dword(pvt->branchmap_werrors, - NERR_FAT_FBD, &info->nerr_fat_fbd); + NERR_FAT_FBD, &info->nerr_fat_fbd); pci_read_config_word(pvt->branchmap_werrors, - NRECMEMA, &info->nrecmema); + NRECMEMA, &info->nrecmema); pci_read_config_word(pvt->branchmap_werrors, - NRECMEMB, &info->nrecmemb); + NRECMEMB, &info->nrecmemb); /* Clear the error bits, by writing them back */ pci_write_config_dword(pvt->branchmap_werrors, - FERR_FAT_FBD, value); + FERR_FAT_FBD, value); } else { info->ferr_fat_fbd = 0; info->nerr_fat_fbd = 0; @@ -434,17 +439,17 @@ static void i5000_get_error_info(struct mem_ctl_info *mci, /* harvest the various error data we need */ pci_read_config_dword(pvt->branchmap_werrors, - NERR_NF_FBD, &info->nerr_nf_fbd); + NERR_NF_FBD, &info->nerr_nf_fbd); pci_read_config_word(pvt->branchmap_werrors, - RECMEMA, &info->recmema); + RECMEMA, &info->recmema); pci_read_config_dword(pvt->branchmap_werrors, - RECMEMB, &info->recmemb); + RECMEMB, &info->recmemb); pci_read_config_dword(pvt->branchmap_werrors, - REDMEMB, &info->redmemb); + REDMEMB, &info->redmemb); /* Clear the error bits, by writing them back */ pci_write_config_dword(pvt->branchmap_werrors, - FERR_NF_FBD, value); + FERR_NF_FBD, value); } else { info->ferr_nf_fbd = 0; info->nerr_nf_fbd = 0; @@ -454,7 +459,7 @@ static void i5000_get_error_info(struct mem_ctl_info *mci, } } -/****************************************************************************** +/* * i5000_process_fatal_error_info(struct mem_ctl_info *mci, * struct i5000_error_info *info, * int handle_errors); @@ -462,10 +467,11 @@ static void i5000_get_error_info(struct mem_ctl_info *mci, * handle the Intel FATAL errors, if any */ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci, - struct i5000_error_info * info, - int handle_errors) + struct i5000_error_info *info, + int handle_errors) { - char msg[EDAC_MC_LABEL_LEN + 1 + 90]; + char msg[EDAC_MC_LABEL_LEN + 1 + 160]; + char *specific = NULL; u32 allErrors; int branch; int channel; @@ -479,11 +485,6 @@ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci, if (!allErrors) return; /* if no error, return now */ - /* ONLY ONE of the possible error bits will be set, as per the docs */ - i5000_mc_printk(mci, KERN_ERR, - "FATAL ERRORS Found!!! 1st FATAL Err Reg= 0x%x\n", - allErrors); - branch = EXTRACT_FBDCHAN_INDX(info->ferr_fat_fbd); channel = branch; @@ -500,45 +501,60 @@ static void i5000_process_fatal_error_info(struct mem_ctl_info *mci, rdwr ? "Write" : "Read", ras, cas); /* Only 1 bit will be on */ - if (allErrors & FERR_FAT_M1ERR) { - i5000_mc_printk(mci, KERN_ERR, - "Alert on non-redundant retry or fast " - "reset timeout\n"); - - } else if (allErrors & FERR_FAT_M2ERR) { - i5000_mc_printk(mci, KERN_ERR, - "Northbound CRC error on non-redundant " - "retry\n"); - - } else if (allErrors & FERR_FAT_M3ERR) { - i5000_mc_printk(mci, KERN_ERR, - ">Tmid Thermal event with intelligent " - "throttling disabled\n"); + switch (allErrors) { + case FERR_FAT_M1ERR: + specific = "Alert on non-redundant retry or fast " + "reset timeout"; + break; + case FERR_FAT_M2ERR: + specific = "Northbound CRC error on non-redundant " + "retry"; + break; + case FERR_FAT_M3ERR: + { + static int done; + + /* + * This error is generated to inform that the intelligent + * throttling is disabled and the temperature passed the + * specified middle point. Since this is something the BIOS + * should take care of, we'll warn only once to avoid + * worthlessly flooding the log. + */ + if (done) + return; + done++; + + specific = ">Tmid Thermal event with intelligent " + "throttling disabled"; + } + break; } /* Form out message */ snprintf(msg, sizeof(msg), "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d CAS=%d " - "FATAL Err=0x%x)", + "FATAL Err=0x%x (%s))", branch >> 1, bank, rdwr ? "Write" : "Read", ras, cas, - allErrors); + allErrors, specific); /* Call the helper to output message */ edac_mc_handle_fbd_ue(mci, rank, channel, channel + 1, msg); } -/****************************************************************************** +/* * i5000_process_fatal_error_info(struct mem_ctl_info *mci, - * struct i5000_error_info *info, - * int handle_errors); + * struct i5000_error_info *info, + * int handle_errors); * * handle the Intel NON-FATAL errors, if any */ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci, - struct i5000_error_info * info, - int handle_errors) + struct i5000_error_info *info, + int handle_errors) { - char msg[EDAC_MC_LABEL_LEN + 1 + 90]; + char msg[EDAC_MC_LABEL_LEN + 1 + 170]; + char *specific = NULL; u32 allErrors; u32 ue_errors; u32 ce_errors; @@ -556,10 +572,6 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci, return; /* if no error, return now */ /* ONLY ONE of the possible error bits will be set, as per the docs */ - i5000_mc_printk(mci, KERN_WARNING, - "NON-FATAL ERRORS Found!!! 1st NON-FATAL Err " - "Reg= 0x%x\n", allErrors); - ue_errors = allErrors & FERR_NF_UNCORRECTABLE; if (ue_errors) { debugf0("\tUncorrected bits= 0x%x\n", ue_errors); @@ -573,17 +585,52 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci, cas = NREC_CAS(info->nrecmemb); debugf0 - ("\t\tCSROW= %d Channels= %d,%d (Branch= %d " - "DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", - rank, channel, channel + 1, branch >> 1, bank, - rdwr ? "Write" : "Read", ras, cas); + ("\t\tCSROW= %d Channels= %d,%d (Branch= %d " + "DRAM Bank= %d rdwr= %s ras= %d cas= %d)\n", + rank, channel, channel + 1, branch >> 1, bank, + rdwr ? "Write" : "Read", ras, cas); + + switch (ue_errors) { + case FERR_NF_M12ERR: + specific = "Non-Aliased Uncorrectable Patrol Data ECC"; + break; + case FERR_NF_M11ERR: + specific = "Non-Aliased Uncorrectable Spare-Copy " + "Data ECC"; + break; + case FERR_NF_M10ERR: + specific = "Non-Aliased Uncorrectable Mirrored Demand " + "Data ECC"; + break; + case FERR_NF_M9ERR: + specific = "Non-Aliased Uncorrectable Non-Mirrored " + "Demand Data ECC"; + break; + case FERR_NF_M8ERR: + specific = "Aliased Uncorrectable Patrol Data ECC"; + break; + case FERR_NF_M7ERR: + specific = "Aliased Uncorrectable Spare-Copy Data ECC"; + break; + case FERR_NF_M6ERR: + specific = "Aliased Uncorrectable Mirrored Demand " + "Data ECC"; + break; + case FERR_NF_M5ERR: + specific = "Aliased Uncorrectable Non-Mirrored Demand " + "Data ECC"; + break; + case FERR_NF_M4ERR: + specific = "Uncorrectable Data ECC on Replay"; + break; + } /* Form out message */ snprintf(msg, sizeof(msg), "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d " - "CAS=%d, UE Err=0x%x)", + "CAS=%d, UE Err=0x%x (%s))", branch >> 1, bank, rdwr ? "Write" : "Read", ras, cas, - ue_errors); + ue_errors, specific); /* Call the helper to output message */ edac_mc_handle_fbd_ue(mci, rank, channel, channel + 1, msg); @@ -615,61 +662,84 @@ static void i5000_process_nonfatal_error_info(struct mem_ctl_info *mci, rank, channel, branch >> 1, bank, rdwr ? "Write" : "Read", ras, cas); + switch (ce_errors) { + case FERR_NF_M17ERR: + specific = "Correctable Non-Mirrored Demand Data ECC"; + break; + case FERR_NF_M18ERR: + specific = "Correctable Mirrored Demand Data ECC"; + break; + case FERR_NF_M19ERR: + specific = "Correctable Spare-Copy Data ECC"; + break; + case FERR_NF_M20ERR: + specific = "Correctable Patrol Data ECC"; + break; + } + /* Form out message */ snprintf(msg, sizeof(msg), "(Branch=%d DRAM-Bank=%d RDWR=%s RAS=%d " - "CAS=%d, CE Err=0x%x)", branch >> 1, bank, - rdwr ? "Write" : "Read", ras, cas, ce_errors); + "CAS=%d, CE Err=0x%x (%s))", branch >> 1, bank, + rdwr ? "Write" : "Read", ras, cas, ce_errors, + specific); /* Call the helper to output message */ edac_mc_handle_fbd_ce(mci, rank, channel, msg); } - /* See if any of the thermal errors have fired */ - misc_errors = allErrors & FERR_NF_THERMAL; - if (misc_errors) { - i5000_printk(KERN_WARNING, "\tTHERMAL Error, bits= 0x%x\n", - misc_errors); - } - - /* See if any of the thermal errors have fired */ - misc_errors = allErrors & FERR_NF_NON_RETRY; - if (misc_errors) { - i5000_printk(KERN_WARNING, "\tNON-Retry Errors, bits= 0x%x\n", - misc_errors); - } + if (!misc_messages) + return; - /* See if any of the thermal errors have fired */ - misc_errors = allErrors & FERR_NF_NORTH_CRC; + misc_errors = allErrors & (FERR_NF_NON_RETRY | FERR_NF_NORTH_CRC | + FERR_NF_SPD_PROTOCOL | FERR_NF_DIMM_SPARE); if (misc_errors) { - i5000_printk(KERN_WARNING, - "\tNORTHBOUND CRC Error, bits= 0x%x\n", - misc_errors); - } + switch (misc_errors) { + case FERR_NF_M13ERR: + specific = "Non-Retry or Redundant Retry FBD Memory " + "Alert or Redundant Fast Reset Timeout"; + break; + case FERR_NF_M14ERR: + specific = "Non-Retry or Redundant Retry FBD " + "Configuration Alert"; + break; + case FERR_NF_M15ERR: + specific = "Non-Retry or Redundant Retry FBD " + "Northbound CRC error on read data"; + break; + case FERR_NF_M21ERR: + specific = "FBD Northbound CRC error on " + "FBD Sync Status"; + break; + case FERR_NF_M22ERR: + specific = "SPD protocol error"; + break; + case FERR_NF_M27ERR: + specific = "DIMM-spare copy started"; + break; + case FERR_NF_M28ERR: + specific = "DIMM-spare copy completed"; + break; + } + branch = EXTRACT_FBDCHAN_INDX(info->ferr_nf_fbd); - /* See if any of the thermal errors have fired */ - misc_errors = allErrors & FERR_NF_SPD_PROTOCOL; - if (misc_errors) { - i5000_printk(KERN_WARNING, - "\tSPD Protocol Error, bits= 0x%x\n", - misc_errors); - } + /* Form out message */ + snprintf(msg, sizeof(msg), + "(Branch=%d Err=%#x (%s))", branch >> 1, + misc_errors, specific); - /* See if any of the thermal errors have fired */ - misc_errors = allErrors & FERR_NF_DIMM_SPARE; - if (misc_errors) { - i5000_printk(KERN_WARNING, "\tDIMM-Spare Error, bits= 0x%x\n", - misc_errors); + /* Call the helper to output message */ + edac_mc_handle_fbd_ce(mci, 0, 0, msg); } } -/****************************************************************************** +/* * i5000_process_error_info Process the error info that is * in the 'info' structure, previously retrieved from hardware */ static void i5000_process_error_info(struct mem_ctl_info *mci, - struct i5000_error_info * info, - int handle_errors) + struct i5000_error_info *info, + int handle_errors) { /* First handle any fatal errors that occurred */ i5000_process_fatal_error_info(mci, info, handle_errors); @@ -678,7 +748,7 @@ static void i5000_process_error_info(struct mem_ctl_info *mci, i5000_process_nonfatal_error_info(mci, info, handle_errors); } -/****************************************************************************** +/* * i5000_clear_error Retrieve any error from the hardware * but do NOT process that error. * Used for 'clearing' out of previous errors @@ -691,7 +761,7 @@ static void i5000_clear_error(struct mem_ctl_info *mci) i5000_get_error_info(mci, &info); } -/****************************************************************************** +/* * i5000_check_error Retrieve and process errors reported by the * hardware. Called by the Core module. */ @@ -703,7 +773,7 @@ static void i5000_check_error(struct mem_ctl_info *mci) i5000_process_error_info(mci, &info, 1); } -/****************************************************************************** +/* * i5000_get_devices Find and perform 'get' operation on the MCH's * device/functions we want to reference for this driver * @@ -715,23 +785,23 @@ static int i5000_get_devices(struct mem_ctl_info *mci, int dev_idx) struct i5000_pvt *pvt; struct pci_dev *pdev; - pvt = (struct i5000_pvt *)mci->pvt_info; + pvt = mci->pvt_info; /* Attempt to 'get' the MCH register we want */ pdev = NULL; while (1) { pdev = pci_get_device(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_I5000_DEV16, pdev); + PCI_DEVICE_ID_INTEL_I5000_DEV16, pdev); /* End of list, leave */ if (pdev == NULL) { i5000_printk(KERN_ERR, - "'system address,Process Bus' " - "device not found:" - "vendor 0x%x device 0x%x FUNC 1 " - "(broken BIOS?)\n", - PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_I5000_DEV16); + "'system address,Process Bus' " + "device not found:" + "vendor 0x%x device 0x%x FUNC 1 " + "(broken BIOS?)\n", + PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_INTEL_I5000_DEV16); return 1; } @@ -747,16 +817,16 @@ static int i5000_get_devices(struct mem_ctl_info *mci, int dev_idx) pdev = NULL; while (1) { pdev = pci_get_device(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_I5000_DEV16, pdev); + PCI_DEVICE_ID_INTEL_I5000_DEV16, pdev); if (pdev == NULL) { i5000_printk(KERN_ERR, - "MC: 'branchmap,control,errors' " - "device not found:" - "vendor 0x%x device 0x%x Func 2 " - "(broken BIOS?)\n", - PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_INTEL_I5000_DEV16); + "MC: 'branchmap,control,errors' " + "device not found:" + "vendor 0x%x device 0x%x Func 2 " + "(broken BIOS?)\n", + PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_INTEL_I5000_DEV16); pci_dev_put(pvt->branchmap_werrors); return 1; @@ -781,13 +851,13 @@ static int i5000_get_devices(struct mem_ctl_info *mci, int dev_idx) pdev = NULL; pdev = pci_get_device(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_I5000_BRANCH_0, pdev); + PCI_DEVICE_ID_I5000_BRANCH_0, pdev); if (pdev == NULL) { i5000_printk(KERN_ERR, - "MC: 'BRANCH 0' device not found:" - "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n", - PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_I5000_BRANCH_0); + "MC: 'BRANCH 0' device not found:" + "vendor 0x%x device 0x%x Func 0 (broken BIOS?)\n", + PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_I5000_BRANCH_0); pci_dev_put(pvt->branchmap_werrors); pci_dev_put(pvt->fsb_error_regs); @@ -802,15 +872,15 @@ static int i5000_get_devices(struct mem_ctl_info *mci, int dev_idx) if (pvt->maxch >= CHANNELS_PER_BRANCH) { pdev = NULL; pdev = pci_get_device(PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_I5000_BRANCH_1, pdev); + PCI_DEVICE_ID_I5000_BRANCH_1, pdev); if (pdev == NULL) { i5000_printk(KERN_ERR, - "MC: 'BRANCH 1' device not found:" - "vendor 0x%x device 0x%x Func 0 " - "(broken BIOS?)\n", - PCI_VENDOR_ID_INTEL, - PCI_DEVICE_ID_I5000_BRANCH_1); + "MC: 'BRANCH 1' device not found:" + "vendor 0x%x device 0x%x Func 0 " + "(broken BIOS?)\n", + PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_I5000_BRANCH_1); pci_dev_put(pvt->branchmap_werrors); pci_dev_put(pvt->fsb_error_regs); @@ -824,7 +894,7 @@ static int i5000_get_devices(struct mem_ctl_info *mci, int dev_idx) return 0; } -/****************************************************************************** +/* * i5000_put_devices 'put' all the devices that we have * reserved via 'get' */ @@ -832,19 +902,18 @@ static void i5000_put_devices(struct mem_ctl_info *mci) { struct i5000_pvt *pvt; - pvt = (struct i5000_pvt *)mci->pvt_info; + pvt = mci->pvt_info; pci_dev_put(pvt->branchmap_werrors); /* FUNC 1 */ pci_dev_put(pvt->fsb_error_regs); /* FUNC 2 */ pci_dev_put(pvt->branch_0); /* DEV 21 */ /* Only if more than 2 channels do we release the second branch */ - if (pvt->maxch >= CHANNELS_PER_BRANCH) { + if (pvt->maxch >= CHANNELS_PER_BRANCH) pci_dev_put(pvt->branch_1); /* DEV 22 */ - } } -/****************************************************************************** +/* * determine_amb_resent * * the information is contained in NUM_MTRS different registers @@ -876,7 +945,7 @@ static int determine_amb_present_reg(struct i5000_pvt *pvt, int channel) return amb_present; } -/****************************************************************************** +/* * determine_mtr(pvt, csrow, channel) * * return the proper MTR register as determine by the csrow and channel desired @@ -893,7 +962,7 @@ static int determine_mtr(struct i5000_pvt *pvt, int csrow, int channel) return mtr; } -/****************************************************************************** +/* */ static void decode_mtr(int slot_row, u16 mtr) { @@ -914,7 +983,7 @@ static void decode_mtr(int slot_row, u16 mtr) } static void handle_channel(struct i5000_pvt *pvt, int csrow, int channel, - struct i5000_dimm_info *dinfo) + struct i5000_dimm_info *dinfo) { int mtr; int amb_present_reg; @@ -929,7 +998,7 @@ static void handle_channel(struct i5000_pvt *pvt, int csrow, int channel, dinfo->dual_rank = MTR_DIMM_RANK(mtr); if (!((dinfo->dual_rank == 0) && - ((csrow & 0x1) == 0x1))) { + ((csrow & 0x1) == 0x1))) { /* Start with the number of bits for a Bank * on the DRAM */ addrBits = MTR_DRAM_BANKS_ADDR_BITS(mtr); @@ -948,7 +1017,7 @@ static void handle_channel(struct i5000_pvt *pvt, int csrow, int channel, } } -/****************************************************************************** +/* * calculate_dimm_size * * also will output a DIMM matrix map, if debug is enabled, for viewing @@ -967,7 +1036,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt) mem_buffer = p = kmalloc(space, GFP_KERNEL); if (p == NULL) { i5000_printk(KERN_ERR, "MC: %s:%s() kmalloc() failed\n", - __FILE__, __func__); + __FILE__, __func__); return; } @@ -987,7 +1056,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt) * then reset the message buffer */ if (csrow & 0x1) { n = snprintf(p, space, "---------------------------" - "--------------------------------"); + "--------------------------------"); p += n; space -= n; debugf2("%s\n", mem_buffer); @@ -1012,7 +1081,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt) /* Output the last bottom 'boundary' marker */ n = snprintf(p, space, "---------------------------" - "--------------------------------\n"); + "--------------------------------\n"); p += n; space -= n; @@ -1034,7 +1103,7 @@ static void calculate_dimm_size(struct i5000_pvt *pvt) kfree(mem_buffer); } -/****************************************************************************** +/* * i5000_get_mc_regs read in the necessary registers and * cache locally * @@ -1050,12 +1119,12 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci) int maxdimmperch; int way0, way1; - pvt = (struct i5000_pvt *)mci->pvt_info; + pvt = mci->pvt_info; pci_read_config_dword(pvt->system_address, AMBASE, - (u32 *) & pvt->ambase); + (u32 *) & pvt->ambase); pci_read_config_dword(pvt->system_address, AMBASE + sizeof(u32), - ((u32 *) & pvt->ambase) + sizeof(u32)); + ((u32 *) & pvt->ambase) + sizeof(u32)); maxdimmperch = pvt->maxdimmperch; maxch = pvt->maxch; @@ -1095,16 +1164,16 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci) int where = MTR0 + (slot_row * sizeof(u32)); pci_read_config_word(pvt->branch_0, where, - &pvt->b0_mtr[slot_row]); + &pvt->b0_mtr[slot_row]); debugf2("MTR%d where=0x%x B0 value=0x%x\n", slot_row, where, pvt->b0_mtr[slot_row]); if (pvt->maxch >= CHANNELS_PER_BRANCH) { pci_read_config_word(pvt->branch_1, where, - &pvt->b1_mtr[slot_row]); + &pvt->b1_mtr[slot_row]); debugf2("MTR%d where=0x%x B1 value=0x%x\n", slot_row, - where, pvt->b0_mtr[slot_row]); + where, pvt->b1_mtr[slot_row]); } else { pvt->b1_mtr[slot_row] = 0; } @@ -1117,10 +1186,10 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci) decode_mtr(slot_row, pvt->b0_mtr[slot_row]); } pci_read_config_word(pvt->branch_0, AMB_PRESENT_0, - &pvt->b0_ambpresent0); + &pvt->b0_ambpresent0); debugf2("\t\tAMB-Branch 0-present0 0x%x:\n", pvt->b0_ambpresent0); pci_read_config_word(pvt->branch_0, AMB_PRESENT_1, - &pvt->b0_ambpresent1); + &pvt->b0_ambpresent1); debugf2("\t\tAMB-Branch 0-present1 0x%x:\n", pvt->b0_ambpresent1); /* Only if we have 2 branchs (4 channels) */ @@ -1134,11 +1203,11 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci) decode_mtr(slot_row, pvt->b1_mtr[slot_row]); } pci_read_config_word(pvt->branch_1, AMB_PRESENT_0, - &pvt->b1_ambpresent0); + &pvt->b1_ambpresent0); debugf2("\t\tAMB-Branch 1-present0 0x%x:\n", pvt->b1_ambpresent0); pci_read_config_word(pvt->branch_1, AMB_PRESENT_1, - &pvt->b1_ambpresent1); + &pvt->b1_ambpresent1); debugf2("\t\tAMB-Branch 1-present1 0x%x:\n", pvt->b1_ambpresent1); } @@ -1148,7 +1217,7 @@ static void i5000_get_mc_regs(struct mem_ctl_info *mci) calculate_dimm_size(pvt); } -/****************************************************************************** +/* * i5000_init_csrows Initialize the 'csrows' table within * the mci control structure with the * addressing of memory. @@ -1163,12 +1232,12 @@ static int i5000_init_csrows(struct mem_ctl_info *mci) struct csrow_info *p_csrow; int empty, channel_count; int max_csrows; - int mtr; + int mtr, mtr1; int csrow_megs; int channel; int csrow; - pvt = (struct i5000_pvt *)mci->pvt_info; + pvt = mci->pvt_info; channel_count = pvt->maxch; max_csrows = pvt->maxdimmperch * 2; @@ -1182,9 +1251,10 @@ static int i5000_init_csrows(struct mem_ctl_info *mci) /* use branch 0 for the basis */ mtr = pvt->b0_mtr[csrow >> 1]; + mtr1 = pvt->b1_mtr[csrow >> 1]; /* if no DIMMS on this row, continue */ - if (!MTR_DIMMS_PRESENT(mtr)) + if (!MTR_DIMMS_PRESENT(mtr) && !MTR_DIMMS_PRESENT(mtr1)) continue; /* FAKE OUT VALUES, FIXME */ @@ -1218,7 +1288,7 @@ static int i5000_init_csrows(struct mem_ctl_info *mci) return empty; } -/****************************************************************************** +/* * i5000_enable_error_reporting * Turn on the memory reporting features of the hardware */ @@ -1227,28 +1297,28 @@ static void i5000_enable_error_reporting(struct mem_ctl_info *mci) struct i5000_pvt *pvt; u32 fbd_error_mask; - pvt = (struct i5000_pvt *)mci->pvt_info; + pvt = mci->pvt_info; /* Read the FBD Error Mask Register */ pci_read_config_dword(pvt->branchmap_werrors, EMASK_FBD, - &fbd_error_mask); + &fbd_error_mask); /* Enable with a '0' */ fbd_error_mask &= ~(ENABLE_EMASK_ALL); pci_write_config_dword(pvt->branchmap_werrors, EMASK_FBD, - fbd_error_mask); + fbd_error_mask); } -/****************************************************************************** +/* * i5000_get_dimm_and_channel_counts(pdev, &num_csrows, &num_channels) * * ask the device how many channels are present and how many CSROWS * as well */ static void i5000_get_dimm_and_channel_counts(struct pci_dev *pdev, - int *num_dimms_per_channel, - int *num_channels) + int *num_dimms_per_channel, + int *num_channels) { u8 value; @@ -1262,7 +1332,7 @@ static void i5000_get_dimm_and_channel_counts(struct pci_dev *pdev, *num_channels = (int)value; } -/****************************************************************************** +/* * i5000_probe1 Probe for ONE instance of device to see if it is * present. * return: @@ -1286,16 +1356,6 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) if (PCI_FUNC(pdev->devfn) != 0) return -ENODEV; - /* make sure error reporting method is sane */ - switch(edac_op_state) { - case EDAC_OPSTATE_POLL: - case EDAC_OPSTATE_NMI: - break; - default: - edac_op_state = EDAC_OPSTATE_POLL; - break; - } - /* Ask the devices for the number of CSROWS and CHANNELS so * that we can calculate the memory resources, etc * @@ -1310,23 +1370,24 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) * some fancy mobo determination. */ i5000_get_dimm_and_channel_counts(pdev, &num_dimms_per_channel, - &num_channels); + &num_channels); num_csrows = num_dimms_per_channel * 2; debugf0("MC: %s(): Number of - Channels= %d DIMMS= %d CSROWS= %d\n", __func__, num_channels, num_dimms_per_channel, num_csrows); /* allocate a new MC control structure */ - mci = edac_mc_alloc(sizeof(*pvt), num_csrows, num_channels); + mci = edac_mc_alloc(sizeof(*pvt), num_csrows, num_channels, 0); if (mci == NULL) return -ENOMEM; + kobject_get(&mci->edac_mci_kobj); debugf0("MC: " __FILE__ ": %s(): mci = %p\n", __func__, mci); mci->dev = &pdev->dev; /* record ptr to the generic device */ - pvt = (struct i5000_pvt *)mci->pvt_info; + pvt = mci->pvt_info; pvt->system_address = pdev; /* Record this device in our private */ pvt->maxch = num_channels; pvt->maxdimmperch = num_dimms_per_channel; @@ -1345,6 +1406,7 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) mci->mod_name = "i5000_edac.c"; mci->mod_ver = I5000_REVISION; mci->ctl_name = i5000_devs[dev_idx].ctl_name; + mci->dev_name = pci_name(pdev); mci->ctl_page_to_phys = NULL; /* Set the function pointer to an actual operation function */ @@ -1363,7 +1425,7 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) } /* add this new MC control structure to EDAC's list of MCs */ - if (edac_mc_add_mc(mci, pvt->node_id)) { + if (edac_mc_add_mc(mci)) { debugf0("MC: " __FILE__ ": %s(): failed edac_mc_add_mc()\n", __func__); /* FIXME: perhaps some code should go here that disables error @@ -1374,19 +1436,31 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) i5000_clear_error(mci); + /* allocating generic PCI control info */ + i5000_pci = edac_pci_create_generic_ctl(&pdev->dev, EDAC_MOD_STR); + if (!i5000_pci) { + printk(KERN_WARNING + "%s(): Unable to create PCI control\n", + __func__); + printk(KERN_WARNING + "%s(): PCI error report via EDAC not setup\n", + __func__); + } + return 0; /* Error exit unwinding stack */ - fail1: +fail1: i5000_put_devices(mci); - fail0: +fail0: + kobject_put(&mci->edac_mci_kobj); edac_mc_free(mci); return -ENODEV; } -/****************************************************************************** +/* * i5000_init_one constructor for one instance of device * * returns: @@ -1394,7 +1468,7 @@ static int i5000_probe1(struct pci_dev *pdev, int dev_idx) * count (>= 0) */ static int __devinit i5000_init_one(struct pci_dev *pdev, - const struct pci_device_id *id) + const struct pci_device_id *id) { int rc; @@ -1409,7 +1483,7 @@ static int __devinit i5000_init_one(struct pci_dev *pdev, return i5000_probe1(pdev, id->driver_data); } -/************************************************************************** +/* * i5000_remove_one destructor for one instance of device * */ @@ -1419,16 +1493,19 @@ static void __devexit i5000_remove_one(struct pci_dev *pdev) debugf0(__FILE__ ": %s()\n", __func__); + if (i5000_pci) + edac_pci_release_generic_ctl(i5000_pci); + if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL) return; /* retrieve references to resources, and free those resources */ i5000_put_devices(mci); - + kobject_put(&mci->edac_mci_kobj); edac_mc_free(mci); } -/************************************************************************** +/* * pci_device_id table for which devices we are looking for * * The "E500P" device is the first device supported. @@ -1442,18 +1519,18 @@ static const struct pci_device_id i5000_pci_tbl[] __devinitdata = { MODULE_DEVICE_TABLE(pci, i5000_pci_tbl); -/************************************************************************** +/* * i5000_driver pci_driver structure for this module * */ static struct pci_driver i5000_driver = { - .name = __stringify(KBUILD_BASENAME), + .name = KBUILD_BASENAME, .probe = i5000_init_one, .remove = __devexit_p(i5000_remove_one), .id_table = i5000_pci_tbl, }; -/************************************************************************** +/* * i5000_init Module entry function * Try to initialize this module for its devices */ @@ -1463,12 +1540,15 @@ static int __init i5000_init(void) debugf2("MC: " __FILE__ ": %s()\n", __func__); + /* Ensure that the OPSTATE is set correctly for POLL or NMI */ + opstate_init(); + pci_rc = pci_register_driver(&i5000_driver); return (pci_rc < 0) ? pci_rc : 0; } -/************************************************************************** +/* * i5000_exit() Module exit function * Unregister the driver */ @@ -1485,6 +1565,10 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR ("Linux Networx (http://lnxi.com) Doug Thompson "); MODULE_DESCRIPTION("MC Driver for Intel I5000 memory controllers - " - I5000_REVISION); + I5000_REVISION); + module_param(edac_op_state, int, 0444); MODULE_PARM_DESC(edac_op_state, "EDAC Error Reporting state: 0=Poll,1=NMI"); +module_param(misc_messages, int, 0444); +MODULE_PARM_DESC(misc_messages, "Log miscellaneous non fatal messages"); +