aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/edac_pci_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/edac/edac_pci_sysfs.c')
-rw-r--r--drivers/edac/edac_pci_sysfs.c140
1 files changed, 68 insertions, 72 deletions
diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
index a3f81d72c950..f471659a1c35 100644
--- a/drivers/edac/edac_pci_sysfs.c
+++ b/drivers/edac/edac_pci_sysfs.c
@@ -13,7 +13,6 @@
13#include "edac_core.h" 13#include "edac_core.h"
14#include "edac_module.h" 14#include "edac_module.h"
15 15
16
17#ifdef CONFIG_PCI 16#ifdef CONFIG_PCI
18 17
19#define EDAC_PCI_SYMLINK "device" 18#define EDAC_PCI_SYMLINK "device"
@@ -26,7 +25,7 @@ static atomic_t pci_parity_count = ATOMIC_INIT(0);
26static atomic_t pci_nonparity_count = ATOMIC_INIT(0); 25static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
27static int edac_pci_poll_msec = 1000; 26static int edac_pci_poll_msec = 1000;
28 27
29static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */ 28static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */
30static struct completion edac_pci_kobj_complete; 29static struct completion edac_pci_kobj_complete;
31static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0); 30static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
32 31
@@ -58,13 +57,13 @@ int edac_pci_get_poll_msec(void)
58/**************************** EDAC PCI sysfs instance *******************/ 57/**************************** EDAC PCI sysfs instance *******************/
59static ssize_t instance_pe_count_show(struct edac_pci_ctl_info *pci, char *data) 58static ssize_t instance_pe_count_show(struct edac_pci_ctl_info *pci, char *data)
60{ 59{
61 return sprintf(data,"%u\n", atomic_read(&pci->counters.pe_count)); 60 return sprintf(data, "%u\n", atomic_read(&pci->counters.pe_count));
62} 61}
63 62
64static ssize_t instance_npe_count_show(struct edac_pci_ctl_info *pci, 63static ssize_t instance_npe_count_show(struct edac_pci_ctl_info *pci,
65 char *data) 64 char *data)
66{ 65{
67 return sprintf(data,"%u\n", atomic_read(&pci->counters.npe_count)); 66 return sprintf(data, "%u\n", atomic_read(&pci->counters.npe_count));
68} 67}
69 68
70#define to_instance(k) container_of(k, struct edac_pci_ctl_info, kobj) 69#define to_instance(k) container_of(k, struct edac_pci_ctl_info, kobj)
@@ -83,36 +82,34 @@ static void edac_pci_instance_release(struct kobject *kobj)
83 82
84/* instance specific attribute structure */ 83/* instance specific attribute structure */
85struct instance_attribute { 84struct instance_attribute {
86 struct attribute attr; 85 struct attribute attr;
87 ssize_t (*show)(struct edac_pci_ctl_info *, char *); 86 ssize_t(*show) (struct edac_pci_ctl_info *, char *);
88 ssize_t (*store)(struct edac_pci_ctl_info *, const char *, size_t); 87 ssize_t(*store) (struct edac_pci_ctl_info *, const char *, size_t);
89}; 88};
90 89
91/* Function to 'show' fields from the edac_pci 'instance' structure */ 90/* Function to 'show' fields from the edac_pci 'instance' structure */
92static ssize_t edac_pci_instance_show(struct kobject *kobj, 91static ssize_t edac_pci_instance_show(struct kobject *kobj,
93 struct attribute *attr, 92 struct attribute *attr, char *buffer)
94 char *buffer)
95{ 93{
96 struct edac_pci_ctl_info *pci = to_instance(kobj); 94 struct edac_pci_ctl_info *pci = to_instance(kobj);
97 struct instance_attribute *instance_attr = to_instance_attr(attr); 95 struct instance_attribute *instance_attr = to_instance_attr(attr);
98 96
99 if (instance_attr->show) 97 if (instance_attr->show)
100 return instance_attr->show(pci, buffer); 98 return instance_attr->show(pci, buffer);
101 return -EIO; 99 return -EIO;
102} 100}
103 101
104
105/* Function to 'store' fields into the edac_pci 'instance' structure */ 102/* Function to 'store' fields into the edac_pci 'instance' structure */
106static ssize_t edac_pci_instance_store(struct kobject *kobj, 103static ssize_t edac_pci_instance_store(struct kobject *kobj,
107 struct attribute *attr, 104 struct attribute *attr,
108 const char *buffer, size_t count) 105 const char *buffer, size_t count)
109{ 106{
110 struct edac_pci_ctl_info *pci = to_instance(kobj); 107 struct edac_pci_ctl_info *pci = to_instance(kobj);
111 struct instance_attribute *instance_attr = to_instance_attr(attr); 108 struct instance_attribute *instance_attr = to_instance_attr(attr);
112 109
113 if (instance_attr->store) 110 if (instance_attr->store)
114 return instance_attr->store(pci, buffer, count); 111 return instance_attr->store(pci, buffer, count);
115 return -EIO; 112 return -EIO;
116} 113}
117 114
118static struct sysfs_ops pci_instance_ops = { 115static struct sysfs_ops pci_instance_ops = {
@@ -158,7 +155,7 @@ static int edac_pci_create_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
158 err = kobject_register(&pci->kobj); 155 err = kobject_register(&pci->kobj);
159 if (err != 0) { 156 if (err != 0) {
160 debugf2("%s() failed to register instance pci%d\n", 157 debugf2("%s() failed to register instance pci%d\n",
161 __func__, idx); 158 __func__, idx);
162 return err; 159 return err;
163 } 160 }
164 161
@@ -182,7 +179,7 @@ edac_pci_delete_instance_kobj(struct edac_pci_ctl_info *pci, int idx)
182static ssize_t edac_pci_int_show(void *ptr, char *buffer) 179static ssize_t edac_pci_int_show(void *ptr, char *buffer)
183{ 180{
184 int *value = ptr; 181 int *value = ptr;
185 return sprintf(buffer,"%d\n",*value); 182 return sprintf(buffer, "%d\n", *value);
186} 183}
187 184
188static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count) 185static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
@@ -190,7 +187,7 @@ static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
190 int *value = ptr; 187 int *value = ptr;
191 188
192 if (isdigit(*buffer)) 189 if (isdigit(*buffer))
193 *value = simple_strtoul(buffer,NULL,0); 190 *value = simple_strtoul(buffer, NULL, 0);
194 191
195 return count; 192 return count;
196} 193}
@@ -198,16 +195,16 @@ static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
198struct edac_pci_dev_attribute { 195struct edac_pci_dev_attribute {
199 struct attribute attr; 196 struct attribute attr;
200 void *value; 197 void *value;
201 ssize_t (*show)(void *,char *); 198 ssize_t(*show) (void *, char *);
202 ssize_t (*store)(void *, const char *,size_t); 199 ssize_t(*store) (void *, const char *, size_t);
203}; 200};
204 201
205/* Set of show/store abstract level functions for PCI Parity object */ 202/* Set of show/store abstract level functions for PCI Parity object */
206static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr, 203static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
207 char *buffer) 204 char *buffer)
208{ 205{
209 struct edac_pci_dev_attribute *edac_pci_dev; 206 struct edac_pci_dev_attribute *edac_pci_dev;
210 edac_pci_dev= (struct edac_pci_dev_attribute*)attr; 207 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
211 208
212 if (edac_pci_dev->show) 209 if (edac_pci_dev->show)
213 return edac_pci_dev->show(edac_pci_dev->value, buffer); 210 return edac_pci_dev->show(edac_pci_dev->value, buffer);
@@ -215,10 +212,11 @@ static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
215} 212}
216 213
217static ssize_t edac_pci_dev_store(struct kobject *kobj, 214static ssize_t edac_pci_dev_store(struct kobject *kobj,
218 struct attribute *attr, const char *buffer, size_t count) 215 struct attribute *attr, const char *buffer,
216 size_t count)
219{ 217{
220 struct edac_pci_dev_attribute *edac_pci_dev; 218 struct edac_pci_dev_attribute *edac_pci_dev;
221 edac_pci_dev= (struct edac_pci_dev_attribute*)attr; 219 edac_pci_dev = (struct edac_pci_dev_attribute *)attr;
222 220
223 if (edac_pci_dev->show) 221 if (edac_pci_dev->show)
224 return edac_pci_dev->store(edac_pci_dev->value, buffer, count); 222 return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
@@ -226,8 +224,8 @@ static ssize_t edac_pci_dev_store(struct kobject *kobj,
226} 224}
227 225
228static struct sysfs_ops edac_pci_sysfs_ops = { 226static struct sysfs_ops edac_pci_sysfs_ops = {
229 .show = edac_pci_dev_show, 227 .show = edac_pci_dev_show,
230 .store = edac_pci_dev_store 228 .store = edac_pci_dev_store
231}; 229};
232 230
233#define EDAC_PCI_ATTR(_name,_mode,_show,_store) \ 231#define EDAC_PCI_ATTR(_name,_mode,_show,_store) \
@@ -247,14 +245,14 @@ static struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
247}; 245};
248 246
249/* PCI Parity control files */ 247/* PCI Parity control files */
250EDAC_PCI_ATTR(check_pci_errors, S_IRUGO|S_IWUSR, edac_pci_int_show, 248EDAC_PCI_ATTR(check_pci_errors, S_IRUGO | S_IWUSR, edac_pci_int_show,
251 edac_pci_int_store); 249 edac_pci_int_store);
252EDAC_PCI_ATTR(edac_pci_log_pe, S_IRUGO|S_IWUSR, edac_pci_int_show, 250EDAC_PCI_ATTR(edac_pci_log_pe, S_IRUGO | S_IWUSR, edac_pci_int_show,
253 edac_pci_int_store); 251 edac_pci_int_store);
254EDAC_PCI_ATTR(edac_pci_log_npe, S_IRUGO|S_IWUSR, edac_pci_int_show, 252EDAC_PCI_ATTR(edac_pci_log_npe, S_IRUGO | S_IWUSR, edac_pci_int_show,
255 edac_pci_int_store); 253 edac_pci_int_store);
256EDAC_PCI_ATTR(edac_pci_panic_on_pe, S_IRUGO|S_IWUSR, edac_pci_int_show, 254EDAC_PCI_ATTR(edac_pci_panic_on_pe, S_IRUGO | S_IWUSR, edac_pci_int_show,
257 edac_pci_int_store); 255 edac_pci_int_store);
258EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL); 256EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL);
259EDAC_PCI_ATTR(pci_nonparity_count, S_IRUGO, edac_pci_int_show, NULL); 257EDAC_PCI_ATTR(pci_nonparity_count, S_IRUGO, edac_pci_int_show, NULL);
260 258
@@ -283,7 +281,7 @@ static void edac_pci_release(struct kobject *kobj)
283static struct kobj_type ktype_edac_pci = { 281static struct kobj_type ktype_edac_pci = {
284 .release = edac_pci_release, 282 .release = edac_pci_release,
285 .sysfs_ops = &edac_pci_sysfs_ops, 283 .sysfs_ops = &edac_pci_sysfs_ops,
286 .default_attrs = (struct attribute **) edac_pci_attr, 284 .default_attrs = (struct attribute **)edac_pci_attr,
287}; 285};
288 286
289/** 287/**
@@ -310,7 +308,7 @@ int edac_pci_register_main_kobj(void)
310 edac_pci_kobj.parent = &edac_class->kset.kobj; 308 edac_pci_kobj.parent = &edac_class->kset.kobj;
311 309
312 err = kobject_set_name(&edac_pci_kobj, "pci"); 310 err = kobject_set_name(&edac_pci_kobj, "pci");
313 if(err) 311 if (err)
314 return err; 312 return err;
315 313
316 /* Instanstiate the pci object */ 314 /* Instanstiate the pci object */
@@ -359,15 +357,12 @@ int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci)
359 edac_pci_unregister_main_kobj(); 357 edac_pci_unregister_main_kobj();
360 } 358 }
361 359
362
363 debugf0("%s() idx=%d\n", __func__, pci->pci_idx); 360 debugf0("%s() idx=%d\n", __func__, pci->pci_idx);
364 361
365 err = sysfs_create_link(edac_kobj, 362 err = sysfs_create_link(edac_kobj, &pci->dev->kobj, EDAC_PCI_SYMLINK);
366 &pci->dev->kobj,
367 EDAC_PCI_SYMLINK);
368 if (err) { 363 if (err) {
369 debugf0("%s() sysfs_create_link() returned err= %d\n", 364 debugf0("%s() sysfs_create_link() returned err= %d\n",
370 __func__, err); 365 __func__, err);
371 return err; 366 return err;
372 } 367 }
373 368
@@ -410,7 +405,7 @@ static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
410 } 405 }
411 406
412 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR | 407 status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
413 PCI_STATUS_PARITY; 408 PCI_STATUS_PARITY;
414 409
415 if (status) 410 if (status)
416 /* reset only the bits we are interested in */ 411 /* reset only the bits we are interested in */
@@ -419,7 +414,7 @@ static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
419 return status; 414 return status;
420} 415}
421 416
422typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev); 417typedef void (*pci_parity_check_fn_t) (struct pci_dev * dev);
423 418
424/* Clear any PCI parity errors logged by this device. */ 419/* Clear any PCI parity errors logged by this device. */
425static void edac_pci_dev_parity_clear(struct pci_dev *dev) 420static void edac_pci_dev_parity_clear(struct pci_dev *dev)
@@ -442,35 +437,35 @@ static void edac_pci_dev_parity_clear(struct pci_dev *dev)
442static void edac_pci_dev_parity_test(struct pci_dev *dev) 437static void edac_pci_dev_parity_test(struct pci_dev *dev)
443{ 438{
444 u16 status; 439 u16 status;
445 u8 header_type; 440 u8 header_type;
446 441
447 /* read the STATUS register on this device 442 /* read the STATUS register on this device
448 */ 443 */
449 status = get_pci_parity_status(dev, 0); 444 status = get_pci_parity_status(dev, 0);
450 445
451 debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id ); 446 debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
452 447
453 /* check the status reg for errors */ 448 /* check the status reg for errors */
454 if (status) { 449 if (status) {
455 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) { 450 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
456 edac_printk(KERN_CRIT, EDAC_PCI, 451 edac_printk(KERN_CRIT, EDAC_PCI,
457 "Signaled System Error on %s\n", 452 "Signaled System Error on %s\n",
458 pci_name(dev)); 453 pci_name(dev));
459 atomic_inc(&pci_nonparity_count); 454 atomic_inc(&pci_nonparity_count);
460 } 455 }
461 456
462 if (status & (PCI_STATUS_PARITY)) { 457 if (status & (PCI_STATUS_PARITY)) {
463 edac_printk(KERN_CRIT, EDAC_PCI, 458 edac_printk(KERN_CRIT, EDAC_PCI,
464 "Master Data Parity Error on %s\n", 459 "Master Data Parity Error on %s\n",
465 pci_name(dev)); 460 pci_name(dev));
466 461
467 atomic_inc(&pci_parity_count); 462 atomic_inc(&pci_parity_count);
468 } 463 }
469 464
470 if (status & (PCI_STATUS_DETECTED_PARITY)) { 465 if (status & (PCI_STATUS_DETECTED_PARITY)) {
471 edac_printk(KERN_CRIT, EDAC_PCI, 466 edac_printk(KERN_CRIT, EDAC_PCI,
472 "Detected Parity Error on %s\n", 467 "Detected Parity Error on %s\n",
473 pci_name(dev)); 468 pci_name(dev));
474 469
475 atomic_inc(&pci_parity_count); 470 atomic_inc(&pci_parity_count);
476 } 471 }
@@ -479,36 +474,35 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
479 /* read the device TYPE, looking for bridges */ 474 /* read the device TYPE, looking for bridges */
480 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type); 475 pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
481 476
482 debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id ); 477 debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id);
483 478
484 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 479 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
485 /* On bridges, need to examine secondary status register */ 480 /* On bridges, need to examine secondary status register */
486 status = get_pci_parity_status(dev, 1); 481 status = get_pci_parity_status(dev, 1);
487 482
488 debugf2("PCI SEC_STATUS= 0x%04x %s\n", 483 debugf2("PCI SEC_STATUS= 0x%04x %s\n", status, dev->dev.bus_id);
489 status, dev->dev.bus_id );
490 484
491 /* check the secondary status reg for errors */ 485 /* check the secondary status reg for errors */
492 if (status) { 486 if (status) {
493 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) { 487 if (status & (PCI_STATUS_SIG_SYSTEM_ERROR)) {
494 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge " 488 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
495 "Signaled System Error on %s\n", 489 "Signaled System Error on %s\n",
496 pci_name(dev)); 490 pci_name(dev));
497 atomic_inc(&pci_nonparity_count); 491 atomic_inc(&pci_nonparity_count);
498 } 492 }
499 493
500 if (status & (PCI_STATUS_PARITY)) { 494 if (status & (PCI_STATUS_PARITY)) {
501 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge " 495 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
502 "Master Data Parity Error on " 496 "Master Data Parity Error on "
503 "%s\n", pci_name(dev)); 497 "%s\n", pci_name(dev));
504 498
505 atomic_inc(&pci_parity_count); 499 atomic_inc(&pci_parity_count);
506 } 500 }
507 501
508 if (status & (PCI_STATUS_DETECTED_PARITY)) { 502 if (status & (PCI_STATUS_DETECTED_PARITY)) {
509 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge " 503 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
510 "Detected Parity Error on %s\n", 504 "Detected Parity Error on %s\n",
511 pci_name(dev)); 505 pci_name(dev));
512 506
513 atomic_inc(&pci_parity_count); 507 atomic_inc(&pci_parity_count);
514 } 508 }
@@ -529,7 +523,7 @@ static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
529 * and while we are looking at it have its reference count 523 * and while we are looking at it have its reference count
530 * bumped until we are done with it 524 * bumped until we are done with it
531 */ 525 */
532 while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { 526 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
533 fn(dev); 527 fn(dev);
534 } 528 }
535} 529}
@@ -590,6 +584,7 @@ void edac_pci_handle_pe(struct edac_pci_ctl_info *pci, const char *msg)
590 */ 584 */
591 edac_pci_do_parity_check(); 585 edac_pci_do_parity_check();
592} 586}
587
593EXPORT_SYMBOL_GPL(edac_pci_handle_pe); 588EXPORT_SYMBOL_GPL(edac_pci_handle_pe);
594 589
595void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg) 590void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg)
@@ -609,6 +604,7 @@ void edac_pci_handle_npe(struct edac_pci_ctl_info *pci, const char *msg)
609 */ 604 */
610 edac_pci_do_parity_check(); 605 edac_pci_do_parity_check();
611} 606}
607
612EXPORT_SYMBOL_GPL(edac_pci_handle_npe); 608EXPORT_SYMBOL_GPL(edac_pci_handle_npe);
613 609
614/* 610/*
@@ -616,9 +612,9 @@ EXPORT_SYMBOL_GPL(edac_pci_handle_npe);
616 */ 612 */
617module_param(check_pci_errors, int, 0644); 613module_param(check_pci_errors, int, 0644);
618MODULE_PARM_DESC(check_pci_errors, 614MODULE_PARM_DESC(check_pci_errors,
619 "Check for PCI bus parity errors: 0=off 1=on"); 615 "Check for PCI bus parity errors: 0=off 1=on");
620module_param(edac_pci_panic_on_pe, int, 0644); 616module_param(edac_pci_panic_on_pe, int, 0644);
621MODULE_PARM_DESC(edac_pci_panic_on_pe, 617MODULE_PARM_DESC(edac_pci_panic_on_pe,
622 "Panic on PCI Bus Parity error: 0=off 1=on"); 618 "Panic on PCI Bus Parity error: 0=off 1=on");
623 619
624#endif /* CONFIG_PCI */ 620#endif /* CONFIG_PCI */