aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDave Peterson <dsp@llnl.gov>2006-03-26 04:38:52 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-26 11:57:08 -0500
commite7ecd8910293564d357dbaf18eb179e06fa35fd0 (patch)
tree7ec33cd42783cc53dd3ce161802d1032cea869a7 /drivers
parent54933dddc3e8ccd9db48966d8ada11951cb8a558 (diff)
[PATCH] EDAC: formatting cleanup
Cosmetic indentation/formatting cleanup for EDAC code. Make sure we are using tabs rather than spaces to indent, etc. Signed-off-by: David S. Peterson <dsp@llnl.gov> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/edac/amd76x_edac.c91
-rw-r--r--drivers/edac/e752x_edac.c234
-rw-r--r--drivers/edac/e7xxx_edac.c165
-rw-r--r--drivers/edac/edac_mc.c325
-rw-r--r--drivers/edac/edac_mc.h96
-rw-r--r--drivers/edac/i82860_edac.c66
-rw-r--r--drivers/edac/i82875p_edac.c112
-rw-r--r--drivers/edac/r82600_edac.c71
8 files changed, 558 insertions, 602 deletions
diff --git a/drivers/edac/amd76x_edac.c b/drivers/edac/amd76x_edac.c
index 87bd8b4d561f..53423ad6d4a3 100644
--- a/drivers/edac/amd76x_edac.c
+++ b/drivers/edac/amd76x_edac.c
@@ -12,33 +12,26 @@
12 * 12 *
13 */ 13 */
14 14
15
16#include <linux/config.h> 15#include <linux/config.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/init.h> 17#include <linux/init.h>
19
20#include <linux/pci.h> 18#include <linux/pci.h>
21#include <linux/pci_ids.h> 19#include <linux/pci_ids.h>
22
23#include <linux/slab.h> 20#include <linux/slab.h>
24
25#include "edac_mc.h" 21#include "edac_mc.h"
26 22
27
28#define amd76x_printk(level, fmt, arg...) \ 23#define amd76x_printk(level, fmt, arg...) \
29 edac_printk(level, "amd76x", fmt, ##arg) 24 edac_printk(level, "amd76x", fmt, ##arg)
30
31 25
32#define amd76x_mc_printk(mci, level, fmt, arg...) \ 26#define amd76x_mc_printk(mci, level, fmt, arg...) \
33 edac_mc_chipset_printk(mci, level, "amd76x", fmt, ##arg) 27 edac_mc_chipset_printk(mci, level, "amd76x", fmt, ##arg)
34
35 28
36#define AMD76X_NR_CSROWS 8 29#define AMD76X_NR_CSROWS 8
37#define AMD76X_NR_CHANS 1 30#define AMD76X_NR_CHANS 1
38#define AMD76X_NR_DIMMS 4 31#define AMD76X_NR_DIMMS 4
39 32
40
41/* AMD 76x register addresses - device 0 function 0 - PCI bridge */ 33/* AMD 76x register addresses - device 0 function 0 - PCI bridge */
34
42#define AMD76X_ECC_MODE_STATUS 0x48 /* Mode and status of ECC (32b) 35#define AMD76X_ECC_MODE_STATUS 0x48 /* Mode and status of ECC (32b)
43 * 36 *
44 * 31:16 reserved 37 * 31:16 reserved
@@ -50,6 +43,7 @@
50 * 7:4 UE cs row 43 * 7:4 UE cs row
51 * 3:0 CE cs row 44 * 3:0 CE cs row
52 */ 45 */
46
53#define AMD76X_DRAM_MODE_STATUS 0x58 /* DRAM Mode and status (32b) 47#define AMD76X_DRAM_MODE_STATUS 0x58 /* DRAM Mode and status (32b)
54 * 48 *
55 * 31:26 clock disable 5 - 0 49 * 31:26 clock disable 5 - 0
@@ -64,6 +58,7 @@
64 * 15:8 reserved 58 * 15:8 reserved
65 * 7:0 x4 mode enable 7 - 0 59 * 7:0 x4 mode enable 7 - 0
66 */ 60 */
61
67#define AMD76X_MEM_BASE_ADDR 0xC0 /* Memory base address (8 x 32b) 62#define AMD76X_MEM_BASE_ADDR 0xC0 /* Memory base address (8 x 32b)
68 * 63 *
69 * 31:23 chip-select base 64 * 31:23 chip-select base
@@ -74,29 +69,28 @@
74 * 0 chip-select enable 69 * 0 chip-select enable
75 */ 70 */
76 71
77
78struct amd76x_error_info { 72struct amd76x_error_info {
79 u32 ecc_mode_status; 73 u32 ecc_mode_status;
80}; 74};
81 75
82
83enum amd76x_chips { 76enum amd76x_chips {
84 AMD761 = 0, 77 AMD761 = 0,
85 AMD762 78 AMD762
86}; 79};
87 80
88
89struct amd76x_dev_info { 81struct amd76x_dev_info {
90 const char *ctl_name; 82 const char *ctl_name;
91}; 83};
92 84
93
94static const struct amd76x_dev_info amd76x_devs[] = { 85static const struct amd76x_dev_info amd76x_devs[] = {
95 [AMD761] = {.ctl_name = "AMD761"}, 86 [AMD761] = {
96 [AMD762] = {.ctl_name = "AMD762"}, 87 .ctl_name = "AMD761"
88 },
89 [AMD762] = {
90 .ctl_name = "AMD762"
91 },
97}; 92};
98 93
99
100/** 94/**
101 * amd76x_get_error_info - fetch error information 95 * amd76x_get_error_info - fetch error information
102 * @mci: Memory controller 96 * @mci: Memory controller
@@ -105,23 +99,21 @@ static const struct amd76x_dev_info amd76x_devs[] = {
105 * Fetch and store the AMD76x ECC status. Clear pending status 99 * Fetch and store the AMD76x ECC status. Clear pending status
106 * on the chip so that further errors will be reported 100 * on the chip so that further errors will be reported
107 */ 101 */
108 102static void amd76x_get_error_info(struct mem_ctl_info *mci,
109static void amd76x_get_error_info (struct mem_ctl_info *mci, 103 struct amd76x_error_info *info)
110 struct amd76x_error_info *info)
111{ 104{
112 pci_read_config_dword(mci->pdev, AMD76X_ECC_MODE_STATUS, 105 pci_read_config_dword(mci->pdev, AMD76X_ECC_MODE_STATUS,
113 &info->ecc_mode_status); 106 &info->ecc_mode_status);
114 107
115 if (info->ecc_mode_status & BIT(8)) 108 if (info->ecc_mode_status & BIT(8))
116 pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS, 109 pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS,
117 (u32) BIT(8), (u32) BIT(8)); 110 (u32) BIT(8), (u32) BIT(8));
118 111
119 if (info->ecc_mode_status & BIT(9)) 112 if (info->ecc_mode_status & BIT(9))
120 pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS, 113 pci_write_bits32(mci->pdev, AMD76X_ECC_MODE_STATUS,
121 (u32) BIT(9), (u32) BIT(9)); 114 (u32) BIT(9), (u32) BIT(9));
122} 115}
123 116
124
125/** 117/**
126 * amd76x_process_error_info - Error check 118 * amd76x_process_error_info - Error check
127 * @mci: Memory controller 119 * @mci: Memory controller
@@ -132,8 +124,7 @@ static void amd76x_get_error_info (struct mem_ctl_info *mci,
132 * A return of 1 indicates an error. Also if handle_errors is true 124 * A return of 1 indicates an error. Also if handle_errors is true
133 * then attempt to handle and clean up after the error 125 * then attempt to handle and clean up after the error
134 */ 126 */
135 127static int amd76x_process_error_info(struct mem_ctl_info *mci,
136static int amd76x_process_error_info (struct mem_ctl_info *mci,
137 struct amd76x_error_info *info, int handle_errors) 128 struct amd76x_error_info *info, int handle_errors)
138{ 129{
139 int error_found; 130 int error_found;
@@ -149,9 +140,8 @@ static int amd76x_process_error_info (struct mem_ctl_info *mci,
149 140
150 if (handle_errors) { 141 if (handle_errors) {
151 row = (info->ecc_mode_status >> 4) & 0xf; 142 row = (info->ecc_mode_status >> 4) & 0xf;
152 edac_mc_handle_ue(mci, 143 edac_mc_handle_ue(mci, mci->csrows[row].first_page, 0,
153 mci->csrows[row].first_page, 0, row, 144 row, mci->ctl_name);
154 mci->ctl_name);
155 } 145 }
156 } 146 }
157 147
@@ -163,11 +153,11 @@ static int amd76x_process_error_info (struct mem_ctl_info *mci,
163 153
164 if (handle_errors) { 154 if (handle_errors) {
165 row = info->ecc_mode_status & 0xf; 155 row = info->ecc_mode_status & 0xf;
166 edac_mc_handle_ce(mci, 156 edac_mc_handle_ce(mci, mci->csrows[row].first_page, 0,
167 mci->csrows[row].first_page, 0, 0, row, 0, 157 0, row, 0, mci->ctl_name);
168 mci->ctl_name);
169 } 158 }
170 } 159 }
160
171 return error_found; 161 return error_found;
172} 162}
173 163
@@ -178,7 +168,6 @@ static int amd76x_process_error_info (struct mem_ctl_info *mci,
178 * Called by the poll handlers this function reads the status 168 * Called by the poll handlers this function reads the status
179 * from the controller and checks for errors. 169 * from the controller and checks for errors.
180 */ 170 */
181
182static void amd76x_check(struct mem_ctl_info *mci) 171static void amd76x_check(struct mem_ctl_info *mci)
183{ 172{
184 struct amd76x_error_info info; 173 struct amd76x_error_info info;
@@ -187,7 +176,6 @@ static void amd76x_check(struct mem_ctl_info *mci)
187 amd76x_process_error_info(mci, &info, 1); 176 amd76x_process_error_info(mci, &info, 1);
188} 177}
189 178
190
191/** 179/**
192 * amd76x_probe1 - Perform set up for detected device 180 * amd76x_probe1 - Perform set up for detected device
193 * @pdev; PCI device detected 181 * @pdev; PCI device detected
@@ -197,7 +185,6 @@ static void amd76x_check(struct mem_ctl_info *mci)
197 * controller status reporting. We configure and set up the 185 * controller status reporting. We configure and set up the
198 * memory controller reporting and claim the device. 186 * memory controller reporting and claim the device.
199 */ 187 */
200
201static int amd76x_probe1(struct pci_dev *pdev, int dev_idx) 188static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
202{ 189{
203 int rc = -ENODEV; 190 int rc = -ENODEV;
@@ -214,10 +201,8 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
214 struct amd76x_error_info discard; 201 struct amd76x_error_info discard;
215 202
216 debugf0("%s()\n", __func__); 203 debugf0("%s()\n", __func__);
217
218 pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS, &ems); 204 pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS, &ems);
219 ems_mode = (ems >> 10) & 0x3; 205 ems_mode = (ems >> 10) & 0x3;
220
221 mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS); 206 mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS);
222 207
223 if (mci == NULL) { 208 if (mci == NULL) {
@@ -226,14 +211,11 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
226 } 211 }
227 212
228 debugf0("%s(): mci = %p\n", __func__, mci); 213 debugf0("%s(): mci = %p\n", __func__, mci);
229
230 mci->pdev = pdev; 214 mci->pdev = pdev;
231 mci->mtype_cap = MEM_FLAG_RDDR; 215 mci->mtype_cap = MEM_FLAG_RDDR;
232
233 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 216 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
234 mci->edac_cap = ems_mode ? 217 mci->edac_cap = ems_mode ?
235 (EDAC_FLAG_EC | EDAC_FLAG_SECDED) : EDAC_FLAG_NONE; 218 (EDAC_FLAG_EC | EDAC_FLAG_SECDED) : EDAC_FLAG_NONE;
236
237 mci->mod_name = EDAC_MOD_STR; 219 mci->mod_name = EDAC_MOD_STR;
238 mci->mod_ver = "$Revision: 1.4.2.5 $"; 220 mci->mod_ver = "$Revision: 1.4.2.5 $";
239 mci->ctl_name = amd76x_devs[dev_idx].ctl_name; 221 mci->ctl_name = amd76x_devs[dev_idx].ctl_name;
@@ -249,18 +231,15 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
249 231
250 /* find the DRAM Chip Select Base address and mask */ 232 /* find the DRAM Chip Select Base address and mask */
251 pci_read_config_dword(mci->pdev, 233 pci_read_config_dword(mci->pdev,
252 AMD76X_MEM_BASE_ADDR + (index * 4), 234 AMD76X_MEM_BASE_ADDR + (index * 4), &mba);
253 &mba);
254 235
255 if (!(mba & BIT(0))) 236 if (!(mba & BIT(0)))
256 continue; 237 continue;
257 238
258 mba_base = mba & 0xff800000UL; 239 mba_base = mba & 0xff800000UL;
259 mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL; 240 mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;
260
261 pci_read_config_dword(mci->pdev, AMD76X_DRAM_MODE_STATUS, 241 pci_read_config_dword(mci->pdev, AMD76X_DRAM_MODE_STATUS,
262 &dms); 242 &dms);
263
264 csrow->first_page = mba_base >> PAGE_SHIFT; 243 csrow->first_page = mba_base >> PAGE_SHIFT;
265 csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT; 244 csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
266 csrow->last_page = csrow->first_page + csrow->nr_pages - 1; 245 csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
@@ -290,7 +269,7 @@ fail:
290 269
291/* returns count (>= 0), or negative on error */ 270/* returns count (>= 0), or negative on error */
292static int __devinit amd76x_init_one(struct pci_dev *pdev, 271static int __devinit amd76x_init_one(struct pci_dev *pdev,
293 const struct pci_device_id *ent) 272 const struct pci_device_id *ent)
294{ 273{
295 debugf0("%s()\n", __func__); 274 debugf0("%s()\n", __func__);
296 275
@@ -298,7 +277,6 @@ static int __devinit amd76x_init_one(struct pci_dev *pdev,
298 return amd76x_probe1(pdev, ent->driver_data); 277 return amd76x_probe1(pdev, ent->driver_data);
299} 278}
300 279
301
302/** 280/**
303 * amd76x_remove_one - driver shutdown 281 * amd76x_remove_one - driver shutdown
304 * @pdev: PCI device being handed back 282 * @pdev: PCI device being handed back
@@ -307,7 +285,6 @@ static int __devinit amd76x_init_one(struct pci_dev *pdev,
307 * structure for the device then delete the mci and free the 285 * structure for the device then delete the mci and free the
308 * resources. 286 * resources.
309 */ 287 */
310
311static void __devexit amd76x_remove_one(struct pci_dev *pdev) 288static void __devexit amd76x_remove_one(struct pci_dev *pdev)
312{ 289{
313 struct mem_ctl_info *mci; 290 struct mem_ctl_info *mci;
@@ -320,18 +297,22 @@ static void __devexit amd76x_remove_one(struct pci_dev *pdev)
320 edac_mc_free(mci); 297 edac_mc_free(mci);
321} 298}
322 299
323
324static const struct pci_device_id amd76x_pci_tbl[] __devinitdata = { 300static const struct pci_device_id amd76x_pci_tbl[] __devinitdata = {
325 {PCI_VEND_DEV(AMD, FE_GATE_700C), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 301 {
326 AMD762}, 302 PCI_VEND_DEV(AMD, FE_GATE_700C), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
327 {PCI_VEND_DEV(AMD, FE_GATE_700E), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 303 AMD762
328 AMD761}, 304 },
329 {0,} /* 0 terminated list. */ 305 {
306 PCI_VEND_DEV(AMD, FE_GATE_700E), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
307 AMD761
308 },
309 {
310 0,
311 } /* 0 terminated list. */
330}; 312};
331 313
332MODULE_DEVICE_TABLE(pci, amd76x_pci_tbl); 314MODULE_DEVICE_TABLE(pci, amd76x_pci_tbl);
333 315
334
335static struct pci_driver amd76x_driver = { 316static struct pci_driver amd76x_driver = {
336 .name = EDAC_MOD_STR, 317 .name = EDAC_MOD_STR,
337 .probe = amd76x_init_one, 318 .probe = amd76x_init_one,
diff --git a/drivers/edac/e752x_edac.c b/drivers/edac/e752x_edac.c
index c86db23d3af3..265cce72497c 100644
--- a/drivers/edac/e752x_edac.c
+++ b/drivers/edac/e752x_edac.c
@@ -17,26 +17,19 @@
17 * 17 *
18 */ 18 */
19 19
20
21#include <linux/config.h> 20#include <linux/config.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <linux/init.h> 22#include <linux/init.h>
24
25#include <linux/pci.h> 23#include <linux/pci.h>
26#include <linux/pci_ids.h> 24#include <linux/pci_ids.h>
27
28#include <linux/slab.h> 25#include <linux/slab.h>
29
30#include "edac_mc.h" 26#include "edac_mc.h"
31 27
32
33#define e752x_printk(level, fmt, arg...) \ 28#define e752x_printk(level, fmt, arg...) \
34 edac_printk(level, "e752x", fmt, ##arg) 29 edac_printk(level, "e752x", fmt, ##arg)
35
36 30
37#define e752x_mc_printk(mci, level, fmt, arg...) \ 31#define e752x_mc_printk(mci, level, fmt, arg...) \
38 edac_mc_chipset_printk(mci, level, "e752x", fmt, ##arg) 32 edac_mc_chipset_printk(mci, level, "e752x", fmt, ##arg)
39
40 33
41#ifndef PCI_DEVICE_ID_INTEL_7520_0 34#ifndef PCI_DEVICE_ID_INTEL_7520_0
42#define PCI_DEVICE_ID_INTEL_7520_0 0x3590 35#define PCI_DEVICE_ID_INTEL_7520_0 0x3590
@@ -64,7 +57,6 @@
64 57
65#define E752X_NR_CSROWS 8 /* number of csrows */ 58#define E752X_NR_CSROWS 8 /* number of csrows */
66 59
67
68/* E752X register addresses - device 0 function 0 */ 60/* E752X register addresses - device 0 function 0 */
69#define E752X_DRB 0x60 /* DRAM row boundary register (8b) */ 61#define E752X_DRB 0x60 /* DRAM row boundary register (8b) */
70#define E752X_DRA 0x70 /* DRAM row attribute register (8b) */ 62#define E752X_DRA 0x70 /* DRAM row attribute register (8b) */
@@ -164,7 +156,6 @@ enum e752x_chips {
164 E7320 = 2 156 E7320 = 2
165}; 157};
166 158
167
168struct e752x_pvt { 159struct e752x_pvt {
169 struct pci_dev *bridge_ck; 160 struct pci_dev *bridge_ck;
170 struct pci_dev *dev_d0f0; 161 struct pci_dev *dev_d0f0;
@@ -178,7 +169,6 @@ struct e752x_pvt {
178 const struct e752x_dev_info *dev_info; 169 const struct e752x_dev_info *dev_info;
179}; 170};
180 171
181
182struct e752x_dev_info { 172struct e752x_dev_info {
183 u16 err_dev; 173 u16 err_dev;
184 u16 ctl_dev; 174 u16 ctl_dev;
@@ -207,22 +197,24 @@ struct e752x_error_info {
207 197
208static const struct e752x_dev_info e752x_devs[] = { 198static const struct e752x_dev_info e752x_devs[] = {
209 [E7520] = { 199 [E7520] = {
210 .err_dev = PCI_DEVICE_ID_INTEL_7520_1_ERR, 200 .err_dev = PCI_DEVICE_ID_INTEL_7520_1_ERR,
211 .ctl_dev = PCI_DEVICE_ID_INTEL_7520_0, 201 .ctl_dev = PCI_DEVICE_ID_INTEL_7520_0,
212 .ctl_name = "E7520"}, 202 .ctl_name = "E7520"
203 },
213 [E7525] = { 204 [E7525] = {
214 .err_dev = PCI_DEVICE_ID_INTEL_7525_1_ERR, 205 .err_dev = PCI_DEVICE_ID_INTEL_7525_1_ERR,
215 .ctl_dev = PCI_DEVICE_ID_INTEL_7525_0, 206 .ctl_dev = PCI_DEVICE_ID_INTEL_7525_0,
216 .ctl_name = "E7525"}, 207 .ctl_name = "E7525"
208 },
217 [E7320] = { 209 [E7320] = {
218 .err_dev = PCI_DEVICE_ID_INTEL_7320_1_ERR, 210 .err_dev = PCI_DEVICE_ID_INTEL_7320_1_ERR,
219 .ctl_dev = PCI_DEVICE_ID_INTEL_7320_0, 211 .ctl_dev = PCI_DEVICE_ID_INTEL_7320_0,
220 .ctl_name = "E7320"}, 212 .ctl_name = "E7320"
213 },
221}; 214};
222 215
223
224static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci, 216static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
225 unsigned long page) 217 unsigned long page)
226{ 218{
227 u32 remap; 219 u32 remap;
228 struct e752x_pvt *pvt = (struct e752x_pvt *) mci->pvt_info; 220 struct e752x_pvt *pvt = (struct e752x_pvt *) mci->pvt_info;
@@ -231,17 +223,21 @@ static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
231 223
232 if (page < pvt->tolm) 224 if (page < pvt->tolm)
233 return page; 225 return page;
226
234 if ((page >= 0x100000) && (page < pvt->remapbase)) 227 if ((page >= 0x100000) && (page < pvt->remapbase))
235 return page; 228 return page;
229
236 remap = (page - pvt->tolm) + pvt->remapbase; 230 remap = (page - pvt->tolm) + pvt->remapbase;
231
237 if (remap < pvt->remaplimit) 232 if (remap < pvt->remaplimit)
238 return remap; 233 return remap;
234
239 e752x_printk(KERN_ERR, "Invalid page %lx - out of range\n", page); 235 e752x_printk(KERN_ERR, "Invalid page %lx - out of range\n", page);
240 return pvt->tolm - 1; 236 return pvt->tolm - 1;
241} 237}
242 238
243static void do_process_ce(struct mem_ctl_info *mci, u16 error_one, 239static void do_process_ce(struct mem_ctl_info *mci, u16 error_one,
244 u32 sec1_add, u16 sec1_syndrome) 240 u32 sec1_add, u16 sec1_syndrome)
245{ 241{
246 u32 page; 242 u32 page;
247 int row; 243 int row;
@@ -259,34 +255,36 @@ static void do_process_ce(struct mem_ctl_info *mci, u16 error_one,
259 /* chip select are bits 14 & 13 */ 255 /* chip select are bits 14 & 13 */
260 row = ((page >> 1) & 3); 256 row = ((page >> 1) & 3);
261 e752x_printk(KERN_WARNING, 257 e752x_printk(KERN_WARNING,
262 "Test row %d Table %d %d %d %d %d %d %d %d\n", 258 "Test row %d Table %d %d %d %d %d %d %d %d\n", row,
263 row, pvt->map[0], pvt->map[1], pvt->map[2], 259 pvt->map[0], pvt->map[1], pvt->map[2], pvt->map[3],
264 pvt->map[3], pvt->map[4], pvt->map[5], 260 pvt->map[4], pvt->map[5], pvt->map[6], pvt->map[7]);
265 pvt->map[6], pvt->map[7]);
266 261
267 /* test for channel remapping */ 262 /* test for channel remapping */
268 for (i = 0; i < 8; i++) { 263 for (i = 0; i < 8; i++) {
269 if (pvt->map[i] == row) 264 if (pvt->map[i] == row)
270 break; 265 break;
271 } 266 }
267
272 e752x_printk(KERN_WARNING, "Test computed row %d\n", i); 268 e752x_printk(KERN_WARNING, "Test computed row %d\n", i);
269
273 if (i < 8) 270 if (i < 8)
274 row = i; 271 row = i;
275 else 272 else
276 e752x_mc_printk(mci, KERN_WARNING, 273 e752x_mc_printk(mci, KERN_WARNING,
277 "row %d not found in remap table\n", row); 274 "row %d not found in remap table\n", row);
278 } else 275 } else
279 row = edac_mc_find_csrow_by_page(mci, page); 276 row = edac_mc_find_csrow_by_page(mci, page);
277
280 /* 0 = channel A, 1 = channel B */ 278 /* 0 = channel A, 1 = channel B */
281 channel = !(error_one & 1); 279 channel = !(error_one & 1);
282 280
283 if (!pvt->map_type) 281 if (!pvt->map_type)
284 row = 7 - row; 282 row = 7 - row;
283
285 edac_mc_handle_ce(mci, page, 0, sec1_syndrome, row, channel, 284 edac_mc_handle_ce(mci, page, 0, sec1_syndrome, row, channel,
286 "e752x CE"); 285 "e752x CE");
287} 286}
288 287
289
290static inline void process_ce(struct mem_ctl_info *mci, u16 error_one, 288static inline void process_ce(struct mem_ctl_info *mci, u16 error_one,
291 u32 sec1_add, u16 sec1_syndrome, int *error_found, 289 u32 sec1_add, u16 sec1_syndrome, int *error_found,
292 int handle_error) 290 int handle_error)
@@ -297,8 +295,8 @@ static inline void process_ce(struct mem_ctl_info *mci, u16 error_one,
297 do_process_ce(mci, error_one, sec1_add, sec1_syndrome); 295 do_process_ce(mci, error_one, sec1_add, sec1_syndrome);
298} 296}
299 297
300static void do_process_ue(struct mem_ctl_info *mci, u16 error_one, u32 ded_add, 298static void do_process_ue(struct mem_ctl_info *mci, u16 error_one,
301 u32 scrb_add) 299 u32 ded_add, u32 scrb_add)
302{ 300{
303 u32 error_2b, block_page; 301 u32 error_2b, block_page;
304 int row; 302 int row;
@@ -308,25 +306,31 @@ static void do_process_ue(struct mem_ctl_info *mci, u16 error_one, u32 ded_add,
308 306
309 if (error_one & 0x0202) { 307 if (error_one & 0x0202) {
310 error_2b = ded_add; 308 error_2b = ded_add;
309
311 /* convert to 4k address */ 310 /* convert to 4k address */
312 block_page = error_2b >> (PAGE_SHIFT - 4); 311 block_page = error_2b >> (PAGE_SHIFT - 4);
312
313 row = pvt->mc_symmetric ? 313 row = pvt->mc_symmetric ?
314 /* chip select are bits 14 & 13 */ 314 /* chip select are bits 14 & 13 */
315 ((block_page >> 1) & 3) : 315 ((block_page >> 1) & 3) :
316 edac_mc_find_csrow_by_page(mci, block_page); 316 edac_mc_find_csrow_by_page(mci, block_page);
317
317 edac_mc_handle_ue(mci, block_page, 0, row, 318 edac_mc_handle_ue(mci, block_page, 0, row,
318 "e752x UE from Read"); 319 "e752x UE from Read");
319 } 320 }
320 if (error_one & 0x0404) { 321 if (error_one & 0x0404) {
321 error_2b = scrb_add; 322 error_2b = scrb_add;
323
322 /* convert to 4k address */ 324 /* convert to 4k address */
323 block_page = error_2b >> (PAGE_SHIFT - 4); 325 block_page = error_2b >> (PAGE_SHIFT - 4);
326
324 row = pvt->mc_symmetric ? 327 row = pvt->mc_symmetric ?
325 /* chip select are bits 14 & 13 */ 328 /* chip select are bits 14 & 13 */
326 ((block_page >> 1) & 3) : 329 ((block_page >> 1) & 3) :
327 edac_mc_find_csrow_by_page(mci, block_page); 330 edac_mc_find_csrow_by_page(mci, block_page);
331
328 edac_mc_handle_ue(mci, block_page, 0, row, 332 edac_mc_handle_ue(mci, block_page, 0, row,
329 "e752x UE from Scruber"); 333 "e752x UE from Scruber");
330 } 334 }
331} 335}
332 336
@@ -359,13 +363,13 @@ static void do_process_ded_retry(struct mem_ctl_info *mci, u16 error,
359 struct e752x_pvt *pvt = (struct e752x_pvt *) mci->pvt_info; 363 struct e752x_pvt *pvt = (struct e752x_pvt *) mci->pvt_info;
360 364
361 error_1b = retry_add; 365 error_1b = retry_add;
362 page = error_1b >> (PAGE_SHIFT - 4); /* convert the addr to 4k page */ 366 page = error_1b >> (PAGE_SHIFT - 4); /* convert the addr to 4k page */
363 row = pvt->mc_symmetric ? 367 row = pvt->mc_symmetric ?
364 ((page >> 1) & 3) : /* chip select are bits 14 & 13 */ 368 ((page >> 1) & 3) : /* chip select are bits 14 & 13 */
365 edac_mc_find_csrow_by_page(mci, page); 369 edac_mc_find_csrow_by_page(mci, page);
366 e752x_mc_printk(mci, KERN_WARNING, 370 e752x_mc_printk(mci, KERN_WARNING,
367 "CE page 0x%lx, row %d : Memory read retry\n", 371 "CE page 0x%lx, row %d : Memory read retry\n",
368 (long unsigned int) page, row); 372 (long unsigned int) page, row);
369} 373}
370 374
371static inline void process_ded_retry(struct mem_ctl_info *mci, u16 error, 375static inline void process_ded_retry(struct mem_ctl_info *mci, u16 error,
@@ -402,7 +406,7 @@ static void do_global_error(int fatal, u32 errors)
402 for (i = 0; i < 11; i++) { 406 for (i = 0; i < 11; i++) {
403 if (errors & (1 << i)) 407 if (errors & (1 << i))
404 e752x_printk(KERN_WARNING, "%sError %s\n", 408 e752x_printk(KERN_WARNING, "%sError %s\n",
405 fatal_message[fatal], global_message[i]); 409 fatal_message[fatal], global_message[i]);
406 } 410 }
407} 411}
408 412
@@ -429,7 +433,7 @@ static void do_hub_error(int fatal, u8 errors)
429 for (i = 0; i < 7; i++) { 433 for (i = 0; i < 7; i++) {
430 if (errors & (1 << i)) 434 if (errors & (1 << i))
431 e752x_printk(KERN_WARNING, "%sError %s\n", 435 e752x_printk(KERN_WARNING, "%sError %s\n",
432 fatal_message[fatal], hub_message[i]); 436 fatal_message[fatal], hub_message[i]);
433 } 437 }
434} 438}
435 439
@@ -456,7 +460,7 @@ static void do_membuf_error(u8 errors)
456 for (i = 0; i < 4; i++) { 460 for (i = 0; i < 4; i++) {
457 if (errors & (1 << i)) 461 if (errors & (1 << i))
458 e752x_printk(KERN_WARNING, "Non-Fatal Error %s\n", 462 e752x_printk(KERN_WARNING, "Non-Fatal Error %s\n",
459 membuf_message[i]); 463 membuf_message[i]);
460 } 464 }
461} 465}
462 466
@@ -489,7 +493,7 @@ static void do_sysbus_error(int fatal, u32 errors)
489 for (i = 0; i < 10; i++) { 493 for (i = 0; i < 10; i++) {
490 if (errors & (1 << i)) 494 if (errors & (1 << i))
491 e752x_printk(KERN_WARNING, "%sError System Bus %s\n", 495 e752x_printk(KERN_WARNING, "%sError System Bus %s\n",
492 fatal_message[fatal], global_message[i]); 496 fatal_message[fatal], global_message[i]);
493 } 497 }
494} 498}
495 499
@@ -502,33 +506,42 @@ static inline void sysbus_error(int fatal, u32 errors, int *error_found,
502 do_sysbus_error(fatal, errors); 506 do_sysbus_error(fatal, errors);
503} 507}
504 508
505static void e752x_check_hub_interface (struct e752x_error_info *info, 509static void e752x_check_hub_interface(struct e752x_error_info *info,
506 int *error_found, int handle_error) 510 int *error_found, int handle_error)
507{ 511{
508 u8 stat8; 512 u8 stat8;
509 513
510 //pci_read_config_byte(dev,E752X_HI_FERR,&stat8); 514 //pci_read_config_byte(dev,E752X_HI_FERR,&stat8);
515
511 stat8 = info->hi_ferr; 516 stat8 = info->hi_ferr;
517
512 if(stat8 & 0x7f) { /* Error, so process */ 518 if(stat8 & 0x7f) { /* Error, so process */
513 stat8 &= 0x7f; 519 stat8 &= 0x7f;
520
514 if(stat8 & 0x2b) 521 if(stat8 & 0x2b)
515 hub_error(1, stat8 & 0x2b, error_found, handle_error); 522 hub_error(1, stat8 & 0x2b, error_found, handle_error);
523
516 if(stat8 & 0x54) 524 if(stat8 & 0x54)
517 hub_error(0, stat8 & 0x54, error_found, handle_error); 525 hub_error(0, stat8 & 0x54, error_found, handle_error);
518 } 526 }
527
519 //pci_read_config_byte(dev,E752X_HI_NERR,&stat8); 528 //pci_read_config_byte(dev,E752X_HI_NERR,&stat8);
529
520 stat8 = info->hi_nerr; 530 stat8 = info->hi_nerr;
531
521 if(stat8 & 0x7f) { /* Error, so process */ 532 if(stat8 & 0x7f) { /* Error, so process */
522 stat8 &= 0x7f; 533 stat8 &= 0x7f;
534
523 if (stat8 & 0x2b) 535 if (stat8 & 0x2b)
524 hub_error(1, stat8 & 0x2b, error_found, handle_error); 536 hub_error(1, stat8 & 0x2b, error_found, handle_error);
537
525 if(stat8 & 0x54) 538 if(stat8 & 0x54)
526 hub_error(0, stat8 & 0x54, error_found, handle_error); 539 hub_error(0, stat8 & 0x54, error_found, handle_error);
527 } 540 }
528} 541}
529 542
530static void e752x_check_sysbus (struct e752x_error_info *info, int *error_found, 543static void e752x_check_sysbus(struct e752x_error_info *info,
531 int handle_error) 544 int *error_found, int handle_error)
532{ 545{
533 u32 stat32, error32; 546 u32 stat32, error32;
534 547
@@ -540,27 +553,34 @@ static void e752x_check_sysbus (struct e752x_error_info *info, int *error_found,
540 553
541 error32 = (stat32 >> 16) & 0x3ff; 554 error32 = (stat32 >> 16) & 0x3ff;
542 stat32 = stat32 & 0x3ff; 555 stat32 = stat32 & 0x3ff;
556
543 if(stat32 & 0x083) 557 if(stat32 & 0x083)
544 sysbus_error(1, stat32 & 0x083, error_found, handle_error); 558 sysbus_error(1, stat32 & 0x083, error_found, handle_error);
559
545 if(stat32 & 0x37c) 560 if(stat32 & 0x37c)
546 sysbus_error(0, stat32 & 0x37c, error_found, handle_error); 561 sysbus_error(0, stat32 & 0x37c, error_found, handle_error);
562
547 if(error32 & 0x083) 563 if(error32 & 0x083)
548 sysbus_error(1, error32 & 0x083, error_found, handle_error); 564 sysbus_error(1, error32 & 0x083, error_found, handle_error);
565
549 if(error32 & 0x37c) 566 if(error32 & 0x37c)
550 sysbus_error(0, error32 & 0x37c, error_found, handle_error); 567 sysbus_error(0, error32 & 0x37c, error_found, handle_error);
551} 568}
552 569
553static void e752x_check_membuf (struct e752x_error_info *info, int *error_found, 570static void e752x_check_membuf (struct e752x_error_info *info,
554 int handle_error) 571 int *error_found, int handle_error)
555{ 572{
556 u8 stat8; 573 u8 stat8;
557 574
558 stat8 = info->buf_ferr; 575 stat8 = info->buf_ferr;
576
559 if (stat8 & 0x0f) { /* Error, so process */ 577 if (stat8 & 0x0f) { /* Error, so process */
560 stat8 &= 0x0f; 578 stat8 &= 0x0f;
561 membuf_error(stat8, error_found, handle_error); 579 membuf_error(stat8, error_found, handle_error);
562 } 580 }
581
563 stat8 = info->buf_nerr; 582 stat8 = info->buf_nerr;
583
564 if (stat8 & 0x0f) { /* Error, so process */ 584 if (stat8 & 0x0f) { /* Error, so process */
565 stat8 &= 0x0f; 585 stat8 &= 0x0f;
566 membuf_error(stat8, error_found, handle_error); 586 membuf_error(stat8, error_found, handle_error);
@@ -568,7 +588,8 @@ static void e752x_check_membuf (struct e752x_error_info *info, int *error_found,
568} 588}
569 589
570static void e752x_check_dram (struct mem_ctl_info *mci, 590static void e752x_check_dram (struct mem_ctl_info *mci,
571 struct e752x_error_info *info, int *error_found, int handle_error) 591 struct e752x_error_info *info, int *error_found,
592 int handle_error)
572{ 593{
573 u16 error_one, error_next; 594 u16 error_one, error_next;
574 595
@@ -618,7 +639,7 @@ static void e752x_check_dram (struct mem_ctl_info *mci,
618} 639}
619 640
620static void e752x_get_error_info (struct mem_ctl_info *mci, 641static void e752x_get_error_info (struct mem_ctl_info *mci,
621 struct e752x_error_info *info) 642 struct e752x_error_info *info)
622{ 643{
623 struct pci_dev *dev; 644 struct pci_dev *dev;
624 struct e752x_pvt *pvt; 645 struct e752x_pvt *pvt;
@@ -626,7 +647,6 @@ static void e752x_get_error_info (struct mem_ctl_info *mci,
626 memset(info, 0, sizeof(*info)); 647 memset(info, 0, sizeof(*info));
627 pvt = (struct e752x_pvt *) mci->pvt_info; 648 pvt = (struct e752x_pvt *) mci->pvt_info;
628 dev = pvt->dev_d0f1; 649 dev = pvt->dev_d0f1;
629
630 pci_read_config_dword(dev, E752X_FERR_GLOBAL, &info->ferr_global); 650 pci_read_config_dword(dev, E752X_FERR_GLOBAL, &info->ferr_global);
631 651
632 if (info->ferr_global) { 652 if (info->ferr_global) {
@@ -737,6 +757,7 @@ static int e752x_process_error_info (struct mem_ctl_info *mci,
737static void e752x_check(struct mem_ctl_info *mci) 757static void e752x_check(struct mem_ctl_info *mci)
738{ 758{
739 struct e752x_error_info info; 759 struct e752x_error_info info;
760
740 debugf3("%s()\n", __func__); 761 debugf3("%s()\n", __func__);
741 e752x_get_error_info(mci, &info); 762 e752x_get_error_info(mci, &info);
742 e752x_process_error_info(mci, &info, 1); 763 e752x_process_error_info(mci, &info, 1);
@@ -752,9 +773,9 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
752 struct e752x_pvt *pvt = NULL; 773 struct e752x_pvt *pvt = NULL;
753 u16 ddrcsr; 774 u16 ddrcsr;
754 u32 drc; 775 u32 drc;
755 int drc_chan; /* Number of channels 0=1chan,1=2chan */ 776 int drc_chan; /* Number of channels 0=1chan,1=2chan */
756 int drc_drbg; /* DRB granularity 0=64mb,1=128mb */ 777 int drc_drbg; /* DRB granularity 0=64mb, 1=128mb */
757 int drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */ 778 int drc_ddim; /* DRAM Data Integrity Mode 0=none,2=edac */
758 u32 dra; 779 u32 dra;
759 unsigned long last_cumul_size; 780 unsigned long last_cumul_size;
760 struct pci_dev *dev = NULL; 781 struct pci_dev *dev = NULL;
@@ -785,7 +806,6 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
785 } 806 }
786 807
787 debugf3("%s(): init mci\n", __func__); 808 debugf3("%s(): init mci\n", __func__);
788
789 mci->mtype_cap = MEM_FLAG_RDDR; 809 mci->mtype_cap = MEM_FLAG_RDDR;
790 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED | 810 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
791 EDAC_FLAG_S4ECD4ED; 811 EDAC_FLAG_S4ECD4ED;
@@ -798,19 +818,21 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
798 pvt = (struct e752x_pvt *) mci->pvt_info; 818 pvt = (struct e752x_pvt *) mci->pvt_info;
799 pvt->dev_info = &e752x_devs[dev_idx]; 819 pvt->dev_info = &e752x_devs[dev_idx];
800 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, 820 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
801 pvt->dev_info->err_dev, 821 pvt->dev_info->err_dev,
802 pvt->bridge_ck); 822 pvt->bridge_ck);
823
803 if (pvt->bridge_ck == NULL) 824 if (pvt->bridge_ck == NULL)
804 pvt->bridge_ck = pci_scan_single_device(pdev->bus, 825 pvt->bridge_ck = pci_scan_single_device(pdev->bus,
805 PCI_DEVFN(0, 1)); 826 PCI_DEVFN(0, 1));
827
806 if (pvt->bridge_ck == NULL) { 828 if (pvt->bridge_ck == NULL) {
807 e752x_printk(KERN_ERR, "error reporting device not found:" 829 e752x_printk(KERN_ERR, "error reporting device not found:"
808 "vendor %x device 0x%x (broken BIOS?)\n", 830 "vendor %x device 0x%x (broken BIOS?)\n",
809 PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev); 831 PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
810 goto fail; 832 goto fail;
811 } 833 }
812 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
813 834
835 pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
814 debugf3("%s(): more mci init\n", __func__); 836 debugf3("%s(): more mci init\n", __func__);
815 mci->ctl_name = pvt->dev_info->ctl_name; 837 mci->ctl_name = pvt->dev_info->ctl_name;
816 mci->edac_check = e752x_check; 838 mci->edac_check = e752x_check;
@@ -828,6 +850,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
828 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) { 850 for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
829 u8 value; 851 u8 value;
830 u32 cumul_size; 852 u32 cumul_size;
853
831 /* mem_dev 0=x8, 1=x4 */ 854 /* mem_dev 0=x8, 1=x4 */
832 int mem_dev = (dra >> (index * 4 + 2)) & 0x3; 855 int mem_dev = (dra >> (index * 4 + 2)) & 0x3;
833 struct csrow_info *csrow = &mci->csrows[index]; 856 struct csrow_info *csrow = &mci->csrows[index];
@@ -838,15 +861,16 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
838 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT); 861 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
839 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 862 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
840 cumul_size); 863 cumul_size);
864
841 if (cumul_size == last_cumul_size) 865 if (cumul_size == last_cumul_size)
842 continue; /* not populated */ 866 continue; /* not populated */
843 867
844 csrow->first_page = last_cumul_size; 868 csrow->first_page = last_cumul_size;
845 csrow->last_page = cumul_size - 1; 869 csrow->last_page = cumul_size - 1;
846 csrow->nr_pages = cumul_size - last_cumul_size; 870 csrow->nr_pages = cumul_size - last_cumul_size;
847 last_cumul_size = cumul_size; 871 last_cumul_size = cumul_size;
848 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */ 872 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
849 csrow->mtype = MEM_RDDR; /* only one type supported */ 873 csrow->mtype = MEM_RDDR; /* only one type supported */
850 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8; 874 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
851 875
852 /* 876 /*
@@ -870,29 +894,32 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
870 u8 value; 894 u8 value;
871 u8 last = 0; 895 u8 last = 0;
872 u8 row = 0; 896 u8 row = 0;
873 for (index = 0; index < 8; index += 2) {
874 897
898 for (index = 0; index < 8; index += 2) {
875 pci_read_config_byte(mci->pdev, E752X_DRB + index, 899 pci_read_config_byte(mci->pdev, E752X_DRB + index,
876 &value); 900 &value);
901
877 /* test if there is a dimm in this slot */ 902 /* test if there is a dimm in this slot */
878 if (value == last) { 903 if (value == last) {
879 /* no dimm in the slot, so flag it as empty */ 904 /* no dimm in the slot, so flag it as empty */
880 pvt->map[index] = 0xff; 905 pvt->map[index] = 0xff;
881 pvt->map[index + 1] = 0xff; 906 pvt->map[index + 1] = 0xff;
882 } else { /* there is a dimm in the slot */ 907 } else { /* there is a dimm in the slot */
883 pvt->map[index] = row; 908 pvt->map[index] = row;
884 row++; 909 row++;
885 last = value; 910 last = value;
886 /* test the next value to see if the dimm is 911 /* test the next value to see if the dimm is
887 double sided */ 912 double sided */
888 pci_read_config_byte(mci->pdev, 913 pci_read_config_byte(mci->pdev,
889 E752X_DRB + index + 1, 914 E752X_DRB + index + 1,
890 &value); 915 &value);
891 pvt->map[index + 1] = (value == last) ? 916 pvt->map[index + 1] = (value == last) ?
892 0xff : /* the dimm is single sided, 917 0xff : /* the dimm is single sided,
893 so flag as empty */ 918 * so flag as empty
894 row; /* this is a double sided dimm 919 */
895 to save the next row # */ 920 row; /* this is a double sided dimm
921 * to save the next row #
922 */
896 row++; 923 row++;
897 last = value; 924 last = value;
898 } 925 }
@@ -904,8 +931,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
904 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f)); 931 pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));
905 932
906 mci->edac_cap |= EDAC_FLAG_NONE; 933 mci->edac_cap |= EDAC_FLAG_NONE;
907
908 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__); 934 debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);
935
909 /* load the top of low memory, remap base, and remap limit vars */ 936 /* load the top of low memory, remap base, and remap limit vars */
910 pci_read_config_word(mci->pdev, E752X_TOLM, &pci_data); 937 pci_read_config_word(mci->pdev, E752X_TOLM, &pci_data);
911 pvt->tolm = ((u32) pci_data) << 4; 938 pvt->tolm = ((u32) pci_data) << 4;
@@ -914,8 +941,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
914 pci_read_config_word(mci->pdev, E752X_REMAPLIMIT, &pci_data); 941 pci_read_config_word(mci->pdev, E752X_REMAPLIMIT, &pci_data);
915 pvt->remaplimit = ((u32) pci_data) << 14; 942 pvt->remaplimit = ((u32) pci_data) << 14;
916 e752x_printk(KERN_INFO, 943 e752x_printk(KERN_INFO,
917 "tolm = %x, remapbase = %x, remaplimit = %x\n", 944 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
918 pvt->tolm, pvt->remapbase, pvt->remaplimit); 945 pvt->remapbase, pvt->remaplimit);
919 946
920 if (edac_mc_add_mc(mci)) { 947 if (edac_mc_add_mc(mci)) {
921 debugf3("%s(): failed edac_mc_add_mc()\n", __func__); 948 debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
@@ -923,7 +950,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
923 } 950 }
924 951
925 dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev, 952 dev = pci_get_device(PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].ctl_dev,
926 NULL); 953 NULL);
927 pvt->dev_d0f0 = dev; 954 pvt->dev_d0f0 = dev;
928 /* find the error reporting device and clear errors */ 955 /* find the error reporting device and clear errors */
929 dev = pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck); 956 dev = pvt->dev_d0f1 = pci_dev_get(pvt->bridge_ck);
@@ -936,8 +963,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
936 pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00); 963 pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
937 pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00); 964 pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
938 pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00); 965 pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
939 /* clear other MCH errors */ 966
940 e752x_get_error_info(mci, &discard); 967 e752x_get_error_info(mci, &discard); /* clear other MCH errors */
941 968
942 /* get this far and it's successful */ 969 /* get this far and it's successful */
943 debugf3("%s(): success\n", __func__); 970 debugf3("%s(): success\n", __func__);
@@ -947,28 +974,32 @@ fail:
947 if (mci) { 974 if (mci) {
948 if (pvt->dev_d0f0) 975 if (pvt->dev_d0f0)
949 pci_dev_put(pvt->dev_d0f0); 976 pci_dev_put(pvt->dev_d0f0);
977
950 if (pvt->dev_d0f1) 978 if (pvt->dev_d0f1)
951 pci_dev_put(pvt->dev_d0f1); 979 pci_dev_put(pvt->dev_d0f1);
980
952 if (pvt->bridge_ck) 981 if (pvt->bridge_ck)
953 pci_dev_put(pvt->bridge_ck); 982 pci_dev_put(pvt->bridge_ck);
983
954 edac_mc_free(mci); 984 edac_mc_free(mci);
955 } 985 }
986
956 return rc; 987 return rc;
957} 988}
958 989
959/* returns count (>= 0), or negative on error */ 990/* returns count (>= 0), or negative on error */
960static int __devinit e752x_init_one(struct pci_dev *pdev, 991static int __devinit e752x_init_one(struct pci_dev *pdev,
961 const struct pci_device_id *ent) 992 const struct pci_device_id *ent)
962{ 993{
963 debugf0("%s()\n", __func__); 994 debugf0("%s()\n", __func__);
964 995
965 /* wake up and enable device */ 996 /* wake up and enable device */
966 if(pci_enable_device(pdev) < 0) 997 if(pci_enable_device(pdev) < 0)
967 return -EIO; 998 return -EIO;
999
968 return e752x_probe1(pdev, ent->driver_data); 1000 return e752x_probe1(pdev, ent->driver_data);
969} 1001}
970 1002
971
972static void __devexit e752x_remove_one(struct pci_dev *pdev) 1003static void __devexit e752x_remove_one(struct pci_dev *pdev)
973{ 1004{
974 struct mem_ctl_info *mci; 1005 struct mem_ctl_info *mci;
@@ -986,20 +1017,26 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
986 edac_mc_free(mci); 1017 edac_mc_free(mci);
987} 1018}
988 1019
989
990static const struct pci_device_id e752x_pci_tbl[] __devinitdata = { 1020static const struct pci_device_id e752x_pci_tbl[] __devinitdata = {
991 {PCI_VEND_DEV(INTEL, 7520_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1021 {
992 E7520}, 1022 PCI_VEND_DEV(INTEL, 7520_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
993 {PCI_VEND_DEV(INTEL, 7525_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1023 E7520
994 E7525}, 1024 },
995 {PCI_VEND_DEV(INTEL, 7320_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1025 {
996 E7320}, 1026 PCI_VEND_DEV(INTEL, 7525_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
997 {0,} /* 0 terminated list. */ 1027 E7525
1028 },
1029 {
1030 PCI_VEND_DEV(INTEL, 7320_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
1031 E7320
1032 },
1033 {
1034 0,
1035 } /* 0 terminated list. */
998}; 1036};
999 1037
1000MODULE_DEVICE_TABLE(pci, e752x_pci_tbl); 1038MODULE_DEVICE_TABLE(pci, e752x_pci_tbl);
1001 1039
1002
1003static struct pci_driver e752x_driver = { 1040static struct pci_driver e752x_driver = {
1004 .name = EDAC_MOD_STR, 1041 .name = EDAC_MOD_STR,
1005 .probe = e752x_init_one, 1042 .probe = e752x_init_one,
@@ -1007,7 +1044,6 @@ static struct pci_driver e752x_driver = {
1007 .id_table = e752x_pci_tbl, 1044 .id_table = e752x_pci_tbl,
1008}; 1045};
1009 1046
1010
1011static int __init e752x_init(void) 1047static int __init e752x_init(void)
1012{ 1048{
1013 int pci_rc; 1049 int pci_rc;
@@ -1017,14 +1053,12 @@ static int __init e752x_init(void)
1017 return (pci_rc < 0) ? pci_rc : 0; 1053 return (pci_rc < 0) ? pci_rc : 0;
1018} 1054}
1019 1055
1020
1021static void __exit e752x_exit(void) 1056static void __exit e752x_exit(void)
1022{ 1057{
1023 debugf3("%s()\n", __func__); 1058 debugf3("%s()\n", __func__);
1024 pci_unregister_driver(&e752x_driver); 1059 pci_unregister_driver(&e752x_driver);
1025} 1060}
1026 1061
1027
1028module_init(e752x_init); 1062module_init(e752x_init);
1029module_exit(e752x_exit); 1063module_exit(e752x_exit);
1030 1064
diff --git a/drivers/edac/e7xxx_edac.c b/drivers/edac/e7xxx_edac.c
index 9b59c661f45e..a9518d3e4be4 100644
--- a/drivers/edac/e7xxx_edac.c
+++ b/drivers/edac/e7xxx_edac.c
@@ -11,9 +11,9 @@
11 * http://www.anime.net/~goemon/linux-ecc/ 11 * http://www.anime.net/~goemon/linux-ecc/
12 * 12 *
13 * Contributors: 13 * Contributors:
14 * Eric Biederman (Linux Networx) 14 * Eric Biederman (Linux Networx)
15 * Tom Zimmerman (Linux Networx) 15 * Tom Zimmerman (Linux Networx)
16 * Jim Garlick (Lawrence Livermore National Labs) 16 * Jim Garlick (Lawrence Livermore National Labs)
17 * Dave Peterson (Lawrence Livermore National Labs) 17 * Dave Peterson (Lawrence Livermore National Labs)
18 * That One Guy (Some other place) 18 * That One Guy (Some other place)
19 * Wang Zhenyu (intel.com) 19 * Wang Zhenyu (intel.com)
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25
26#include <linux/config.h> 25#include <linux/config.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <linux/init.h> 27#include <linux/init.h>
@@ -31,14 +30,11 @@
31#include <linux/slab.h> 30#include <linux/slab.h>
32#include "edac_mc.h" 31#include "edac_mc.h"
33 32
34
35#define e7xxx_printk(level, fmt, arg...) \ 33#define e7xxx_printk(level, fmt, arg...) \
36 edac_printk(level, "e7xxx", fmt, ##arg) 34 edac_printk(level, "e7xxx", fmt, ##arg)
37
38 35
39#define e7xxx_mc_printk(mci, level, fmt, arg...) \ 36#define e7xxx_mc_printk(mci, level, fmt, arg...) \
40 edac_mc_chipset_printk(mci, level, "e7xxx", fmt, ##arg) 37 edac_mc_chipset_printk(mci, level, "e7xxx", fmt, ##arg)
41
42 38
43#ifndef PCI_DEVICE_ID_INTEL_7205_0 39#ifndef PCI_DEVICE_ID_INTEL_7205_0
44#define PCI_DEVICE_ID_INTEL_7205_0 0x255d 40#define PCI_DEVICE_ID_INTEL_7205_0 0x255d
@@ -72,11 +68,9 @@
72#define PCI_DEVICE_ID_INTEL_7505_1_ERR 0x2551 68#define PCI_DEVICE_ID_INTEL_7505_1_ERR 0x2551
73#endif /* PCI_DEVICE_ID_INTEL_7505_1_ERR */ 69#endif /* PCI_DEVICE_ID_INTEL_7505_1_ERR */
74 70
75
76#define E7XXX_NR_CSROWS 8 /* number of csrows */ 71#define E7XXX_NR_CSROWS 8 /* number of csrows */
77#define E7XXX_NR_DIMMS 8 /* FIXME - is this correct? */ 72#define E7XXX_NR_DIMMS 8 /* FIXME - is this correct? */
78 73
79
80/* E7XXX register addresses - device 0 function 0 */ 74/* E7XXX register addresses - device 0 function 0 */
81#define E7XXX_DRB 0x60 /* DRAM row boundary register (8b) */ 75#define E7XXX_DRB 0x60 /* DRAM row boundary register (8b) */
82#define E7XXX_DRA 0x70 /* DRAM row attribute register (8b) */ 76#define E7XXX_DRA 0x70 /* DRAM row attribute register (8b) */
@@ -126,7 +120,6 @@ enum e7xxx_chips {
126 E7205, 120 E7205,
127}; 121};
128 122
129
130struct e7xxx_pvt { 123struct e7xxx_pvt {
131 struct pci_dev *bridge_ck; 124 struct pci_dev *bridge_ck;
132 u32 tolm; 125 u32 tolm;
@@ -135,13 +128,11 @@ struct e7xxx_pvt {
135 const struct e7xxx_dev_info *dev_info; 128 const struct e7xxx_dev_info *dev_info;
136}; 129};
137 130
138
139struct e7xxx_dev_info { 131struct e7xxx_dev_info {
140 u16 err_dev; 132 u16 err_dev;
141 const char *ctl_name; 133 const char *ctl_name;
142}; 134};
143 135
144
145struct e7xxx_error_info { 136struct e7xxx_error_info {
146 u8 dram_ferr; 137 u8 dram_ferr;
147 u8 dram_nerr; 138 u8 dram_nerr;
@@ -152,20 +143,23 @@ struct e7xxx_error_info {
152 143
153static const struct e7xxx_dev_info e7xxx_devs[] = { 144static const struct e7xxx_dev_info e7xxx_devs[] = {
154 [E7500] = { 145 [E7500] = {
155 .err_dev = PCI_DEVICE_ID_INTEL_7500_1_ERR, 146 .err_dev = PCI_DEVICE_ID_INTEL_7500_1_ERR,
156 .ctl_name = "E7500"}, 147 .ctl_name = "E7500"
148 },
157 [E7501] = { 149 [E7501] = {
158 .err_dev = PCI_DEVICE_ID_INTEL_7501_1_ERR, 150 .err_dev = PCI_DEVICE_ID_INTEL_7501_1_ERR,
159 .ctl_name = "E7501"}, 151 .ctl_name = "E7501"
152 },
160 [E7505] = { 153 [E7505] = {
161 .err_dev = PCI_DEVICE_ID_INTEL_7505_1_ERR, 154 .err_dev = PCI_DEVICE_ID_INTEL_7505_1_ERR,
162 .ctl_name = "E7505"}, 155 .ctl_name = "E7505"
156 },
163 [E7205] = { 157 [E7205] = {
164 .err_dev = PCI_DEVICE_ID_INTEL_7205_1_ERR, 158 .err_dev = PCI_DEVICE_ID_INTEL_7205_1_ERR,
165 .ctl_name = "E7205"}, 159 .ctl_name = "E7205"
160 },
166}; 161};
167 162
168
169/* FIXME - is this valid for both SECDED and S4ECD4ED? */ 163/* FIXME - is this valid for both SECDED and S4ECD4ED? */
170static inline int e7xxx_find_channel(u16 syndrome) 164static inline int e7xxx_find_channel(u16 syndrome)
171{ 165{
@@ -173,16 +167,18 @@ static inline int e7xxx_find_channel(u16 syndrome)
173 167
174 if ((syndrome & 0xff00) == 0) 168 if ((syndrome & 0xff00) == 0)
175 return 0; 169 return 0;
170
176 if ((syndrome & 0x00ff) == 0) 171 if ((syndrome & 0x00ff) == 0)
177 return 1; 172 return 1;
173
178 if ((syndrome & 0xf000) == 0 || (syndrome & 0x0f00) == 0) 174 if ((syndrome & 0xf000) == 0 || (syndrome & 0x0f00) == 0)
179 return 0; 175 return 0;
176
180 return 1; 177 return 1;
181} 178}
182 179
183 180static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
184static unsigned long 181 unsigned long page)
185ctl_page_to_phys(struct mem_ctl_info *mci, unsigned long page)
186{ 182{
187 u32 remap; 183 u32 remap;
188 struct e7xxx_pvt *pvt = (struct e7xxx_pvt *) mci->pvt_info; 184 struct e7xxx_pvt *pvt = (struct e7xxx_pvt *) mci->pvt_info;
@@ -190,17 +186,20 @@ ctl_page_to_phys(struct mem_ctl_info *mci, unsigned long page)
190 debugf3("%s()\n", __func__); 186 debugf3("%s()\n", __func__);
191 187
192 if ((page < pvt->tolm) || 188 if ((page < pvt->tolm) ||
193 ((page >= 0x100000) && (page < pvt->remapbase))) 189 ((page >= 0x100000) && (page < pvt->remapbase)))
194 return page; 190 return page;
191
195 remap = (page - pvt->tolm) + pvt->remapbase; 192 remap = (page - pvt->tolm) + pvt->remapbase;
193
196 if (remap < pvt->remaplimit) 194 if (remap < pvt->remaplimit)
197 return remap; 195 return remap;
196
198 e7xxx_printk(KERN_ERR, "Invalid page %lx - out of range\n", page); 197 e7xxx_printk(KERN_ERR, "Invalid page %lx - out of range\n", page);
199 return pvt->tolm - 1; 198 return pvt->tolm - 1;
200} 199}
201 200
202 201static void process_ce(struct mem_ctl_info *mci,
203static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info) 202 struct e7xxx_error_info *info)
204{ 203{
205 u32 error_1b, page; 204 u32 error_1b, page;
206 u16 syndrome; 205 u16 syndrome;
@@ -208,52 +207,46 @@ static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
208 int channel; 207 int channel;
209 208
210 debugf3("%s()\n", __func__); 209 debugf3("%s()\n", __func__);
211
212 /* read the error address */ 210 /* read the error address */
213 error_1b = info->dram_celog_add; 211 error_1b = info->dram_celog_add;
214 /* FIXME - should use PAGE_SHIFT */ 212 /* FIXME - should use PAGE_SHIFT */
215 page = error_1b >> 6; /* convert the address to 4k page */ 213 page = error_1b >> 6; /* convert the address to 4k page */
216 /* read the syndrome */ 214 /* read the syndrome */
217 syndrome = info->dram_celog_syndrome; 215 syndrome = info->dram_celog_syndrome;
218 /* FIXME - check for -1 */ 216 /* FIXME - check for -1 */
219 row = edac_mc_find_csrow_by_page(mci, page); 217 row = edac_mc_find_csrow_by_page(mci, page);
220 /* convert syndrome to channel */ 218 /* convert syndrome to channel */
221 channel = e7xxx_find_channel(syndrome); 219 channel = e7xxx_find_channel(syndrome);
222 edac_mc_handle_ce(mci, page, 0, syndrome, row, channel, 220 edac_mc_handle_ce(mci, page, 0, syndrome, row, channel, "e7xxx CE");
223 "e7xxx CE");
224} 221}
225 222
226
227static void process_ce_no_info(struct mem_ctl_info *mci) 223static void process_ce_no_info(struct mem_ctl_info *mci)
228{ 224{
229 debugf3("%s()\n", __func__); 225 debugf3("%s()\n", __func__);
230 edac_mc_handle_ce_no_info(mci, "e7xxx CE log register overflow"); 226 edac_mc_handle_ce_no_info(mci, "e7xxx CE log register overflow");
231} 227}
232 228
233 229static void process_ue(struct mem_ctl_info *mci,
234static void process_ue(struct mem_ctl_info *mci, struct e7xxx_error_info *info) 230 struct e7xxx_error_info *info)
235{ 231{
236 u32 error_2b, block_page; 232 u32 error_2b, block_page;
237 int row; 233 int row;
238 234
239 debugf3("%s()\n", __func__); 235 debugf3("%s()\n", __func__);
240
241 /* read the error address */ 236 /* read the error address */
242 error_2b = info->dram_uelog_add; 237 error_2b = info->dram_uelog_add;
243 /* FIXME - should use PAGE_SHIFT */ 238 /* FIXME - should use PAGE_SHIFT */
244 block_page = error_2b >> 6; /* convert to 4k address */ 239 block_page = error_2b >> 6; /* convert to 4k address */
245 row = edac_mc_find_csrow_by_page(mci, block_page); 240 row = edac_mc_find_csrow_by_page(mci, block_page);
246 edac_mc_handle_ue(mci, block_page, 0, row, "e7xxx UE"); 241 edac_mc_handle_ue(mci, block_page, 0, row, "e7xxx UE");
247} 242}
248 243
249
250static void process_ue_no_info(struct mem_ctl_info *mci) 244static void process_ue_no_info(struct mem_ctl_info *mci)
251{ 245{
252 debugf3("%s()\n", __func__); 246 debugf3("%s()\n", __func__);
253 edac_mc_handle_ue_no_info(mci, "e7xxx UE log register overflow"); 247 edac_mc_handle_ue_no_info(mci, "e7xxx UE log register overflow");
254} 248}
255 249
256
257static void e7xxx_get_error_info (struct mem_ctl_info *mci, 250static void e7xxx_get_error_info (struct mem_ctl_info *mci,
258 struct e7xxx_error_info *info) 251 struct e7xxx_error_info *info)
259{ 252{
@@ -261,31 +254,29 @@ static void e7xxx_get_error_info (struct mem_ctl_info *mci,
261 254
262 pvt = (struct e7xxx_pvt *) mci->pvt_info; 255 pvt = (struct e7xxx_pvt *) mci->pvt_info;
263 pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_FERR, 256 pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_FERR,
264 &info->dram_ferr); 257 &info->dram_ferr);
265 pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_NERR, 258 pci_read_config_byte(pvt->bridge_ck, E7XXX_DRAM_NERR,
266 &info->dram_nerr); 259 &info->dram_nerr);
267 260
268 if ((info->dram_ferr & 1) || (info->dram_nerr & 1)) { 261 if ((info->dram_ferr & 1) || (info->dram_nerr & 1)) {
269 pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_CELOG_ADD, 262 pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_CELOG_ADD,
270 &info->dram_celog_add); 263 &info->dram_celog_add);
271 pci_read_config_word(pvt->bridge_ck, 264 pci_read_config_word(pvt->bridge_ck,
272 E7XXX_DRAM_CELOG_SYNDROME, &info->dram_celog_syndrome); 265 E7XXX_DRAM_CELOG_SYNDROME,
266 &info->dram_celog_syndrome);
273 } 267 }
274 268
275 if ((info->dram_ferr & 2) || (info->dram_nerr & 2)) 269 if ((info->dram_ferr & 2) || (info->dram_nerr & 2))
276 pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_UELOG_ADD, 270 pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_UELOG_ADD,
277 &info->dram_uelog_add); 271 &info->dram_uelog_add);
278 272
279 if (info->dram_ferr & 3) 273 if (info->dram_ferr & 3)
280 pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_FERR, 0x03, 274 pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_FERR, 0x03, 0x03);
281 0x03);
282 275
283 if (info->dram_nerr & 3) 276 if (info->dram_nerr & 3)
284 pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_NERR, 0x03, 277 pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_NERR, 0x03, 0x03);
285 0x03);
286} 278}
287 279
288
289static int e7xxx_process_error_info (struct mem_ctl_info *mci, 280static int e7xxx_process_error_info (struct mem_ctl_info *mci,
290 struct e7xxx_error_info *info, int handle_errors) 281 struct e7xxx_error_info *info, int handle_errors)
291{ 282{
@@ -333,7 +324,6 @@ static int e7xxx_process_error_info (struct mem_ctl_info *mci,
333 return error_found; 324 return error_found;
334} 325}
335 326
336
337static void e7xxx_check(struct mem_ctl_info *mci) 327static void e7xxx_check(struct mem_ctl_info *mci)
338{ 328{
339 struct e7xxx_error_info info; 329 struct e7xxx_error_info info;
@@ -343,7 +333,6 @@ static void e7xxx_check(struct mem_ctl_info *mci)
343 e7xxx_process_error_info(mci, &info, 1); 333 e7xxx_process_error_info(mci, &info, 1);
344} 334}
345 335
346
347static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx) 336static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
348{ 337{
349 int rc = -ENODEV; 338 int rc = -ENODEV;
@@ -363,13 +352,14 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
363 352
364 /* need to find out the number of channels */ 353 /* need to find out the number of channels */
365 pci_read_config_dword(pdev, E7XXX_DRC, &drc); 354 pci_read_config_dword(pdev, E7XXX_DRC, &drc);
355
366 /* only e7501 can be single channel */ 356 /* only e7501 can be single channel */
367 if (dev_idx == E7501) { 357 if (dev_idx == E7501) {
368 drc_chan = ((drc >> 22) & 0x1); 358 drc_chan = ((drc >> 22) & 0x1);
369 drc_drbg = (drc >> 18) & 0x3; 359 drc_drbg = (drc >> 18) & 0x3;
370 } 360 }
371 drc_ddim = (drc >> 20) & 0x3;
372 361
362 drc_ddim = (drc >> 20) & 0x3;
373 mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1); 363 mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);
374 364
375 if (mci == NULL) { 365 if (mci == NULL) {
@@ -378,10 +368,9 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
378 } 368 }
379 369
380 debugf3("%s(): init mci\n", __func__); 370 debugf3("%s(): init mci\n", __func__);
381
382 mci->mtype_cap = MEM_FLAG_RDDR; 371 mci->mtype_cap = MEM_FLAG_RDDR;
383 mci->edac_ctl_cap = 372 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
384 EDAC_FLAG_NONE | EDAC_FLAG_SECDED | EDAC_FLAG_S4ECD4ED; 373 EDAC_FLAG_S4ECD4ED;
385 /* FIXME - what if different memory types are in different csrows? */ 374 /* FIXME - what if different memory types are in different csrows? */
386 mci->mod_name = EDAC_MOD_STR; 375 mci->mod_name = EDAC_MOD_STR;
387 mci->mod_ver = "$Revision: 1.5.2.9 $"; 376 mci->mod_ver = "$Revision: 1.5.2.9 $";
@@ -391,19 +380,18 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
391 pvt = (struct e7xxx_pvt *) mci->pvt_info; 380 pvt = (struct e7xxx_pvt *) mci->pvt_info;
392 pvt->dev_info = &e7xxx_devs[dev_idx]; 381 pvt->dev_info = &e7xxx_devs[dev_idx];
393 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL, 382 pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
394 pvt->dev_info->err_dev, 383 pvt->dev_info->err_dev,
395 pvt->bridge_ck); 384 pvt->bridge_ck);
385
396 if (!pvt->bridge_ck) { 386 if (!pvt->bridge_ck) {
397 e7xxx_printk(KERN_ERR, "error reporting device not found:" 387 e7xxx_printk(KERN_ERR, "error reporting device not found:"
398 "vendor %x device 0x%x (broken BIOS?)\n", 388 "vendor %x device 0x%x (broken BIOS?)\n",
399 PCI_VENDOR_ID_INTEL, 389 PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
400 e7xxx_devs[dev_idx].err_dev);
401 goto fail; 390 goto fail;
402 } 391 }
403 392
404 debugf3("%s(): more mci init\n", __func__); 393 debugf3("%s(): more mci init\n", __func__);
405 mci->ctl_name = pvt->dev_info->ctl_name; 394 mci->ctl_name = pvt->dev_info->ctl_name;
406
407 mci->edac_check = e7xxx_check; 395 mci->edac_check = e7xxx_check;
408 mci->ctl_page_to_phys = ctl_page_to_phys; 396 mci->ctl_page_to_phys = ctl_page_to_phys;
409 397
@@ -428,15 +416,16 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
428 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT); 416 cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
429 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 417 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
430 cumul_size); 418 cumul_size);
419
431 if (cumul_size == last_cumul_size) 420 if (cumul_size == last_cumul_size)
432 continue; /* not populated */ 421 continue; /* not populated */
433 422
434 csrow->first_page = last_cumul_size; 423 csrow->first_page = last_cumul_size;
435 csrow->last_page = cumul_size - 1; 424 csrow->last_page = cumul_size - 1;
436 csrow->nr_pages = cumul_size - last_cumul_size; 425 csrow->nr_pages = cumul_size - last_cumul_size;
437 last_cumul_size = cumul_size; 426 last_cumul_size = cumul_size;
438 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */ 427 csrow->grain = 1 << 12; /* 4KiB - resolution of CELOG */
439 csrow->mtype = MEM_RDDR; /* only one type supported */ 428 csrow->mtype = MEM_RDDR; /* only one type supported */
440 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8; 429 csrow->dtype = mem_dev ? DEV_X4 : DEV_X8;
441 430
442 /* 431 /*
@@ -466,8 +455,8 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
466 pci_read_config_word(mci->pdev, E7XXX_REMAPLIMIT, &pci_data); 455 pci_read_config_word(mci->pdev, E7XXX_REMAPLIMIT, &pci_data);
467 pvt->remaplimit = ((u32) pci_data) << 14; 456 pvt->remaplimit = ((u32) pci_data) << 14;
468 e7xxx_printk(KERN_INFO, 457 e7xxx_printk(KERN_INFO,
469 "tolm = %x, remapbase = %x, remaplimit = %x\n", 458 "tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
470 pvt->tolm, pvt->remapbase, pvt->remaplimit); 459 pvt->remapbase, pvt->remaplimit);
471 460
472 /* clear any pending errors, or initial state bits */ 461 /* clear any pending errors, or initial state bits */
473 e7xxx_get_error_info(mci, &discard); 462 e7xxx_get_error_info(mci, &discard);
@@ -492,17 +481,16 @@ fail:
492} 481}
493 482
494/* returns count (>= 0), or negative on error */ 483/* returns count (>= 0), or negative on error */
495static int __devinit 484static int __devinit e7xxx_init_one(struct pci_dev *pdev,
496e7xxx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 485 const struct pci_device_id *ent)
497{ 486{
498 debugf0("%s()\n", __func__); 487 debugf0("%s()\n", __func__);
499 488
500 /* wake up and enable device */ 489 /* wake up and enable device */
501 return pci_enable_device(pdev) ? 490 return pci_enable_device(pdev) ?
502 -EIO : e7xxx_probe1(pdev, ent->driver_data); 491 -EIO : e7xxx_probe1(pdev, ent->driver_data);
503} 492}
504 493
505
506static void __devexit e7xxx_remove_one(struct pci_dev *pdev) 494static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
507{ 495{
508 struct mem_ctl_info *mci; 496 struct mem_ctl_info *mci;
@@ -518,22 +506,30 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
518 edac_mc_free(mci); 506 edac_mc_free(mci);
519} 507}
520 508
521
522static const struct pci_device_id e7xxx_pci_tbl[] __devinitdata = { 509static const struct pci_device_id e7xxx_pci_tbl[] __devinitdata = {
523 {PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 510 {
524 E7205}, 511 PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
525 {PCI_VEND_DEV(INTEL, 7500_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 512 E7205
526 E7500}, 513 },
527 {PCI_VEND_DEV(INTEL, 7501_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 514 {
528 E7501}, 515 PCI_VEND_DEV(INTEL, 7500_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
529 {PCI_VEND_DEV(INTEL, 7505_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 516 E7500
530 E7505}, 517 },
531 {0,} /* 0 terminated list. */ 518 {
519 PCI_VEND_DEV(INTEL, 7501_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
520 E7501
521 },
522 {
523 PCI_VEND_DEV(INTEL, 7505_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
524 E7505
525 },
526 {
527 0,
528 } /* 0 terminated list. */
532}; 529};
533 530
534MODULE_DEVICE_TABLE(pci, e7xxx_pci_tbl); 531MODULE_DEVICE_TABLE(pci, e7xxx_pci_tbl);
535 532
536
537static struct pci_driver e7xxx_driver = { 533static struct pci_driver e7xxx_driver = {
538 .name = EDAC_MOD_STR, 534 .name = EDAC_MOD_STR,
539 .probe = e7xxx_init_one, 535 .probe = e7xxx_init_one,
@@ -541,13 +537,11 @@ static struct pci_driver e7xxx_driver = {
541 .id_table = e7xxx_pci_tbl, 537 .id_table = e7xxx_pci_tbl,
542}; 538};
543 539
544
545static int __init e7xxx_init(void) 540static int __init e7xxx_init(void)
546{ 541{
547 return pci_register_driver(&e7xxx_driver); 542 return pci_register_driver(&e7xxx_driver);
548} 543}
549 544
550
551static void __exit e7xxx_exit(void) 545static void __exit e7xxx_exit(void)
552{ 546{
553 pci_unregister_driver(&e7xxx_driver); 547 pci_unregister_driver(&e7xxx_driver);
@@ -556,8 +550,7 @@ static void __exit e7xxx_exit(void)
556module_init(e7xxx_init); 550module_init(e7xxx_init);
557module_exit(e7xxx_exit); 551module_exit(e7xxx_exit);
558 552
559
560MODULE_LICENSE("GPL"); 553MODULE_LICENSE("GPL");
561MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n" 554MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n"
562 "Based on.work by Dan Hollis et al"); 555 "Based on.work by Dan Hollis et al");
563MODULE_DESCRIPTION("MC support for Intel e7xxx memory controllers"); 556MODULE_DESCRIPTION("MC support for Intel e7xxx memory controllers");
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index f67a4d6f8974..bb3460457fa3 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -12,7 +12,6 @@
12 * 12 *
13 */ 13 */
14 14
15
16#include <linux/config.h> 15#include <linux/config.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
@@ -30,14 +29,12 @@
30#include <linux/sysdev.h> 29#include <linux/sysdev.h>
31#include <linux/ctype.h> 30#include <linux/ctype.h>
32#include <linux/kthread.h> 31#include <linux/kthread.h>
33
34#include <asm/uaccess.h> 32#include <asm/uaccess.h>
35#include <asm/page.h> 33#include <asm/page.h>
36#include <asm/edac.h> 34#include <asm/edac.h>
37
38#include "edac_mc.h" 35#include "edac_mc.h"
39 36
40#define EDAC_MC_VERSION "Ver: 2.0.0 " __DATE__ 37#define EDAC_MC_VERSION "Ver: 2.0.0 " __DATE__
41 38
42/* For now, disable the EDAC sysfs code. The sysfs interface that EDAC 39/* For now, disable the EDAC sysfs code. The sysfs interface that EDAC
43 * presents to user space needs more thought, and is likely to change 40 * presents to user space needs more thought, and is likely to change
@@ -73,7 +70,6 @@ struct edac_pci_device_list {
73 unsigned int device; /* Deviice ID */ 70 unsigned int device; /* Deviice ID */
74}; 71};
75 72
76
77#define MAX_LISTED_PCI_DEVICES 32 73#define MAX_LISTED_PCI_DEVICES 32
78 74
79/* List of PCI devices (vendor-id:device-id) that should be skipped */ 75/* List of PCI devices (vendor-id:device-id) that should be skipped */
@@ -126,7 +122,6 @@ static const char *edac_caps[] = {
126 [EDAC_S16ECD16ED] = "S16ECD16ED" 122 [EDAC_S16ECD16ED] = "S16ECD16ED"
127}; 123};
128 124
129
130/* sysfs object: /sys/devices/system/edac */ 125/* sysfs object: /sys/devices/system/edac */
131static struct sysdev_class edac_class = { 126static struct sysdev_class edac_class = {
132 set_kset_name("edac"), 127 set_kset_name("edac"),
@@ -147,7 +142,7 @@ static struct completion edac_pci_kobj_complete;
147 142
148/* 143/*
149 * /sys/devices/system/edac/mc; 144 * /sys/devices/system/edac/mc;
150 * data structures and methods 145 * data structures and methods
151 */ 146 */
152#if 0 147#if 0
153static ssize_t memctrl_string_show(void *ptr, char *buffer) 148static ssize_t memctrl_string_show(void *ptr, char *buffer)
@@ -174,33 +169,34 @@ static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
174} 169}
175 170
176struct memctrl_dev_attribute { 171struct memctrl_dev_attribute {
177 struct attribute attr; 172 struct attribute attr;
178 void *value; 173 void *value;
179 ssize_t (*show)(void *,char *); 174 ssize_t (*show)(void *,char *);
180 ssize_t (*store)(void *, const char *, size_t); 175 ssize_t (*store)(void *, const char *, size_t);
181}; 176};
182 177
183/* Set of show/store abstract level functions for memory control object */ 178/* Set of show/store abstract level functions for memory control object */
184static ssize_t 179static ssize_t memctrl_dev_show(struct kobject *kobj,
185memctrl_dev_show(struct kobject *kobj, struct attribute *attr, char *buffer) 180 struct attribute *attr, char *buffer)
186{ 181{
187 struct memctrl_dev_attribute *memctrl_dev; 182 struct memctrl_dev_attribute *memctrl_dev;
188 memctrl_dev = (struct memctrl_dev_attribute*)attr; 183 memctrl_dev = (struct memctrl_dev_attribute*)attr;
189 184
190 if (memctrl_dev->show) 185 if (memctrl_dev->show)
191 return memctrl_dev->show(memctrl_dev->value, buffer); 186 return memctrl_dev->show(memctrl_dev->value, buffer);
187
192 return -EIO; 188 return -EIO;
193} 189}
194 190
195static ssize_t 191static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr,
196memctrl_dev_store(struct kobject *kobj, struct attribute *attr, 192 const char *buffer, size_t count)
197 const char *buffer, size_t count)
198{ 193{
199 struct memctrl_dev_attribute *memctrl_dev; 194 struct memctrl_dev_attribute *memctrl_dev;
200 memctrl_dev = (struct memctrl_dev_attribute*)attr; 195 memctrl_dev = (struct memctrl_dev_attribute*)attr;
201 196
202 if (memctrl_dev->store) 197 if (memctrl_dev->store)
203 return memctrl_dev->store(memctrl_dev->value, buffer, count); 198 return memctrl_dev->store(memctrl_dev->value, buffer, count);
199
204 return -EIO; 200 return -EIO;
205} 201}
206 202
@@ -236,7 +232,6 @@ MEMCTRL_ATTR(log_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
236MEMCTRL_ATTR(log_ce,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store); 232MEMCTRL_ATTR(log_ce,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
237MEMCTRL_ATTR(poll_msec,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store); 233MEMCTRL_ATTR(poll_msec,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
238 234
239
240/* Base Attributes of the memory ECC object */ 235/* Base Attributes of the memory ECC object */
241static struct memctrl_dev_attribute *memctrl_attr[] = { 236static struct memctrl_dev_attribute *memctrl_attr[] = {
242 &attr_panic_on_ue, 237 &attr_panic_on_ue,
@@ -254,9 +249,9 @@ static void edac_memctrl_master_release(struct kobject *kobj)
254} 249}
255 250
256static struct kobj_type ktype_memctrl = { 251static struct kobj_type ktype_memctrl = {
257 .release = edac_memctrl_master_release, 252 .release = edac_memctrl_master_release,
258 .sysfs_ops = &memctrlfs_ops, 253 .sysfs_ops = &memctrlfs_ops,
259 .default_attrs = (struct attribute **) memctrl_attr, 254 .default_attrs = (struct attribute **) memctrl_attr,
260}; 255};
261 256
262#endif /* DISABLE_EDAC_SYSFS */ 257#endif /* DISABLE_EDAC_SYSFS */
@@ -282,6 +277,7 @@ static int edac_sysfs_memctrl_setup(void)
282 277
283 /* create the /sys/devices/system/edac directory */ 278 /* create the /sys/devices/system/edac directory */
284 err = sysdev_class_register(&edac_class); 279 err = sysdev_class_register(&edac_class);
280
285 if (!err) { 281 if (!err) {
286 /* Init the MC's kobject */ 282 /* Init the MC's kobject */
287 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj)); 283 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
@@ -290,18 +286,18 @@ static int edac_sysfs_memctrl_setup(void)
290 286
291 /* generate sysfs "..../edac/mc" */ 287 /* generate sysfs "..../edac/mc" */
292 err = kobject_set_name(&edac_memctrl_kobj,"mc"); 288 err = kobject_set_name(&edac_memctrl_kobj,"mc");
289
293 if (!err) { 290 if (!err) {
294 /* FIXME: maybe new sysdev_create_subdir() */ 291 /* FIXME: maybe new sysdev_create_subdir() */
295 err = kobject_register(&edac_memctrl_kobj); 292 err = kobject_register(&edac_memctrl_kobj);
296 if (err) { 293
294 if (err)
297 debugf1("Failed to register '.../edac/mc'\n"); 295 debugf1("Failed to register '.../edac/mc'\n");
298 } else { 296 else
299 debugf1("Registered '.../edac/mc' kobject\n"); 297 debugf1("Registered '.../edac/mc' kobject\n");
300 }
301 } 298 }
302 } else { 299 } else
303 debugf1("%s() error=%d\n", __func__, err); 300 debugf1("%s() error=%d\n", __func__, err);
304 }
305 301
306 return err; 302 return err;
307} 303}
@@ -340,7 +336,6 @@ struct list_control {
340 int *count; 336 int *count;
341}; 337};
342 338
343
344#if 0 339#if 0
345/* Output the list as: vendor_id:device:id<,vendor_id:device_id> */ 340/* Output the list as: vendor_id:device:id<,vendor_id:device_id> */
346static ssize_t edac_pci_list_string_show(void *ptr, char *buffer) 341static ssize_t edac_pci_list_string_show(void *ptr, char *buffer)
@@ -365,7 +360,6 @@ static ssize_t edac_pci_list_string_show(void *ptr, char *buffer)
365 } 360 }
366 361
367 len += snprintf(p + len,(PAGE_SIZE-len), "\n"); 362 len += snprintf(p + len,(PAGE_SIZE-len), "\n");
368
369 return (ssize_t) len; 363 return (ssize_t) len;
370} 364}
371 365
@@ -387,7 +381,7 @@ static int parse_one_device(const char **s,const char **e,
387 381
388 /* if null byte, we are done */ 382 /* if null byte, we are done */
389 if (!**s) { 383 if (!**s) {
390 (*s)++; /* keep *s moving */ 384 (*s)++; /* keep *s moving */
391 return 0; 385 return 0;
392 } 386 }
393 387
@@ -404,6 +398,7 @@ static int parse_one_device(const char **s,const char **e,
404 398
405 /* parse vendor_id */ 399 /* parse vendor_id */
406 runner = *s; 400 runner = *s;
401
407 while (runner < *e) { 402 while (runner < *e) {
408 /* scan for vendor:device delimiter */ 403 /* scan for vendor:device delimiter */
409 if (*runner == ':') { 404 if (*runner == ':') {
@@ -411,6 +406,7 @@ static int parse_one_device(const char **s,const char **e,
411 runner = p + 1; 406 runner = p + 1;
412 break; 407 break;
413 } 408 }
409
414 runner++; 410 runner++;
415 } 411 }
416 412
@@ -426,12 +422,11 @@ static int parse_one_device(const char **s,const char **e,
426 } 422 }
427 423
428 *s = runner; 424 *s = runner;
429
430 return 1; 425 return 1;
431} 426}
432 427
433static ssize_t edac_pci_list_string_store(void *ptr, const char *buffer, 428static ssize_t edac_pci_list_string_store(void *ptr, const char *buffer,
434 size_t count) 429 size_t count)
435{ 430{
436 struct list_control *listctl; 431 struct list_control *listctl;
437 struct edac_pci_device_list *list; 432 struct edac_pci_device_list *list;
@@ -441,14 +436,12 @@ static ssize_t edac_pci_list_string_store(void *ptr, const char *buffer,
441 436
442 s = (char*)buffer; 437 s = (char*)buffer;
443 e = s + count; 438 e = s + count;
444
445 listctl = ptr; 439 listctl = ptr;
446 list = listctl->list; 440 list = listctl->list;
447 index = listctl->count; 441 index = listctl->count;
448
449 *index = 0; 442 *index = 0;
450 while (*index < MAX_LISTED_PCI_DEVICES) {
451 443
444 while (*index < MAX_LISTED_PCI_DEVICES) {
452 if (parse_one_device(&s,&e,&vendor_id,&device_id)) { 445 if (parse_one_device(&s,&e,&vendor_id,&device_id)) {
453 list[ *index ].vendor = vendor_id; 446 list[ *index ].vendor = vendor_id;
454 list[ *index ].device = device_id; 447 list[ *index ].device = device_id;
@@ -481,15 +474,15 @@ static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
481} 474}
482 475
483struct edac_pci_dev_attribute { 476struct edac_pci_dev_attribute {
484 struct attribute attr; 477 struct attribute attr;
485 void *value; 478 void *value;
486 ssize_t (*show)(void *,char *); 479 ssize_t (*show)(void *,char *);
487 ssize_t (*store)(void *, const char *,size_t); 480 ssize_t (*store)(void *, const char *,size_t);
488}; 481};
489 482
490/* Set of show/store abstract level functions for PCI Parity object */ 483/* Set of show/store abstract level functions for PCI Parity object */
491static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr, 484static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
492 char *buffer) 485 char *buffer)
493{ 486{
494 struct edac_pci_dev_attribute *edac_pci_dev; 487 struct edac_pci_dev_attribute *edac_pci_dev;
495 edac_pci_dev= (struct edac_pci_dev_attribute*)attr; 488 edac_pci_dev= (struct edac_pci_dev_attribute*)attr;
@@ -499,8 +492,8 @@ static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
499 return -EIO; 492 return -EIO;
500} 493}
501 494
502static ssize_t edac_pci_dev_store(struct kobject *kobj, struct attribute *attr, 495static ssize_t edac_pci_dev_store(struct kobject *kobj,
503 const char *buffer, size_t count) 496 struct attribute *attr, const char *buffer, size_t count)
504{ 497{
505 struct edac_pci_dev_attribute *edac_pci_dev; 498 struct edac_pci_dev_attribute *edac_pci_dev;
506 edac_pci_dev= (struct edac_pci_dev_attribute*)attr; 499 edac_pci_dev= (struct edac_pci_dev_attribute*)attr;
@@ -515,7 +508,6 @@ static struct sysfs_ops edac_pci_sysfs_ops = {
515 .store = edac_pci_dev_store 508 .store = edac_pci_dev_store
516}; 509};
517 510
518
519#define EDAC_PCI_ATTR(_name,_mode,_show,_store) \ 511#define EDAC_PCI_ATTR(_name,_mode,_show,_store) \
520struct edac_pci_dev_attribute edac_pci_attr_##_name = { \ 512struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
521 .attr = {.name = __stringify(_name), .mode = _mode }, \ 513 .attr = {.name = __stringify(_name), .mode = _mode }, \
@@ -558,9 +550,11 @@ EDAC_PCI_STRING_ATTR(pci_parity_blacklist,
558#endif 550#endif
559 551
560/* PCI Parity control files */ 552/* PCI Parity control files */
561EDAC_PCI_ATTR(check_pci_parity,S_IRUGO|S_IWUSR,edac_pci_int_show,edac_pci_int_store); 553EDAC_PCI_ATTR(check_pci_parity, S_IRUGO|S_IWUSR, edac_pci_int_show,
562EDAC_PCI_ATTR(panic_on_pci_parity,S_IRUGO|S_IWUSR,edac_pci_int_show,edac_pci_int_store); 554 edac_pci_int_store);
563EDAC_PCI_ATTR(pci_parity_count,S_IRUGO,edac_pci_int_show,NULL); 555EDAC_PCI_ATTR(panic_on_pci_parity, S_IRUGO|S_IWUSR, edac_pci_int_show,
556 edac_pci_int_store);
557EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL);
564 558
565/* Base Attributes of the memory ECC object */ 559/* Base Attributes of the memory ECC object */
566static struct edac_pci_dev_attribute *edac_pci_attr[] = { 560static struct edac_pci_dev_attribute *edac_pci_attr[] = {
@@ -578,9 +572,9 @@ static void edac_pci_release(struct kobject *kobj)
578} 572}
579 573
580static struct kobj_type ktype_edac_pci = { 574static struct kobj_type ktype_edac_pci = {
581 .release = edac_pci_release, 575 .release = edac_pci_release,
582 .sysfs_ops = &edac_pci_sysfs_ops, 576 .sysfs_ops = &edac_pci_sysfs_ops,
583 .default_attrs = (struct attribute **) edac_pci_attr, 577 .default_attrs = (struct attribute **) edac_pci_attr,
584}; 578};
585 579
586#endif /* DISABLE_EDAC_SYSFS */ 580#endif /* DISABLE_EDAC_SYSFS */
@@ -603,17 +597,19 @@ static int edac_sysfs_pci_setup(void)
603 memset(&edac_pci_kobj, 0, sizeof(edac_pci_kobj)); 597 memset(&edac_pci_kobj, 0, sizeof(edac_pci_kobj));
604 edac_pci_kobj.parent = &edac_class.kset.kobj; 598 edac_pci_kobj.parent = &edac_class.kset.kobj;
605 edac_pci_kobj.ktype = &ktype_edac_pci; 599 edac_pci_kobj.ktype = &ktype_edac_pci;
606
607 err = kobject_set_name(&edac_pci_kobj, "pci"); 600 err = kobject_set_name(&edac_pci_kobj, "pci");
601
608 if (!err) { 602 if (!err) {
609 /* Instanstiate the csrow object */ 603 /* Instanstiate the csrow object */
610 /* FIXME: maybe new sysdev_create_subdir() */ 604 /* FIXME: maybe new sysdev_create_subdir() */
611 err = kobject_register(&edac_pci_kobj); 605 err = kobject_register(&edac_pci_kobj);
606
612 if (err) 607 if (err)
613 debugf1("Failed to register '.../edac/pci'\n"); 608 debugf1("Failed to register '.../edac/pci'\n");
614 else 609 else
615 debugf1("Registered '.../edac/pci' kobject\n"); 610 debugf1("Registered '.../edac/pci' kobject\n");
616 } 611 }
612
617 return err; 613 return err;
618} 614}
619#endif /* DISABLE_EDAC_SYSFS */ 615#endif /* DISABLE_EDAC_SYSFS */
@@ -641,6 +637,7 @@ static ssize_t csrow_ch0_dimm_label_show(struct csrow_info *csrow, char *data)
641 size = snprintf(data, EDAC_MC_LABEL_LEN,"%s\n", 637 size = snprintf(data, EDAC_MC_LABEL_LEN,"%s\n",
642 csrow->channels[0].label); 638 csrow->channels[0].label);
643 } 639 }
640
644 return size; 641 return size;
645} 642}
646 643
@@ -652,11 +649,12 @@ static ssize_t csrow_ch1_dimm_label_show(struct csrow_info *csrow, char *data)
652 size = snprintf(data, EDAC_MC_LABEL_LEN, "%s\n", 649 size = snprintf(data, EDAC_MC_LABEL_LEN, "%s\n",
653 csrow->channels[1].label); 650 csrow->channels[1].label);
654 } 651 }
652
655 return size; 653 return size;
656} 654}
657 655
658static ssize_t csrow_ch0_dimm_label_store(struct csrow_info *csrow, 656static ssize_t csrow_ch0_dimm_label_store(struct csrow_info *csrow,
659 const char *data, size_t size) 657 const char *data, size_t size)
660{ 658{
661 ssize_t max_size = 0; 659 ssize_t max_size = 0;
662 660
@@ -665,11 +663,12 @@ static ssize_t csrow_ch0_dimm_label_store(struct csrow_info *csrow,
665 strncpy(csrow->channels[0].label, data, max_size); 663 strncpy(csrow->channels[0].label, data, max_size);
666 csrow->channels[0].label[max_size] = '\0'; 664 csrow->channels[0].label[max_size] = '\0';
667 } 665 }
666
668 return size; 667 return size;
669} 668}
670 669
671static ssize_t csrow_ch1_dimm_label_store(struct csrow_info *csrow, 670static ssize_t csrow_ch1_dimm_label_store(struct csrow_info *csrow,
672 const char *data, size_t size) 671 const char *data, size_t size)
673{ 672{
674 ssize_t max_size = 0; 673 ssize_t max_size = 0;
675 674
@@ -678,6 +677,7 @@ static ssize_t csrow_ch1_dimm_label_store(struct csrow_info *csrow,
678 strncpy(csrow->channels[1].label, data, max_size); 677 strncpy(csrow->channels[1].label, data, max_size);
679 csrow->channels[1].label[max_size] = '\0'; 678 csrow->channels[1].label[max_size] = '\0';
680 } 679 }
680
681 return max_size; 681 return max_size;
682} 682}
683 683
@@ -698,6 +698,7 @@ static ssize_t csrow_ch0_ce_count_show(struct csrow_info *csrow, char *data)
698 if (csrow->nr_channels > 0) { 698 if (csrow->nr_channels > 0) {
699 size = sprintf(data,"%u\n", csrow->channels[0].ce_count); 699 size = sprintf(data,"%u\n", csrow->channels[0].ce_count);
700 } 700 }
701
701 return size; 702 return size;
702} 703}
703 704
@@ -708,6 +709,7 @@ static ssize_t csrow_ch1_ce_count_show(struct csrow_info *csrow, char *data)
708 if (csrow->nr_channels > 1) { 709 if (csrow->nr_channels > 1) {
709 size = sprintf(data,"%u\n", csrow->channels[1].ce_count); 710 size = sprintf(data,"%u\n", csrow->channels[1].ce_count);
710 } 711 }
712
711 return size; 713 return size;
712} 714}
713 715
@@ -732,7 +734,7 @@ static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data)
732} 734}
733 735
734struct csrowdev_attribute { 736struct csrowdev_attribute {
735 struct attribute attr; 737 struct attribute attr;
736 ssize_t (*show)(struct csrow_info *,char *); 738 ssize_t (*show)(struct csrow_info *,char *);
737 ssize_t (*store)(struct csrow_info *, const char *,size_t); 739 ssize_t (*store)(struct csrow_info *, const char *,size_t);
738}; 740};
@@ -742,24 +744,26 @@ struct csrowdev_attribute {
742 744
743/* Set of show/store higher level functions for csrow objects */ 745/* Set of show/store higher level functions for csrow objects */
744static ssize_t csrowdev_show(struct kobject *kobj, struct attribute *attr, 746static ssize_t csrowdev_show(struct kobject *kobj, struct attribute *attr,
745 char *buffer) 747 char *buffer)
746{ 748{
747 struct csrow_info *csrow = to_csrow(kobj); 749 struct csrow_info *csrow = to_csrow(kobj);
748 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr); 750 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
749 751
750 if (csrowdev_attr->show) 752 if (csrowdev_attr->show)
751 return csrowdev_attr->show(csrow, buffer); 753 return csrowdev_attr->show(csrow, buffer);
754
752 return -EIO; 755 return -EIO;
753} 756}
754 757
755static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr, 758static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
756 const char *buffer, size_t count) 759 const char *buffer, size_t count)
757{ 760{
758 struct csrow_info *csrow = to_csrow(kobj); 761 struct csrow_info *csrow = to_csrow(kobj);
759 struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr); 762 struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr);
760 763
761 if (csrowdev_attr->store) 764 if (csrowdev_attr->store)
762 return csrowdev_attr->store(csrow, buffer, count); 765 return csrowdev_attr->store(csrow, buffer, count);
766
763 return -EIO; 767 return -EIO;
764} 768}
765 769
@@ -793,7 +797,6 @@ CSROWDEV_ATTR(ch1_dimm_label,S_IRUGO|S_IWUSR,
793 csrow_ch1_dimm_label_show, 797 csrow_ch1_dimm_label_show,
794 csrow_ch1_dimm_label_store); 798 csrow_ch1_dimm_label_store);
795 799
796
797/* Attributes of the CSROW<id> object */ 800/* Attributes of the CSROW<id> object */
798static struct csrowdev_attribute *csrow_attr[] = { 801static struct csrowdev_attribute *csrow_attr[] = {
799 &attr_dev_type, 802 &attr_dev_type,
@@ -809,7 +812,6 @@ static struct csrowdev_attribute *csrow_attr[] = {
809 NULL, 812 NULL,
810}; 813};
811 814
812
813/* No memory to release */ 815/* No memory to release */
814static void edac_csrow_instance_release(struct kobject *kobj) 816static void edac_csrow_instance_release(struct kobject *kobj)
815{ 817{
@@ -821,19 +823,18 @@ static void edac_csrow_instance_release(struct kobject *kobj)
821} 823}
822 824
823static struct kobj_type ktype_csrow = { 825static struct kobj_type ktype_csrow = {
824 .release = edac_csrow_instance_release, 826 .release = edac_csrow_instance_release,
825 .sysfs_ops = &csrowfs_ops, 827 .sysfs_ops = &csrowfs_ops,
826 .default_attrs = (struct attribute **) csrow_attr, 828 .default_attrs = (struct attribute **) csrow_attr,
827}; 829};
828 830
829/* Create a CSROW object under specifed edac_mc_device */ 831/* Create a CSROW object under specifed edac_mc_device */
830static int edac_create_csrow_object(struct kobject *edac_mci_kobj, 832static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
831 struct csrow_info *csrow, int index ) 833 struct csrow_info *csrow, int index)
832{ 834{
833 int err = 0; 835 int err = 0;
834 836
835 debugf0("%s()\n", __func__); 837 debugf0("%s()\n", __func__);
836
837 memset(&csrow->kobj, 0, sizeof(csrow->kobj)); 838 memset(&csrow->kobj, 0, sizeof(csrow->kobj));
838 839
839 /* generate ..../edac/mc/mc<id>/csrow<index> */ 840 /* generate ..../edac/mc/mc<id>/csrow<index> */
@@ -843,9 +844,11 @@ static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
843 844
844 /* name this instance of csrow<id> */ 845 /* name this instance of csrow<id> */
845 err = kobject_set_name(&csrow->kobj,"csrow%d",index); 846 err = kobject_set_name(&csrow->kobj,"csrow%d",index);
847
846 if (!err) { 848 if (!err) {
847 /* Instanstiate the csrow object */ 849 /* Instanstiate the csrow object */
848 err = kobject_register(&csrow->kobj); 850 err = kobject_register(&csrow->kobj);
851
849 if (err) 852 if (err)
850 debugf0("Failed to register CSROW%d\n",index); 853 debugf0("Failed to register CSROW%d\n",index);
851 else 854 else
@@ -857,8 +860,8 @@ static int edac_create_csrow_object(struct kobject *edac_mci_kobj,
857 860
858/* sysfs data structures and methods for the MCI kobjects */ 861/* sysfs data structures and methods for the MCI kobjects */
859 862
860static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci, 863static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
861 const char *data, size_t count ) 864 const char *data, size_t count)
862{ 865{
863 int row, chan; 866 int row, chan;
864 867
@@ -866,16 +869,18 @@ static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
866 mci->ce_noinfo_count = 0; 869 mci->ce_noinfo_count = 0;
867 mci->ue_count = 0; 870 mci->ue_count = 0;
868 mci->ce_count = 0; 871 mci->ce_count = 0;
872
869 for (row = 0; row < mci->nr_csrows; row++) { 873 for (row = 0; row < mci->nr_csrows; row++) {
870 struct csrow_info *ri = &mci->csrows[row]; 874 struct csrow_info *ri = &mci->csrows[row];
871 875
872 ri->ue_count = 0; 876 ri->ue_count = 0;
873 ri->ce_count = 0; 877 ri->ce_count = 0;
878
874 for (chan = 0; chan < ri->nr_channels; chan++) 879 for (chan = 0; chan < ri->nr_channels; chan++)
875 ri->channels[chan].ce_count = 0; 880 ri->channels[chan].ce_count = 0;
876 } 881 }
877 mci->start_time = jiffies;
878 882
883 mci->start_time = jiffies;
879 return count; 884 return count;
880} 885}
881 886
@@ -933,18 +938,16 @@ static ssize_t mci_edac_capability_show(struct mem_ctl_info *mci, char *data)
933 938
934 p += mci_output_edac_cap(p,mci->edac_ctl_cap); 939 p += mci_output_edac_cap(p,mci->edac_ctl_cap);
935 p += sprintf(p, "\n"); 940 p += sprintf(p, "\n");
936
937 return p - data; 941 return p - data;
938} 942}
939 943
940static ssize_t mci_edac_current_capability_show(struct mem_ctl_info *mci, 944static ssize_t mci_edac_current_capability_show(struct mem_ctl_info *mci,
941 char *data) 945 char *data)
942{ 946{
943 char *p = data; 947 char *p = data;
944 948
945 p += mci_output_edac_cap(p,mci->edac_cap); 949 p += mci_output_edac_cap(p,mci->edac_cap);
946 p += sprintf(p, "\n"); 950 p += sprintf(p, "\n");
947
948 return p - data; 951 return p - data;
949} 952}
950 953
@@ -961,13 +964,13 @@ static int mci_output_mtype_cap(char *buf, unsigned long mtype_cap)
961 return p - buf; 964 return p - buf;
962} 965}
963 966
964static ssize_t mci_supported_mem_type_show(struct mem_ctl_info *mci, char *data) 967static ssize_t mci_supported_mem_type_show(struct mem_ctl_info *mci,
968 char *data)
965{ 969{
966 char *p = data; 970 char *p = data;
967 971
968 p += mci_output_mtype_cap(p,mci->mtype_cap); 972 p += mci_output_mtype_cap(p,mci->mtype_cap);
969 p += sprintf(p, "\n"); 973 p += sprintf(p, "\n");
970
971 return p - data; 974 return p - data;
972} 975}
973 976
@@ -981,6 +984,7 @@ static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
981 984
982 if (!csrow->nr_pages) 985 if (!csrow->nr_pages)
983 continue; 986 continue;
987
984 total_pages += csrow->nr_pages; 988 total_pages += csrow->nr_pages;
985 } 989 }
986 990
@@ -988,7 +992,7 @@ static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
988} 992}
989 993
990struct mcidev_attribute { 994struct mcidev_attribute {
991 struct attribute attr; 995 struct attribute attr;
992 ssize_t (*show)(struct mem_ctl_info *,char *); 996 ssize_t (*show)(struct mem_ctl_info *,char *);
993 ssize_t (*store)(struct mem_ctl_info *, const char *,size_t); 997 ssize_t (*store)(struct mem_ctl_info *, const char *,size_t);
994}; 998};
@@ -997,30 +1001,32 @@ struct mcidev_attribute {
997#define to_mcidev_attr(a) container_of(a, struct mcidev_attribute, attr) 1001#define to_mcidev_attr(a) container_of(a, struct mcidev_attribute, attr)
998 1002
999static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr, 1003static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
1000 char *buffer) 1004 char *buffer)
1001{ 1005{
1002 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 1006 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
1003 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr); 1007 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr);
1004 1008
1005 if (mcidev_attr->show) 1009 if (mcidev_attr->show)
1006 return mcidev_attr->show(mem_ctl_info, buffer); 1010 return mcidev_attr->show(mem_ctl_info, buffer);
1011
1007 return -EIO; 1012 return -EIO;
1008} 1013}
1009 1014
1010static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr, 1015static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
1011 const char *buffer, size_t count) 1016 const char *buffer, size_t count)
1012{ 1017{
1013 struct mem_ctl_info *mem_ctl_info = to_mci(kobj); 1018 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
1014 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr); 1019 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr);
1015 1020
1016 if (mcidev_attr->store) 1021 if (mcidev_attr->store)
1017 return mcidev_attr->store(mem_ctl_info, buffer, count); 1022 return mcidev_attr->store(mem_ctl_info, buffer, count);
1023
1018 return -EIO; 1024 return -EIO;
1019} 1025}
1020 1026
1021static struct sysfs_ops mci_ops = { 1027static struct sysfs_ops mci_ops = {
1022 .show = mcidev_show, 1028 .show = mcidev_show,
1023 .store = mcidev_store 1029 .store = mcidev_store
1024}; 1030};
1025 1031
1026#define MCIDEV_ATTR(_name,_mode,_show,_store) \ 1032#define MCIDEV_ATTR(_name,_mode,_show,_store) \
@@ -1048,7 +1054,6 @@ MCIDEV_ATTR(edac_current_capability,S_IRUGO,
1048MCIDEV_ATTR(supported_mem_type,S_IRUGO, 1054MCIDEV_ATTR(supported_mem_type,S_IRUGO,
1049 mci_supported_mem_type_show,NULL); 1055 mci_supported_mem_type_show,NULL);
1050 1056
1051
1052static struct mcidev_attribute *mci_attr[] = { 1057static struct mcidev_attribute *mci_attr[] = {
1053 &mci_attr_reset_counters, 1058 &mci_attr_reset_counters,
1054 &mci_attr_module_name, 1059 &mci_attr_module_name,
@@ -1065,7 +1070,6 @@ static struct mcidev_attribute *mci_attr[] = {
1065 NULL 1070 NULL
1066}; 1071};
1067 1072
1068
1069/* 1073/*
1070 * Release of a MC controlling instance 1074 * Release of a MC controlling instance
1071 */ 1075 */
@@ -1079,9 +1083,9 @@ static void edac_mci_instance_release(struct kobject *kobj)
1079} 1083}
1080 1084
1081static struct kobj_type ktype_mci = { 1085static struct kobj_type ktype_mci = {
1082 .release = edac_mci_instance_release, 1086 .release = edac_mci_instance_release,
1083 .sysfs_ops = &mci_ops, 1087 .sysfs_ops = &mci_ops,
1084 .default_attrs = (struct attribute **) mci_attr, 1088 .default_attrs = (struct attribute **) mci_attr,
1085}; 1089};
1086 1090
1087#endif /* DISABLE_EDAC_SYSFS */ 1091#endif /* DISABLE_EDAC_SYSFS */
@@ -1109,11 +1113,11 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1109 struct kobject *edac_mci_kobj=&mci->edac_mci_kobj; 1113 struct kobject *edac_mci_kobj=&mci->edac_mci_kobj;
1110 1114
1111 debugf0("%s() idx=%d\n", __func__, mci->mc_idx); 1115 debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
1112
1113 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj)); 1116 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj));
1114 1117
1115 /* set the name of the mc<id> object */ 1118 /* set the name of the mc<id> object */
1116 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx); 1119 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx);
1120
1117 if (err) 1121 if (err)
1118 return err; 1122 return err;
1119 1123
@@ -1123,12 +1127,14 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1123 1127
1124 /* register the mc<id> kobject */ 1128 /* register the mc<id> kobject */
1125 err = kobject_register(edac_mci_kobj); 1129 err = kobject_register(edac_mci_kobj);
1130
1126 if (err) 1131 if (err)
1127 return err; 1132 return err;
1128 1133
1129 /* create a symlink for the device */ 1134 /* create a symlink for the device */
1130 err = sysfs_create_link(edac_mci_kobj, &mci->pdev->dev.kobj, 1135 err = sysfs_create_link(edac_mci_kobj, &mci->pdev->dev.kobj,
1131 EDAC_DEVICE_SYMLINK); 1136 EDAC_DEVICE_SYMLINK);
1137
1132 if (err) 1138 if (err)
1133 goto fail0; 1139 goto fail0;
1134 1140
@@ -1136,12 +1142,12 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1136 * under the mc<id> kobject 1142 * under the mc<id> kobject
1137 */ 1143 */
1138 for (i = 0; i < mci->nr_csrows; i++) { 1144 for (i = 0; i < mci->nr_csrows; i++) {
1139
1140 csrow = &mci->csrows[i]; 1145 csrow = &mci->csrows[i];
1141 1146
1142 /* Only expose populated CSROWs */ 1147 /* Only expose populated CSROWs */
1143 if (csrow->nr_pages > 0) { 1148 if (csrow->nr_pages > 0) {
1144 err = edac_create_csrow_object(edac_mci_kobj,csrow,i); 1149 err = edac_create_csrow_object(edac_mci_kobj,csrow,i);
1150
1145 if (err) 1151 if (err)
1146 goto fail1; 1152 goto fail1;
1147 } 1153 }
@@ -1149,7 +1155,6 @@ static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
1149 1155
1150 return 0; 1156 return 0;
1151 1157
1152
1153 /* CSROW error: backout what has already been registered, */ 1158 /* CSROW error: backout what has already been registered, */
1154fail1: 1159fail1:
1155 for ( i--; i >= 0; i--) { 1160 for ( i--; i >= 0; i--) {
@@ -1164,7 +1169,6 @@ fail0:
1164 init_completion(&mci->kobj_complete); 1169 init_completion(&mci->kobj_complete);
1165 kobject_unregister(edac_mci_kobj); 1170 kobject_unregister(edac_mci_kobj);
1166 wait_for_completion(&mci->kobj_complete); 1171 wait_for_completion(&mci->kobj_complete);
1167
1168 return err; 1172 return err;
1169} 1173}
1170#endif /* DISABLE_EDAC_SYSFS */ 1174#endif /* DISABLE_EDAC_SYSFS */
@@ -1199,7 +1203,6 @@ static void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
1199 1203
1200#ifdef CONFIG_EDAC_DEBUG 1204#ifdef CONFIG_EDAC_DEBUG
1201 1205
1202
1203void edac_mc_dump_channel(struct channel_info *chan) 1206void edac_mc_dump_channel(struct channel_info *chan)
1204{ 1207{
1205 debugf4("\tchannel = %p\n", chan); 1208 debugf4("\tchannel = %p\n", chan);
@@ -1210,7 +1213,6 @@ void edac_mc_dump_channel(struct channel_info *chan)
1210} 1213}
1211EXPORT_SYMBOL(edac_mc_dump_channel); 1214EXPORT_SYMBOL(edac_mc_dump_channel);
1212 1215
1213
1214void edac_mc_dump_csrow(struct csrow_info *csrow) 1216void edac_mc_dump_csrow(struct csrow_info *csrow)
1215{ 1217{
1216 debugf4("\tcsrow = %p\n", csrow); 1218 debugf4("\tcsrow = %p\n", csrow);
@@ -1227,7 +1229,6 @@ void edac_mc_dump_csrow(struct csrow_info *csrow)
1227} 1229}
1228EXPORT_SYMBOL(edac_mc_dump_csrow); 1230EXPORT_SYMBOL(edac_mc_dump_csrow);
1229 1231
1230
1231void edac_mc_dump_mci(struct mem_ctl_info *mci) 1232void edac_mc_dump_mci(struct mem_ctl_info *mci)
1232{ 1233{
1233 debugf3("\tmci = %p\n", mci); 1234 debugf3("\tmci = %p\n", mci);
@@ -1244,8 +1245,7 @@ void edac_mc_dump_mci(struct mem_ctl_info *mci)
1244} 1245}
1245EXPORT_SYMBOL(edac_mc_dump_mci); 1246EXPORT_SYMBOL(edac_mc_dump_mci);
1246 1247
1247 1248#endif /* CONFIG_EDAC_DEBUG */
1248#endif /* CONFIG_EDAC_DEBUG */
1249 1249
1250/* 'ptr' points to a possibly unaligned item X such that sizeof(X) is 'size'. 1250/* 'ptr' points to a possibly unaligned item X such that sizeof(X) is 'size'.
1251 * Adjust 'ptr' so that its alignment is at least as stringent as what the 1251 * Adjust 'ptr' so that its alignment is at least as stringent as what the
@@ -1254,7 +1254,7 @@ EXPORT_SYMBOL(edac_mc_dump_mci);
1254 * If 'size' is a constant, the compiler will optimize this whole function 1254 * If 'size' is a constant, the compiler will optimize this whole function
1255 * down to either a no-op or the addition of a constant to the value of 'ptr'. 1255 * down to either a no-op or the addition of a constant to the value of 'ptr'.
1256 */ 1256 */
1257static inline char * align_ptr (void *ptr, unsigned size) 1257static inline char * align_ptr(void *ptr, unsigned size)
1258{ 1258{
1259 unsigned align, r; 1259 unsigned align, r;
1260 1260
@@ -1281,7 +1281,6 @@ static inline char * align_ptr (void *ptr, unsigned size)
1281 return (char *) (((unsigned long) ptr) + align - r); 1281 return (char *) (((unsigned long) ptr) + align - r);
1282} 1282}
1283 1283
1284
1285/** 1284/**
1286 * edac_mc_alloc: Allocate a struct mem_ctl_info structure 1285 * edac_mc_alloc: Allocate a struct mem_ctl_info structure
1287 * @size_pvt: size of private storage needed 1286 * @size_pvt: size of private storage needed
@@ -1299,7 +1298,7 @@ static inline char * align_ptr (void *ptr, unsigned size)
1299 * struct mem_ctl_info pointer 1298 * struct mem_ctl_info pointer
1300 */ 1299 */
1301struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows, 1300struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
1302 unsigned nr_chans) 1301 unsigned nr_chans)
1303{ 1302{
1304 struct mem_ctl_info *mci; 1303 struct mem_ctl_info *mci;
1305 struct csrow_info *csi, *csrow; 1304 struct csrow_info *csi, *csrow;
@@ -1330,8 +1329,7 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
1330 chi = (struct channel_info *) (((char *) mci) + ((unsigned long) chi)); 1329 chi = (struct channel_info *) (((char *) mci) + ((unsigned long) chi));
1331 pvt = sz_pvt ? (((char *) mci) + ((unsigned long) pvt)) : NULL; 1330 pvt = sz_pvt ? (((char *) mci) + ((unsigned long) pvt)) : NULL;
1332 1331
1333 memset(mci, 0, size); /* clear all fields */ 1332 memset(mci, 0, size); /* clear all fields */
1334
1335 mci->csrows = csi; 1333 mci->csrows = csi;
1336 mci->pvt_info = pvt; 1334 mci->pvt_info = pvt;
1337 mci->nr_csrows = nr_csrows; 1335 mci->nr_csrows = nr_csrows;
@@ -1355,7 +1353,6 @@ struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
1355} 1353}
1356EXPORT_SYMBOL(edac_mc_alloc); 1354EXPORT_SYMBOL(edac_mc_alloc);
1357 1355
1358
1359/** 1356/**
1360 * edac_mc_free: Free a previously allocated 'mci' structure 1357 * edac_mc_free: Free a previously allocated 'mci' structure
1361 * @mci: pointer to a struct mem_ctl_info structure 1358 * @mci: pointer to a struct mem_ctl_info structure
@@ -1383,7 +1380,7 @@ static struct mem_ctl_info *find_mci_by_pdev(struct pci_dev *pdev)
1383 return NULL; 1380 return NULL;
1384} 1381}
1385 1382
1386static int add_mc_to_global_list (struct mem_ctl_info *mci) 1383static int add_mc_to_global_list(struct mem_ctl_info *mci)
1387{ 1384{
1388 struct list_head *item, *insert_before; 1385 struct list_head *item, *insert_before;
1389 struct mem_ctl_info *p; 1386 struct mem_ctl_info *p;
@@ -1426,8 +1423,7 @@ static int add_mc_to_global_list (struct mem_ctl_info *mci)
1426 return 0; 1423 return 0;
1427} 1424}
1428 1425
1429 1426static void complete_mc_list_del(struct rcu_head *head)
1430static void complete_mc_list_del (struct rcu_head *head)
1431{ 1427{
1432 struct mem_ctl_info *mci; 1428 struct mem_ctl_info *mci;
1433 1429
@@ -1436,8 +1432,7 @@ static void complete_mc_list_del (struct rcu_head *head)
1436 complete(&mci->complete); 1432 complete(&mci->complete);
1437} 1433}
1438 1434
1439 1435static void del_mc_from_global_list(struct mem_ctl_info *mci)
1440static void del_mc_from_global_list (struct mem_ctl_info *mci)
1441{ 1436{
1442 list_del_rcu(&mci->link); 1437 list_del_rcu(&mci->link);
1443 init_completion(&mci->complete); 1438 init_completion(&mci->complete);
@@ -1445,7 +1440,6 @@ static void del_mc_from_global_list (struct mem_ctl_info *mci)
1445 wait_for_completion(&mci->complete); 1440 wait_for_completion(&mci->complete);
1446} 1441}
1447 1442
1448
1449/** 1443/**
1450 * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and 1444 * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and
1451 * create sysfs entries associated with mci structure 1445 * create sysfs entries associated with mci structure
@@ -1463,15 +1457,17 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
1463#ifdef CONFIG_EDAC_DEBUG 1457#ifdef CONFIG_EDAC_DEBUG
1464 if (edac_debug_level >= 3) 1458 if (edac_debug_level >= 3)
1465 edac_mc_dump_mci(mci); 1459 edac_mc_dump_mci(mci);
1460
1466 if (edac_debug_level >= 4) { 1461 if (edac_debug_level >= 4) {
1467 int i; 1462 int i;
1468 1463
1469 for (i = 0; i < mci->nr_csrows; i++) { 1464 for (i = 0; i < mci->nr_csrows; i++) {
1470 int j; 1465 int j;
1466
1471 edac_mc_dump_csrow(&mci->csrows[i]); 1467 edac_mc_dump_csrow(&mci->csrows[i]);
1472 for (j = 0; j < mci->csrows[i].nr_channels; j++) 1468 for (j = 0; j < mci->csrows[i].nr_channels; j++)
1473 edac_mc_dump_channel(&mci->csrows[i]. 1469 edac_mc_dump_channel(
1474 channels[j]); 1470 &mci->csrows[i].channels[j]);
1475 } 1471 }
1476 } 1472 }
1477#endif 1473#endif
@@ -1505,7 +1501,6 @@ fail0:
1505} 1501}
1506EXPORT_SYMBOL(edac_mc_add_mc); 1502EXPORT_SYMBOL(edac_mc_add_mc);
1507 1503
1508
1509/** 1504/**
1510 * edac_mc_del_mc: Remove sysfs entries for specified mci structure and 1505 * edac_mc_del_mc: Remove sysfs entries for specified mci structure and
1511 * remove mci structure from global list 1506 * remove mci structure from global list
@@ -1535,9 +1530,7 @@ struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev)
1535} 1530}
1536EXPORT_SYMBOL(edac_mc_del_mc); 1531EXPORT_SYMBOL(edac_mc_del_mc);
1537 1532
1538 1533void edac_mc_scrub_block(unsigned long page, unsigned long offset, u32 size)
1539void edac_mc_scrub_block(unsigned long page, unsigned long offset,
1540 u32 size)
1541{ 1534{
1542 struct page *pg; 1535 struct page *pg;
1543 void *virt_addr; 1536 void *virt_addr;
@@ -1568,10 +1561,8 @@ void edac_mc_scrub_block(unsigned long page, unsigned long offset,
1568} 1561}
1569EXPORT_SYMBOL(edac_mc_scrub_block); 1562EXPORT_SYMBOL(edac_mc_scrub_block);
1570 1563
1571
1572/* FIXME - should return -1 */ 1564/* FIXME - should return -1 */
1573int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, 1565int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page)
1574 unsigned long page)
1575{ 1566{
1576 struct csrow_info *csrows = mci->csrows; 1567 struct csrow_info *csrows = mci->csrows;
1577 int row, i; 1568 int row, i;
@@ -1608,14 +1599,11 @@ int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
1608} 1599}
1609EXPORT_SYMBOL(edac_mc_find_csrow_by_page); 1600EXPORT_SYMBOL(edac_mc_find_csrow_by_page);
1610 1601
1611
1612/* FIXME - setable log (warning/emerg) levels */ 1602/* FIXME - setable log (warning/emerg) levels */
1613/* FIXME - integrate with evlog: http://evlog.sourceforge.net/ */ 1603/* FIXME - integrate with evlog: http://evlog.sourceforge.net/ */
1614void edac_mc_handle_ce(struct mem_ctl_info *mci, 1604void edac_mc_handle_ce(struct mem_ctl_info *mci,
1615 unsigned long page_frame_number, 1605 unsigned long page_frame_number, unsigned long offset_in_page,
1616 unsigned long offset_in_page, 1606 unsigned long syndrome, int row, int channel, const char *msg)
1617 unsigned long syndrome, int row, int channel,
1618 const char *msg)
1619{ 1607{
1620 unsigned long remapped_page; 1608 unsigned long remapped_page;
1621 1609
@@ -1630,6 +1618,7 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
1630 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); 1618 edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
1631 return; 1619 return;
1632 } 1620 }
1621
1633 if (channel >= mci->csrows[row].nr_channels || channel < 0) { 1622 if (channel >= mci->csrows[row].nr_channels || channel < 0) {
1634 /* something is wrong */ 1623 /* something is wrong */
1635 edac_mc_printk(mci, KERN_ERR, 1624 edac_mc_printk(mci, KERN_ERR,
@@ -1668,28 +1657,25 @@ void edac_mc_handle_ce(struct mem_ctl_info *mci,
1668 page_frame_number; 1657 page_frame_number;
1669 1658
1670 edac_mc_scrub_block(remapped_page, offset_in_page, 1659 edac_mc_scrub_block(remapped_page, offset_in_page,
1671 mci->csrows[row].grain); 1660 mci->csrows[row].grain);
1672 } 1661 }
1673} 1662}
1674EXPORT_SYMBOL(edac_mc_handle_ce); 1663EXPORT_SYMBOL(edac_mc_handle_ce);
1675 1664
1676 1665void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci, const char *msg)
1677void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci,
1678 const char *msg)
1679{ 1666{
1680 if (log_ce) 1667 if (log_ce)
1681 edac_mc_printk(mci, KERN_WARNING, 1668 edac_mc_printk(mci, KERN_WARNING,
1682 "CE - no information available: %s\n", msg); 1669 "CE - no information available: %s\n", msg);
1670
1683 mci->ce_noinfo_count++; 1671 mci->ce_noinfo_count++;
1684 mci->ce_count++; 1672 mci->ce_count++;
1685} 1673}
1686EXPORT_SYMBOL(edac_mc_handle_ce_no_info); 1674EXPORT_SYMBOL(edac_mc_handle_ce_no_info);
1687 1675
1688
1689void edac_mc_handle_ue(struct mem_ctl_info *mci, 1676void edac_mc_handle_ue(struct mem_ctl_info *mci,
1690 unsigned long page_frame_number, 1677 unsigned long page_frame_number, unsigned long offset_in_page,
1691 unsigned long offset_in_page, int row, 1678 int row, const char *msg)
1692 const char *msg)
1693{ 1679{
1694 int len = EDAC_MC_LABEL_LEN * 4; 1680 int len = EDAC_MC_LABEL_LEN * 4;
1695 char labels[len + 1]; 1681 char labels[len + 1];
@@ -1710,13 +1696,14 @@ void edac_mc_handle_ue(struct mem_ctl_info *mci,
1710 } 1696 }
1711 1697
1712 chars = snprintf(pos, len + 1, "%s", 1698 chars = snprintf(pos, len + 1, "%s",
1713 mci->csrows[row].channels[0].label); 1699 mci->csrows[row].channels[0].label);
1714 len -= chars; 1700 len -= chars;
1715 pos += chars; 1701 pos += chars;
1702
1716 for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0); 1703 for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0);
1717 chan++) { 1704 chan++) {
1718 chars = snprintf(pos, len + 1, ":%s", 1705 chars = snprintf(pos, len + 1, ":%s",
1719 mci->csrows[row].channels[chan].label); 1706 mci->csrows[row].channels[chan].label);
1720 len -= chars; 1707 len -= chars;
1721 pos += chars; 1708 pos += chars;
1722 } 1709 }
@@ -1729,20 +1716,17 @@ void edac_mc_handle_ue(struct mem_ctl_info *mci,
1729 msg); 1716 msg);
1730 1717
1731 if (panic_on_ue) 1718 if (panic_on_ue)
1732 panic 1719 panic("EDAC MC%d: UE page 0x%lx, offset 0x%lx, grain %d, "
1733 ("EDAC MC%d: UE page 0x%lx, offset 0x%lx, grain %d, row %d," 1720 "row %d, labels \"%s\": %s\n", mci->mc_idx,
1734 " labels \"%s\": %s\n", mci->mc_idx, 1721 page_frame_number, offset_in_page,
1735 page_frame_number, offset_in_page, 1722 mci->csrows[row].grain, row, labels, msg);
1736 mci->csrows[row].grain, row, labels, msg);
1737 1723
1738 mci->ue_count++; 1724 mci->ue_count++;
1739 mci->csrows[row].ue_count++; 1725 mci->csrows[row].ue_count++;
1740} 1726}
1741EXPORT_SYMBOL(edac_mc_handle_ue); 1727EXPORT_SYMBOL(edac_mc_handle_ue);
1742 1728
1743 1729void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg)
1744void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci,
1745 const char *msg)
1746{ 1730{
1747 if (panic_on_ue) 1731 if (panic_on_ue)
1748 panic("EDAC MC%d: Uncorrected Error", mci->mc_idx); 1732 panic("EDAC MC%d: Uncorrected Error", mci->mc_idx);
@@ -1755,7 +1739,6 @@ void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci,
1755} 1739}
1756EXPORT_SYMBOL(edac_mc_handle_ue_no_info); 1740EXPORT_SYMBOL(edac_mc_handle_ue_no_info);
1757 1741
1758
1759#ifdef CONFIG_PCI 1742#ifdef CONFIG_PCI
1760 1743
1761static u16 get_pci_parity_status(struct pci_dev *dev, int secondary) 1744static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
@@ -1766,18 +1749,22 @@ static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
1766 where = secondary ? PCI_SEC_STATUS : PCI_STATUS; 1749 where = secondary ? PCI_SEC_STATUS : PCI_STATUS;
1767 pci_read_config_word(dev, where, &status); 1750 pci_read_config_word(dev, where, &status);
1768 1751
1769 /* If we get back 0xFFFF then we must suspect that the card has been pulled but 1752 /* If we get back 0xFFFF then we must suspect that the card has been
1770 the Linux PCI layer has not yet finished cleaning up. We don't want to report 1753 * pulled but the Linux PCI layer has not yet finished cleaning up.
1771 on such devices */ 1754 * We don't want to report on such devices
1755 */
1772 1756
1773 if (status == 0xFFFF) { 1757 if (status == 0xFFFF) {
1774 u32 sanity; 1758 u32 sanity;
1759
1775 pci_read_config_dword(dev, 0, &sanity); 1760 pci_read_config_dword(dev, 0, &sanity);
1761
1776 if (sanity == 0xFFFFFFFF) 1762 if (sanity == 0xFFFFFFFF)
1777 return 0; 1763 return 0;
1778 } 1764 }
1765
1779 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR | 1766 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
1780 PCI_STATUS_PARITY; 1767 PCI_STATUS_PARITY;
1781 1768
1782 if (status) 1769 if (status)
1783 /* reset only the bits we are interested in */ 1770 /* reset only the bits we are interested in */
@@ -1789,7 +1776,7 @@ static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
1789typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev); 1776typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
1790 1777
1791/* Clear any PCI parity errors logged by this device. */ 1778/* Clear any PCI parity errors logged by this device. */
1792static void edac_pci_dev_parity_clear( struct pci_dev *dev ) 1779static void edac_pci_dev_parity_clear(struct pci_dev *dev)
1793{ 1780{
1794 u8 header_type; 1781 u8 header_type;
1795 1782
@@ -1890,58 +1877,55 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
1890 * Returns: 0 not found 1877 * Returns: 0 not found
1891 * 1 found on list 1878 * 1 found on list
1892 */ 1879 */
1893static int check_dev_on_list(struct edac_pci_device_list *list, int free_index, 1880static int check_dev_on_list(struct edac_pci_device_list *list,
1894 struct pci_dev *dev) 1881 int free_index, struct pci_dev *dev)
1895{ 1882{
1896 int i; 1883 int i;
1897 int rc = 0; /* Assume not found */ 1884 int rc = 0; /* Assume not found */
1898 unsigned short vendor=dev->vendor; 1885 unsigned short vendor=dev->vendor;
1899 unsigned short device=dev->device; 1886 unsigned short device=dev->device;
1900 1887
1901 /* Scan the list, looking for a vendor/device match 1888 /* Scan the list, looking for a vendor/device match */
1902 */ 1889 for (i = 0; i < free_index; i++, list++ ) {
1903 for (i = 0; i < free_index; i++, list++ ) { 1890 if ((list->vendor == vendor ) && (list->device == device )) {
1904 if ( (list->vendor == vendor ) && 1891 rc = 1;
1905 (list->device == device )) { 1892 break;
1906 rc = 1; 1893 }
1907 break; 1894 }
1908 }
1909 }
1910 1895
1911 return rc; 1896 return rc;
1912} 1897}
1913 1898
1914/* 1899/*
1915 * pci_dev parity list iterator 1900 * pci_dev parity list iterator
1916 * Scan the PCI device list for one iteration, looking for SERRORs 1901 * Scan the PCI device list for one iteration, looking for SERRORs
1917 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices 1902 * Master Parity ERRORS or Parity ERRORs on primary or secondary devices
1918 */ 1903 */
1919static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn) 1904static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
1920{ 1905{
1921 struct pci_dev *dev=NULL; 1906 struct pci_dev *dev = NULL;
1922 1907
1923 /* request for kernel access to the next PCI device, if any, 1908 /* request for kernel access to the next PCI device, if any,
1924 * and while we are looking at it have its reference count 1909 * and while we are looking at it have its reference count
1925 * bumped until we are done with it 1910 * bumped until we are done with it
1926 */ 1911 */
1927 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 1912 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
1928 1913 /* if whitelist exists then it has priority, so only scan
1929 /* if whitelist exists then it has priority, so only scan those 1914 * those devices on the whitelist
1930 * devices on the whitelist 1915 */
1931 */ 1916 if (pci_whitelist_count > 0 ) {
1932 if (pci_whitelist_count > 0 ) { 1917 if (check_dev_on_list(pci_whitelist,
1933 if (check_dev_on_list(pci_whitelist,
1934 pci_whitelist_count, dev)) 1918 pci_whitelist_count, dev))
1935 fn(dev); 1919 fn(dev);
1936 } else { 1920 } else {
1937 /* 1921 /*
1938 * if no whitelist, then check if this devices is 1922 * if no whitelist, then check if this devices is
1939 * blacklisted 1923 * blacklisted
1940 */ 1924 */
1941 if (!check_dev_on_list(pci_blacklist, 1925 if (!check_dev_on_list(pci_blacklist,
1942 pci_blacklist_count, dev)) 1926 pci_blacklist_count, dev))
1943 fn(dev); 1927 fn(dev);
1944 } 1928 }
1945 } 1929 }
1946} 1930}
1947 1931
@@ -1972,7 +1956,6 @@ static void do_pci_parity_check(void)
1972 } 1956 }
1973} 1957}
1974 1958
1975
1976static inline void clear_pci_parity_errors(void) 1959static inline void clear_pci_parity_errors(void)
1977{ 1960{
1978 /* Clear any PCI bus parity errors that devices initially have logged 1961 /* Clear any PCI bus parity errors that devices initially have logged
@@ -1981,34 +1964,29 @@ static inline void clear_pci_parity_errors(void)
1981 edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear); 1964 edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
1982} 1965}
1983 1966
1984
1985#else /* CONFIG_PCI */ 1967#else /* CONFIG_PCI */
1986 1968
1987
1988static inline void do_pci_parity_check(void) 1969static inline void do_pci_parity_check(void)
1989{ 1970{
1990 /* no-op */ 1971 /* no-op */
1991} 1972}
1992 1973
1993
1994static inline void clear_pci_parity_errors(void) 1974static inline void clear_pci_parity_errors(void)
1995{ 1975{
1996 /* no-op */ 1976 /* no-op */
1997} 1977}
1998 1978
1999
2000#endif /* CONFIG_PCI */ 1979#endif /* CONFIG_PCI */
2001 1980
2002/* 1981/*
2003 * Iterate over all MC instances and check for ECC, et al, errors 1982 * Iterate over all MC instances and check for ECC, et al, errors
2004 */ 1983 */
2005static inline void check_mc_devices (void) 1984static inline void check_mc_devices(void)
2006{ 1985{
2007 struct list_head *item; 1986 struct list_head *item;
2008 struct mem_ctl_info *mci; 1987 struct mem_ctl_info *mci;
2009 1988
2010 debugf3("%s()\n", __func__); 1989 debugf3("%s()\n", __func__);
2011
2012 down(&mem_ctls_mutex); 1990 down(&mem_ctls_mutex);
2013 1991
2014 list_for_each(item, &mc_devices) { 1992 list_for_each(item, &mc_devices) {
@@ -2021,7 +1999,6 @@ static inline void check_mc_devices (void)
2021 up(&mem_ctls_mutex); 1999 up(&mem_ctls_mutex);
2022} 2000}
2023 2001
2024
2025/* 2002/*
2026 * Check MC status every poll_msec. 2003 * Check MC status every poll_msec.
2027 * Check PCI status every poll_msec as well. 2004 * Check PCI status every poll_msec as well.
@@ -2084,6 +2061,7 @@ static int __init edac_mc_init(void)
2084 2061
2085 /* create our kernel thread */ 2062 /* create our kernel thread */
2086 edac_thread = kthread_run(edac_kernel_thread, NULL, "kedac"); 2063 edac_thread = kthread_run(edac_kernel_thread, NULL, "kedac");
2064
2087 if (IS_ERR(edac_thread)) { 2065 if (IS_ERR(edac_thread)) {
2088 /* remove the sysfs entries */ 2066 /* remove the sysfs entries */
2089 edac_sysfs_memctrl_teardown(); 2067 edac_sysfs_memctrl_teardown();
@@ -2094,7 +2072,6 @@ static int __init edac_mc_init(void)
2094 return 0; 2072 return 0;
2095} 2073}
2096 2074
2097
2098/* 2075/*
2099 * edac_mc_exit() 2076 * edac_mc_exit()
2100 * module exit/termination functioni 2077 * module exit/termination functioni
@@ -2102,7 +2079,6 @@ static int __init edac_mc_init(void)
2102static void __exit edac_mc_exit(void) 2079static void __exit edac_mc_exit(void)
2103{ 2080{
2104 debugf0("%s()\n", __func__); 2081 debugf0("%s()\n", __func__);
2105
2106 kthread_stop(edac_thread); 2082 kthread_stop(edac_thread);
2107 2083
2108 /* tear down the sysfs device */ 2084 /* tear down the sysfs device */
@@ -2110,15 +2086,12 @@ static void __exit edac_mc_exit(void)
2110 edac_sysfs_pci_teardown(); 2086 edac_sysfs_pci_teardown();
2111} 2087}
2112 2088
2113
2114
2115
2116module_init(edac_mc_init); 2089module_init(edac_mc_init);
2117module_exit(edac_mc_exit); 2090module_exit(edac_mc_exit);
2118 2091
2119MODULE_LICENSE("GPL"); 2092MODULE_LICENSE("GPL");
2120MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n" 2093MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n"
2121 "Based on.work by Dan Hollis et al"); 2094 "Based on work by Dan Hollis et al");
2122MODULE_DESCRIPTION("Core library routines for MC reporting"); 2095MODULE_DESCRIPTION("Core library routines for MC reporting");
2123 2096
2124module_param(panic_on_ue, int, 0644); 2097module_param(panic_on_ue, int, 0644);
diff --git a/drivers/edac/edac_mc.h b/drivers/edac/edac_mc.h
index 2cec157aaeba..8d9e83909b9c 100644
--- a/drivers/edac/edac_mc.h
+++ b/drivers/edac/edac_mc.h
@@ -15,11 +15,9 @@
15 * 15 *
16 */ 16 */
17 17
18
19#ifndef _EDAC_MC_H_ 18#ifndef _EDAC_MC_H_
20#define _EDAC_MC_H_ 19#define _EDAC_MC_H_
21 20
22
23#include <linux/config.h> 21#include <linux/config.h>
24#include <linux/kernel.h> 22#include <linux/kernel.h>
25#include <linux/types.h> 23#include <linux/types.h>
@@ -33,7 +31,6 @@
33#include <linux/completion.h> 31#include <linux/completion.h>
34#include <linux/kobject.h> 32#include <linux/kobject.h>
35 33
36
37#define EDAC_MC_LABEL_LEN 31 34#define EDAC_MC_LABEL_LEN 31
38#define MC_PROC_NAME_MAX_LEN 7 35#define MC_PROC_NAME_MAX_LEN 7
39 36
@@ -44,13 +41,13 @@
44#endif 41#endif
45 42
46#define edac_printk(level, prefix, fmt, arg...) \ 43#define edac_printk(level, prefix, fmt, arg...) \
47 printk(level "EDAC " prefix ": " fmt, ##arg) 44 printk(level "EDAC " prefix ": " fmt, ##arg)
48 45
49#define edac_mc_printk(mci, level, fmt, arg...) \ 46#define edac_mc_printk(mci, level, fmt, arg...) \
50 printk(level "EDAC MC%d: " fmt, mci->mc_idx, ##arg) 47 printk(level "EDAC MC%d: " fmt, mci->mc_idx, ##arg)
51 48
52#define edac_mc_chipset_printk(mci, level, prefix, fmt, arg...) \ 49#define edac_mc_chipset_printk(mci, level, prefix, fmt, arg...) \
53 printk(level "EDAC " prefix " MC%d: " fmt, mci->mc_idx, ##arg) 50 printk(level "EDAC " prefix " MC%d: " fmt, mci->mc_idx, ##arg)
54 51
55/* prefixes for edac_printk() and edac_mc_printk() */ 52/* prefixes for edac_printk() and edac_mc_printk() */
56#define EDAC_MC "MC" 53#define EDAC_MC "MC"
@@ -71,14 +68,16 @@ extern int edac_debug_level;
71#define debugf2( ... ) edac_debug_printk(2, __VA_ARGS__ ) 68#define debugf2( ... ) edac_debug_printk(2, __VA_ARGS__ )
72#define debugf3( ... ) edac_debug_printk(3, __VA_ARGS__ ) 69#define debugf3( ... ) edac_debug_printk(3, __VA_ARGS__ )
73#define debugf4( ... ) edac_debug_printk(4, __VA_ARGS__ ) 70#define debugf4( ... ) edac_debug_printk(4, __VA_ARGS__ )
74#else /* !CONFIG_EDAC_DEBUG */ 71
72#else /* !CONFIG_EDAC_DEBUG */
73
75#define debugf0( ... ) 74#define debugf0( ... )
76#define debugf1( ... ) 75#define debugf1( ... )
77#define debugf2( ... ) 76#define debugf2( ... )
78#define debugf3( ... ) 77#define debugf3( ... )
79#define debugf4( ... ) 78#define debugf4( ... )
80#endif /* !CONFIG_EDAC_DEBUG */
81 79
80#endif /* !CONFIG_EDAC_DEBUG */
82 81
83#define edac_xstr(s) edac_str(s) 82#define edac_xstr(s) edac_str(s)
84#define edac_str(s) #s 83#define edac_str(s) #s
@@ -86,7 +85,8 @@ extern int edac_debug_level;
86 85
87#define BIT(x) (1 << (x)) 86#define BIT(x) (1 << (x))
88 87
89#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, PCI_DEVICE_ID_ ## vend ## _ ## dev 88#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
89 PCI_DEVICE_ID_ ## vend ## _ ## dev
90 90
91/* memory devices */ 91/* memory devices */
92enum dev_type { 92enum dev_type {
@@ -136,7 +136,6 @@ enum mem_type {
136#define MEM_FLAG_RDDR BIT(MEM_RDDR) 136#define MEM_FLAG_RDDR BIT(MEM_RDDR)
137#define MEM_FLAG_RMBS BIT(MEM_RMBS) 137#define MEM_FLAG_RMBS BIT(MEM_RMBS)
138 138
139
140/* chipset Error Detection and Correction capabilities and mode */ 139/* chipset Error Detection and Correction capabilities and mode */
141enum edac_type { 140enum edac_type {
142 EDAC_UNKNOWN = 0, /* Unknown if ECC is available */ 141 EDAC_UNKNOWN = 0, /* Unknown if ECC is available */
@@ -161,7 +160,6 @@ enum edac_type {
161#define EDAC_FLAG_S8ECD8ED BIT(EDAC_S8ECD8ED) 160#define EDAC_FLAG_S8ECD8ED BIT(EDAC_S8ECD8ED)
162#define EDAC_FLAG_S16ECD16ED BIT(EDAC_S16ECD16ED) 161#define EDAC_FLAG_S16ECD16ED BIT(EDAC_S16ECD16ED)
163 162
164
165/* scrubbing capabilities */ 163/* scrubbing capabilities */
166enum scrub_type { 164enum scrub_type {
167 SCRUB_UNKNOWN = 0, /* Unknown if scrubber is available */ 165 SCRUB_UNKNOWN = 0, /* Unknown if scrubber is available */
@@ -269,20 +267,19 @@ enum scrub_type {
269 * PS - I enjoyed writing all that about as much as you enjoyed reading it. 267 * PS - I enjoyed writing all that about as much as you enjoyed reading it.
270 */ 268 */
271 269
272
273struct channel_info { 270struct channel_info {
274 int chan_idx; /* channel index */ 271 int chan_idx; /* channel index */
275 u32 ce_count; /* Correctable Errors for this CHANNEL */ 272 u32 ce_count; /* Correctable Errors for this CHANNEL */
276 char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */ 273 char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */
277 struct csrow_info *csrow; /* the parent */ 274 struct csrow_info *csrow; /* the parent */
278}; 275};
279 276
280
281struct csrow_info { 277struct csrow_info {
282 unsigned long first_page; /* first page number in dimm */ 278 unsigned long first_page; /* first page number in dimm */
283 unsigned long last_page; /* last page number in dimm */ 279 unsigned long last_page; /* last page number in dimm */
284 unsigned long page_mask; /* used for interleaving - 280 unsigned long page_mask; /* used for interleaving -
285 0UL for non intlv */ 281 * 0UL for non intlv
282 */
286 u32 nr_pages; /* number of pages in csrow */ 283 u32 nr_pages; /* number of pages in csrow */
287 u32 grain; /* granularity of reported error in bytes */ 284 u32 grain; /* granularity of reported error in bytes */
288 int csrow_idx; /* the chip-select row */ 285 int csrow_idx; /* the chip-select row */
@@ -301,18 +298,18 @@ struct csrow_info {
301 struct channel_info *channels; 298 struct channel_info *channels;
302}; 299};
303 300
304
305struct mem_ctl_info { 301struct mem_ctl_info {
306 struct list_head link; /* for global list of mem_ctl_info structs */ 302 struct list_head link; /* for global list of mem_ctl_info structs */
307 unsigned long mtype_cap; /* memory types supported by mc */ 303 unsigned long mtype_cap; /* memory types supported by mc */
308 unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */ 304 unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */
309 unsigned long edac_cap; /* configuration capabilities - this is 305 unsigned long edac_cap; /* configuration capabilities - this is
310 closely related to edac_ctl_cap. The 306 * closely related to edac_ctl_cap. The
311 difference is that the controller 307 * difference is that the controller may be
312 may be capable of s4ecd4ed which would 308 * capable of s4ecd4ed which would be listed
313 be listed in edac_ctl_cap, but if 309 * in edac_ctl_cap, but if channels aren't
314 channels aren't capable of s4ecd4ed then the 310 * capable of s4ecd4ed then the edac_cap would
315 edac_cap would not have that capability. */ 311 * not have that capability.
312 */
316 unsigned long scrub_cap; /* chipset scrub capabilities */ 313 unsigned long scrub_cap; /* chipset scrub capabilities */
317 enum scrub_type scrub_mode; /* current scrub mode */ 314 enum scrub_type scrub_mode; /* current scrub mode */
318 315
@@ -324,7 +321,7 @@ struct mem_ctl_info {
324 */ 321 */
325 /* FIXME - why not send the phys page to begin with? */ 322 /* FIXME - why not send the phys page to begin with? */
326 unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci, 323 unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci,
327 unsigned long page); 324 unsigned long page);
328 int mc_idx; 325 int mc_idx;
329 int nr_csrows; 326 int nr_csrows;
330 struct csrow_info *csrows; 327 struct csrow_info *csrows;
@@ -356,67 +353,66 @@ struct mem_ctl_info {
356 struct completion kobj_complete; 353 struct completion kobj_complete;
357}; 354};
358 355
359
360
361/* write all or some bits in a byte-register*/ 356/* write all or some bits in a byte-register*/
362static inline void pci_write_bits8(struct pci_dev *pdev, int offset, 357static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
363 u8 value, u8 mask) 358 u8 mask)
364{ 359{
365 if (mask != 0xff) { 360 if (mask != 0xff) {
366 u8 buf; 361 u8 buf;
362
367 pci_read_config_byte(pdev, offset, &buf); 363 pci_read_config_byte(pdev, offset, &buf);
368 value &= mask; 364 value &= mask;
369 buf &= ~mask; 365 buf &= ~mask;
370 value |= buf; 366 value |= buf;
371 } 367 }
368
372 pci_write_config_byte(pdev, offset, value); 369 pci_write_config_byte(pdev, offset, value);
373} 370}
374 371
375
376/* write all or some bits in a word-register*/ 372/* write all or some bits in a word-register*/
377static inline void pci_write_bits16(struct pci_dev *pdev, int offset, 373static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
378 u16 value, u16 mask) 374 u16 value, u16 mask)
379{ 375{
380 if (mask != 0xffff) { 376 if (mask != 0xffff) {
381 u16 buf; 377 u16 buf;
378
382 pci_read_config_word(pdev, offset, &buf); 379 pci_read_config_word(pdev, offset, &buf);
383 value &= mask; 380 value &= mask;
384 buf &= ~mask; 381 buf &= ~mask;
385 value |= buf; 382 value |= buf;
386 } 383 }
384
387 pci_write_config_word(pdev, offset, value); 385 pci_write_config_word(pdev, offset, value);
388} 386}
389 387
390
391/* write all or some bits in a dword-register*/ 388/* write all or some bits in a dword-register*/
392static inline void pci_write_bits32(struct pci_dev *pdev, int offset, 389static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
393 u32 value, u32 mask) 390 u32 value, u32 mask)
394{ 391{
395 if (mask != 0xffff) { 392 if (mask != 0xffff) {
396 u32 buf; 393 u32 buf;
394
397 pci_read_config_dword(pdev, offset, &buf); 395 pci_read_config_dword(pdev, offset, &buf);
398 value &= mask; 396 value &= mask;
399 buf &= ~mask; 397 buf &= ~mask;
400 value |= buf; 398 value |= buf;
401 } 399 }
400
402 pci_write_config_dword(pdev, offset, value); 401 pci_write_config_dword(pdev, offset, value);
403} 402}
404 403
405
406#ifdef CONFIG_EDAC_DEBUG 404#ifdef CONFIG_EDAC_DEBUG
407void edac_mc_dump_channel(struct channel_info *chan); 405void edac_mc_dump_channel(struct channel_info *chan);
408void edac_mc_dump_mci(struct mem_ctl_info *mci); 406void edac_mc_dump_mci(struct mem_ctl_info *mci);
409void edac_mc_dump_csrow(struct csrow_info *csrow); 407void edac_mc_dump_csrow(struct csrow_info *csrow);
410#endif /* CONFIG_EDAC_DEBUG */ 408#endif /* CONFIG_EDAC_DEBUG */
411 409
412extern int edac_mc_add_mc(struct mem_ctl_info *mci); 410extern int edac_mc_add_mc(struct mem_ctl_info *mci);
413extern struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev); 411extern struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev);
414
415extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, 412extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
416 unsigned long page); 413 unsigned long page);
417 414extern void edac_mc_scrub_block(unsigned long page, unsigned long offset,
418extern void edac_mc_scrub_block(unsigned long page, 415 u32 size);
419 unsigned long offset, u32 size);
420 416
421/* 417/*
422 * The no info errors are used when error overflows are reported. 418 * The no info errors are used when error overflows are reported.
@@ -429,31 +425,25 @@ extern void edac_mc_scrub_block(unsigned long page,
429 * statement clutter and extra function arguments. 425 * statement clutter and extra function arguments.
430 */ 426 */
431extern void edac_mc_handle_ce(struct mem_ctl_info *mci, 427extern void edac_mc_handle_ce(struct mem_ctl_info *mci,
432 unsigned long page_frame_number, 428 unsigned long page_frame_number, unsigned long offset_in_page,
433 unsigned long offset_in_page, 429 unsigned long syndrome, int row, int channel,
434 unsigned long syndrome, 430 const char *msg);
435 int row, int channel, const char *msg);
436
437extern void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci, 431extern void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci,
438 const char *msg); 432 const char *msg);
439
440extern void edac_mc_handle_ue(struct mem_ctl_info *mci, 433extern void edac_mc_handle_ue(struct mem_ctl_info *mci,
441 unsigned long page_frame_number, 434 unsigned long page_frame_number, unsigned long offset_in_page,
442 unsigned long offset_in_page, 435 int row, const char *msg);
443 int row, const char *msg);
444
445extern void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, 436extern void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci,
446 const char *msg); 437 const char *msg);
447 438
448/* 439/*
449 * This kmalloc's and initializes all the structures. 440 * This kmalloc's and initializes all the structures.
450 * Can't be used if all structures don't have the same lifetime. 441 * Can't be used if all structures don't have the same lifetime.
451 */ 442 */
452extern struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, 443extern struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
453 unsigned nr_csrows, unsigned nr_chans); 444 unsigned nr_chans);
454 445
455/* Free an mc previously allocated by edac_mc_alloc() */ 446/* Free an mc previously allocated by edac_mc_alloc() */
456extern void edac_mc_free(struct mem_ctl_info *mci); 447extern void edac_mc_free(struct mem_ctl_info *mci);
457 448
458
459#endif /* _EDAC_MC_H_ */ 449#endif /* _EDAC_MC_H_ */
diff --git a/drivers/edac/i82860_edac.c b/drivers/edac/i82860_edac.c
index 688854260a0e..fd342163cf97 100644
--- a/drivers/edac/i82860_edac.c
+++ b/drivers/edac/i82860_edac.c
@@ -9,7 +9,6 @@
9 * by Thayne Harbaugh of Linux Networx. (http://lnxi.com) 9 * by Thayne Harbaugh of Linux Networx. (http://lnxi.com)
10 */ 10 */
11 11
12
13#include <linux/config.h> 12#include <linux/config.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/init.h> 14#include <linux/init.h>
@@ -18,14 +17,11 @@
18#include <linux/slab.h> 17#include <linux/slab.h>
19#include "edac_mc.h" 18#include "edac_mc.h"
20 19
21
22#define i82860_printk(level, fmt, arg...) \ 20#define i82860_printk(level, fmt, arg...) \
23 edac_printk(level, "i82860", fmt, ##arg) 21 edac_printk(level, "i82860", fmt, ##arg)
24
25 22
26#define i82860_mc_printk(mci, level, fmt, arg...) \ 23#define i82860_mc_printk(mci, level, fmt, arg...) \
27 edac_mc_chipset_printk(mci, level, "i82860", fmt, ##arg) 24 edac_mc_chipset_printk(mci, level, "i82860", fmt, ##arg)
28
29 25
30#ifndef PCI_DEVICE_ID_INTEL_82860_0 26#ifndef PCI_DEVICE_ID_INTEL_82860_0
31#define PCI_DEVICE_ID_INTEL_82860_0 0x2531 27#define PCI_DEVICE_ID_INTEL_82860_0 0x2531
@@ -56,13 +52,15 @@ struct i82860_error_info {
56 52
57static const struct i82860_dev_info i82860_devs[] = { 53static const struct i82860_dev_info i82860_devs[] = {
58 [I82860] = { 54 [I82860] = {
59 .ctl_name = "i82860"}, 55 .ctl_name = "i82860"
56 },
60}; 57};
61 58
62static struct pci_dev *mci_pdev = NULL; /* init dev: in case that AGP code 59static struct pci_dev *mci_pdev = NULL; /* init dev: in case that AGP code
63 has already registered driver */ 60 * has already registered driver
61 */
64 62
65static void i82860_get_error_info (struct mem_ctl_info *mci, 63static void i82860_get_error_info(struct mem_ctl_info *mci,
66 struct i82860_error_info *info) 64 struct i82860_error_info *info)
67{ 65{
68 /* 66 /*
@@ -84,14 +82,15 @@ static void i82860_get_error_info (struct mem_ctl_info *mci,
84 */ 82 */
85 if (!(info->errsts2 & 0x0003)) 83 if (!(info->errsts2 & 0x0003))
86 return; 84 return;
85
87 if ((info->errsts ^ info->errsts2) & 0x0003) { 86 if ((info->errsts ^ info->errsts2) & 0x0003) {
88 pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap); 87 pci_read_config_dword(mci->pdev, I82860_EAP, &info->eap);
89 pci_read_config_word(mci->pdev, I82860_DERRCTL_STS, 88 pci_read_config_word(mci->pdev, I82860_DERRCTL_STS,
90 &info->derrsyn); 89 &info->derrsyn);
91 } 90 }
92} 91}
93 92
94static int i82860_process_error_info (struct mem_ctl_info *mci, 93static int i82860_process_error_info(struct mem_ctl_info *mci,
95 struct i82860_error_info *info, int handle_errors) 94 struct i82860_error_info *info, int handle_errors)
96{ 95{
97 int row; 96 int row;
@@ -113,8 +112,8 @@ static int i82860_process_error_info (struct mem_ctl_info *mci,
113 if (info->errsts & 0x0002) 112 if (info->errsts & 0x0002)
114 edac_mc_handle_ue(mci, info->eap, 0, row, "i82860 UE"); 113 edac_mc_handle_ue(mci, info->eap, 0, row, "i82860 UE");
115 else 114 else
116 edac_mc_handle_ce(mci, info->eap, 0, info->derrsyn, row, 115 edac_mc_handle_ce(mci, info->eap, 0, info->derrsyn, row, 0,
117 0, "i82860 UE"); 116 "i82860 UE");
118 117
119 return 1; 118 return 1;
120} 119}
@@ -147,15 +146,14 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
147 going to make 1 channel for group. 146 going to make 1 channel for group.
148 */ 147 */
149 mci = edac_mc_alloc(0, 16, 1); 148 mci = edac_mc_alloc(0, 16, 1);
149
150 if (!mci) 150 if (!mci)
151 return -ENOMEM; 151 return -ENOMEM;
152 152
153 debugf3("%s(): init mci\n", __func__); 153 debugf3("%s(): init mci\n", __func__);
154
155 mci->pdev = pdev; 154 mci->pdev = pdev;
156 mci->mtype_cap = MEM_FLAG_DDR; 155 mci->mtype_cap = MEM_FLAG_DDR;
157 156
158
159 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 157 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
160 /* I"m not sure about this but I think that all RDRAM is SECDED */ 158 /* I"m not sure about this but I think that all RDRAM is SECDED */
161 mci->edac_cap = EDAC_FLAG_SECDED; 159 mci->edac_cap = EDAC_FLAG_SECDED;
@@ -182,12 +180,13 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
182 struct csrow_info *csrow = &mci->csrows[index]; 180 struct csrow_info *csrow = &mci->csrows[index];
183 181
184 pci_read_config_word(mci->pdev, I82860_GBA + index * 2, 182 pci_read_config_word(mci->pdev, I82860_GBA + index * 2,
185 &value); 183 &value);
186 184
187 cumul_size = (value & I82860_GBA_MASK) << 185 cumul_size = (value & I82860_GBA_MASK) <<
188 (I82860_GBA_SHIFT - PAGE_SHIFT); 186 (I82860_GBA_SHIFT - PAGE_SHIFT);
189 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 187 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
190 cumul_size); 188 cumul_size);
189
191 if (cumul_size == last_cumul_size) 190 if (cumul_size == last_cumul_size)
192 continue; /* not populated */ 191 continue; /* not populated */
193 192
@@ -195,7 +194,7 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
195 csrow->last_page = cumul_size - 1; 194 csrow->last_page = cumul_size - 1;
196 csrow->nr_pages = cumul_size - last_cumul_size; 195 csrow->nr_pages = cumul_size - last_cumul_size;
197 last_cumul_size = cumul_size; 196 last_cumul_size = cumul_size;
198 csrow->grain = 1 << 12; /* I82860_EAP has 4KiB reolution */ 197 csrow->grain = 1 << 12; /* I82860_EAP has 4KiB reolution */
199 csrow->mtype = MEM_RMBS; 198 csrow->mtype = MEM_RMBS;
200 csrow->dtype = DEV_UNKNOWN; 199 csrow->dtype = DEV_UNKNOWN;
201 csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE; 200 csrow->edac_mode = mchcfg_ddim ? EDAC_SECDED : EDAC_NONE;
@@ -211,23 +210,27 @@ static int i82860_probe1(struct pci_dev *pdev, int dev_idx)
211 debugf3("%s(): success\n", __func__); 210 debugf3("%s(): success\n", __func__);
212 rc = 0; 211 rc = 0;
213 } 212 }
213
214 return rc; 214 return rc;
215} 215}
216 216
217/* returns count (>= 0), or negative on error */ 217/* returns count (>= 0), or negative on error */
218static int __devinit i82860_init_one(struct pci_dev *pdev, 218static int __devinit i82860_init_one(struct pci_dev *pdev,
219 const struct pci_device_id *ent) 219 const struct pci_device_id *ent)
220{ 220{
221 int rc; 221 int rc;
222 222
223 debugf0("%s()\n", __func__); 223 debugf0("%s()\n", __func__);
224
225 i82860_printk(KERN_INFO, "i82860 init one\n"); 224 i82860_printk(KERN_INFO, "i82860 init one\n");
226 if(pci_enable_device(pdev) < 0) 225
226 if (pci_enable_device(pdev) < 0)
227 return -EIO; 227 return -EIO;
228
228 rc = i82860_probe1(pdev, ent->driver_data); 229 rc = i82860_probe1(pdev, ent->driver_data);
229 if(rc == 0) 230
231 if (rc == 0)
230 mci_pdev = pci_dev_get(pdev); 232 mci_pdev = pci_dev_get(pdev);
233
231 return rc; 234 return rc;
232} 235}
233 236
@@ -244,9 +247,13 @@ static void __devexit i82860_remove_one(struct pci_dev *pdev)
244} 247}
245 248
246static const struct pci_device_id i82860_pci_tbl[] __devinitdata = { 249static const struct pci_device_id i82860_pci_tbl[] __devinitdata = {
247 {PCI_VEND_DEV(INTEL, 82860_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 250 {
248 I82860}, 251 PCI_VEND_DEV(INTEL, 82860_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
249 {0,} /* 0 terminated list. */ 252 I82860
253 },
254 {
255 0,
256 } /* 0 terminated list. */
250}; 257};
251 258
252MODULE_DEVICE_TABLE(pci, i82860_pci_tbl); 259MODULE_DEVICE_TABLE(pci, i82860_pci_tbl);
@@ -263,24 +270,29 @@ static int __init i82860_init(void)
263 int pci_rc; 270 int pci_rc;
264 271
265 debugf3("%s()\n", __func__); 272 debugf3("%s()\n", __func__);
273
266 if ((pci_rc = pci_register_driver(&i82860_driver)) < 0) 274 if ((pci_rc = pci_register_driver(&i82860_driver)) < 0)
267 goto fail0; 275 goto fail0;
268 276
269 if (!mci_pdev) { 277 if (!mci_pdev) {
270 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 278 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
271 PCI_DEVICE_ID_INTEL_82860_0, NULL); 279 PCI_DEVICE_ID_INTEL_82860_0, NULL);
280
272 if (mci_pdev == NULL) { 281 if (mci_pdev == NULL) {
273 debugf0("860 pci_get_device fail\n"); 282 debugf0("860 pci_get_device fail\n");
274 pci_rc = -ENODEV; 283 pci_rc = -ENODEV;
275 goto fail1; 284 goto fail1;
276 } 285 }
286
277 pci_rc = i82860_init_one(mci_pdev, i82860_pci_tbl); 287 pci_rc = i82860_init_one(mci_pdev, i82860_pci_tbl);
288
278 if (pci_rc < 0) { 289 if (pci_rc < 0) {
279 debugf0("860 init fail\n"); 290 debugf0("860 init fail\n");
280 pci_rc = -ENODEV; 291 pci_rc = -ENODEV;
281 goto fail1; 292 goto fail1;
282 } 293 }
283 } 294 }
295
284 return 0; 296 return 0;
285 297
286fail1: 298fail1:
@@ -307,6 +319,6 @@ module_init(i82860_init);
307module_exit(i82860_exit); 319module_exit(i82860_exit);
308 320
309MODULE_LICENSE("GPL"); 321MODULE_LICENSE("GPL");
310MODULE_AUTHOR 322MODULE_AUTHOR("Red Hat Inc. (http://www.redhat.com) "
311 ("Red Hat Inc. (http://www.redhat.com) Ben Woodard <woodard@redhat.com>"); 323 "Ben Woodard <woodard@redhat.com>");
312MODULE_DESCRIPTION("ECC support for Intel 82860 memory hub controllers"); 324MODULE_DESCRIPTION("ECC support for Intel 82860 memory hub controllers");
diff --git a/drivers/edac/i82875p_edac.c b/drivers/edac/i82875p_edac.c
index aad1900a4689..0aec92698f17 100644
--- a/drivers/edac/i82875p_edac.c
+++ b/drivers/edac/i82875p_edac.c
@@ -13,26 +13,19 @@
13 * Note: E7210 appears same as D82875P - zhenyu.z.wang at intel.com 13 * Note: E7210 appears same as D82875P - zhenyu.z.wang at intel.com
14 */ 14 */
15 15
16
17#include <linux/config.h> 16#include <linux/config.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/init.h> 18#include <linux/init.h>
20
21#include <linux/pci.h> 19#include <linux/pci.h>
22#include <linux/pci_ids.h> 20#include <linux/pci_ids.h>
23
24#include <linux/slab.h> 21#include <linux/slab.h>
25
26#include "edac_mc.h" 22#include "edac_mc.h"
27 23
28
29#define i82875p_printk(level, fmt, arg...) \ 24#define i82875p_printk(level, fmt, arg...) \
30 edac_printk(level, "i82875p", fmt, ##arg) 25 edac_printk(level, "i82875p", fmt, ##arg)
31
32 26
33#define i82875p_mc_printk(mci, level, fmt, arg...) \ 27#define i82875p_mc_printk(mci, level, fmt, arg...) \
34 edac_mc_chipset_printk(mci, level, "i82875p", fmt, ##arg) 28 edac_mc_chipset_printk(mci, level, "i82875p", fmt, ##arg)
35
36 29
37#ifndef PCI_DEVICE_ID_INTEL_82875_0 30#ifndef PCI_DEVICE_ID_INTEL_82875_0
38#define PCI_DEVICE_ID_INTEL_82875_0 0x2578 31#define PCI_DEVICE_ID_INTEL_82875_0 0x2578
@@ -42,11 +35,9 @@
42#define PCI_DEVICE_ID_INTEL_82875_6 0x257e 35#define PCI_DEVICE_ID_INTEL_82875_6 0x257e
43#endif /* PCI_DEVICE_ID_INTEL_82875_6 */ 36#endif /* PCI_DEVICE_ID_INTEL_82875_6 */
44 37
45
46/* four csrows in dual channel, eight in single channel */ 38/* four csrows in dual channel, eight in single channel */
47#define I82875P_NR_CSROWS(nr_chans) (8/(nr_chans)) 39#define I82875P_NR_CSROWS(nr_chans) (8/(nr_chans))
48 40
49
50/* Intel 82875p register addresses - device 0 function 0 - DRAM Controller */ 41/* Intel 82875p register addresses - device 0 function 0 - DRAM Controller */
51#define I82875P_EAP 0x58 /* Error Address Pointer (32b) 42#define I82875P_EAP 0x58 /* Error Address Pointer (32b)
52 * 43 *
@@ -95,7 +86,6 @@
95 * 0 reserved 86 * 0 reserved
96 */ 87 */
97 88
98
99/* Intel 82875p register addresses - device 6 function 0 - DRAM Controller */ 89/* Intel 82875p register addresses - device 6 function 0 - DRAM Controller */
100#define I82875P_PCICMD6 0x04 /* PCI Command Register (16b) 90#define I82875P_PCICMD6 0x04 /* PCI Command Register (16b)
101 * 91 *
@@ -159,23 +149,19 @@
159 * 1:0 DRAM type 01=DDR 149 * 1:0 DRAM type 01=DDR
160 */ 150 */
161 151
162
163enum i82875p_chips { 152enum i82875p_chips {
164 I82875P = 0, 153 I82875P = 0,
165}; 154};
166 155
167
168struct i82875p_pvt { 156struct i82875p_pvt {
169 struct pci_dev *ovrfl_pdev; 157 struct pci_dev *ovrfl_pdev;
170 void __iomem *ovrfl_window; 158 void __iomem *ovrfl_window;
171}; 159};
172 160
173
174struct i82875p_dev_info { 161struct i82875p_dev_info {
175 const char *ctl_name; 162 const char *ctl_name;
176}; 163};
177 164
178
179struct i82875p_error_info { 165struct i82875p_error_info {
180 u16 errsts; 166 u16 errsts;
181 u32 eap; 167 u32 eap;
@@ -184,17 +170,19 @@ struct i82875p_error_info {
184 u16 errsts2; 170 u16 errsts2;
185}; 171};
186 172
187
188static const struct i82875p_dev_info i82875p_devs[] = { 173static const struct i82875p_dev_info i82875p_devs[] = {
189 [I82875P] = { 174 [I82875P] = {
190 .ctl_name = "i82875p"}, 175 .ctl_name = "i82875p"
176 },
191}; 177};
192 178
193static struct pci_dev *mci_pdev = NULL; /* init dev: in case that AGP code 179static struct pci_dev *mci_pdev = NULL; /* init dev: in case that AGP code has
194 has already registered driver */ 180 * already registered driver
181 */
182
195static int i82875p_registered = 1; 183static int i82875p_registered = 1;
196 184
197static void i82875p_get_error_info (struct mem_ctl_info *mci, 185static void i82875p_get_error_info(struct mem_ctl_info *mci,
198 struct i82875p_error_info *info) 186 struct i82875p_error_info *info)
199{ 187{
200 /* 188 /*
@@ -218,15 +206,16 @@ static void i82875p_get_error_info (struct mem_ctl_info *mci,
218 */ 206 */
219 if (!(info->errsts2 & 0x0081)) 207 if (!(info->errsts2 & 0x0081))
220 return; 208 return;
209
221 if ((info->errsts ^ info->errsts2) & 0x0081) { 210 if ((info->errsts ^ info->errsts2) & 0x0081) {
222 pci_read_config_dword(mci->pdev, I82875P_EAP, &info->eap); 211 pci_read_config_dword(mci->pdev, I82875P_EAP, &info->eap);
223 pci_read_config_byte(mci->pdev, I82875P_DES, &info->des); 212 pci_read_config_byte(mci->pdev, I82875P_DES, &info->des);
224 pci_read_config_byte(mci->pdev, I82875P_DERRSYN, 213 pci_read_config_byte(mci->pdev, I82875P_DERRSYN,
225 &info->derrsyn); 214 &info->derrsyn);
226 } 215 }
227} 216}
228 217
229static int i82875p_process_error_info (struct mem_ctl_info *mci, 218static int i82875p_process_error_info(struct mem_ctl_info *mci,
230 struct i82875p_error_info *info, int handle_errors) 219 struct i82875p_error_info *info, int handle_errors)
231{ 220{
232 int row, multi_chan; 221 int row, multi_chan;
@@ -251,13 +240,12 @@ static int i82875p_process_error_info (struct mem_ctl_info *mci,
251 edac_mc_handle_ue(mci, info->eap, 0, row, "i82875p UE"); 240 edac_mc_handle_ue(mci, info->eap, 0, row, "i82875p UE");
252 else 241 else
253 edac_mc_handle_ce(mci, info->eap, 0, info->derrsyn, row, 242 edac_mc_handle_ce(mci, info->eap, 0, info->derrsyn, row,
254 multi_chan ? (info->des & 0x1) : 0, 243 multi_chan ? (info->des & 0x1) : 0,
255 "i82875p CE"); 244 "i82875p CE");
256 245
257 return 1; 246 return 1;
258} 247}
259 248
260
261static void i82875p_check(struct mem_ctl_info *mci) 249static void i82875p_check(struct mem_ctl_info *mci)
262{ 250{
263 struct i82875p_error_info info; 251 struct i82875p_error_info info;
@@ -267,7 +255,6 @@ static void i82875p_check(struct mem_ctl_info *mci)
267 i82875p_process_error_info(mci, &info, 1); 255 i82875p_process_error_info(mci, &info, 1);
268} 256}
269 257
270
271#ifdef CONFIG_PROC_FS 258#ifdef CONFIG_PROC_FS
272extern int pci_proc_attach_device(struct pci_dev *); 259extern int pci_proc_attach_device(struct pci_dev *);
273#endif 260#endif
@@ -281,7 +268,6 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
281 unsigned long last_cumul_size; 268 unsigned long last_cumul_size;
282 struct pci_dev *ovrfl_pdev; 269 struct pci_dev *ovrfl_pdev;
283 void __iomem *ovrfl_window = NULL; 270 void __iomem *ovrfl_window = NULL;
284
285 u32 drc; 271 u32 drc;
286 u32 drc_chan; /* Number of channels 0=1chan,1=2chan */ 272 u32 drc_chan; /* Number of channels 0=1chan,1=2chan */
287 u32 nr_chans; 273 u32 nr_chans;
@@ -289,7 +275,6 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
289 struct i82875p_error_info discard; 275 struct i82875p_error_info discard;
290 276
291 debugf0("%s()\n", __func__); 277 debugf0("%s()\n", __func__);
292
293 ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL); 278 ovrfl_pdev = pci_get_device(PCI_VEND_DEV(INTEL, 82875_6), NULL);
294 279
295 if (!ovrfl_pdev) { 280 if (!ovrfl_pdev) {
@@ -301,22 +286,23 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
301 */ 286 */
302 pci_write_bits8(pdev, 0xf4, 0x2, 0x2); 287 pci_write_bits8(pdev, 0xf4, 0x2, 0x2);
303 ovrfl_pdev = 288 ovrfl_pdev =
304 pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0)); 289 pci_scan_single_device(pdev->bus, PCI_DEVFN(6, 0));
290
305 if (!ovrfl_pdev) 291 if (!ovrfl_pdev)
306 return -ENODEV; 292 return -ENODEV;
307 } 293 }
294
308#ifdef CONFIG_PROC_FS 295#ifdef CONFIG_PROC_FS
309 if (!ovrfl_pdev->procent && pci_proc_attach_device(ovrfl_pdev)) { 296 if (!ovrfl_pdev->procent && pci_proc_attach_device(ovrfl_pdev)) {
310 i82875p_printk(KERN_ERR, 297 i82875p_printk(KERN_ERR,
311 "%s(): Failed to attach overflow device\n", 298 "%s(): Failed to attach overflow device\n", __func__);
312 __func__);
313 return -ENODEV; 299 return -ENODEV;
314 } 300 }
315#endif /* CONFIG_PROC_FS */ 301#endif
302 /* CONFIG_PROC_FS */
316 if (pci_enable_device(ovrfl_pdev)) { 303 if (pci_enable_device(ovrfl_pdev)) {
317 i82875p_printk(KERN_ERR, 304 i82875p_printk(KERN_ERR,
318 "%s(): Failed to enable overflow device\n", 305 "%s(): Failed to enable overflow device\n", __func__);
319 __func__);
320 return -ENODEV; 306 return -ENODEV;
321 } 307 }
322 308
@@ -325,13 +311,14 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
325 goto fail0; 311 goto fail0;
326#endif 312#endif
327 } 313 }
314
328 /* cache is irrelevant for PCI bus reads/writes */ 315 /* cache is irrelevant for PCI bus reads/writes */
329 ovrfl_window = ioremap_nocache(pci_resource_start(ovrfl_pdev, 0), 316 ovrfl_window = ioremap_nocache(pci_resource_start(ovrfl_pdev, 0),
330 pci_resource_len(ovrfl_pdev, 0)); 317 pci_resource_len(ovrfl_pdev, 0));
331 318
332 if (!ovrfl_window) { 319 if (!ovrfl_window) {
333 i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n", 320 i82875p_printk(KERN_ERR, "%s(): Failed to ioremap bar6\n",
334 __func__); 321 __func__);
335 goto fail1; 322 goto fail1;
336 } 323 }
337 324
@@ -339,10 +326,10 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
339 drc = readl(ovrfl_window + I82875P_DRC); 326 drc = readl(ovrfl_window + I82875P_DRC);
340 drc_chan = ((drc >> 21) & 0x1); 327 drc_chan = ((drc >> 21) & 0x1);
341 nr_chans = drc_chan + 1; 328 nr_chans = drc_chan + 1;
342 drc_ddim = (drc >> 18) & 0x1;
343 329
330 drc_ddim = (drc >> 18) & 0x1;
344 mci = edac_mc_alloc(sizeof(*pvt), I82875P_NR_CSROWS(nr_chans), 331 mci = edac_mc_alloc(sizeof(*pvt), I82875P_NR_CSROWS(nr_chans),
345 nr_chans); 332 nr_chans);
346 333
347 if (!mci) { 334 if (!mci) {
348 rc = -ENOMEM; 335 rc = -ENOMEM;
@@ -350,10 +337,8 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
350 } 337 }
351 338
352 debugf3("%s(): init mci\n", __func__); 339 debugf3("%s(): init mci\n", __func__);
353
354 mci->pdev = pdev; 340 mci->pdev = pdev;
355 mci->mtype_cap = MEM_FLAG_DDR; 341 mci->mtype_cap = MEM_FLAG_DDR;
356
357 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED; 342 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
358 mci->edac_cap = EDAC_FLAG_UNKNOWN; 343 mci->edac_cap = EDAC_FLAG_UNKNOWN;
359 /* adjust FLAGS */ 344 /* adjust FLAGS */
@@ -363,9 +348,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
363 mci->ctl_name = i82875p_devs[dev_idx].ctl_name; 348 mci->ctl_name = i82875p_devs[dev_idx].ctl_name;
364 mci->edac_check = i82875p_check; 349 mci->edac_check = i82875p_check;
365 mci->ctl_page_to_phys = NULL; 350 mci->ctl_page_to_phys = NULL;
366
367 debugf3("%s(): init pvt\n", __func__); 351 debugf3("%s(): init pvt\n", __func__);
368
369 pvt = (struct i82875p_pvt *) mci->pvt_info; 352 pvt = (struct i82875p_pvt *) mci->pvt_info;
370 pvt->ovrfl_pdev = ovrfl_pdev; 353 pvt->ovrfl_pdev = ovrfl_pdev;
371 pvt->ovrfl_window = ovrfl_window; 354 pvt->ovrfl_window = ovrfl_window;
@@ -385,6 +368,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
385 cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT); 368 cumul_size = value << (I82875P_DRB_SHIFT - PAGE_SHIFT);
386 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index, 369 debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
387 cumul_size); 370 cumul_size);
371
388 if (cumul_size == last_cumul_size) 372 if (cumul_size == last_cumul_size)
389 continue; /* not populated */ 373 continue; /* not populated */
390 374
@@ -392,7 +376,7 @@ static int i82875p_probe1(struct pci_dev *pdev, int dev_idx)
392 csrow->last_page = cumul_size - 1; 376 csrow->last_page = cumul_size - 1;
393 csrow->nr_pages = cumul_size - last_cumul_size; 377 csrow->nr_pages = cumul_size - last_cumul_size;
394 last_cumul_size = cumul_size; 378 last_cumul_size = cumul_size;
395 csrow->grain = 1 << 12; /* I82875P_EAP has 4KiB reolution */ 379 csrow->grain = 1 << 12; /* I82875P_EAP has 4KiB reolution */
396 csrow->mtype = MEM_DDR; 380 csrow->mtype = MEM_DDR;
397 csrow->dtype = DEV_UNKNOWN; 381 csrow->dtype = DEV_UNKNOWN;
398 csrow->edac_mode = drc_ddim ? EDAC_SECDED : EDAC_NONE; 382 csrow->edac_mode = drc_ddim ? EDAC_SECDED : EDAC_NONE;
@@ -426,25 +410,26 @@ fail0:
426 return rc; 410 return rc;
427} 411}
428 412
429
430/* returns count (>= 0), or negative on error */ 413/* returns count (>= 0), or negative on error */
431static int __devinit i82875p_init_one(struct pci_dev *pdev, 414static int __devinit i82875p_init_one(struct pci_dev *pdev,
432 const struct pci_device_id *ent) 415 const struct pci_device_id *ent)
433{ 416{
434 int rc; 417 int rc;
435 418
436 debugf0("%s()\n", __func__); 419 debugf0("%s()\n", __func__);
437
438 i82875p_printk(KERN_INFO, "i82875p init one\n"); 420 i82875p_printk(KERN_INFO, "i82875p init one\n");
439 if(pci_enable_device(pdev) < 0) 421
422 if (pci_enable_device(pdev) < 0)
440 return -EIO; 423 return -EIO;
424
441 rc = i82875p_probe1(pdev, ent->driver_data); 425 rc = i82875p_probe1(pdev, ent->driver_data);
426
442 if (mci_pdev == NULL) 427 if (mci_pdev == NULL)
443 mci_pdev = pci_dev_get(pdev); 428 mci_pdev = pci_dev_get(pdev);
429
444 return rc; 430 return rc;
445} 431}
446 432
447
448static void __devexit i82875p_remove_one(struct pci_dev *pdev) 433static void __devexit i82875p_remove_one(struct pci_dev *pdev)
449{ 434{
450 struct mem_ctl_info *mci; 435 struct mem_ctl_info *mci;
@@ -456,6 +441,7 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
456 return; 441 return;
457 442
458 pvt = (struct i82875p_pvt *) mci->pvt_info; 443 pvt = (struct i82875p_pvt *) mci->pvt_info;
444
459 if (pvt->ovrfl_window) 445 if (pvt->ovrfl_window)
460 iounmap(pvt->ovrfl_window); 446 iounmap(pvt->ovrfl_window);
461 447
@@ -470,16 +456,18 @@ static void __devexit i82875p_remove_one(struct pci_dev *pdev)
470 edac_mc_free(mci); 456 edac_mc_free(mci);
471} 457}
472 458
473
474static const struct pci_device_id i82875p_pci_tbl[] __devinitdata = { 459static const struct pci_device_id i82875p_pci_tbl[] __devinitdata = {
475 {PCI_VEND_DEV(INTEL, 82875_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0, 460 {
476 I82875P}, 461 PCI_VEND_DEV(INTEL, 82875_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
477 {0,} /* 0 terminated list. */ 462 I82875P
463 },
464 {
465 0,
466 } /* 0 terminated list. */
478}; 467};
479 468
480MODULE_DEVICE_TABLE(pci, i82875p_pci_tbl); 469MODULE_DEVICE_TABLE(pci, i82875p_pci_tbl);
481 470
482
483static struct pci_driver i82875p_driver = { 471static struct pci_driver i82875p_driver = {
484 .name = EDAC_MOD_STR, 472 .name = EDAC_MOD_STR,
485 .probe = i82875p_init_one, 473 .probe = i82875p_init_one,
@@ -487,31 +475,35 @@ static struct pci_driver i82875p_driver = {
487 .id_table = i82875p_pci_tbl, 475 .id_table = i82875p_pci_tbl,
488}; 476};
489 477
490
491static int __init i82875p_init(void) 478static int __init i82875p_init(void)
492{ 479{
493 int pci_rc; 480 int pci_rc;
494 481
495 debugf3("%s()\n", __func__); 482 debugf3("%s()\n", __func__);
496 pci_rc = pci_register_driver(&i82875p_driver); 483 pci_rc = pci_register_driver(&i82875p_driver);
484
497 if (pci_rc < 0) 485 if (pci_rc < 0)
498 goto fail0; 486 goto fail0;
487
499 if (mci_pdev == NULL) { 488 if (mci_pdev == NULL) {
500 mci_pdev = 489 mci_pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
501 pci_get_device(PCI_VENDOR_ID_INTEL, 490 PCI_DEVICE_ID_INTEL_82875_0, NULL);
502 PCI_DEVICE_ID_INTEL_82875_0, NULL); 491
503 if (!mci_pdev) { 492 if (!mci_pdev) {
504 debugf0("875p pci_get_device fail\n"); 493 debugf0("875p pci_get_device fail\n");
505 pci_rc = -ENODEV; 494 pci_rc = -ENODEV;
506 goto fail1; 495 goto fail1;
507 } 496 }
497
508 pci_rc = i82875p_init_one(mci_pdev, i82875p_pci_tbl); 498 pci_rc = i82875p_init_one(mci_pdev, i82875p_pci_tbl);
499
509 if (pci_rc < 0) { 500 if (pci_rc < 0) {
510 debugf0("875p init fail\n"); 501 debugf0("875p init fail\n");
511 pci_rc = -ENODEV; 502 pci_rc = -ENODEV;
512 goto fail1; 503 goto fail1;
513 } 504 }
514 } 505 }
506
515 return 0; 507 return 0;
516 508
517fail1: 509fail1:
@@ -524,23 +516,21 @@ fail0:
524 return pci_rc; 516 return pci_rc;
525} 517}
526 518
527
528static void __exit i82875p_exit(void) 519static void __exit i82875p_exit(void)
529{ 520{
530 debugf3("%s()\n", __func__); 521 debugf3("%s()\n", __func__);
531 522
532 pci_unregister_driver(&i82875p_driver); 523 pci_unregister_driver(&i82875p_driver);
524
533 if (!i82875p_registered) { 525 if (!i82875p_registered) {
534 i82875p_remove_one(mci_pdev); 526 i82875p_remove_one(mci_pdev);
535 pci_dev_put(mci_pdev); 527 pci_dev_put(mci_pdev);
536 } 528 }
537} 529}
538 530
539
540module_init(i82875p_init); 531module_init(i82875p_init);
541module_exit(i82875p_exit); 532module_exit(i82875p_exit);
542 533
543
544MODULE_LICENSE("GPL"); 534MODULE_LICENSE("GPL");
545MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh"); 535MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh");
546MODULE_DESCRIPTION("MC support for Intel 82875 memory hub controllers"); 536MODULE_DESCRIPTION("MC support for Intel 82875 memory hub controllers");
diff --git a/drivers/edac/r82600_edac.c b/drivers/edac/r82600_edac.c
index 5966916d02bd..2c29fafe67c7 100644
--- a/drivers/edac/r82600_edac.c
+++ b/drivers/edac/r82600_edac.c
@@ -18,19 +18,16 @@
18#include <linux/config.h> 18#include <linux/config.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/init.h> 20#include <linux/init.h>
21
22#include <linux/pci.h> 21#include <linux/pci.h>
23#include <linux/pci_ids.h> 22#include <linux/pci_ids.h>
24
25#include <linux/slab.h> 23#include <linux/slab.h>
26
27#include "edac_mc.h" 24#include "edac_mc.h"
28 25
29#define r82600_printk(level, fmt, arg...) \ 26#define r82600_printk(level, fmt, arg...) \
30 edac_printk(level, "r82600", fmt, ##arg) 27 edac_printk(level, "r82600", fmt, ##arg)
31 28
32#define r82600_mc_printk(mci, level, fmt, arg...) \ 29#define r82600_mc_printk(mci, level, fmt, arg...) \
33 edac_mc_chipset_printk(mci, level, "r82600", fmt, ##arg) 30 edac_mc_chipset_printk(mci, level, "r82600", fmt, ##arg)
34 31
35/* Radisys say "The 82600 integrates a main memory SDRAM controller that 32/* Radisys say "The 82600 integrates a main memory SDRAM controller that
36 * supports up to four banks of memory. The four banks can support a mix of 33 * supports up to four banks of memory. The four banks can support a mix of
@@ -132,10 +129,8 @@ struct r82600_error_info {
132 u32 eapr; 129 u32 eapr;
133}; 130};
134 131
135
136static unsigned int disable_hardware_scrub = 0; 132static unsigned int disable_hardware_scrub = 0;
137 133
138
139static void r82600_get_error_info (struct mem_ctl_info *mci, 134static void r82600_get_error_info (struct mem_ctl_info *mci,
140 struct r82600_error_info *info) 135 struct r82600_error_info *info)
141{ 136{
@@ -144,17 +139,16 @@ static void r82600_get_error_info (struct mem_ctl_info *mci,
144 if (info->eapr & BIT(0)) 139 if (info->eapr & BIT(0))
145 /* Clear error to allow next error to be reported [p.62] */ 140 /* Clear error to allow next error to be reported [p.62] */
146 pci_write_bits32(mci->pdev, R82600_EAP, 141 pci_write_bits32(mci->pdev, R82600_EAP,
147 ((u32) BIT(0) & (u32) BIT(1)), 142 ((u32) BIT(0) & (u32) BIT(1)),
148 ((u32) BIT(0) & (u32) BIT(1))); 143 ((u32) BIT(0) & (u32) BIT(1)));
149 144
150 if (info->eapr & BIT(1)) 145 if (info->eapr & BIT(1))
151 /* Clear error to allow next error to be reported [p.62] */ 146 /* Clear error to allow next error to be reported [p.62] */
152 pci_write_bits32(mci->pdev, R82600_EAP, 147 pci_write_bits32(mci->pdev, R82600_EAP,
153 ((u32) BIT(0) & (u32) BIT(1)), 148 ((u32) BIT(0) & (u32) BIT(1)),
154 ((u32) BIT(0) & (u32) BIT(1))); 149 ((u32) BIT(0) & (u32) BIT(1)));
155} 150}
156 151
157
158static int r82600_process_error_info (struct mem_ctl_info *mci, 152static int r82600_process_error_info (struct mem_ctl_info *mci,
159 struct r82600_error_info *info, int handle_errors) 153 struct r82600_error_info *info, int handle_errors)
160{ 154{
@@ -173,26 +167,25 @@ static int r82600_process_error_info (struct mem_ctl_info *mci,
173 * granularity (upper 19 bits only) */ 167 * granularity (upper 19 bits only) */
174 page = eapaddr >> PAGE_SHIFT; 168 page = eapaddr >> PAGE_SHIFT;
175 169
176 if (info->eapr & BIT(0)) { /* CE? */ 170 if (info->eapr & BIT(0)) { /* CE? */
177 error_found = 1; 171 error_found = 1;
178 172
179 if (handle_errors) 173 if (handle_errors)
180 edac_mc_handle_ce( 174 edac_mc_handle_ce(mci, page, 0, /* not avail */
181 mci, page, 0, /* not avail */ 175 syndrome,
182 syndrome, 176 edac_mc_find_csrow_by_page(mci, page),
183 edac_mc_find_csrow_by_page(mci, page), 177 0, /* channel */
184 0, /* channel */ 178 mci->ctl_name);
185 mci->ctl_name);
186 } 179 }
187 180
188 if (info->eapr & BIT(1)) { /* UE? */ 181 if (info->eapr & BIT(1)) { /* UE? */
189 error_found = 1; 182 error_found = 1;
190 183
191 if (handle_errors) 184 if (handle_errors)
192 /* 82600 doesn't give enough info */ 185 /* 82600 doesn't give enough info */
193 edac_mc_handle_ue(mci, page, 0, 186 edac_mc_handle_ue(mci, page, 0,
194 edac_mc_find_csrow_by_page(mci, page), 187 edac_mc_find_csrow_by_page(mci, page),
195 mci->ctl_name); 188 mci->ctl_name);
196 } 189 }
197 190
198 return error_found; 191 return error_found;
@@ -222,21 +215,15 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
222 struct r82600_error_info discard; 215 struct r82600_error_info discard;
223 216
224 debugf0("%s()\n", __func__); 217 debugf0("%s()\n", __func__);
225
226
227 pci_read_config_byte(pdev, R82600_DRAMC, &dramcr); 218 pci_read_config_byte(pdev, R82600_DRAMC, &dramcr);
228 pci_read_config_dword(pdev, R82600_EAP, &eapr); 219 pci_read_config_dword(pdev, R82600_EAP, &eapr);
229
230 ecc_on = dramcr & BIT(5); 220 ecc_on = dramcr & BIT(5);
231 reg_sdram = dramcr & BIT(4); 221 reg_sdram = dramcr & BIT(4);
232 scrub_disabled = eapr & BIT(31); 222 scrub_disabled = eapr & BIT(31);
233 sdram_refresh_rate = dramcr & (BIT(0) | BIT(1)); 223 sdram_refresh_rate = dramcr & (BIT(0) | BIT(1));
234
235 debugf2("%s(): sdram refresh rate = %#0x\n", __func__, 224 debugf2("%s(): sdram refresh rate = %#0x\n", __func__,
236 sdram_refresh_rate); 225 sdram_refresh_rate);
237
238 debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr); 226 debugf2("%s(): DRAMC register = %#0x\n", __func__, dramcr);
239
240 mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS); 227 mci = edac_mc_alloc(0, R82600_NR_CSROWS, R82600_NR_CHANS);
241 228
242 if (mci == NULL) { 229 if (mci == NULL) {
@@ -245,19 +232,19 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
245 } 232 }
246 233
247 debugf0("%s(): mci = %p\n", __func__, mci); 234 debugf0("%s(): mci = %p\n", __func__, mci);
248
249 mci->pdev = pdev; 235 mci->pdev = pdev;
250 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR; 236 mci->mtype_cap = MEM_FLAG_RDDR | MEM_FLAG_DDR;
251
252 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 237 mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
253 /* FIXME try to work out if the chip leads have been * 238 /* FIXME try to work out if the chip leads have been used for COM2
254 * used for COM2 instead on this board? [MA6?] MAYBE: */ 239 * instead on this board? [MA6?] MAYBE:
240 */
255 241
256 /* On the R82600, the pins for memory bits 72:65 - i.e. the * 242 /* On the R82600, the pins for memory bits 72:65 - i.e. the *
257 * EC bits are shared with the pins for COM2 (!), so if COM2 * 243 * EC bits are shared with the pins for COM2 (!), so if COM2 *
258 * is enabled, we assume COM2 is wired up, and thus no EDAC * 244 * is enabled, we assume COM2 is wired up, and thus no EDAC *
259 * is possible. */ 245 * is possible. */
260 mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED; 246 mci->edac_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
247
261 if (ecc_on) { 248 if (ecc_on) {
262 if (scrub_disabled) 249 if (scrub_disabled)
263 debugf3("%s(): mci = %p - Scrubbing disabled! EAP: " 250 debugf3("%s(): mci = %p - Scrubbing disabled! EAP: "
@@ -295,7 +282,6 @@ static int r82600_probe1(struct pci_dev *pdev, int dev_idx)
295 continue; 282 continue;
296 283
297 row_base = row_high_limit_last; 284 row_base = row_high_limit_last;
298
299 csrow->first_page = row_base >> PAGE_SHIFT; 285 csrow->first_page = row_base >> PAGE_SHIFT;
300 csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1; 286 csrow->last_page = (row_high_limit >> PAGE_SHIFT) - 1;
301 csrow->nr_pages = csrow->last_page - csrow->first_page + 1; 287 csrow->nr_pages = csrow->last_page - csrow->first_page + 1;
@@ -338,7 +324,7 @@ fail:
338 324
339/* returns count (>= 0), or negative on error */ 325/* returns count (>= 0), or negative on error */
340static int __devinit r82600_init_one(struct pci_dev *pdev, 326static int __devinit r82600_init_one(struct pci_dev *pdev,
341 const struct pci_device_id *ent) 327 const struct pci_device_id *ent)
342{ 328{
343 debugf0("%s()\n", __func__); 329 debugf0("%s()\n", __func__);
344 330
@@ -346,7 +332,6 @@ static int __devinit r82600_init_one(struct pci_dev *pdev,
346 return r82600_probe1(pdev, ent->driver_data); 332 return r82600_probe1(pdev, ent->driver_data);
347} 333}
348 334
349
350static void __devexit r82600_remove_one(struct pci_dev *pdev) 335static void __devexit r82600_remove_one(struct pci_dev *pdev)
351{ 336{
352 struct mem_ctl_info *mci; 337 struct mem_ctl_info *mci;
@@ -359,15 +344,17 @@ static void __devexit r82600_remove_one(struct pci_dev *pdev)
359 edac_mc_free(mci); 344 edac_mc_free(mci);
360} 345}
361 346
362
363static const struct pci_device_id r82600_pci_tbl[] __devinitdata = { 347static const struct pci_device_id r82600_pci_tbl[] __devinitdata = {
364 {PCI_DEVICE(PCI_VENDOR_ID_RADISYS, R82600_BRIDGE_ID)}, 348 {
365 {0,} /* 0 terminated list. */ 349 PCI_DEVICE(PCI_VENDOR_ID_RADISYS, R82600_BRIDGE_ID)
350 },
351 {
352 0,
353 } /* 0 terminated list. */
366}; 354};
367 355
368MODULE_DEVICE_TABLE(pci, r82600_pci_tbl); 356MODULE_DEVICE_TABLE(pci, r82600_pci_tbl);
369 357
370
371static struct pci_driver r82600_driver = { 358static struct pci_driver r82600_driver = {
372 .name = EDAC_MOD_STR, 359 .name = EDAC_MOD_STR,
373 .probe = r82600_init_one, 360 .probe = r82600_init_one,
@@ -375,26 +362,22 @@ static struct pci_driver r82600_driver = {
375 .id_table = r82600_pci_tbl, 362 .id_table = r82600_pci_tbl,
376}; 363};
377 364
378
379static int __init r82600_init(void) 365static int __init r82600_init(void)
380{ 366{
381 return pci_register_driver(&r82600_driver); 367 return pci_register_driver(&r82600_driver);
382} 368}
383 369
384
385static void __exit r82600_exit(void) 370static void __exit r82600_exit(void)
386{ 371{
387 pci_unregister_driver(&r82600_driver); 372 pci_unregister_driver(&r82600_driver);
388} 373}
389 374
390
391module_init(r82600_init); 375module_init(r82600_init);
392module_exit(r82600_exit); 376module_exit(r82600_exit);
393 377
394
395MODULE_LICENSE("GPL"); 378MODULE_LICENSE("GPL");
396MODULE_AUTHOR("Tim Small <tim@buttersideup.com> - WPAD Ltd. " 379MODULE_AUTHOR("Tim Small <tim@buttersideup.com> - WPAD Ltd. "
397 "on behalf of EADS Astrium"); 380 "on behalf of EADS Astrium");
398MODULE_DESCRIPTION("MC support for Radisys 82600 memory controllers"); 381MODULE_DESCRIPTION("MC support for Radisys 82600 memory controllers");
399 382
400module_param(disable_hardware_scrub, bool, 0644); 383module_param(disable_hardware_scrub, bool, 0644);