Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 1 | /* |
| 2 | * edac_mc kernel module |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 3 | * (C) 2005-2007 Linux Networx (http://lnxi.com) |
| 4 | * |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 5 | * This file may be distributed under the terms of the |
| 6 | * GNU General Public License. |
| 7 | * |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 8 | * Written Doug Thompson <norsk5@xmission.com> www.softwarebitmaker.com |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 9 | * |
| 10 | */ |
| 11 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 12 | #include <linux/ctype.h> |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 13 | #include <linux/bug.h> |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 14 | |
Douglas Thompson | 20bcb7a | 2007-07-19 01:49:47 -0700 | [diff] [blame] | 15 | #include "edac_core.h" |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 16 | #include "edac_module.h" |
| 17 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 18 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 19 | /* MC EDAC Controls, setable by module parameter, and sysfs */ |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 20 | static int edac_mc_log_ue = 1; |
| 21 | static int edac_mc_log_ce = 1; |
Douglas Thompson | f044091 | 2007-07-19 01:50:19 -0700 | [diff] [blame] | 22 | static int edac_mc_panic_on_ue; |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 23 | static int edac_mc_poll_msec = 1000; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 24 | |
| 25 | /* Getter functions for above */ |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 26 | int edac_mc_get_log_ue(void) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 27 | { |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 28 | return edac_mc_log_ue; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 31 | int edac_mc_get_log_ce(void) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 32 | { |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 33 | return edac_mc_log_ce; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 36 | int edac_mc_get_panic_on_ue(void) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 37 | { |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 38 | return edac_mc_panic_on_ue; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Dave Jiang | 81d87cb | 2007-07-19 01:49:52 -0700 | [diff] [blame] | 41 | /* this is temporary */ |
| 42 | int edac_mc_get_poll_msec(void) |
| 43 | { |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 44 | return edac_mc_poll_msec; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | /* Parameter declarations for above */ |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 48 | module_param(edac_mc_panic_on_ue, int, 0644); |
| 49 | MODULE_PARM_DESC(edac_mc_panic_on_ue, "Panic on uncorrected error: 0=off 1=on"); |
| 50 | module_param(edac_mc_log_ue, int, 0644); |
| 51 | MODULE_PARM_DESC(edac_mc_log_ue, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 52 | "Log uncorrectable error to console: 0=off 1=on"); |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 53 | module_param(edac_mc_log_ce, int, 0644); |
| 54 | MODULE_PARM_DESC(edac_mc_log_ce, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 55 | "Log correctable error to console: 0=off 1=on"); |
Dave Jiang | 4de78c6 | 2007-07-19 01:49:54 -0700 | [diff] [blame] | 56 | module_param(edac_mc_poll_msec, int, 0644); |
| 57 | MODULE_PARM_DESC(edac_mc_poll_msec, "Polling period in milliseconds"); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 58 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 59 | /* |
| 60 | * various constants for Memory Controllers |
| 61 | */ |
| 62 | static const char *mem_types[] = { |
| 63 | [MEM_EMPTY] = "Empty", |
| 64 | [MEM_RESERVED] = "Reserved", |
| 65 | [MEM_UNKNOWN] = "Unknown", |
| 66 | [MEM_FPM] = "FPM", |
| 67 | [MEM_EDO] = "EDO", |
| 68 | [MEM_BEDO] = "BEDO", |
| 69 | [MEM_SDR] = "Unbuffered-SDR", |
| 70 | [MEM_RDR] = "Registered-SDR", |
| 71 | [MEM_DDR] = "Unbuffered-DDR", |
| 72 | [MEM_RDDR] = "Registered-DDR", |
Dave Jiang | 1a9b85e | 2007-07-19 01:49:38 -0700 | [diff] [blame] | 73 | [MEM_RMBS] = "RMBS", |
| 74 | [MEM_DDR2] = "Unbuffered-DDR2", |
| 75 | [MEM_FB_DDR2] = "FullyBuffered-DDR2", |
| 76 | [MEM_RDDR2] = "Registered-DDR2" |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static const char *dev_types[] = { |
| 80 | [DEV_UNKNOWN] = "Unknown", |
| 81 | [DEV_X1] = "x1", |
| 82 | [DEV_X2] = "x2", |
| 83 | [DEV_X4] = "x4", |
| 84 | [DEV_X8] = "x8", |
| 85 | [DEV_X16] = "x16", |
| 86 | [DEV_X32] = "x32", |
| 87 | [DEV_X64] = "x64" |
| 88 | }; |
| 89 | |
| 90 | static const char *edac_caps[] = { |
| 91 | [EDAC_UNKNOWN] = "Unknown", |
| 92 | [EDAC_NONE] = "None", |
| 93 | [EDAC_RESERVED] = "Reserved", |
| 94 | [EDAC_PARITY] = "PARITY", |
| 95 | [EDAC_EC] = "EC", |
| 96 | [EDAC_SECDED] = "SECDED", |
| 97 | [EDAC_S2ECD2ED] = "S2ECD2ED", |
| 98 | [EDAC_S4ECD4ED] = "S4ECD4ED", |
| 99 | [EDAC_S8ECD8ED] = "S8ECD8ED", |
| 100 | [EDAC_S16ECD16ED] = "S16ECD16ED" |
| 101 | }; |
| 102 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 103 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * /sys/devices/system/edac/mc; |
| 107 | * data structures and methods |
| 108 | */ |
| 109 | static ssize_t memctrl_int_show(void *ptr, char *buffer) |
| 110 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 111 | int *value = (int *)ptr; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 112 | return sprintf(buffer, "%u\n", *value); |
| 113 | } |
| 114 | |
| 115 | static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count) |
| 116 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 117 | int *value = (int *)ptr; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 118 | |
| 119 | if (isdigit(*buffer)) |
| 120 | *value = simple_strtoul(buffer, NULL, 0); |
| 121 | |
| 122 | return count; |
| 123 | } |
| 124 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 125 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 126 | /* EDAC sysfs CSROW data structures and methods |
| 127 | */ |
| 128 | |
| 129 | /* Set of more default csrow<id> attribute show/store functions */ |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame] | 130 | static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 131 | int private) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 132 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 133 | return sprintf(data, "%u\n", csrow->ue_count); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame] | 136 | static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 137 | int private) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 138 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 139 | return sprintf(data, "%u\n", csrow->ce_count); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame] | 142 | static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 143 | int private) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 144 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 145 | return sprintf(data, "%u\n", PAGES_TO_MiB(csrow->nr_pages)); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 146 | } |
| 147 | |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame] | 148 | static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 149 | int private) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 150 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 151 | return sprintf(data, "%s\n", mem_types[csrow->mtype]); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame] | 154 | static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 155 | int private) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 156 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 157 | return sprintf(data, "%s\n", dev_types[csrow->dtype]); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame] | 160 | static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 161 | int private) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 162 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 163 | return sprintf(data, "%s\n", edac_caps[csrow->edac_mode]); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /* show/store functions for DIMM Label attributes */ |
| 167 | static ssize_t channel_dimm_label_show(struct csrow_info *csrow, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 168 | char *data, int channel) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 169 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 170 | return snprintf(data, EDAC_MC_LABEL_LEN, "%s", |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 171 | csrow->channels[channel].label); |
| 172 | } |
| 173 | |
| 174 | static ssize_t channel_dimm_label_store(struct csrow_info *csrow, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 175 | const char *data, |
| 176 | size_t count, int channel) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 177 | { |
| 178 | ssize_t max_size = 0; |
| 179 | |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 180 | max_size = min((ssize_t) count, (ssize_t) EDAC_MC_LABEL_LEN - 1); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 181 | strncpy(csrow->channels[channel].label, data, max_size); |
| 182 | csrow->channels[channel].label[max_size] = '\0'; |
| 183 | |
| 184 | return max_size; |
| 185 | } |
| 186 | |
| 187 | /* show function for dynamic chX_ce_count attribute */ |
| 188 | static ssize_t channel_ce_count_show(struct csrow_info *csrow, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 189 | char *data, int channel) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 190 | { |
| 191 | return sprintf(data, "%u\n", csrow->channels[channel].ce_count); |
| 192 | } |
| 193 | |
| 194 | /* csrow specific attribute structure */ |
| 195 | struct csrowdev_attribute { |
| 196 | struct attribute attr; |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 197 | ssize_t(*show) (struct csrow_info *, char *, int); |
| 198 | ssize_t(*store) (struct csrow_info *, const char *, size_t, int); |
| 199 | int private; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | #define to_csrow(k) container_of(k, struct csrow_info, kobj) |
| 203 | #define to_csrowdev_attr(a) container_of(a, struct csrowdev_attribute, attr) |
| 204 | |
| 205 | /* Set of show/store higher level functions for default csrow attributes */ |
| 206 | static ssize_t csrowdev_show(struct kobject *kobj, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 207 | struct attribute *attr, char *buffer) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 208 | { |
| 209 | struct csrow_info *csrow = to_csrow(kobj); |
| 210 | struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr); |
| 211 | |
| 212 | if (csrowdev_attr->show) |
| 213 | return csrowdev_attr->show(csrow, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 214 | buffer, csrowdev_attr->private); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 215 | return -EIO; |
| 216 | } |
| 217 | |
| 218 | static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 219 | const char *buffer, size_t count) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 220 | { |
| 221 | struct csrow_info *csrow = to_csrow(kobj); |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 222 | struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 223 | |
| 224 | if (csrowdev_attr->store) |
| 225 | return csrowdev_attr->store(csrow, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 226 | buffer, |
| 227 | count, csrowdev_attr->private); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 228 | return -EIO; |
| 229 | } |
| 230 | |
| 231 | static struct sysfs_ops csrowfs_ops = { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 232 | .show = csrowdev_show, |
| 233 | .store = csrowdev_store |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 234 | }; |
| 235 | |
| 236 | #define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \ |
| 237 | static struct csrowdev_attribute attr_##_name = { \ |
| 238 | .attr = {.name = __stringify(_name), .mode = _mode }, \ |
| 239 | .show = _show, \ |
| 240 | .store = _store, \ |
| 241 | .private = _private, \ |
| 242 | }; |
| 243 | |
| 244 | /* default cwrow<id>/attribute files */ |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 245 | CSROWDEV_ATTR(size_mb, S_IRUGO, csrow_size_show, NULL, 0); |
| 246 | CSROWDEV_ATTR(dev_type, S_IRUGO, csrow_dev_type_show, NULL, 0); |
| 247 | CSROWDEV_ATTR(mem_type, S_IRUGO, csrow_mem_type_show, NULL, 0); |
| 248 | CSROWDEV_ATTR(edac_mode, S_IRUGO, csrow_edac_mode_show, NULL, 0); |
| 249 | CSROWDEV_ATTR(ue_count, S_IRUGO, csrow_ue_count_show, NULL, 0); |
| 250 | CSROWDEV_ATTR(ce_count, S_IRUGO, csrow_ce_count_show, NULL, 0); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 251 | |
| 252 | /* default attributes of the CSROW<id> object */ |
| 253 | static struct csrowdev_attribute *default_csrow_attr[] = { |
| 254 | &attr_dev_type, |
| 255 | &attr_mem_type, |
| 256 | &attr_edac_mode, |
| 257 | &attr_size_mb, |
| 258 | &attr_ue_count, |
| 259 | &attr_ce_count, |
| 260 | NULL, |
| 261 | }; |
| 262 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 263 | /* possible dynamic channel DIMM Label attribute files */ |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 264 | CSROWDEV_ATTR(ch0_dimm_label, S_IRUGO | S_IWUSR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 265 | channel_dimm_label_show, channel_dimm_label_store, 0); |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 266 | CSROWDEV_ATTR(ch1_dimm_label, S_IRUGO | S_IWUSR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 267 | channel_dimm_label_show, channel_dimm_label_store, 1); |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 268 | CSROWDEV_ATTR(ch2_dimm_label, S_IRUGO | S_IWUSR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 269 | channel_dimm_label_show, channel_dimm_label_store, 2); |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 270 | CSROWDEV_ATTR(ch3_dimm_label, S_IRUGO | S_IWUSR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 271 | channel_dimm_label_show, channel_dimm_label_store, 3); |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 272 | CSROWDEV_ATTR(ch4_dimm_label, S_IRUGO | S_IWUSR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 273 | channel_dimm_label_show, channel_dimm_label_store, 4); |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 274 | CSROWDEV_ATTR(ch5_dimm_label, S_IRUGO | S_IWUSR, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 275 | channel_dimm_label_show, channel_dimm_label_store, 5); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 276 | |
| 277 | /* Total possible dynamic DIMM Label attribute file table */ |
| 278 | static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 279 | &attr_ch0_dimm_label, |
| 280 | &attr_ch1_dimm_label, |
| 281 | &attr_ch2_dimm_label, |
| 282 | &attr_ch3_dimm_label, |
| 283 | &attr_ch4_dimm_label, |
| 284 | &attr_ch5_dimm_label |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | /* possible dynamic channel ce_count attribute files */ |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 288 | CSROWDEV_ATTR(ch0_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 0); |
| 289 | CSROWDEV_ATTR(ch1_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 1); |
| 290 | CSROWDEV_ATTR(ch2_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 2); |
| 291 | CSROWDEV_ATTR(ch3_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 3); |
| 292 | CSROWDEV_ATTR(ch4_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 4); |
| 293 | CSROWDEV_ATTR(ch5_ce_count, S_IRUGO | S_IWUSR, channel_ce_count_show, NULL, 5); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 294 | |
| 295 | /* Total possible dynamic ce_count attribute file table */ |
| 296 | static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 297 | &attr_ch0_ce_count, |
| 298 | &attr_ch1_ce_count, |
| 299 | &attr_ch2_ce_count, |
| 300 | &attr_ch3_ce_count, |
| 301 | &attr_ch4_ce_count, |
| 302 | &attr_ch5_ce_count |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 303 | }; |
| 304 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 305 | #define EDAC_NR_CHANNELS 6 |
| 306 | |
| 307 | /* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */ |
| 308 | static int edac_create_channel_files(struct kobject *kobj, int chan) |
| 309 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 310 | int err = -ENODEV; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 311 | |
| 312 | if (chan >= EDAC_NR_CHANNELS) |
| 313 | return err; |
| 314 | |
| 315 | /* create the DIMM label attribute file */ |
| 316 | err = sysfs_create_file(kobj, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 317 | (struct attribute *) |
| 318 | dynamic_csrow_dimm_attr[chan]); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 319 | |
| 320 | if (!err) { |
| 321 | /* create the CE Count attribute file */ |
| 322 | err = sysfs_create_file(kobj, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 323 | (struct attribute *) |
| 324 | dynamic_csrow_ce_count_attr[chan]); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 325 | } else { |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame] | 326 | debugf1("%s() dimm labels and ce_count files created", |
| 327 | __func__); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | return err; |
| 331 | } |
| 332 | |
| 333 | /* No memory to release for this kobj */ |
| 334 | static void edac_csrow_instance_release(struct kobject *kobj) |
| 335 | { |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 336 | struct mem_ctl_info *mci; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 337 | struct csrow_info *cs; |
| 338 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 339 | debugf1("%s()\n", __func__); |
| 340 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 341 | cs = container_of(kobj, struct csrow_info, kobj); |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 342 | mci = cs->mci; |
| 343 | |
| 344 | kobject_put(&mci->edac_mci_kobj); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | /* the kobj_type instance for a CSROW */ |
| 348 | static struct kobj_type ktype_csrow = { |
| 349 | .release = edac_csrow_instance_release, |
| 350 | .sysfs_ops = &csrowfs_ops, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 351 | .default_attrs = (struct attribute **)default_csrow_attr, |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 352 | }; |
| 353 | |
| 354 | /* Create a CSROW object under specifed edac_mc_device */ |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 355 | static int edac_create_csrow_object(struct mem_ctl_info *mci, |
| 356 | struct csrow_info *csrow, int index) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 357 | { |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 358 | struct kobject *kobj_mci = &mci->edac_mci_kobj; |
| 359 | struct kobject *kobj; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 360 | int chan; |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 361 | int err; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 362 | |
| 363 | /* generate ..../edac/mc/mc<id>/csrow<index> */ |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 364 | memset(&csrow->kobj, 0, sizeof(csrow->kobj)); |
| 365 | csrow->mci = mci; /* include container up link */ |
| 366 | csrow->kobj.parent = kobj_mci; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 367 | csrow->kobj.ktype = &ktype_csrow; |
| 368 | |
| 369 | /* name this instance of csrow<id> */ |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 370 | err = kobject_set_name(&csrow->kobj, "csrow%d", index); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 371 | if (err) |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 372 | goto err_out; |
| 373 | |
| 374 | /* bump the mci instance's kobject's ref count */ |
| 375 | kobj = kobject_get(&mci->edac_mci_kobj); |
| 376 | if (!kobj) { |
| 377 | err = -ENODEV; |
| 378 | goto err_out; |
| 379 | } |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 380 | |
| 381 | /* Instanstiate the csrow object */ |
| 382 | err = kobject_register(&csrow->kobj); |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 383 | if (err) |
| 384 | goto err_release_top_kobj; |
| 385 | |
| 386 | /* At this point, to release a csrow kobj, one must |
| 387 | * call the kobject_unregister and allow that tear down |
| 388 | * to work the releasing |
| 389 | */ |
| 390 | |
| 391 | /* Create the dyanmic attribute files on this csrow, |
| 392 | * namely, the DIMM labels and the channel ce_count |
| 393 | */ |
| 394 | for (chan = 0; chan < csrow->nr_channels; chan++) { |
| 395 | err = edac_create_channel_files(&csrow->kobj, chan); |
| 396 | if (err) { |
| 397 | /* special case the unregister here */ |
| 398 | kobject_unregister(&csrow->kobj); |
| 399 | goto err_out; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 400 | } |
| 401 | } |
| 402 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 403 | return 0; |
| 404 | |
| 405 | /* error unwind stack */ |
| 406 | err_release_top_kobj: |
| 407 | kobject_put(&mci->edac_mci_kobj); |
| 408 | |
| 409 | err_out: |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 410 | return err; |
| 411 | } |
| 412 | |
| 413 | /* default sysfs methods and data structures for the main MCI kobject */ |
| 414 | |
| 415 | static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 416 | const char *data, size_t count) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 417 | { |
| 418 | int row, chan; |
| 419 | |
| 420 | mci->ue_noinfo_count = 0; |
| 421 | mci->ce_noinfo_count = 0; |
| 422 | mci->ue_count = 0; |
| 423 | mci->ce_count = 0; |
| 424 | |
| 425 | for (row = 0; row < mci->nr_csrows; row++) { |
| 426 | struct csrow_info *ri = &mci->csrows[row]; |
| 427 | |
| 428 | ri->ue_count = 0; |
| 429 | ri->ce_count = 0; |
| 430 | |
| 431 | for (chan = 0; chan < ri->nr_channels; chan++) |
| 432 | ri->channels[chan].ce_count = 0; |
| 433 | } |
| 434 | |
| 435 | mci->start_time = jiffies; |
| 436 | return count; |
| 437 | } |
| 438 | |
| 439 | /* memory scrubbing */ |
| 440 | static ssize_t mci_sdram_scrub_rate_store(struct mem_ctl_info *mci, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 441 | const char *data, size_t count) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 442 | { |
| 443 | u32 bandwidth = -1; |
| 444 | |
| 445 | if (mci->set_sdram_scrub_rate) { |
| 446 | |
| 447 | memctrl_int_store(&bandwidth, data, count); |
| 448 | |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 449 | if (!(*mci->set_sdram_scrub_rate) (mci, &bandwidth)) { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 450 | edac_printk(KERN_DEBUG, EDAC_MC, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 451 | "Scrub rate set successfully, applied: %d\n", |
| 452 | bandwidth); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 453 | } else { |
| 454 | /* FIXME: error codes maybe? */ |
| 455 | edac_printk(KERN_DEBUG, EDAC_MC, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 456 | "Scrub rate set FAILED, could not apply: %d\n", |
| 457 | bandwidth); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 458 | } |
| 459 | } else { |
| 460 | /* FIXME: produce "not implemented" ERROR for user-side. */ |
| 461 | edac_printk(KERN_WARNING, EDAC_MC, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 462 | "Memory scrubbing 'set'control is not implemented!\n"); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 463 | } |
| 464 | return count; |
| 465 | } |
| 466 | |
| 467 | static ssize_t mci_sdram_scrub_rate_show(struct mem_ctl_info *mci, char *data) |
| 468 | { |
| 469 | u32 bandwidth = -1; |
| 470 | |
| 471 | if (mci->get_sdram_scrub_rate) { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 472 | if (!(*mci->get_sdram_scrub_rate) (mci, &bandwidth)) { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 473 | edac_printk(KERN_DEBUG, EDAC_MC, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 474 | "Scrub rate successfully, fetched: %d\n", |
| 475 | bandwidth); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 476 | } else { |
| 477 | /* FIXME: error codes maybe? */ |
| 478 | edac_printk(KERN_DEBUG, EDAC_MC, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 479 | "Scrub rate fetch FAILED, got: %d\n", |
| 480 | bandwidth); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 481 | } |
| 482 | } else { |
| 483 | /* FIXME: produce "not implemented" ERROR for user-side. */ |
| 484 | edac_printk(KERN_WARNING, EDAC_MC, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 485 | "Memory scrubbing 'get' control is not implemented\n"); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 486 | } |
| 487 | return sprintf(data, "%d\n", bandwidth); |
| 488 | } |
| 489 | |
| 490 | /* default attribute files for the MCI object */ |
| 491 | static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data) |
| 492 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 493 | return sprintf(data, "%d\n", mci->ue_count); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data) |
| 497 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 498 | return sprintf(data, "%d\n", mci->ce_count); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data) |
| 502 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 503 | return sprintf(data, "%d\n", mci->ce_noinfo_count); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data) |
| 507 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 508 | return sprintf(data, "%d\n", mci->ue_noinfo_count); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data) |
| 512 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 513 | return sprintf(data, "%ld\n", (jiffies - mci->start_time) / HZ); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data) |
| 517 | { |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 518 | return sprintf(data, "%s\n", mci->ctl_name); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data) |
| 522 | { |
| 523 | int total_pages, csrow_idx; |
| 524 | |
| 525 | for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows; |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 526 | csrow_idx++) { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 527 | struct csrow_info *csrow = &mci->csrows[csrow_idx]; |
| 528 | |
| 529 | if (!csrow->nr_pages) |
| 530 | continue; |
| 531 | |
| 532 | total_pages += csrow->nr_pages; |
| 533 | } |
| 534 | |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 535 | return sprintf(data, "%u\n", PAGES_TO_MiB(total_pages)); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 538 | #define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj) |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 539 | #define to_mcidev_attr(a) container_of(a,struct mcidev_sysfs_attribute,attr) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 540 | |
| 541 | /* MCI show/store functions for top most object */ |
| 542 | static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 543 | char *buffer) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 544 | { |
| 545 | struct mem_ctl_info *mem_ctl_info = to_mci(kobj); |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 546 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 547 | |
| 548 | if (mcidev_attr->show) |
| 549 | return mcidev_attr->show(mem_ctl_info, buffer); |
| 550 | |
| 551 | return -EIO; |
| 552 | } |
| 553 | |
| 554 | static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 555 | const char *buffer, size_t count) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 556 | { |
| 557 | struct mem_ctl_info *mem_ctl_info = to_mci(kobj); |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 558 | struct mcidev_sysfs_attribute *mcidev_attr = to_mcidev_attr(attr); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 559 | |
| 560 | if (mcidev_attr->store) |
| 561 | return mcidev_attr->store(mem_ctl_info, buffer, count); |
| 562 | |
| 563 | return -EIO; |
| 564 | } |
| 565 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 566 | /* Intermediate show/store table */ |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 567 | static struct sysfs_ops mci_ops = { |
| 568 | .show = mcidev_show, |
| 569 | .store = mcidev_store |
| 570 | }; |
| 571 | |
| 572 | #define MCIDEV_ATTR(_name,_mode,_show,_store) \ |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 573 | static struct mcidev_sysfs_attribute mci_attr_##_name = { \ |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 574 | .attr = {.name = __stringify(_name), .mode = _mode }, \ |
| 575 | .show = _show, \ |
| 576 | .store = _store, \ |
| 577 | }; |
| 578 | |
| 579 | /* default Control file */ |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 580 | MCIDEV_ATTR(reset_counters, S_IWUSR, NULL, mci_reset_counters_store); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 581 | |
| 582 | /* default Attribute files */ |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 583 | MCIDEV_ATTR(mc_name, S_IRUGO, mci_ctl_name_show, NULL); |
| 584 | MCIDEV_ATTR(size_mb, S_IRUGO, mci_size_mb_show, NULL); |
| 585 | MCIDEV_ATTR(seconds_since_reset, S_IRUGO, mci_seconds_show, NULL); |
| 586 | MCIDEV_ATTR(ue_noinfo_count, S_IRUGO, mci_ue_noinfo_show, NULL); |
| 587 | MCIDEV_ATTR(ce_noinfo_count, S_IRUGO, mci_ce_noinfo_show, NULL); |
| 588 | MCIDEV_ATTR(ue_count, S_IRUGO, mci_ue_count_show, NULL); |
| 589 | MCIDEV_ATTR(ce_count, S_IRUGO, mci_ce_count_show, NULL); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 590 | |
| 591 | /* memory scrubber attribute file */ |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 592 | MCIDEV_ATTR(sdram_scrub_rate, S_IRUGO | S_IWUSR, mci_sdram_scrub_rate_show, |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 593 | mci_sdram_scrub_rate_store); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 594 | |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 595 | static struct mcidev_sysfs_attribute *mci_attr[] = { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 596 | &mci_attr_reset_counters, |
| 597 | &mci_attr_mc_name, |
| 598 | &mci_attr_size_mb, |
| 599 | &mci_attr_seconds_since_reset, |
| 600 | &mci_attr_ue_noinfo_count, |
| 601 | &mci_attr_ce_noinfo_count, |
| 602 | &mci_attr_ue_count, |
| 603 | &mci_attr_ce_count, |
| 604 | &mci_attr_sdram_scrub_rate, |
| 605 | NULL |
| 606 | }; |
| 607 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 608 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 609 | /* |
| 610 | * Release of a MC controlling instance |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 611 | * |
| 612 | * each MC control instance has the following resources upon entry: |
| 613 | * a) a ref count on the top memctl kobj |
| 614 | * b) a ref count on this module |
| 615 | * |
| 616 | * this function must decrement those ref counts and then |
| 617 | * issue a free on the instance's memory |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 618 | */ |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 619 | static void edac_mci_control_release(struct kobject *kobj) |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 620 | { |
| 621 | struct mem_ctl_info *mci; |
| 622 | |
| 623 | mci = to_mci(kobj); |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 624 | |
| 625 | debugf0("%s() mci instance idx=%d releasing\n", __func__, mci->mc_idx); |
| 626 | |
| 627 | /* decrement the module ref count */ |
| 628 | module_put(mci->owner); |
| 629 | |
| 630 | /* free the mci instance memory here */ |
| 631 | kfree(mci); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | static struct kobj_type ktype_mci = { |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 635 | .release = edac_mci_control_release, |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 636 | .sysfs_ops = &mci_ops, |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 637 | .default_attrs = (struct attribute **)mci_attr, |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 638 | }; |
| 639 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 640 | /* show/store, tables, etc for the MC kset */ |
| 641 | |
| 642 | |
| 643 | struct memctrl_dev_attribute { |
| 644 | struct attribute attr; |
| 645 | void *value; |
| 646 | ssize_t(*show) (void *, char *); |
| 647 | ssize_t(*store) (void *, const char *, size_t); |
| 648 | }; |
| 649 | |
| 650 | /* Set of show/store abstract level functions for memory control object */ |
| 651 | static ssize_t memctrl_dev_show(struct kobject *kobj, |
| 652 | struct attribute *attr, char *buffer) |
| 653 | { |
| 654 | struct memctrl_dev_attribute *memctrl_dev; |
| 655 | memctrl_dev = (struct memctrl_dev_attribute *)attr; |
| 656 | |
| 657 | if (memctrl_dev->show) |
| 658 | return memctrl_dev->show(memctrl_dev->value, buffer); |
| 659 | |
| 660 | return -EIO; |
| 661 | } |
| 662 | |
| 663 | static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr, |
| 664 | const char *buffer, size_t count) |
| 665 | { |
| 666 | struct memctrl_dev_attribute *memctrl_dev; |
| 667 | memctrl_dev = (struct memctrl_dev_attribute *)attr; |
| 668 | |
| 669 | if (memctrl_dev->store) |
| 670 | return memctrl_dev->store(memctrl_dev->value, buffer, count); |
| 671 | |
| 672 | return -EIO; |
| 673 | } |
| 674 | |
| 675 | static struct sysfs_ops memctrlfs_ops = { |
| 676 | .show = memctrl_dev_show, |
| 677 | .store = memctrl_dev_store |
| 678 | }; |
| 679 | |
| 680 | #define MEMCTRL_ATTR(_name, _mode, _show, _store) \ |
| 681 | static struct memctrl_dev_attribute attr_##_name = { \ |
| 682 | .attr = {.name = __stringify(_name), .mode = _mode }, \ |
| 683 | .value = &_name, \ |
| 684 | .show = _show, \ |
| 685 | .store = _store, \ |
| 686 | }; |
| 687 | |
| 688 | #define MEMCTRL_STRING_ATTR(_name, _data, _mode, _show, _store) \ |
| 689 | static struct memctrl_dev_attribute attr_##_name = { \ |
| 690 | .attr = {.name = __stringify(_name), .mode = _mode }, \ |
| 691 | .value = _data, \ |
| 692 | .show = _show, \ |
| 693 | .store = _store, \ |
| 694 | }; |
| 695 | |
| 696 | /* csrow<id> control files */ |
| 697 | MEMCTRL_ATTR(edac_mc_panic_on_ue, |
| 698 | S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); |
| 699 | |
| 700 | MEMCTRL_ATTR(edac_mc_log_ue, |
| 701 | S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); |
| 702 | |
| 703 | MEMCTRL_ATTR(edac_mc_log_ce, |
| 704 | S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); |
| 705 | |
| 706 | MEMCTRL_ATTR(edac_mc_poll_msec, |
| 707 | S_IRUGO | S_IWUSR, memctrl_int_show, memctrl_int_store); |
| 708 | |
| 709 | /* Base Attributes of the memory ECC object */ |
| 710 | static struct memctrl_dev_attribute *memctrl_attr[] = { |
| 711 | &attr_edac_mc_panic_on_ue, |
| 712 | &attr_edac_mc_log_ue, |
| 713 | &attr_edac_mc_log_ce, |
| 714 | &attr_edac_mc_poll_msec, |
| 715 | NULL, |
| 716 | }; |
| 717 | |
| 718 | |
| 719 | /* the ktype for the mc_kset internal kobj */ |
| 720 | static struct kobj_type ktype_mc_set_attribs = { |
| 721 | .sysfs_ops = &memctrlfs_ops, |
| 722 | .default_attrs = (struct attribute **)memctrl_attr, |
| 723 | }; |
| 724 | |
| 725 | /* EDAC memory controller sysfs kset: |
| 726 | * /sys/devices/system/edac/mc |
| 727 | */ |
| 728 | static struct kset mc_kset = { |
| 729 | .kobj = {.name = "mc", .ktype = &ktype_mc_set_attribs }, |
| 730 | .ktype = &ktype_mci, |
| 731 | }; |
| 732 | |
| 733 | |
| 734 | /* |
| 735 | * edac_mc_register_sysfs_main_kobj |
| 736 | * |
| 737 | * setups and registers the main kobject for each mci |
| 738 | */ |
| 739 | int edac_mc_register_sysfs_main_kobj(struct mem_ctl_info *mci) |
| 740 | { |
| 741 | struct kobject *kobj_mci; |
| 742 | int err; |
| 743 | |
| 744 | debugf1("%s()\n", __func__); |
| 745 | |
| 746 | kobj_mci = &mci->edac_mci_kobj; |
| 747 | |
| 748 | /* Init the mci's kobject */ |
| 749 | memset(kobj_mci, 0, sizeof(*kobj_mci)); |
| 750 | |
| 751 | /* this instance become part of the mc_kset */ |
| 752 | kobj_mci->kset = &mc_kset; |
| 753 | |
| 754 | /* set the name of the mc<id> object */ |
| 755 | err = kobject_set_name(kobj_mci, "mc%d", mci->mc_idx); |
| 756 | if (err) |
| 757 | goto fail_out; |
| 758 | |
| 759 | /* Record which module 'owns' this control structure |
| 760 | * and bump the ref count of the module |
| 761 | */ |
| 762 | mci->owner = THIS_MODULE; |
| 763 | |
| 764 | /* bump ref count on this module */ |
| 765 | if (!try_module_get(mci->owner)) { |
| 766 | err = -ENODEV; |
| 767 | goto fail_out; |
| 768 | } |
| 769 | |
| 770 | /* register the mc<id> kobject to the mc_kset */ |
| 771 | err = kobject_register(kobj_mci); |
| 772 | if (err) { |
| 773 | debugf1("%s()Failed to register '.../edac/mc%d'\n", |
| 774 | __func__, mci->mc_idx); |
| 775 | goto kobj_reg_fail; |
| 776 | } |
| 777 | |
| 778 | /* At this point, to 'free' the control struct, |
| 779 | * edac_mc_unregister_sysfs_main_kobj() must be used |
| 780 | */ |
| 781 | |
| 782 | debugf1("%s() Registered '.../edac/mc%d' kobject\n", |
| 783 | __func__, mci->mc_idx); |
| 784 | |
| 785 | return 0; |
| 786 | |
| 787 | /* Error exit stack */ |
| 788 | |
| 789 | kobj_reg_fail: |
| 790 | module_put(mci->owner); |
| 791 | |
| 792 | fail_out: |
| 793 | return err; |
| 794 | } |
| 795 | |
| 796 | /* |
| 797 | * edac_mc_register_sysfs_main_kobj |
| 798 | * |
| 799 | * tears down and the main mci kobject from the mc_kset |
| 800 | */ |
| 801 | void edac_mc_unregister_sysfs_main_kobj(struct mem_ctl_info *mci) |
| 802 | { |
| 803 | /* delete the kobj from the mc_kset */ |
| 804 | kobject_unregister(&mci->edac_mci_kobj); |
| 805 | } |
| 806 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 807 | #define EDAC_DEVICE_SYMLINK "device" |
| 808 | |
| 809 | /* |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 810 | * edac_create_mci_instance_attributes |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 811 | * create MC driver specific attributes at the topmost level |
| 812 | * directory of this mci instance. |
| 813 | */ |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 814 | static int edac_create_mci_instance_attributes(struct mem_ctl_info *mci) |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 815 | { |
| 816 | int err; |
| 817 | struct mcidev_sysfs_attribute *sysfs_attrib; |
| 818 | |
| 819 | /* point to the start of the array and iterate over it |
| 820 | * adding each attribute listed to this mci instance's kobject |
| 821 | */ |
| 822 | sysfs_attrib = mci->mc_driver_sysfs_attributes; |
| 823 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 824 | while (sysfs_attrib && sysfs_attrib->attr.name) { |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 825 | err = sysfs_create_file(&mci->edac_mci_kobj, |
| 826 | (struct attribute*) sysfs_attrib); |
| 827 | if (err) { |
| 828 | return err; |
| 829 | } |
| 830 | |
| 831 | sysfs_attrib++; |
| 832 | } |
| 833 | |
| 834 | return 0; |
| 835 | } |
| 836 | |
| 837 | /* |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 838 | * edac_remove_mci_instance_attributes |
| 839 | * remove MC driver specific attributes at the topmost level |
| 840 | * directory of this mci instance. |
| 841 | */ |
| 842 | static void edac_remove_mci_instance_attributes(struct mem_ctl_info *mci) |
| 843 | { |
| 844 | struct mcidev_sysfs_attribute *sysfs_attrib; |
| 845 | |
| 846 | /* point to the start of the array and iterate over it |
| 847 | * adding each attribute listed to this mci instance's kobject |
| 848 | */ |
| 849 | sysfs_attrib = mci->mc_driver_sysfs_attributes; |
| 850 | |
| 851 | /* loop if there are attributes and until we hit a NULL entry */ |
| 852 | while (sysfs_attrib && sysfs_attrib->attr.name) { |
| 853 | sysfs_remove_file(&mci->edac_mci_kobj, |
| 854 | (struct attribute *) sysfs_attrib); |
| 855 | sysfs_attrib++; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | |
| 860 | /* |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 861 | * Create a new Memory Controller kobject instance, |
| 862 | * mc<id> under the 'mc' directory |
| 863 | * |
| 864 | * Return: |
| 865 | * 0 Success |
| 866 | * !0 Failure |
| 867 | */ |
| 868 | int edac_create_sysfs_mci_device(struct mem_ctl_info *mci) |
| 869 | { |
| 870 | int i; |
| 871 | int err; |
| 872 | struct csrow_info *csrow; |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 873 | struct kobject *kobj_mci = &mci->edac_mci_kobj; |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 874 | |
| 875 | debugf0("%s() idx=%d\n", __func__, mci->mc_idx); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 876 | |
| 877 | /* create a symlink for the device */ |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 878 | err = sysfs_create_link(kobj_mci, &mci->dev->kobj, |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 879 | EDAC_DEVICE_SYMLINK); |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 880 | if (err) { |
| 881 | debugf1("%s() failure to create symlink\n", __func__); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 882 | goto fail0; |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 883 | } |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 884 | |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 885 | /* If the low level driver desires some attributes, |
| 886 | * then create them now for the driver. |
| 887 | */ |
| 888 | if (mci->mc_driver_sysfs_attributes) { |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 889 | err = edac_create_mci_instance_attributes(mci); |
| 890 | if (err) { |
| 891 | debugf1("%s() failure to create mci attributes\n", |
| 892 | __func__); |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 893 | goto fail0; |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 894 | } |
Douglas Thompson | 42a8e39 | 2007-07-19 01:50:10 -0700 | [diff] [blame] | 895 | } |
| 896 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 897 | /* Make directories for each CSROW object under the mc<id> kobject |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 898 | */ |
| 899 | for (i = 0; i < mci->nr_csrows; i++) { |
| 900 | csrow = &mci->csrows[i]; |
| 901 | |
| 902 | /* Only expose populated CSROWs */ |
| 903 | if (csrow->nr_pages > 0) { |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 904 | err = edac_create_csrow_object(mci, csrow, i); |
| 905 | if (err) { |
| 906 | debugf1("%s() failure: create csrow %d obj\n", |
| 907 | __func__, i); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 908 | goto fail1; |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 909 | } |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 910 | } |
| 911 | } |
| 912 | |
| 913 | return 0; |
| 914 | |
| 915 | /* CSROW error: backout what has already been registered, */ |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 916 | fail1: |
Douglas Thompson | 079708b | 2007-07-19 01:49:58 -0700 | [diff] [blame] | 917 | for (i--; i >= 0; i--) { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 918 | if (csrow->nr_pages > 0) { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 919 | kobject_unregister(&mci->csrows[i].kobj); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 920 | } |
| 921 | } |
| 922 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 923 | /* remove the mci instance's attributes, if any */ |
| 924 | edac_remove_mci_instance_attributes(mci); |
| 925 | |
| 926 | /* remove the symlink */ |
| 927 | sysfs_remove_link(kobj_mci, EDAC_DEVICE_SYMLINK); |
| 928 | |
Douglas Thompson | 052dfb4 | 2007-07-19 01:50:13 -0700 | [diff] [blame] | 929 | fail0: |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 930 | return err; |
| 931 | } |
| 932 | |
| 933 | /* |
| 934 | * remove a Memory Controller instance |
| 935 | */ |
| 936 | void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) |
| 937 | { |
| 938 | int i; |
| 939 | |
| 940 | debugf0("%s()\n", __func__); |
| 941 | |
| 942 | /* remove all csrow kobjects */ |
| 943 | for (i = 0; i < mci->nr_csrows; i++) { |
| 944 | if (mci->csrows[i].nr_pages > 0) { |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 945 | debugf0("%s() unreg csrow-%d\n", __func__, i); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 946 | kobject_unregister(&mci->csrows[i].kobj); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 947 | } |
| 948 | } |
| 949 | |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 950 | debugf0("%s() remove_link\n", __func__); |
| 951 | |
| 952 | /* remove the symlink */ |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 953 | sysfs_remove_link(&mci->edac_mci_kobj, EDAC_DEVICE_SYMLINK); |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 954 | |
| 955 | debugf0("%s() remove_mci_instance\n", __func__); |
| 956 | |
| 957 | /* remove this mci instance's attribtes */ |
| 958 | edac_remove_mci_instance_attributes(mci); |
| 959 | |
| 960 | debugf0("%s() unregister this mci kobj\n", __func__); |
| 961 | |
| 962 | /* unregister this instance's kobject */ |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 963 | kobject_unregister(&mci->edac_mci_kobj); |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 964 | } |
Doug Thompson | 8096cfa | 2007-07-19 01:50:27 -0700 | [diff] [blame] | 965 | |
| 966 | |
| 967 | |
| 968 | |
| 969 | /* |
| 970 | * edac_setup_sysfs_mc_kset(void) |
| 971 | * |
| 972 | * Initialize the mc_kset for the 'mc' entry |
| 973 | * This requires creating the top 'mc' directory with a kset |
| 974 | * and its controls/attributes. |
| 975 | * |
| 976 | * To this 'mc' kset, instance 'mci' will be grouped as children. |
| 977 | * |
| 978 | * Return: 0 SUCCESS |
| 979 | * !0 FAILURE error code |
| 980 | */ |
| 981 | int edac_sysfs_setup_mc_kset(void) |
| 982 | { |
| 983 | int err = 0; |
| 984 | struct sysdev_class *edac_class; |
| 985 | |
| 986 | debugf1("%s()\n", __func__); |
| 987 | |
| 988 | /* get the /sys/devices/system/edac class reference */ |
| 989 | edac_class = edac_get_edac_class(); |
| 990 | if (edac_class == NULL) { |
| 991 | debugf1("%s() no edac_class error=%d\n", __func__, err); |
| 992 | goto fail_out; |
| 993 | } |
| 994 | |
| 995 | /* Init the MC's kobject */ |
| 996 | mc_kset.kobj.parent = &edac_class->kset.kobj; |
| 997 | |
| 998 | /* register the mc_kset */ |
| 999 | err = kset_register(&mc_kset); |
| 1000 | if (err) { |
| 1001 | debugf1("%s() Failed to register '.../edac/mc'\n", __func__); |
| 1002 | goto fail_out; |
| 1003 | } |
| 1004 | |
| 1005 | debugf1("%s() Registered '.../edac/mc' kobject\n", __func__); |
| 1006 | |
| 1007 | return 0; |
| 1008 | |
| 1009 | |
| 1010 | /* error unwind stack */ |
| 1011 | fail_out: |
| 1012 | return err; |
| 1013 | } |
| 1014 | |
| 1015 | /* |
| 1016 | * edac_sysfs_teardown_mc_kset |
| 1017 | * |
| 1018 | * deconstruct the mc_ket for memory controllers |
| 1019 | */ |
| 1020 | void edac_sysfs_teardown_mc_kset(void) |
| 1021 | { |
| 1022 | kset_unregister(&mc_kset); |
| 1023 | } |
| 1024 | |