aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/e752x_edac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/edac/e752x_edac.c')
-rw-r--r--drivers/edac/e752x_edac.c344
1 files changed, 190 insertions, 154 deletions
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index a52573b3280c..815c3eb783de 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -24,6 +24,8 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include "edac_mc.h" 25#include "edac_mc.h"
26 26
27#define E752X_REVISION " Ver: 2.0.0 " __DATE__
28
27static int force_function_unhide; 29static int force_function_unhide;
28 30
29#define e752x_printk(level, fmt, arg...) \ 31#define e752x_printk(level, fmt, arg...) \
@@ -762,22 +764,174 @@ static void e752x_check(struct mem_ctl_info *mci)
762 e752x_process_error_info(mci, &info, 1); 764 e752x_process_error_info(mci, &info, 1);
763} 765}
764 766
765static int e752x_probe1(struct pci_dev *pdev, int dev_idx) 767/* Return 1 if dual channel mode is active. Else return 0. */
768static inline int dual_channel_active(u16 ddrcsr)
769{
770 return (((ddrcsr >> 12) & 3) == 3);
771}
772
773static void e752x_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev,
774 u16 ddrcsr)
775{
776 struct csrow_info *csrow;
777 unsigned long last_cumul_size;
778 int index, mem_dev, drc_chan;
779 int drc_drbg; /* DRB granularity 0=64mb, 1=128mb */
780 int drc_ddim; /* DRAM Data Integrity Mode 0=none, 2=edac */
781 u8 value;
782 u32 dra, drc, cumul_size;
783
784 pci_read_config_dword(pdev, E752X_DRA, &dra);
785 pci_read_config_dword(pdev, E752X_DRC, &drc);
786 drc_chan = dual_channel_active(ddrcsr);
787 drc_drbg = drc_chan + 1; /* 128 in dual mode, 64 in single */
788 drc_ddim = (drc >> 20) & 0x3;
789
790 /* The dram row boundary (DRB) reg values are boundary address for
791 * each DRAM row with a granularity of 64 or 128MB (single/dual
792 * channel operation). DRB regs are cumulative; therefore DRB7 will
793 * contain the total memory contained in all eight rows.
794 */
795 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
796 /* mem_dev 0=x8, 1=x4 */
797 mem_dev = (dra >> (index * 4 + 2)) & 0x3;
798 csrow = &mci->csrows[index];
799
800 mem_dev = (mem_dev == 2);
801 pci_read_config_byte(pdev, E752X_DRB + index, &value);
802 /* convert a 128 or 64 MiB DRB to a page size. */
803 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
804 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
805 cumul_size);
806 if (cumul_size == last_cumul_size)
807 continue; /* not populated */
808
809 csrow->first_page = last_cumul_size;
810 csrow->last_page = cumul_size - 1;
811 csrow->nr_pages = cumul_size - last_cumul_size;
812 last_cumul_size = cumul_size;
813 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
814 csrow->mtype = MEM_RDDR; /* only one type supported */
815 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
816
817 /*
818 * if single channel or x8 devices then SECDED
819 * if dual channel and x4 then S4ECD4ED
820 */
821 if (drc_ddim) {
822 if (drc_chan && mem_dev) {
823 csrow->edac_mode = EDAC_S4ECD4ED;
824 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
825 } else {
826 csrow->edac_mode = EDAC_SECDED;
827 mci->edac_cap |= EDAC_FLAG_SECDED;
828 }
829 } else
830 csrow->edac_mode = EDAC_NONE;
831 }
832}
833
834static void e752x_init_mem_map_table(struct pci_dev *pdev,
835 struct e752x_pvt *pvt)
766{ 836{
767 int rc = -ENODEV;
768 int index; 837 int index;
838 u8 value, last, row, stat8;
839
840 last = 0;
841 row = 0;
842
843 for (index = 0; index < 8; index += 2) {
844 pci_read_config_byte(pdev, E752X_DRB + index, &value);
845 /* test if there is a dimm in this slot */
846 if (value == last) {
847 /* no dimm in the slot, so flag it as empty */
848 pvt->map[index] = 0xff;
849 pvt->map[index + 1] = 0xff;
850 } else { /* there is a dimm in the slot */
851 pvt->map[index] = row;
852 row++;
853 last = value;
854 /* test the next value to see if the dimm is double
855 * sided
856 */
857 pci_read_config_byte(pdev, E752X_DRB + index + 1,
858 &value);
859 pvt->map[index + 1] = (value == last) ?
860 0xff : /* the dimm is single sided,
861 so flag as empty */
862 row; /* this is a double sided dimm
863 to save the next row # */
864 row++;
865 last = value;
866 }
867 }
868
869 /* set the map type. 1 = normal, 0 = reversed */
870 pci_read_config_byte(pdev, E752X_DRM, &stat8);
871 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
872}
873
874/* Return 0 on success or 1 on failure. */
875static int e752x_get_devs(struct pci_dev *pdev, int dev_idx,
876 struct e752x_pvt *pvt)
877{
878 struct pci_dev *dev;
879
880 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
881 pvt->dev_info->err_dev,
882 pvt->bridge_ck);
883
884 if (pvt->bridge_ck == NULL)
885 pvt->bridge_ck = pci_scan_single_device(pdev->bus,
886 PCI_DEVFN(0, 1));
887
888 if (pvt->bridge_ck == NULL) {
889 e752x_printk(KERN_ERR, "error reporting device not found:"
890 "vendor %x device 0x%x (broken BIOS?)\n",
891 PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
892 return 1;
893 }
894
895 dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev,
896 NULL);
897
898 if (dev == NULL)
899 goto fail;
900
901 pvt->dev_d0f0 = dev;
902 pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck);
903
904 return 0;
905
906fail:
907 pci_dev_put(pvt->bridge_ck);
908 return 1;
909}
910
911static void e752x_init_error_reporting_regs(struct e752x_pvt *pvt)
912{
913 struct pci_dev *dev;
914
915 dev = pvt->dev_d0f1;
916 /* Turn off error disable & SMI in case the BIOS turned it on */
917 pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00);
918 pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00);
919 pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x00);
920 pci_write_config_word(dev, E752X_SYSBUS_SMICMD, 0x00);
921 pci_write_config_byte(dev, E752X_BUF_ERRMASK, 0x00);
922 pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
923 pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
924 pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
925}
926
927static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
928{
769 u16 pci_data; 929 u16 pci_data;
770 u8 stat8; 930 u8 stat8;
771 struct mem_ctl_info *mci = NULL; 931 struct mem_ctl_info *mci;
772 struct e752x_pvt *pvt = NULL; 932 struct e752x_pvt *pvt;
773 u16 ddrcsr; 933 u16 ddrcsr;
774 u32 drc;
775 int drc_chan; /* Number of channels 0=1chan,1=2chan */ 934 int drc_chan; /* Number of channels 0=1chan,1=2chan */
776 int drc_drbg; /* DRB granularity 0=64mb, 1=128mb */
777 int drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */
778 u32 dra;
779 unsigned long last_cumul_size;
780 struct pci_dev *dev = NULL;
781 struct e752x_error_info discard; 935 struct e752x_error_info discard;
782 936
783 debugf0("%s(): mci\n", __func__); 937 debugf0("%s(): mci\n", __func__);
@@ -791,25 +945,20 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
791 if (!force_function_unhide && !(stat8 & (1 << 5))) { 945 if (!force_function_unhide && !(stat8 & (1 << 5))) {
792 printk(KERN_INFO "Contact your BIOS vendor to see if the " 946 printk(KERN_INFO "Contact your BIOS vendor to see if the "
793 "E752x error registers can be safely un-hidden\n"); 947 "E752x error registers can be safely un-hidden\n");
794 goto fail; 948 return -ENOMEM;
795 } 949 }
796 stat8 |= (1 << 5); 950 stat8 |= (1 << 5);
797 pci_write_config_byte(pdev, E752X_DEVPRES1, stat8); 951 pci_write_config_byte(pdev, E752X_DEVPRES1, stat8);
798 952
799 /* need to find out the number of channels */
800 pci_read_config_dword(pdev, E752X_DRC, &drc);
801 pci_read_config_word(pdev, E752X_DDRCSR, &ddrcsr); 953 pci_read_config_word(pdev, E752X_DDRCSR, &ddrcsr);
802 /* FIXME: should check >>12 or 0xf, true for all? */ 954 /* FIXME: should check >>12 or 0xf, true for all? */
803 /* Dual channel = 1, Single channel = 0 */ 955 /* Dual channel = 1, Single channel = 0 */
804 drc_chan = (((ddrcsr >> 12) & 3) == 3); 956 drc_chan = dual_channel_active(ddrcsr);
805 drc_drbg = drc_chan + 1; /* 128 in dual mode, 64 in single */
806 drc_ddim = (drc >> 20) & 0x3;
807 957
808 mci = edac_mc_alloc(sizeof(*pvt), E752X_NR_CSROWS, drc_chan + 1); 958 mci = edac_mc_alloc(sizeof(*pvt), E752X_NR_CSROWS, drc_chan + 1);
809 959
810 if (mci == NULL) { 960 if (mci == NULL) {
811 rc = -ENOMEM; 961 return -ENOMEM;
812 goto fail;
813 } 962 }
814 963
815 debugf3("%s(): init mci\n", __func__); 964 debugf3("%s(): init mci\n", __func__);
@@ -818,159 +967,54 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
818 EDAC_FLAG_S4ECD4ED; 967 EDAC_FLAG_S4ECD4ED;
819 /* FIXME - what if different memory types are in different csrows? */ 968 /* FIXME - what if different memory types are in different csrows? */
820 mci->mod_name = EDAC_MOD_STR; 969 mci->mod_name = EDAC_MOD_STR;
821 mci->mod_ver = "$Revision: 1.5.2.11 $"; 970 mci->mod_ver = E752X_REVISION;
822 mci->pdev = pdev; 971 mci->dev = &pdev->dev;
823 972
824 debugf3("%s(): init pvt\n", __func__); 973 debugf3("%s(): init pvt\n", __func__);
825 pvt = (struct e752x_pvt *) mci->pvt_info; 974 pvt = (struct e752x_pvt *) mci->pvt_info;
826 pvt->dev_info = &e752x_devs[dev_idx]; 975 pvt->dev_info = &e752x_devs[dev_idx];
827 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, 976 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
828 pvt->dev_info->err_dev,
829 pvt->bridge_ck);
830
831 if (pvt->bridge_ck == NULL)
832 pvt->bridge_ck = pci_scan_single_device(pdev->bus,
833 PCI_DEVFN(0, 1));
834 977
835 if (pvt->bridge_ck == NULL) { 978 if (e752x_get_devs(pdev, dev_idx, pvt)) {
836 e752x_printk(KERN_ERR, "error reporting device not found:" 979 edac_mc_free(mci);
837 "vendor %x device 0x%x (broken BIOS?)\n", 980 return -ENODEV;
838 PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
839 goto fail;
840 } 981 }
841 982
842 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
843 debugf3("%s(): more mci init\n", __func__); 983 debugf3("%s(): more mci init\n", __func__);
844 mci->ctl_name = pvt->dev_info->ctl_name; 984 mci->ctl_name = pvt->dev_info->ctl_name;
845 mci->edac_check = e752x_check; 985 mci->edac_check = e752x_check;
846 mci->ctl_page_to_phys = ctl_page_to_phys; 986 mci->ctl_page_to_phys = ctl_page_to_phys;
847 987
848 /* find out the device types */ 988 e752x_init_csrows(mci, pdev, ddrcsr);
849 pci_read_config_dword(pdev, E752X_DRA, &dra); 989 e752x_init_mem_map_table(pdev, pvt);
850
851 /*
852 * The dram row boundary (DRB) reg values are boundary address for
853 * each DRAM row with a granularity of 64 or 128MB (single/dual
854 * channel operation). DRB regs are cumulative; therefore DRB7 will
855 * contain the total memory contained in all eight rows.
856 */
857 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
858 u8 value;
859 u32 cumul_size;
860
861 /* mem_dev 0=x8, 1=x4 */
862 int mem_dev = (dra >> (index * 4 + 2)) & 0x3;
863 struct csrow_info *csrow = &mci->csrows[index];
864
865 mem_dev = (mem_dev == 2);
866 pci_read_config_byte(mci->pdev, E752X_DRB + index, &value);
867 /* convert a 128 or 64 MiB DRB to a page size. */
868 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
869 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
870 cumul_size);
871
872 if (cumul_size == last_cumul_size)
873 continue; /* not populated */
874
875 csrow->first_page = last_cumul_size;
876 csrow->last_page = cumul_size - 1;
877 csrow->nr_pages = cumul_size - last_cumul_size;
878 last_cumul_size = cumul_size;
879 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
880 csrow->mtype = MEM_RDDR; /* only one type supported */
881 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
882
883 /*
884 * if single channel or x8 devices then SECDED
885 * if dual channel and x4 then S4ECD4ED
886 */
887 if (drc_ddim) {
888 if (drc_chan && mem_dev) {
889 csrow->edac_mode = EDAC_S4ECD4ED;
890 mci->edac_cap |= EDAC_FLAG_S4ECD4ED;
891 } else {
892 csrow->edac_mode = EDAC_SECDED;
893 mci->edac_cap |= EDAC_FLAG_SECDED;
894 }
895 } else
896 csrow->edac_mode = EDAC_NONE;
897 }
898
899 /* Fill in the memory map table */
900 {
901 u8 value;
902 u8 last = 0;
903 u8 row = 0;
904
905 for (index = 0; index < 8; index += 2) {
906 pci_read_config_byte(mci->pdev, E752X_DRB + index,
907 &value);
908
909 /* test if there is a dimm in this slot */
910 if (value == last) {
911 /* no dimm in the slot, so flag it as empty */
912 pvt->map[index] = 0xff;
913 pvt->map[index + 1] = 0xff;
914 } else { /* there is a dimm in the slot */
915 pvt->map[index] = row;
916 row++;
917 last = value;
918 /* test the next value to see if the dimm is
919 double sided */
920 pci_read_config_byte(mci->pdev,
921 E752X_DRB + index + 1,
922 &value);
923 pvt->map[index + 1] = (value == last) ?
924 0xff : /* the dimm is single sided,
925 * so flag as empty
926 */
927 row; /* this is a double sided dimm
928 * to save the next row #
929 */
930 row++;
931 last = value;
932 }
933 }
934 }
935 990
936 /* set the map type. 1 = normal, 0 = reversed */ 991 /* set the map type. 1 = normal, 0 = reversed */
937 pci_read_config_byte(mci->pdev, E752X_DRM, &stat8); 992 pci_read_config_byte(pdev, E752X_DRM, &stat8);
938 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f)); 993 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
939 994
940 mci->edac_cap |= EDAC_FLAG_NONE; 995 mci->edac_cap |= EDAC_FLAG_NONE;
941 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__); 996 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);
942 997
943 /* load the top of low memory, remap base, and remap limit vars */ 998 /* load the top of low memory, remap base, and remap limit vars */
944 pci_read_config_word(mci->pdev, E752X_TOLM, &pci_data); 999 pci_read_config_word(pdev, E752X_TOLM, &pci_data);
945 pvt->tolm = ((u32) pci_data) << 4; 1000 pvt->tolm = ((u32) pci_data) << 4;
946 pci_read_config_word(mci->pdev, E752X_REMAPBASE, &pci_data); 1001 pci_read_config_word(pdev, E752X_REMAPBASE, &pci_data);
947 pvt->remapbase = ((u32) pci_data) << 14; 1002 pvt->remapbase = ((u32) pci_data) << 14;
948 pci_read_config_word(mci->pdev, E752X_REMAPLIMIT, &pci_data); 1003 pci_read_config_word(pdev, E752X_REMAPLIMIT, &pci_data);
949 pvt->remaplimit = ((u32) pci_data) << 14; 1004 pvt->remaplimit = ((u32) pci_data) << 14;
950 e752x_printk(KERN_INFO, 1005 e752x_printk(KERN_INFO,
951 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm, 1006 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
952 pvt->remapbase, pvt->remaplimit); 1007 pvt->remapbase, pvt->remaplimit);
953 1008
954 if (edac_mc_add_mc(mci)) { 1009 /* Here we assume that we will never see multiple instances of this
1010 * type of memory controller. The ID is therefore hardcoded to 0.
1011 */
1012 if (edac_mc_add_mc(mci,0)) {
955 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 1013 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
956 goto fail; 1014 goto fail;
957 } 1015 }
958 1016
959 dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev, 1017 e752x_init_error_reporting_regs(pvt);
960 NULL);
961 pvt->dev_d0f0 = dev;
962 /* find the error reporting device and clear errors */
963 dev = pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck);
964 /* Turn off error disable & SMI in case the BIOS turned it on */
965 pci_write_config_byte(dev, E752X_HI_ERRMASK, 0x00);
966 pci_write_config_byte(dev, E752X_HI_SMICMD, 0x00);
967 pci_write_config_word(dev, E752X_SYSBUS_ERRMASK, 0x00);
968 pci_write_config_word(dev, E752X_SYSBUS_SMICMD, 0x00);
969 pci_write_config_byte(dev, E752X_BUF_ERRMASK, 0x00);
970 pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
971 pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
972 pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
973
974 e752x_get_error_info(mci, &discard); /* clear other MCH errors */ 1018 e752x_get_error_info(mci, &discard); /* clear other MCH errors */
975 1019
976 /* get this far and it's successful */ 1020 /* get this far and it's successful */
@@ -978,20 +1022,12 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
978 return 0; 1022 return 0;
979 1023
980fail: 1024fail:
981 if (mci) { 1025 pci_dev_put(pvt->dev_d0f0);
982 if (pvt->dev_d0f0) 1026 pci_dev_put(pvt->dev_d0f1);
983 pci_dev_put(pvt->dev_d0f0); 1027 pci_dev_put(pvt->bridge_ck);
984 1028 edac_mc_free(mci);
985 if (pvt->dev_d0f1)
986 pci_dev_put(pvt->dev_d0f1);
987
988 if (pvt->bridge_ck)
989 pci_dev_put(pvt->bridge_ck);
990
991 edac_mc_free(mci);
992 }
993 1029
994 return rc; 1030 return -ENODEV;
995} 1031}
996 1032
997/* returns count (>= 0), or negative on error */ 1033/* returns count (>= 0), or negative on error */
@@ -1014,7 +1050,7 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
1014 1050
1015 debugf0("%s()\n", __func__); 1051 debugf0("%s()\n", __func__);
1016 1052
1017 if ((mci = edac_mc_del_mc(pdev)) == NULL) 1053 if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL)
1018 return; 1054 return;
1019 1055
1020 pvt = (struct e752x_pvt *) mci->pvt_info; 1056 pvt = (struct e752x_pvt *) mci->pvt_info;