2 * edac_mc kernel module
3 * (C) 2005, 2006 Linux Networx (http://lnxi.com)
4 * This file may be distributed under the terms of the
5 * GNU General Public License.
7 * Written Doug Thompson <norsk5@xmission.com>
11 #include <linux/module.h>
12 #include <linux/sysdev.h>
13 #include <linux/ctype.h>
15 #include "edac_core.h"
16 #include "edac_module.h"
18 /* MC EDAC Controls, setable by module parameter, and sysfs */
19 static int log_ue = 1;
20 static int log_ce = 1;
21 static int panic_on_ue;
22 static int poll_msec = 1000;
24 /* Getter functions for above */
35 int edac_get_panic_on_ue()
40 int edac_get_poll_msec()
45 /* Parameter declarations for above */
46 module_param(panic_on_ue, int, 0644);
47 MODULE_PARM_DESC(panic_on_ue, "Panic on uncorrected error: 0=off 1=on");
48 module_param(log_ue, int, 0644);
49 MODULE_PARM_DESC(log_ue, "Log uncorrectable error to console: 0=off 1=on");
50 module_param(log_ce, int, 0644);
51 MODULE_PARM_DESC(log_ce, "Log correctable error to console: 0=off 1=on");
52 module_param(poll_msec, int, 0644);
53 MODULE_PARM_DESC(poll_msec, "Polling period in milliseconds");
57 * various constants for Memory Controllers
59 static const char *mem_types[] = {
60 [MEM_EMPTY] = "Empty",
61 [MEM_RESERVED] = "Reserved",
62 [MEM_UNKNOWN] = "Unknown",
66 [MEM_SDR] = "Unbuffered-SDR",
67 [MEM_RDR] = "Registered-SDR",
68 [MEM_DDR] = "Unbuffered-DDR",
69 [MEM_RDDR] = "Registered-DDR",
71 [MEM_DDR2] = "Unbuffered-DDR2",
72 [MEM_FB_DDR2] = "FullyBuffered-DDR2",
73 [MEM_RDDR2] = "Registered-DDR2"
76 static const char *dev_types[] = {
77 [DEV_UNKNOWN] = "Unknown",
87 static const char *edac_caps[] = {
88 [EDAC_UNKNOWN] = "Unknown",
90 [EDAC_RESERVED] = "Reserved",
91 [EDAC_PARITY] = "PARITY",
93 [EDAC_SECDED] = "SECDED",
94 [EDAC_S2ECD2ED] = "S2ECD2ED",
95 [EDAC_S4ECD4ED] = "S4ECD4ED",
96 [EDAC_S8ECD8ED] = "S8ECD8ED",
97 [EDAC_S16ECD16ED] = "S16ECD16ED"
101 * /sys/devices/system/edac/mc
103 static struct kobject edac_memctrl_kobj;
105 /* We use these to wait for the reference counts on edac_memctrl_kobj and
106 * edac_pci_kobj to reach 0.
108 static struct completion edac_memctrl_kobj_complete;
111 * /sys/devices/system/edac/mc;
112 * data structures and methods
114 static ssize_t memctrl_int_show(void *ptr, char *buffer)
116 int *value = (int*) ptr;
117 return sprintf(buffer, "%u\n", *value);
120 static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
122 int *value = (int*) ptr;
124 if (isdigit(*buffer))
125 *value = simple_strtoul(buffer, NULL, 0);
130 struct memctrl_dev_attribute {
131 struct attribute attr;
133 ssize_t (*show)(void *,char *);
134 ssize_t (*store)(void *, const char *, size_t);
137 /* Set of show/store abstract level functions for memory control object */
138 static ssize_t memctrl_dev_show(struct kobject *kobj,
139 struct attribute *attr, char *buffer)
141 struct memctrl_dev_attribute *memctrl_dev;
142 memctrl_dev = (struct memctrl_dev_attribute*)attr;
144 if (memctrl_dev->show)
145 return memctrl_dev->show(memctrl_dev->value, buffer);
150 static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr,
151 const char *buffer, size_t count)
153 struct memctrl_dev_attribute *memctrl_dev;
154 memctrl_dev = (struct memctrl_dev_attribute*)attr;
156 if (memctrl_dev->store)
157 return memctrl_dev->store(memctrl_dev->value, buffer, count);
162 static struct sysfs_ops memctrlfs_ops = {
163 .show = memctrl_dev_show,
164 .store = memctrl_dev_store
167 #define MEMCTRL_ATTR(_name,_mode,_show,_store) \
168 static struct memctrl_dev_attribute attr_##_name = { \
169 .attr = {.name = __stringify(_name), .mode = _mode }, \
175 #define MEMCTRL_STRING_ATTR(_name,_data,_mode,_show,_store) \
176 static struct memctrl_dev_attribute attr_##_name = { \
177 .attr = {.name = __stringify(_name), .mode = _mode }, \
183 /* csrow<id> control files */
184 MEMCTRL_ATTR(panic_on_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
185 MEMCTRL_ATTR(log_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
186 MEMCTRL_ATTR(log_ce,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
187 MEMCTRL_ATTR(poll_msec,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
189 /* Base Attributes of the memory ECC object */
190 static struct memctrl_dev_attribute *memctrl_attr[] = {
198 /* Main MC kobject release() function */
199 static void edac_memctrl_master_release(struct kobject *kobj)
201 debugf1("%s()\n", __func__);
202 complete(&edac_memctrl_kobj_complete);
205 static struct kobj_type ktype_memctrl = {
206 .release = edac_memctrl_master_release,
207 .sysfs_ops = &memctrlfs_ops,
208 .default_attrs = (struct attribute **) memctrl_attr,
211 /* Initialize the main sysfs entries for edac:
212 * /sys/devices/system/edac
219 int edac_sysfs_memctrl_setup(void)
222 struct sysdev_class *edac_class;
224 debugf1("%s()\n", __func__);
226 /* get the /sys/devices/system/edac class reference */
227 edac_class = edac_get_edac_class();
228 if (edac_class == NULL) {
229 debugf1("%s() no edac_class error=%d\n", __func__, err);
233 /* Init the MC's kobject */
234 memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
235 edac_memctrl_kobj.parent = &edac_class->kset.kobj;
236 edac_memctrl_kobj.ktype = &ktype_memctrl;
238 /* generate sysfs "..../edac/mc" */
239 err = kobject_set_name(&edac_memctrl_kobj,"mc");
241 debugf1("%s() Failed to set name '.../edac/mc'\n", __func__ );
245 /* FIXME: maybe new sysdev_create_subdir() */
246 err = kobject_register(&edac_memctrl_kobj);
248 debugf1("%s() Failed to register '.../edac/mc'\n", __func__ );
252 debugf1("%s() Registered '.../edac/mc' kobject\n",__func__);
258 * the '..../edac/mc' kobject followed by '..../edac' itself
260 void edac_sysfs_memctrl_teardown(void)
262 debugf0("MC: " __FILE__ ": %s()\n", __func__);
264 /* Unregister the MC's kobject and wait for reference count to reach 0.
266 init_completion(&edac_memctrl_kobj_complete);
267 kobject_unregister(&edac_memctrl_kobj);
268 wait_for_completion(&edac_memctrl_kobj_complete);
272 /* EDAC sysfs CSROW data structures and methods
275 /* Set of more default csrow<id> attribute show/store functions */
276 static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data,
279 return sprintf(data,"%u\n", csrow->ue_count);
282 static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data,
285 return sprintf(data,"%u\n", csrow->ce_count);
288 static ssize_t csrow_size_show(struct csrow_info *csrow, char *data,
291 return sprintf(data,"%u\n", PAGES_TO_MiB(csrow->nr_pages));
294 static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data,
297 return sprintf(data,"%s\n", mem_types[csrow->mtype]);
300 static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data,
303 return sprintf(data,"%s\n", dev_types[csrow->dtype]);
306 static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data,
309 return sprintf(data,"%s\n", edac_caps[csrow->edac_mode]);
312 /* show/store functions for DIMM Label attributes */
313 static ssize_t channel_dimm_label_show(struct csrow_info *csrow,
314 char *data, int channel)
316 return snprintf(data, EDAC_MC_LABEL_LEN,"%s",
317 csrow->channels[channel].label);
320 static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
325 ssize_t max_size = 0;
327 max_size = min((ssize_t)count,(ssize_t)EDAC_MC_LABEL_LEN-1);
328 strncpy(csrow->channels[channel].label, data, max_size);
329 csrow->channels[channel].label[max_size] = '\0';
334 /* show function for dynamic chX_ce_count attribute */
335 static ssize_t channel_ce_count_show(struct csrow_info *csrow,
339 return sprintf(data, "%u\n", csrow->channels[channel].ce_count);
342 /* csrow specific attribute structure */
343 struct csrowdev_attribute {
344 struct attribute attr;
345 ssize_t (*show)(struct csrow_info *,char *,int);
346 ssize_t (*store)(struct csrow_info *, const char *,size_t,int);
350 #define to_csrow(k) container_of(k, struct csrow_info, kobj)
351 #define to_csrowdev_attr(a) container_of(a, struct csrowdev_attribute, attr)
353 /* Set of show/store higher level functions for default csrow attributes */
354 static ssize_t csrowdev_show(struct kobject *kobj,
355 struct attribute *attr,
358 struct csrow_info *csrow = to_csrow(kobj);
359 struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
361 if (csrowdev_attr->show)
362 return csrowdev_attr->show(csrow,
364 csrowdev_attr->private);
368 static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
369 const char *buffer, size_t count)
371 struct csrow_info *csrow = to_csrow(kobj);
372 struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr);
374 if (csrowdev_attr->store)
375 return csrowdev_attr->store(csrow,
378 csrowdev_attr->private);
382 static struct sysfs_ops csrowfs_ops = {
383 .show = csrowdev_show,
384 .store = csrowdev_store
387 #define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \
388 static struct csrowdev_attribute attr_##_name = { \
389 .attr = {.name = __stringify(_name), .mode = _mode }, \
392 .private = _private, \
395 /* default cwrow<id>/attribute files */
396 CSROWDEV_ATTR(size_mb,S_IRUGO,csrow_size_show,NULL,0);
397 CSROWDEV_ATTR(dev_type,S_IRUGO,csrow_dev_type_show,NULL,0);
398 CSROWDEV_ATTR(mem_type,S_IRUGO,csrow_mem_type_show,NULL,0);
399 CSROWDEV_ATTR(edac_mode,S_IRUGO,csrow_edac_mode_show,NULL,0);
400 CSROWDEV_ATTR(ue_count,S_IRUGO,csrow_ue_count_show,NULL,0);
401 CSROWDEV_ATTR(ce_count,S_IRUGO,csrow_ce_count_show,NULL,0);
403 /* default attributes of the CSROW<id> object */
404 static struct csrowdev_attribute *default_csrow_attr[] = {
415 /* possible dynamic channel DIMM Label attribute files */
416 CSROWDEV_ATTR(ch0_dimm_label,S_IRUGO|S_IWUSR,
417 channel_dimm_label_show,
418 channel_dimm_label_store,
420 CSROWDEV_ATTR(ch1_dimm_label,S_IRUGO|S_IWUSR,
421 channel_dimm_label_show,
422 channel_dimm_label_store,
424 CSROWDEV_ATTR(ch2_dimm_label,S_IRUGO|S_IWUSR,
425 channel_dimm_label_show,
426 channel_dimm_label_store,
428 CSROWDEV_ATTR(ch3_dimm_label,S_IRUGO|S_IWUSR,
429 channel_dimm_label_show,
430 channel_dimm_label_store,
432 CSROWDEV_ATTR(ch4_dimm_label,S_IRUGO|S_IWUSR,
433 channel_dimm_label_show,
434 channel_dimm_label_store,
436 CSROWDEV_ATTR(ch5_dimm_label,S_IRUGO|S_IWUSR,
437 channel_dimm_label_show,
438 channel_dimm_label_store,
441 /* Total possible dynamic DIMM Label attribute file table */
442 static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = {
443 &attr_ch0_dimm_label,
444 &attr_ch1_dimm_label,
445 &attr_ch2_dimm_label,
446 &attr_ch3_dimm_label,
447 &attr_ch4_dimm_label,
451 /* possible dynamic channel ce_count attribute files */
452 CSROWDEV_ATTR(ch0_ce_count,S_IRUGO|S_IWUSR,
453 channel_ce_count_show,
456 CSROWDEV_ATTR(ch1_ce_count,S_IRUGO|S_IWUSR,
457 channel_ce_count_show,
460 CSROWDEV_ATTR(ch2_ce_count,S_IRUGO|S_IWUSR,
461 channel_ce_count_show,
464 CSROWDEV_ATTR(ch3_ce_count,S_IRUGO|S_IWUSR,
465 channel_ce_count_show,
468 CSROWDEV_ATTR(ch4_ce_count,S_IRUGO|S_IWUSR,
469 channel_ce_count_show,
472 CSROWDEV_ATTR(ch5_ce_count,S_IRUGO|S_IWUSR,
473 channel_ce_count_show,
477 /* Total possible dynamic ce_count attribute file table */
478 static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = {
488 #define EDAC_NR_CHANNELS 6
490 /* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */
491 static int edac_create_channel_files(struct kobject *kobj, int chan)
495 if (chan >= EDAC_NR_CHANNELS)
498 /* create the DIMM label attribute file */
499 err = sysfs_create_file(kobj,
500 (struct attribute *) dynamic_csrow_dimm_attr[chan]);
503 /* create the CE Count attribute file */
504 err = sysfs_create_file(kobj,
505 (struct attribute *)dynamic_csrow_ce_count_attr[chan]);
507 debugf1("%s() dimm labels and ce_count files created",
514 /* No memory to release for this kobj */
515 static void edac_csrow_instance_release(struct kobject *kobj)
517 struct csrow_info *cs;
519 cs = container_of(kobj, struct csrow_info, kobj);
520 complete(&cs->kobj_complete);
523 /* the kobj_type instance for a CSROW */
524 static struct kobj_type ktype_csrow = {
525 .release = edac_csrow_instance_release,
526 .sysfs_ops = &csrowfs_ops,
527 .default_attrs = (struct attribute **) default_csrow_attr,
530 /* Create a CSROW object under specifed edac_mc_device */
531 static int edac_create_csrow_object(
532 struct kobject *edac_mci_kobj,
533 struct csrow_info *csrow,
539 memset(&csrow->kobj, 0, sizeof(csrow->kobj));
541 /* generate ..../edac/mc/mc<id>/csrow<index> */
543 csrow->kobj.parent = edac_mci_kobj;
544 csrow->kobj.ktype = &ktype_csrow;
546 /* name this instance of csrow<id> */
547 err = kobject_set_name(&csrow->kobj,"csrow%d",index);
551 /* Instanstiate the csrow object */
552 err = kobject_register(&csrow->kobj);
554 /* Create the dyanmic attribute files on this csrow,
555 * namely, the DIMM labels and the channel ce_count
557 for (chan = 0; chan < csrow->nr_channels; chan++) {
558 err = edac_create_channel_files(&csrow->kobj,chan);
568 /* default sysfs methods and data structures for the main MCI kobject */
570 static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
571 const char *data, size_t count)
575 mci->ue_noinfo_count = 0;
576 mci->ce_noinfo_count = 0;
580 for (row = 0; row < mci->nr_csrows; row++) {
581 struct csrow_info *ri = &mci->csrows[row];
586 for (chan = 0; chan < ri->nr_channels; chan++)
587 ri->channels[chan].ce_count = 0;
590 mci->start_time = jiffies;
594 /* memory scrubbing */
595 static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci,
596 const char *data, size_t count)
600 if (mci->set_sdram_scrub_rate) {
602 memctrl_int_store(&bandwidth, data, count);
604 if (!(*mci->set_sdram_scrub_rate)(mci, &bandwidth)) {
605 edac_printk(KERN_DEBUG, EDAC_MC,
606 "Scrub rate set successfully, applied: %d\n",
609 /* FIXME: error codes maybe? */
610 edac_printk(KERN_DEBUG, EDAC_MC,
611 "Scrub rate set FAILED, could not apply: %d\n",
615 /* FIXME: produce "not implemented" ERROR for user-side. */
616 edac_printk(KERN_WARNING, EDAC_MC,
617 "Memory scrubbing 'set'control is not implemented!\n");
622 static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data)
626 if (mci->get_sdram_scrub_rate) {
627 if (!(*mci->get_sdram_scrub_rate)(mci, &bandwidth)) {
628 edac_printk(KERN_DEBUG, EDAC_MC,
629 "Scrub rate successfully, fetched: %d\n",
632 /* FIXME: error codes maybe? */
633 edac_printk(KERN_DEBUG, EDAC_MC,
634 "Scrub rate fetch FAILED, got: %d\n",
638 /* FIXME: produce "not implemented" ERROR for user-side. */
639 edac_printk(KERN_WARNING, EDAC_MC,
640 "Memory scrubbing 'get' control is not implemented\n");
642 return sprintf(data, "%d\n", bandwidth);
645 /* default attribute files for the MCI object */
646 static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data)
648 return sprintf(data,"%d\n", mci->ue_count);
651 static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data)
653 return sprintf(data,"%d\n", mci->ce_count);
656 static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data)
658 return sprintf(data,"%d\n", mci->ce_noinfo_count);
661 static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data)
663 return sprintf(data,"%d\n", mci->ue_noinfo_count);
666 static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data)
668 return sprintf(data,"%ld\n", (jiffies - mci->start_time) / HZ);
671 static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data)
673 return sprintf(data,"%s\n", mci->ctl_name);
676 static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
678 int total_pages, csrow_idx;
680 for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows;
682 struct csrow_info *csrow = &mci->csrows[csrow_idx];
684 if (!csrow->nr_pages)
687 total_pages += csrow->nr_pages;
690 return sprintf(data,"%u\n", PAGES_TO_MiB(total_pages));
693 struct mcidev_attribute {
694 struct attribute attr;
695 ssize_t (*show)(struct mem_ctl_info *,char *);
696 ssize_t (*store)(struct mem_ctl_info *, const char *,size_t);
699 #define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj)
700 #define to_mcidev_attr(a) container_of(a, struct mcidev_attribute, attr)
702 /* MCI show/store functions for top most object */
703 static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
706 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
707 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr);
709 if (mcidev_attr->show)
710 return mcidev_attr->show(mem_ctl_info, buffer);
715 static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
716 const char *buffer, size_t count)
718 struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
719 struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr);
721 if (mcidev_attr->store)
722 return mcidev_attr->store(mem_ctl_info, buffer, count);
727 static struct sysfs_ops mci_ops = {
729 .store = mcidev_store
732 #define MCIDEV_ATTR(_name,_mode,_show,_store) \
733 static struct mcidev_attribute mci_attr_##_name = { \
734 .attr = {.name = __stringify(_name), .mode = _mode }, \
739 /* default Control file */
740 MCIDEV_ATTR(reset_counters,S_IWUSR,NULL,mci_reset_counters_store);
742 /* default Attribute files */
743 MCIDEV_ATTR(mc_name,S_IRUGO,mci_ctl_name_show,NULL);
744 MCIDEV_ATTR(size_mb,S_IRUGO,mci_size_mb_show,NULL);
745 MCIDEV_ATTR(seconds_since_reset,S_IRUGO,mci_seconds_show,NULL);
746 MCIDEV_ATTR(ue_noinfo_count,S_IRUGO,mci_ue_noinfo_show,NULL);
747 MCIDEV_ATTR(ce_noinfo_count,S_IRUGO,mci_ce_noinfo_show,NULL);
748 MCIDEV_ATTR(ue_count,S_IRUGO,mci_ue_count_show,NULL);
749 MCIDEV_ATTR(ce_count,S_IRUGO,mci_ce_count_show,NULL);
751 /* memory scrubber attribute file */
752 MCIDEV_ATTR(sdram_scrub_rate,S_IRUGO|S_IWUSR,mci_sdram_scrub_rate_show,\
753 mci_sdram_scrub_rate_store);
755 static struct mcidev_attribute *mci_attr[] = {
756 &mci_attr_reset_counters,
759 &mci_attr_seconds_since_reset,
760 &mci_attr_ue_noinfo_count,
761 &mci_attr_ce_noinfo_count,
764 &mci_attr_sdram_scrub_rate,
769 * Release of a MC controlling instance
771 static void edac_mci_instance_release(struct kobject *kobj)
773 struct mem_ctl_info *mci;
776 debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
777 complete(&mci->kobj_complete);
780 static struct kobj_type ktype_mci = {
781 .release = edac_mci_instance_release,
782 .sysfs_ops = &mci_ops,
783 .default_attrs = (struct attribute **) mci_attr,
787 #define EDAC_DEVICE_SYMLINK "device"
790 * Create a new Memory Controller kobject instance,
791 * mc<id> under the 'mc' directory
797 int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
801 struct csrow_info *csrow;
802 struct kobject *edac_mci_kobj=&mci->edac_mci_kobj;
804 debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
805 memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj));
807 /* set the name of the mc<id> object */
808 err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx);
812 /* link to our parent the '..../edac/mc' object */
813 edac_mci_kobj->parent = &edac_memctrl_kobj;
814 edac_mci_kobj->ktype = &ktype_mci;
816 /* register the mc<id> kobject */
817 err = kobject_register(edac_mci_kobj);
821 /* create a symlink for the device */
822 err = sysfs_create_link(edac_mci_kobj, &mci->dev->kobj,
823 EDAC_DEVICE_SYMLINK);
827 /* Make directories for each CSROW object
828 * under the mc<id> kobject
830 for (i = 0; i < mci->nr_csrows; i++) {
831 csrow = &mci->csrows[i];
833 /* Only expose populated CSROWs */
834 if (csrow->nr_pages > 0) {
835 err = edac_create_csrow_object(edac_mci_kobj,csrow,i);
843 /* CSROW error: backout what has already been registered, */
845 for ( i--; i >= 0; i--) {
846 if (csrow->nr_pages > 0) {
847 init_completion(&csrow->kobj_complete);
848 kobject_unregister(&mci->csrows[i].kobj);
849 wait_for_completion(&csrow->kobj_complete);
854 init_completion(&mci->kobj_complete);
855 kobject_unregister(edac_mci_kobj);
856 wait_for_completion(&mci->kobj_complete);
861 * remove a Memory Controller instance
863 void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
867 debugf0("%s()\n", __func__);
869 /* remove all csrow kobjects */
870 for (i = 0; i < mci->nr_csrows; i++) {
871 if (mci->csrows[i].nr_pages > 0) {
872 init_completion(&mci->csrows[i].kobj_complete);
873 kobject_unregister(&mci->csrows[i].kobj);
874 wait_for_completion(&mci->csrows[i].kobj_complete);
878 sysfs_remove_link(&mci->edac_mci_kobj, EDAC_DEVICE_SYMLINK);
879 init_completion(&mci->kobj_complete);
880 kobject_unregister(&mci->edac_mci_kobj);
881 wait_for_completion(&mci->kobj_complete);