diff options
Diffstat (limited to 'drivers/edac/i82860_edac.c')
-rw-r--r-- | drivers/edac/i82860_edac.c | 131 |
1 files changed, 70 insertions, 61 deletions
diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c index 56ba31f85f13..e30a4a2eaf38 100644 --- a/drivers/edac/i82860_edac.c +++ b/drivers/edac/i82860_edac.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include "edac_mc.h" | 17 | #include "edac_mc.h" |
18 | 18 | ||
19 | #define I82860_REVISION " Ver: 2.0.0 " __DATE__ | ||
20 | |||
19 | #define i82860_printk(level, fmt, arg...) \ | 21 | #define i82860_printk(level, fmt, arg...) \ |
20 | edac_printk(level, "i82860", fmt, ##arg) | 22 | edac_printk(level, "i82860", fmt, ##arg) |
21 | 23 | ||
@@ -62,17 +64,21 @@ static struct pci_dev *mci_pdev = NULL; /* init dev: in case that AGP code | |||
62 | static void i82860_get_error_info(struct mem_ctl_info *mci, | 64 | static void i82860_get_error_info(struct mem_ctl_info *mci, |
63 | struct i82860_error_info *info) | 65 | struct i82860_error_info *info) |
64 | { | 66 | { |
67 | struct pci_dev *pdev; | ||
68 | |||
69 | pdev = to_pci_dev(mci->dev); | ||
70 | |||
65 | /* | 71 | /* |
66 | * This is a mess because there is no atomic way to read all the | 72 | * This is a mess because there is no atomic way to read all the |
67 | * registers at once and the registers can transition from CE being | 73 | * registers at once and the registers can transition from CE being |
68 | * overwritten by UE. | 74 | * overwritten by UE. |
69 | */ | 75 | */ |
70 | pci_read_config_word(mci->pdev, I82860_ERRSTS, &info->errsts); | 76 | pci_read_config_word(pdev, I82860_ERRSTS, &info->errsts); |
71 | pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap); | 77 | pci_read_config_dword(pdev, I82860_EAP, &info->eap); |
72 | pci_read_config_word(mci->pdev, I82860_DERRCTL_STS, &info->derrsyn); | 78 | pci_read_config_word(pdev, I82860_DERRCTL_STS, &info->derrsyn); |
73 | pci_read_config_word(mci->pdev, I82860_ERRSTS, &info->errsts2); | 79 | pci_read_config_word(pdev, I82860_ERRSTS, &info->errsts2); |
74 | 80 | ||
75 | pci_write_bits16(mci->pdev, I82860_ERRSTS, 0x0003, 0x0003); | 81 | pci_write_bits16(pdev, I82860_ERRSTS, 0x0003, 0x0003); |
76 | 82 | ||
77 | /* | 83 | /* |
78 | * If the error is the same for both reads then the first set of reads | 84 | * If the error is the same for both reads then the first set of reads |
@@ -83,8 +89,8 @@ static void i82860_get_error_info(struct mem_ctl_info *mci, | |||
83 | return; | 89 | return; |
84 | 90 | ||
85 | if ((info->errsts ^ info->errsts2) & 0x0003) { | 91 | if ((info->errsts ^ info->errsts2) & 0x0003) { |
86 | pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap); | 92 | pci_read_config_dword(pdev, I82860_EAP, &info->eap); |
87 | pci_read_config_word(mci->pdev, I82860_DERRCTL_STS, | 93 | pci_read_config_word(pdev, I82860_DERRCTL_STS, |
88 | &info->derrsyn); | 94 | &info->derrsyn); |
89 | } | 95 | } |
90 | } | 96 | } |
@@ -126,15 +132,50 @@ static void i82860_check(struct mem_ctl_info *mci) | |||
126 | i82860_process_error_info(mci, &info, 1); | 132 | i82860_process_error_info(mci, &info, 1); |
127 | } | 133 | } |
128 | 134 | ||
129 | static int i82860_probe1(struct pci_dev *pdev, int dev_idx) | 135 | static void i82860_init_csrows(struct mem_ctl_info *mci, struct pci_dev *pdev) |
130 | { | 136 | { |
131 | int rc = -ENODEV; | ||
132 | int index; | ||
133 | struct mem_ctl_info *mci = NULL; | ||
134 | unsigned long last_cumul_size; | 137 | unsigned long last_cumul_size; |
135 | struct i82860_error_info discard; | 138 | u16 mchcfg_ddim; /* DRAM Data Integrity Mode 0=none, 2=edac */ |
139 | u16 value; | ||
140 | u32 cumul_size; | ||
141 | struct csrow_info *csrow; | ||
142 | int index; | ||
143 | |||
144 | pci_read_config_word(pdev, I82860_MCHCFG, &mchcfg_ddim); | ||
145 | mchcfg_ddim = mchcfg_ddim & 0x180; | ||
146 | last_cumul_size = 0; | ||
147 | |||
148 | /* The group row boundary (GRA) reg values are boundary address | ||
149 | * for each DRAM row with a granularity of 16MB. GRA regs are | ||
150 | * cumulative; therefore GRA15 will contain the total memory contained | ||
151 | * in all eight rows. | ||
152 | */ | ||
153 | for (index = 0; index < mci->nr_csrows; index++) { | ||
154 | csrow = &mci->csrows[index]; | ||
155 | pci_read_config_word(pdev, I82860_GBA + index * 2, &value); | ||
156 | cumul_size = (value & I82860_GBA_MASK) << | ||
157 | (I82860_GBA_SHIFT - PAGE_SHIFT); | ||
158 | debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, | ||
159 | cumul_size); | ||
136 | 160 | ||
137 | u16 mchcfg_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */ | 161 | if (cumul_size == last_cumul_size) |
162 | continue; /* not populated */ | ||
163 | |||
164 | csrow->first_page = last_cumul_size; | ||
165 | csrow->last_page = cumul_size - 1; | ||
166 | csrow->nr_pages = cumul_size - last_cumul_size; | ||
167 | last_cumul_size = cumul_size; | ||
168 | csrow->grain = 1 << 12; /* I82860_EAP has 4KiB reolution */ | ||
169 | csrow->mtype = MEM_RMBS; | ||
170 | csrow->dtype = DEV_UNKNOWN; | ||
171 | csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | static int i82860_probe1(struct pci_dev *pdev, int dev_idx) | ||
176 | { | ||
177 | struct mem_ctl_info *mci; | ||
178 | struct i82860_error_info discard; | ||
138 | 179 | ||
139 | /* RDRAM has channels but these don't map onto the abstractions that | 180 | /* RDRAM has channels but these don't map onto the abstractions that |
140 | edac uses. | 181 | edac uses. |
@@ -150,67 +191,35 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx) | |||
150 | return -ENOMEM; | 191 | return -ENOMEM; |
151 | 192 | ||
152 | debugf3("%s(): init mci\n", __func__); | 193 | debugf3("%s(): init mci\n", __func__); |
153 | mci->pdev = pdev; | 194 | mci->dev = &pdev->dev; |
154 | mci->mtype_cap = MEM_FLAG_DDR; | 195 | mci->mtype_cap = MEM_FLAG_DDR; |
155 | |||
156 | mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; | 196 | mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; |
157 | /* I"m not sure about this but I think that all RDRAM is SECDED */ | 197 | /* I"m not sure about this but I think that all RDRAM is SECDED */ |
158 | mci->edac_cap = EDAC_FLAG_SECDED; | 198 | mci->edac_cap = EDAC_FLAG_SECDED; |
159 | /* adjust FLAGS */ | ||
160 | |||
161 | mci->mod_name = EDAC_MOD_STR; | 199 | mci->mod_name = EDAC_MOD_STR; |
162 | mci->mod_ver = "$Revision: 1.1.2.6 $"; | 200 | mci->mod_ver = I82860_REVISION; |
163 | mci->ctl_name = i82860_devs[dev_idx].ctl_name; | 201 | mci->ctl_name = i82860_devs[dev_idx].ctl_name; |
164 | mci->edac_check = i82860_check; | 202 | mci->edac_check = i82860_check; |
165 | mci->ctl_page_to_phys = NULL; | 203 | mci->ctl_page_to_phys = NULL; |
204 | i82860_init_csrows(mci, pdev); | ||
205 | i82860_get_error_info(mci, &discard); /* clear counters */ | ||
166 | 206 | ||
167 | pci_read_config_word(mci->pdev, I82860_MCHCFG, &mchcfg_ddim); | 207 | /* Here we assume that we will never see multiple instances of this |
168 | mchcfg_ddim = mchcfg_ddim & 0x180; | 208 | * type of memory controller. The ID is therefore hardcoded to 0. |
169 | |||
170 | /* | ||
171 | * The group row boundary (GRA) reg values are boundary address | ||
172 | * for each DRAM row with a granularity of 16MB. GRA regs are | ||
173 | * cumulative; therefore GRA15 will contain the total memory contained | ||
174 | * in all eight rows. | ||
175 | */ | 209 | */ |
176 | for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) { | 210 | if (edac_mc_add_mc(mci,0)) { |
177 | u16 value; | 211 | debugf3("%s(): failed edac_mc_add_mc()\n", __func__); |
178 | u32 cumul_size; | 212 | goto fail; |
179 | struct csrow_info *csrow = &mci->csrows[index]; | ||
180 | |||
181 | pci_read_config_word(mci->pdev, I82860_GBA + index * 2, | ||
182 | &value); | ||
183 | |||
184 | cumul_size = (value & I82860_GBA_MASK) << | ||
185 | (I82860_GBA_SHIFT - PAGE_SHIFT); | ||
186 | debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, | ||
187 | cumul_size); | ||
188 | |||
189 | if (cumul_size == last_cumul_size) | ||
190 | continue; /* not populated */ | ||
191 | |||
192 | csrow->first_page = last_cumul_size; | ||
193 | csrow->last_page = cumul_size - 1; | ||
194 | csrow->nr_pages = cumul_size - last_cumul_size; | ||
195 | last_cumul_size = cumul_size; | ||
196 | csrow->grain = 1 << 12; /* I82860_EAP has 4KiB reolution */ | ||
197 | csrow->mtype = MEM_RMBS; | ||
198 | csrow->dtype = DEV_UNKNOWN; | ||
199 | csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE; | ||
200 | } | 213 | } |
201 | 214 | ||
202 | i82860_get_error_info(mci, &discard); /* clear counters */ | 215 | /* get this far and it's successful */ |
216 | debugf3("%s(): success\n", __func__); | ||
203 | 217 | ||
204 | if (edac_mc_add_mc(mci)) { | 218 | return 0; |
205 | debugf3("%s(): failed edac_mc_add_mc()\n", __func__); | ||
206 | edac_mc_free(mci); | ||
207 | } else { | ||
208 | /* get this far and it's successful */ | ||
209 | debugf3("%s(): success\n", __func__); | ||
210 | rc = 0; | ||
211 | } | ||
212 | 219 | ||
213 | return rc; | 220 | fail: |
221 | edac_mc_free(mci); | ||
222 | return -ENODEV; | ||
214 | } | 223 | } |
215 | 224 | ||
216 | /* returns count (>= 0), or negative on error */ | 225 | /* returns count (>= 0), or negative on error */ |
@@ -239,7 +248,7 @@ static void __devexit i82860_remove_one(struct pci_dev *pdev) | |||
239 | 248 | ||
240 | debugf0("%s()\n", __func__); | 249 | debugf0("%s()\n", __func__); |
241 | 250 | ||
242 | if ((mci = edac_mc_del_mc(pdev)) == NULL) | 251 | if ((mci = edac_mc_del_mc(&pdev->dev)) == NULL) |
243 | return; | 252 | return; |
244 | 253 | ||
245 | edac_mc_free(mci); | 254 | edac_mc_free(mci); |