aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/amd64_edac.c45
-rw-r--r--drivers/edac/amd64_edac.h2
2 files changed, 29 insertions, 18 deletions
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 84c565d4f56b..98c0150800dc 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -15,10 +15,9 @@ module_param(ecc_enable_override, int, 0644);
15 15
16static struct msr __percpu *msrs; 16static struct msr __percpu *msrs;
17 17
18/* Lookup table for all possible MC control instances */ 18/* Per-node driver instances */
19struct amd64_pvt; 19static struct mem_ctl_info **mcis;
20static struct mem_ctl_info *mci_lookup[EDAC_MAX_NUMNODES]; 20static struct amd64_pvt **pvts;
21static struct amd64_pvt *pvt_lookup[EDAC_MAX_NUMNODES];
22 21
23/* 22/*
24 * Address to DRAM bank mapping: see F2x80 for K8 and F2x[1,0]80 for Fam10 and 23 * Address to DRAM bank mapping: see F2x80 for K8 and F2x[1,0]80 for Fam10 and
@@ -1446,7 +1445,7 @@ static int f10_lookup_addr_in_dct(u32 in_addr, u32 nid, u32 cs)
1446 int cs_found = -EINVAL; 1445 int cs_found = -EINVAL;
1447 int csrow; 1446 int csrow;
1448 1447
1449 mci = mci_lookup[nid]; 1448 mci = mcis[nid];
1450 if (!mci) 1449 if (!mci)
1451 return cs_found; 1450 return cs_found;
1452 1451
@@ -1995,7 +1994,7 @@ static inline void __amd64_decode_bus_error(struct mem_ctl_info *mci,
1995 1994
1996void amd64_decode_bus_error(int node_id, struct mce *m, u32 nbcfg) 1995void amd64_decode_bus_error(int node_id, struct mce *m, u32 nbcfg)
1997{ 1996{
1998 struct mem_ctl_info *mci = mci_lookup[node_id]; 1997 struct mem_ctl_info *mci = mcis[node_id];
1999 struct err_regs regs; 1998 struct err_regs regs;
2000 1999
2001 regs.nbsl = (u32) m->status; 2000 regs.nbsl = (u32) m->status;
@@ -2615,7 +2614,7 @@ static int amd64_probe_one_instance(struct pci_dev *F2)
2615 * Save the pointer to the private data for use in 2nd initialization 2614 * Save the pointer to the private data for use in 2nd initialization
2616 * stage 2615 * stage
2617 */ 2616 */
2618 pvt_lookup[pvt->mc_node_id] = pvt; 2617 pvts[pvt->mc_node_id] = pvt;
2619 2618
2620 return 0; 2619 return 0;
2621 2620
@@ -2672,8 +2671,8 @@ static int amd64_init_2nd_stage(struct amd64_pvt *pvt)
2672 goto err_add_mc; 2671 goto err_add_mc;
2673 } 2672 }
2674 2673
2675 mci_lookup[node_id] = mci; 2674 mcis[node_id] = mci;
2676 pvt_lookup[node_id] = NULL; 2675 pvts[node_id] = NULL;
2677 2676
2678 /* register stuff with EDAC MCE */ 2677 /* register stuff with EDAC MCE */
2679 if (report_gart_errors) 2678 if (report_gart_errors)
@@ -2696,8 +2695,8 @@ err_exit:
2696 2695
2697 amd64_free_mc_sibling_devices(pvt); 2696 amd64_free_mc_sibling_devices(pvt);
2698 2697
2699 kfree(pvt_lookup[pvt->mc_node_id]); 2698 kfree(pvts[pvt->mc_node_id]);
2700 pvt_lookup[node_id] = NULL; 2699 pvts[node_id] = NULL;
2701 2700
2702 return ret; 2701 return ret;
2703} 2702}
@@ -2746,7 +2745,7 @@ static void __devexit amd64_remove_one_instance(struct pci_dev *pdev)
2746 2745
2747 /* Free the EDAC CORE resources */ 2746 /* Free the EDAC CORE resources */
2748 mci->pvt_info = NULL; 2747 mci->pvt_info = NULL;
2749 mci_lookup[pvt->mc_node_id] = NULL; 2748 mcis[pvt->mc_node_id] = NULL;
2750 2749
2751 kfree(pvt); 2750 kfree(pvt);
2752 edac_mc_free(mci); 2751 edac_mc_free(mci);
@@ -2793,7 +2792,7 @@ static void amd64_setup_pci_device(void)
2793 if (amd64_ctl_pci) 2792 if (amd64_ctl_pci)
2794 return; 2793 return;
2795 2794
2796 mci = mci_lookup[0]; 2795 mci = mcis[0];
2797 if (mci) { 2796 if (mci) {
2798 2797
2799 pvt = mci->pvt_info; 2798 pvt = mci->pvt_info;
@@ -2822,6 +2821,12 @@ static int __init amd64_edac_init(void)
2822 if (amd_cache_northbridges() < 0) 2821 if (amd_cache_northbridges() < 0)
2823 goto err_ret; 2822 goto err_ret;
2824 2823
2824 err = -ENOMEM;
2825 pvts = kzalloc(amd_nb_num() * sizeof(pvts[0]), GFP_KERNEL);
2826 mcis = kzalloc(amd_nb_num() * sizeof(mcis[0]), GFP_KERNEL);
2827 if (!(pvts && mcis))
2828 goto err_ret;
2829
2825 msrs = msrs_alloc(); 2830 msrs = msrs_alloc();
2826 if (!msrs) 2831 if (!msrs)
2827 goto err_ret; 2832 goto err_ret;
@@ -2831,16 +2836,16 @@ static int __init amd64_edac_init(void)
2831 goto err_pci; 2836 goto err_pci;
2832 2837
2833 /* 2838 /*
2834 * At this point, the array 'pvt_lookup[]' contains pointers to alloc'd 2839 * At this point, the array 'pvts[]' contains pointers to alloc'd
2835 * amd64_pvt structs. These will be used in the 2nd stage init function 2840 * amd64_pvt structs. These will be used in the 2nd stage init function
2836 * to finish initialization of the MC instances. 2841 * to finish initialization of the MC instances.
2837 */ 2842 */
2838 err = -ENODEV; 2843 err = -ENODEV;
2839 for (nb = 0; nb < amd_nb_num(); nb++) { 2844 for (nb = 0; nb < amd_nb_num(); nb++) {
2840 if (!pvt_lookup[nb]) 2845 if (!pvts[nb])
2841 continue; 2846 continue;
2842 2847
2843 err = amd64_init_2nd_stage(pvt_lookup[nb]); 2848 err = amd64_init_2nd_stage(pvts[nb]);
2844 if (err) 2849 if (err)
2845 goto err_2nd_stage; 2850 goto err_2nd_stage;
2846 2851
@@ -2854,9 +2859,11 @@ static int __init amd64_edac_init(void)
2854 2859
2855err_2nd_stage: 2860err_2nd_stage:
2856 pci_unregister_driver(&amd64_pci_driver); 2861 pci_unregister_driver(&amd64_pci_driver);
2862
2857err_pci: 2863err_pci:
2858 msrs_free(msrs); 2864 msrs_free(msrs);
2859 msrs = NULL; 2865 msrs = NULL;
2866
2860err_ret: 2867err_ret:
2861 return err; 2868 return err;
2862} 2869}
@@ -2868,6 +2875,12 @@ static void __exit amd64_edac_exit(void)
2868 2875
2869 pci_unregister_driver(&amd64_pci_driver); 2876 pci_unregister_driver(&amd64_pci_driver);
2870 2877
2878 kfree(mcis);
2879 mcis = NULL;
2880
2881 kfree(pvts);
2882 pvts = NULL;
2883
2871 msrs_free(msrs); 2884 msrs_free(msrs);
2872 msrs = NULL; 2885 msrs = NULL;
2873} 2886}
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index f15e2b257e72..5538cc19cf4a 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -147,8 +147,6 @@
147#define EDAC_AMD64_VERSION "v3.3.0" 147#define EDAC_AMD64_VERSION "v3.3.0"
148#define EDAC_MOD_STR "amd64_edac" 148#define EDAC_MOD_STR "amd64_edac"
149 149
150#define EDAC_MAX_NUMNODES 8
151
152/* Extended Model from CPUID, for CPU Revision numbers */ 150/* Extended Model from CPUID, for CPU Revision numbers */
153#define K8_REV_D 1 151#define K8_REV_D 1
154#define K8_REV_E 2 152#define K8_REV_E 2