Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 1 | /* |
| 2 | * edac_mc kernel module |
Doug Thompson | 49c0dab7 | 2006-07-10 04:45:19 -0700 | [diff] [blame] | 3 | * (C) 2005, 2006 Linux Networx (http://lnxi.com) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 4 | * This file may be distributed under the terms of the |
| 5 | * GNU General Public License. |
| 6 | * |
| 7 | * Written by Thayne Harbaugh |
| 8 | * Based on work by Dan Hollis <goemon at anime dot net> and others. |
| 9 | * http://www.anime.net/~goemon/linux-ecc/ |
| 10 | * |
| 11 | * Modified by Dave Peterson and Doug Thompson |
| 12 | * |
| 13 | */ |
| 14 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 15 | #include <linux/module.h> |
| 16 | #include <linux/proc_fs.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/types.h> |
| 19 | #include <linux/smp.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/sysctl.h> |
| 22 | #include <linux/highmem.h> |
| 23 | #include <linux/timer.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/jiffies.h> |
| 26 | #include <linux/spinlock.h> |
| 27 | #include <linux/list.h> |
| 28 | #include <linux/sysdev.h> |
| 29 | #include <linux/ctype.h> |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 30 | #include <asm/uaccess.h> |
| 31 | #include <asm/page.h> |
| 32 | #include <asm/edac.h> |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 33 | #include "edac_mc.h" |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 34 | #include "edac_module.h" |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 35 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 36 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 37 | /* lock to memory controller's control array */ |
| 38 | static DECLARE_MUTEX(mem_ctls_mutex); |
| 39 | static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices); |
| 40 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 41 | #ifdef CONFIG_EDAC_DEBUG |
| 42 | |
Adrian Bunk | 2da1c11 | 2007-07-19 01:49:32 -0700 | [diff] [blame] | 43 | static void edac_mc_dump_channel(struct channel_info *chan) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 44 | { |
| 45 | debugf4("\tchannel = %p\n", chan); |
| 46 | debugf4("\tchannel->chan_idx = %d\n", chan->chan_idx); |
| 47 | debugf4("\tchannel->ce_count = %d\n", chan->ce_count); |
| 48 | debugf4("\tchannel->label = '%s'\n", chan->label); |
| 49 | debugf4("\tchannel->csrow = %p\n\n", chan->csrow); |
| 50 | } |
| 51 | |
Adrian Bunk | 2da1c11 | 2007-07-19 01:49:32 -0700 | [diff] [blame] | 52 | static void edac_mc_dump_csrow(struct csrow_info *csrow) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 53 | { |
| 54 | debugf4("\tcsrow = %p\n", csrow); |
| 55 | debugf4("\tcsrow->csrow_idx = %d\n", csrow->csrow_idx); |
| 56 | debugf4("\tcsrow->first_page = 0x%lx\n", |
| 57 | csrow->first_page); |
| 58 | debugf4("\tcsrow->last_page = 0x%lx\n", csrow->last_page); |
| 59 | debugf4("\tcsrow->page_mask = 0x%lx\n", csrow->page_mask); |
| 60 | debugf4("\tcsrow->nr_pages = 0x%x\n", csrow->nr_pages); |
| 61 | debugf4("\tcsrow->nr_channels = %d\n", |
| 62 | csrow->nr_channels); |
| 63 | debugf4("\tcsrow->channels = %p\n", csrow->channels); |
| 64 | debugf4("\tcsrow->mci = %p\n\n", csrow->mci); |
| 65 | } |
| 66 | |
Adrian Bunk | 2da1c11 | 2007-07-19 01:49:32 -0700 | [diff] [blame] | 67 | static void edac_mc_dump_mci(struct mem_ctl_info *mci) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 68 | { |
| 69 | debugf3("\tmci = %p\n", mci); |
| 70 | debugf3("\tmci->mtype_cap = %lx\n", mci->mtype_cap); |
| 71 | debugf3("\tmci->edac_ctl_cap = %lx\n", mci->edac_ctl_cap); |
| 72 | debugf3("\tmci->edac_cap = %lx\n", mci->edac_cap); |
| 73 | debugf4("\tmci->edac_check = %p\n", mci->edac_check); |
| 74 | debugf3("\tmci->nr_csrows = %d, csrows = %p\n", |
| 75 | mci->nr_csrows, mci->csrows); |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 76 | debugf3("\tdev = %p\n", mci->dev); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 77 | debugf3("\tmod_name:ctl_name = %s:%s\n", |
| 78 | mci->mod_name, mci->ctl_name); |
| 79 | debugf3("\tpvt_info = %p\n\n", mci->pvt_info); |
| 80 | } |
| 81 | |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 82 | #endif /* CONFIG_EDAC_DEBUG */ |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 83 | |
| 84 | /* 'ptr' points to a possibly unaligned item X such that sizeof(X) is 'size'. |
| 85 | * Adjust 'ptr' so that its alignment is at least as stringent as what the |
| 86 | * compiler would provide for X and return the aligned result. |
| 87 | * |
| 88 | * If 'size' is a constant, the compiler will optimize this whole function |
| 89 | * down to either a no-op or the addition of a constant to the value of 'ptr'. |
| 90 | */ |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame^] | 91 | char * edac_align_ptr(void *ptr, unsigned size) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 92 | { |
| 93 | unsigned align, r; |
| 94 | |
| 95 | /* Here we assume that the alignment of a "long long" is the most |
| 96 | * stringent alignment that the compiler will ever provide by default. |
| 97 | * As far as I know, this is a reasonable assumption. |
| 98 | */ |
| 99 | if (size > sizeof(long)) |
| 100 | align = sizeof(long long); |
| 101 | else if (size > sizeof(int)) |
| 102 | align = sizeof(long); |
| 103 | else if (size > sizeof(short)) |
| 104 | align = sizeof(int); |
| 105 | else if (size > sizeof(char)) |
| 106 | align = sizeof(short); |
| 107 | else |
| 108 | return (char *) ptr; |
| 109 | |
| 110 | r = size % align; |
| 111 | |
| 112 | if (r == 0) |
| 113 | return (char *) ptr; |
| 114 | |
| 115 | return (char *) (((unsigned long) ptr) + align - r); |
| 116 | } |
| 117 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 118 | /** |
| 119 | * edac_mc_alloc: Allocate a struct mem_ctl_info structure |
| 120 | * @size_pvt: size of private storage needed |
| 121 | * @nr_csrows: Number of CWROWS needed for this MC |
| 122 | * @nr_chans: Number of channels for the MC |
| 123 | * |
| 124 | * Everything is kmalloc'ed as one big chunk - more efficient. |
| 125 | * Only can be used if all structures have the same lifetime - otherwise |
| 126 | * you have to allocate and initialize your own structures. |
| 127 | * |
| 128 | * Use edac_mc_free() to free mc structures allocated by this function. |
| 129 | * |
| 130 | * Returns: |
| 131 | * NULL allocation failed |
| 132 | * struct mem_ctl_info pointer |
| 133 | */ |
| 134 | struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 135 | unsigned nr_chans) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 136 | { |
| 137 | struct mem_ctl_info *mci; |
| 138 | struct csrow_info *csi, *csrow; |
| 139 | struct channel_info *chi, *chp, *chan; |
| 140 | void *pvt; |
| 141 | unsigned size; |
| 142 | int row, chn; |
| 143 | |
| 144 | /* Figure out the offsets of the various items from the start of an mc |
| 145 | * structure. We want the alignment of each item to be at least as |
| 146 | * stringent as what the compiler would provide if we could simply |
| 147 | * hardcode everything into a single struct. |
| 148 | */ |
| 149 | mci = (struct mem_ctl_info *) 0; |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame^] | 150 | csi = (struct csrow_info *)edac_align_ptr(&mci[1], sizeof(*csi)); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 151 | chi = (struct channel_info *) |
Douglas Thompson | e27e3da | 2007-07-19 01:49:36 -0700 | [diff] [blame^] | 152 | edac_align_ptr(&csi[nr_csrows], sizeof(*chi)); |
| 153 | pvt = edac_align_ptr(&chi[nr_chans * nr_csrows], sz_pvt); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 154 | size = ((unsigned long) pvt) + sz_pvt; |
| 155 | |
| 156 | if ((mci = kmalloc(size, GFP_KERNEL)) == NULL) |
| 157 | return NULL; |
| 158 | |
| 159 | /* Adjust pointers so they point within the memory we just allocated |
| 160 | * rather than an imaginary chunk of memory located at address 0. |
| 161 | */ |
| 162 | csi = (struct csrow_info *) (((char *) mci) + ((unsigned long) csi)); |
| 163 | chi = (struct channel_info *) (((char *) mci) + ((unsigned long) chi)); |
| 164 | pvt = sz_pvt ? (((char *) mci) + ((unsigned long) pvt)) : NULL; |
| 165 | |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 166 | memset(mci, 0, size); /* clear all fields */ |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 167 | mci->csrows = csi; |
| 168 | mci->pvt_info = pvt; |
| 169 | mci->nr_csrows = nr_csrows; |
| 170 | |
| 171 | for (row = 0; row < nr_csrows; row++) { |
| 172 | csrow = &csi[row]; |
| 173 | csrow->csrow_idx = row; |
| 174 | csrow->mci = mci; |
| 175 | csrow->nr_channels = nr_chans; |
| 176 | chp = &chi[row * nr_chans]; |
| 177 | csrow->channels = chp; |
| 178 | |
| 179 | for (chn = 0; chn < nr_chans; chn++) { |
| 180 | chan = &chp[chn]; |
| 181 | chan->chan_idx = chn; |
| 182 | chan->csrow = csrow; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | return mci; |
| 187 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 188 | EXPORT_SYMBOL_GPL(edac_mc_alloc); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 189 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 190 | /** |
| 191 | * edac_mc_free: Free a previously allocated 'mci' structure |
| 192 | * @mci: pointer to a struct mem_ctl_info structure |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 193 | */ |
| 194 | void edac_mc_free(struct mem_ctl_info *mci) |
| 195 | { |
Dave Peterson | 472678e | 2006-03-26 01:38:49 -0800 | [diff] [blame] | 196 | kfree(mci); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 197 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 198 | EXPORT_SYMBOL_GPL(edac_mc_free); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 199 | |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 200 | static struct mem_ctl_info *find_mci_by_dev(struct device *dev) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 201 | { |
| 202 | struct mem_ctl_info *mci; |
| 203 | struct list_head *item; |
| 204 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 205 | debugf3("%s()\n", __func__); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 206 | |
| 207 | list_for_each(item, &mc_devices) { |
| 208 | mci = list_entry(item, struct mem_ctl_info, link); |
| 209 | |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 210 | if (mci->dev == dev) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 211 | return mci; |
| 212 | } |
| 213 | |
| 214 | return NULL; |
| 215 | } |
| 216 | |
Doug Thompson | 2d7bbb9 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 217 | /* Return 0 on success, 1 on failure. |
| 218 | * Before calling this function, caller must |
| 219 | * assign a unique value to mci->mc_idx. |
| 220 | */ |
| 221 | static int add_mc_to_global_list (struct mem_ctl_info *mci) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 222 | { |
| 223 | struct list_head *item, *insert_before; |
| 224 | struct mem_ctl_info *p; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 225 | |
Doug Thompson | 2d7bbb9 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 226 | insert_before = &mc_devices; |
| 227 | |
| 228 | if (unlikely((p = find_mci_by_dev(mci->dev)) != NULL)) |
| 229 | goto fail0; |
| 230 | |
| 231 | list_for_each(item, &mc_devices) { |
| 232 | p = list_entry(item, struct mem_ctl_info, link); |
| 233 | |
| 234 | if (p->mc_idx >= mci->mc_idx) { |
| 235 | if (unlikely(p->mc_idx == mci->mc_idx)) |
| 236 | goto fail1; |
| 237 | |
| 238 | insert_before = item; |
| 239 | break; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 240 | } |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | list_add_tail_rcu(&mci->link, insert_before); |
| 244 | return 0; |
Doug Thompson | 2d7bbb9 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 245 | |
| 246 | fail0: |
| 247 | edac_printk(KERN_WARNING, EDAC_MC, |
| 248 | "%s (%s) %s %s already assigned %d\n", p->dev->bus_id, |
| 249 | dev_name(p->dev), p->mod_name, p->ctl_name, p->mc_idx); |
| 250 | return 1; |
| 251 | |
| 252 | fail1: |
| 253 | edac_printk(KERN_WARNING, EDAC_MC, |
| 254 | "bug in low-level driver: attempt to assign\n" |
| 255 | " duplicate mc_idx %d in %s()\n", p->mc_idx, __func__); |
| 256 | return 1; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 259 | static void complete_mc_list_del(struct rcu_head *head) |
Dave Peterson | a1d03fc | 2006-03-26 01:38:46 -0800 | [diff] [blame] | 260 | { |
| 261 | struct mem_ctl_info *mci; |
| 262 | |
| 263 | mci = container_of(head, struct mem_ctl_info, rcu); |
| 264 | INIT_LIST_HEAD(&mci->link); |
| 265 | complete(&mci->complete); |
| 266 | } |
| 267 | |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 268 | static void del_mc_from_global_list(struct mem_ctl_info *mci) |
Dave Peterson | a1d03fc | 2006-03-26 01:38:46 -0800 | [diff] [blame] | 269 | { |
| 270 | list_del_rcu(&mci->link); |
| 271 | init_completion(&mci->complete); |
| 272 | call_rcu(&mci->rcu, complete_mc_list_del); |
| 273 | wait_for_completion(&mci->complete); |
| 274 | } |
| 275 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 276 | /** |
Douglas Thompson | 5da0831 | 2007-07-19 01:49:31 -0700 | [diff] [blame] | 277 | * edac_mc_find: Search for a mem_ctl_info structure whose index is 'idx'. |
| 278 | * |
| 279 | * If found, return a pointer to the structure. |
| 280 | * Else return NULL. |
| 281 | * |
| 282 | * Caller must hold mem_ctls_mutex. |
| 283 | */ |
| 284 | struct mem_ctl_info * edac_mc_find(int idx) |
| 285 | { |
| 286 | struct list_head *item; |
| 287 | struct mem_ctl_info *mci; |
| 288 | |
| 289 | list_for_each(item, &mc_devices) { |
| 290 | mci = list_entry(item, struct mem_ctl_info, link); |
| 291 | |
| 292 | if (mci->mc_idx >= idx) { |
| 293 | if (mci->mc_idx == idx) |
| 294 | return mci; |
| 295 | |
| 296 | break; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return NULL; |
| 301 | } |
| 302 | EXPORT_SYMBOL(edac_mc_find); |
| 303 | |
| 304 | /** |
Dave Peterson | 472678e | 2006-03-26 01:38:49 -0800 | [diff] [blame] | 305 | * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and |
| 306 | * create sysfs entries associated with mci structure |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 307 | * @mci: pointer to the mci structure to be added to the list |
Doug Thompson | 2d7bbb9 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 308 | * @mc_idx: A unique numeric identifier to be assigned to the 'mci' structure. |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 309 | * |
| 310 | * Return: |
| 311 | * 0 Success |
| 312 | * !0 Failure |
| 313 | */ |
| 314 | |
| 315 | /* FIXME - should a warning be printed if no error detection? correction? */ |
Doug Thompson | 2d7bbb9 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 316 | int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 317 | { |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 318 | debugf0("%s()\n", __func__); |
Doug Thompson | 2d7bbb9 | 2006-06-30 01:56:08 -0700 | [diff] [blame] | 319 | mci->mc_idx = mc_idx; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 320 | #ifdef CONFIG_EDAC_DEBUG |
| 321 | if (edac_debug_level >= 3) |
| 322 | edac_mc_dump_mci(mci); |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 323 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 324 | if (edac_debug_level >= 4) { |
| 325 | int i; |
| 326 | |
| 327 | for (i = 0; i < mci->nr_csrows; i++) { |
| 328 | int j; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 329 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 330 | edac_mc_dump_csrow(&mci->csrows[i]); |
| 331 | for (j = 0; j < mci->csrows[i].nr_channels; j++) |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 332 | edac_mc_dump_channel( |
| 333 | &mci->csrows[i].channels[j]); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | #endif |
| 337 | down(&mem_ctls_mutex); |
| 338 | |
| 339 | if (add_mc_to_global_list(mci)) |
Dave Peterson | 028a7b6 | 2006-03-26 01:38:47 -0800 | [diff] [blame] | 340 | goto fail0; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 341 | |
| 342 | /* set load time so that error rate can be tracked */ |
| 343 | mci->start_time = jiffies; |
| 344 | |
eric wollesen | 9794f33 | 2007-02-12 00:53:08 -0800 | [diff] [blame] | 345 | if (edac_create_sysfs_mci_device(mci)) { |
| 346 | edac_mc_printk(mci, KERN_WARNING, |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 347 | "failed to create sysfs device\n"); |
eric wollesen | 9794f33 | 2007-02-12 00:53:08 -0800 | [diff] [blame] | 348 | goto fail1; |
| 349 | } |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 350 | |
| 351 | /* Report action taken */ |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 352 | edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: DEV %s\n", |
| 353 | mci->mod_name, mci->ctl_name, dev_name(mci->dev)); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 354 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 355 | up(&mem_ctls_mutex); |
Dave Peterson | 028a7b6 | 2006-03-26 01:38:47 -0800 | [diff] [blame] | 356 | return 0; |
| 357 | |
| 358 | fail1: |
| 359 | del_mc_from_global_list(mci); |
| 360 | |
| 361 | fail0: |
| 362 | up(&mem_ctls_mutex); |
| 363 | return 1; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 364 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 365 | EXPORT_SYMBOL_GPL(edac_mc_add_mc); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 366 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 367 | /** |
Dave Peterson | 472678e | 2006-03-26 01:38:49 -0800 | [diff] [blame] | 368 | * edac_mc_del_mc: Remove sysfs entries for specified mci structure and |
| 369 | * remove mci structure from global list |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 370 | * @pdev: Pointer to 'struct device' representing mci structure to remove. |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 371 | * |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 372 | * Return pointer to removed mci structure, or NULL if device not found. |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 373 | */ |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 374 | struct mem_ctl_info * edac_mc_del_mc(struct device *dev) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 375 | { |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 376 | struct mem_ctl_info *mci; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 377 | |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 378 | debugf0("MC: %s()\n", __func__); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 379 | down(&mem_ctls_mutex); |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 380 | |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 381 | if ((mci = find_mci_by_dev(dev)) == NULL) { |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 382 | up(&mem_ctls_mutex); |
| 383 | return NULL; |
| 384 | } |
| 385 | |
| 386 | edac_remove_sysfs_mci_device(mci); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 387 | del_mc_from_global_list(mci); |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 388 | up(&mem_ctls_mutex); |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 389 | edac_printk(KERN_INFO, EDAC_MC, |
Doug Thompson | 37f0458 | 2006-06-30 01:56:07 -0700 | [diff] [blame] | 390 | "Removed device %d for %s %s: DEV %s\n", mci->mc_idx, |
| 391 | mci->mod_name, mci->ctl_name, dev_name(mci->dev)); |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 392 | return mci; |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 393 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 394 | EXPORT_SYMBOL_GPL(edac_mc_del_mc); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 395 | |
Adrian Bunk | 2da1c11 | 2007-07-19 01:49:32 -0700 | [diff] [blame] | 396 | static void edac_mc_scrub_block(unsigned long page, unsigned long offset, |
| 397 | u32 size) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 398 | { |
| 399 | struct page *pg; |
| 400 | void *virt_addr; |
| 401 | unsigned long flags = 0; |
| 402 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 403 | debugf3("%s()\n", __func__); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 404 | |
| 405 | /* ECC error page was not in our memory. Ignore it. */ |
| 406 | if(!pfn_valid(page)) |
| 407 | return; |
| 408 | |
| 409 | /* Find the actual page structure then map it and fix */ |
| 410 | pg = pfn_to_page(page); |
| 411 | |
| 412 | if (PageHighMem(pg)) |
| 413 | local_irq_save(flags); |
| 414 | |
| 415 | virt_addr = kmap_atomic(pg, KM_BOUNCE_READ); |
| 416 | |
| 417 | /* Perform architecture specific atomic scrub operation */ |
| 418 | atomic_scrub(virt_addr + offset, size); |
| 419 | |
| 420 | /* Unmap and complete */ |
| 421 | kunmap_atomic(virt_addr, KM_BOUNCE_READ); |
| 422 | |
| 423 | if (PageHighMem(pg)) |
| 424 | local_irq_restore(flags); |
| 425 | } |
| 426 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 427 | /* FIXME - should return -1 */ |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 428 | int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 429 | { |
| 430 | struct csrow_info *csrows = mci->csrows; |
| 431 | int row, i; |
| 432 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 433 | debugf1("MC%d: %s(): 0x%lx\n", mci->mc_idx, __func__, page); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 434 | row = -1; |
| 435 | |
| 436 | for (i = 0; i < mci->nr_csrows; i++) { |
| 437 | struct csrow_info *csrow = &csrows[i]; |
| 438 | |
| 439 | if (csrow->nr_pages == 0) |
| 440 | continue; |
| 441 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 442 | debugf3("MC%d: %s(): first(0x%lx) page(0x%lx) last(0x%lx) " |
| 443 | "mask(0x%lx)\n", mci->mc_idx, __func__, |
| 444 | csrow->first_page, page, csrow->last_page, |
| 445 | csrow->page_mask); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 446 | |
| 447 | if ((page >= csrow->first_page) && |
| 448 | (page <= csrow->last_page) && |
| 449 | ((page & csrow->page_mask) == |
| 450 | (csrow->first_page & csrow->page_mask))) { |
| 451 | row = i; |
| 452 | break; |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | if (row == -1) |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 457 | edac_mc_printk(mci, KERN_ERR, |
| 458 | "could not look up page error address %lx\n", |
| 459 | (unsigned long) page); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 460 | |
| 461 | return row; |
| 462 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 463 | EXPORT_SYMBOL_GPL(edac_mc_find_csrow_by_page); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 464 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 465 | /* FIXME - setable log (warning/emerg) levels */ |
| 466 | /* FIXME - integrate with evlog: http://evlog.sourceforge.net/ */ |
| 467 | void edac_mc_handle_ce(struct mem_ctl_info *mci, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 468 | unsigned long page_frame_number, unsigned long offset_in_page, |
| 469 | unsigned long syndrome, int row, int channel, const char *msg) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 470 | { |
| 471 | unsigned long remapped_page; |
| 472 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 473 | debugf3("MC%d: %s()\n", mci->mc_idx, __func__); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 474 | |
| 475 | /* FIXME - maybe make panic on INTERNAL ERROR an option */ |
| 476 | if (row >= mci->nr_csrows || row < 0) { |
| 477 | /* something is wrong */ |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 478 | edac_mc_printk(mci, KERN_ERR, |
| 479 | "INTERNAL ERROR: row out of range " |
| 480 | "(%d >= %d)\n", row, mci->nr_csrows); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 481 | edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); |
| 482 | return; |
| 483 | } |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 484 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 485 | if (channel >= mci->csrows[row].nr_channels || channel < 0) { |
| 486 | /* something is wrong */ |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 487 | edac_mc_printk(mci, KERN_ERR, |
| 488 | "INTERNAL ERROR: channel out of range " |
| 489 | "(%d >= %d)\n", channel, |
| 490 | mci->csrows[row].nr_channels); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 491 | edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); |
| 492 | return; |
| 493 | } |
| 494 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 495 | if (edac_get_log_ce()) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 496 | /* FIXME - put in DIMM location */ |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 497 | edac_mc_printk(mci, KERN_WARNING, |
| 498 | "CE page 0x%lx, offset 0x%lx, grain %d, syndrome " |
| 499 | "0x%lx, row %d, channel %d, label \"%s\": %s\n", |
| 500 | page_frame_number, offset_in_page, |
| 501 | mci->csrows[row].grain, syndrome, row, channel, |
| 502 | mci->csrows[row].channels[channel].label, msg); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 503 | |
| 504 | mci->ce_count++; |
| 505 | mci->csrows[row].ce_count++; |
| 506 | mci->csrows[row].channels[channel].ce_count++; |
| 507 | |
| 508 | if (mci->scrub_mode & SCRUB_SW_SRC) { |
| 509 | /* |
| 510 | * Some MC's can remap memory so that it is still available |
| 511 | * at a different address when PCI devices map into memory. |
| 512 | * MC's that can't do this lose the memory where PCI devices |
| 513 | * are mapped. This mapping is MC dependant and so we call |
| 514 | * back into the MC driver for it to map the MC page to |
| 515 | * a physical (CPU) page which can then be mapped to a virtual |
| 516 | * page - which can then be scrubbed. |
| 517 | */ |
| 518 | remapped_page = mci->ctl_page_to_phys ? |
| 519 | mci->ctl_page_to_phys(mci, page_frame_number) : |
| 520 | page_frame_number; |
| 521 | |
| 522 | edac_mc_scrub_block(remapped_page, offset_in_page, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 523 | mci->csrows[row].grain); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 524 | } |
| 525 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 526 | EXPORT_SYMBOL_GPL(edac_mc_handle_ce); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 527 | |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 528 | void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci, const char *msg) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 529 | { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 530 | if (edac_get_log_ce()) |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 531 | edac_mc_printk(mci, KERN_WARNING, |
| 532 | "CE - no information available: %s\n", msg); |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 533 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 534 | mci->ce_noinfo_count++; |
| 535 | mci->ce_count++; |
| 536 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 537 | EXPORT_SYMBOL_GPL(edac_mc_handle_ce_no_info); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 538 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 539 | void edac_mc_handle_ue(struct mem_ctl_info *mci, |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 540 | unsigned long page_frame_number, unsigned long offset_in_page, |
| 541 | int row, const char *msg) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 542 | { |
| 543 | int len = EDAC_MC_LABEL_LEN * 4; |
| 544 | char labels[len + 1]; |
| 545 | char *pos = labels; |
| 546 | int chan; |
| 547 | int chars; |
| 548 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 549 | debugf3("MC%d: %s()\n", mci->mc_idx, __func__); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 550 | |
| 551 | /* FIXME - maybe make panic on INTERNAL ERROR an option */ |
| 552 | if (row >= mci->nr_csrows || row < 0) { |
| 553 | /* something is wrong */ |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 554 | edac_mc_printk(mci, KERN_ERR, |
| 555 | "INTERNAL ERROR: row out of range " |
| 556 | "(%d >= %d)\n", row, mci->nr_csrows); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 557 | edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); |
| 558 | return; |
| 559 | } |
| 560 | |
| 561 | chars = snprintf(pos, len + 1, "%s", |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 562 | mci->csrows[row].channels[0].label); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 563 | len -= chars; |
| 564 | pos += chars; |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 565 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 566 | for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0); |
| 567 | chan++) { |
| 568 | chars = snprintf(pos, len + 1, ":%s", |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 569 | mci->csrows[row].channels[chan].label); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 570 | len -= chars; |
| 571 | pos += chars; |
| 572 | } |
| 573 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 574 | if (edac_get_log_ue()) |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 575 | edac_mc_printk(mci, KERN_EMERG, |
| 576 | "UE page 0x%lx, offset 0x%lx, grain %d, row %d, " |
| 577 | "labels \"%s\": %s\n", page_frame_number, |
| 578 | offset_in_page, mci->csrows[row].grain, row, labels, |
| 579 | msg); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 580 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 581 | if (edac_get_panic_on_ue()) |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 582 | panic("EDAC MC%d: UE page 0x%lx, offset 0x%lx, grain %d, " |
| 583 | "row %d, labels \"%s\": %s\n", mci->mc_idx, |
| 584 | page_frame_number, offset_in_page, |
| 585 | mci->csrows[row].grain, row, labels, msg); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 586 | |
| 587 | mci->ue_count++; |
| 588 | mci->csrows[row].ue_count++; |
| 589 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 590 | EXPORT_SYMBOL_GPL(edac_mc_handle_ue); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 591 | |
Dave Peterson | e7ecd89 | 2006-03-26 01:38:52 -0800 | [diff] [blame] | 592 | void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 593 | { |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 594 | if (edac_get_panic_on_ue()) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 595 | panic("EDAC MC%d: Uncorrected Error", mci->mc_idx); |
| 596 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 597 | if (edac_get_log_ue()) |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 598 | edac_mc_printk(mci, KERN_WARNING, |
| 599 | "UE - no information available: %s\n", msg); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 600 | mci->ue_noinfo_count++; |
| 601 | mci->ue_count++; |
| 602 | } |
Dave Peterson | 9110540 | 2006-03-26 01:38:55 -0800 | [diff] [blame] | 603 | EXPORT_SYMBOL_GPL(edac_mc_handle_ue_no_info); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 604 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 605 | |
eric wollesen | 9794f33 | 2007-02-12 00:53:08 -0800 | [diff] [blame] | 606 | /************************************************************* |
| 607 | * On Fully Buffered DIMM modules, this help function is |
| 608 | * called to process UE events |
| 609 | */ |
| 610 | void edac_mc_handle_fbd_ue(struct mem_ctl_info *mci, |
| 611 | unsigned int csrow, |
| 612 | unsigned int channela, |
| 613 | unsigned int channelb, |
| 614 | char *msg) |
| 615 | { |
| 616 | int len = EDAC_MC_LABEL_LEN * 4; |
| 617 | char labels[len + 1]; |
| 618 | char *pos = labels; |
| 619 | int chars; |
| 620 | |
| 621 | if (csrow >= mci->nr_csrows) { |
| 622 | /* something is wrong */ |
| 623 | edac_mc_printk(mci, KERN_ERR, |
| 624 | "INTERNAL ERROR: row out of range (%d >= %d)\n", |
| 625 | csrow, mci->nr_csrows); |
| 626 | edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | if (channela >= mci->csrows[csrow].nr_channels) { |
| 631 | /* something is wrong */ |
| 632 | edac_mc_printk(mci, KERN_ERR, |
| 633 | "INTERNAL ERROR: channel-a out of range " |
| 634 | "(%d >= %d)\n", |
| 635 | channela, mci->csrows[csrow].nr_channels); |
| 636 | edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); |
| 637 | return; |
| 638 | } |
| 639 | |
| 640 | if (channelb >= mci->csrows[csrow].nr_channels) { |
| 641 | /* something is wrong */ |
| 642 | edac_mc_printk(mci, KERN_ERR, |
| 643 | "INTERNAL ERROR: channel-b out of range " |
| 644 | "(%d >= %d)\n", |
| 645 | channelb, mci->csrows[csrow].nr_channels); |
| 646 | edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR"); |
| 647 | return; |
| 648 | } |
| 649 | |
| 650 | mci->ue_count++; |
| 651 | mci->csrows[csrow].ue_count++; |
| 652 | |
| 653 | /* Generate the DIMM labels from the specified channels */ |
| 654 | chars = snprintf(pos, len + 1, "%s", |
| 655 | mci->csrows[csrow].channels[channela].label); |
| 656 | len -= chars; pos += chars; |
| 657 | chars = snprintf(pos, len + 1, "-%s", |
| 658 | mci->csrows[csrow].channels[channelb].label); |
| 659 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 660 | if (edac_get_log_ue()) |
eric wollesen | 9794f33 | 2007-02-12 00:53:08 -0800 | [diff] [blame] | 661 | edac_mc_printk(mci, KERN_EMERG, |
| 662 | "UE row %d, channel-a= %d channel-b= %d " |
| 663 | "labels \"%s\": %s\n", csrow, channela, channelb, |
| 664 | labels, msg); |
| 665 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 666 | if (edac_get_panic_on_ue()) |
eric wollesen | 9794f33 | 2007-02-12 00:53:08 -0800 | [diff] [blame] | 667 | panic("UE row %d, channel-a= %d channel-b= %d " |
| 668 | "labels \"%s\": %s\n", csrow, channela, |
| 669 | channelb, labels, msg); |
| 670 | } |
| 671 | EXPORT_SYMBOL(edac_mc_handle_fbd_ue); |
| 672 | |
| 673 | /************************************************************* |
| 674 | * On Fully Buffered DIMM modules, this help function is |
| 675 | * called to process CE events |
| 676 | */ |
| 677 | void edac_mc_handle_fbd_ce(struct mem_ctl_info *mci, |
| 678 | unsigned int csrow, |
| 679 | unsigned int channel, |
| 680 | char *msg) |
| 681 | { |
| 682 | |
| 683 | /* Ensure boundary values */ |
| 684 | if (csrow >= mci->nr_csrows) { |
| 685 | /* something is wrong */ |
| 686 | edac_mc_printk(mci, KERN_ERR, |
| 687 | "INTERNAL ERROR: row out of range (%d >= %d)\n", |
| 688 | csrow, mci->nr_csrows); |
| 689 | edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); |
| 690 | return; |
| 691 | } |
| 692 | if (channel >= mci->csrows[csrow].nr_channels) { |
| 693 | /* something is wrong */ |
| 694 | edac_mc_printk(mci, KERN_ERR, |
| 695 | "INTERNAL ERROR: channel out of range (%d >= %d)\n", |
| 696 | channel, mci->csrows[csrow].nr_channels); |
| 697 | edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR"); |
| 698 | return; |
| 699 | } |
| 700 | |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 701 | if (edac_get_log_ce()) |
eric wollesen | 9794f33 | 2007-02-12 00:53:08 -0800 | [diff] [blame] | 702 | /* FIXME - put in DIMM location */ |
| 703 | edac_mc_printk(mci, KERN_WARNING, |
| 704 | "CE row %d, channel %d, label \"%s\": %s\n", |
| 705 | csrow, channel, |
| 706 | mci->csrows[csrow].channels[channel].label, |
| 707 | msg); |
| 708 | |
| 709 | mci->ce_count++; |
| 710 | mci->csrows[csrow].ce_count++; |
| 711 | mci->csrows[csrow].channels[channel].ce_count++; |
| 712 | } |
| 713 | EXPORT_SYMBOL(edac_mc_handle_fbd_ce); |
| 714 | |
| 715 | |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 716 | /* |
| 717 | * Iterate over all MC instances and check for ECC, et al, errors |
| 718 | */ |
Douglas Thompson | 7c9281d | 2007-07-19 01:49:33 -0700 | [diff] [blame] | 719 | void edac_check_mc_devices(void) |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 720 | { |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 721 | struct list_head *item; |
| 722 | struct mem_ctl_info *mci; |
| 723 | |
Dave Peterson | 537fba2 | 2006-03-26 01:38:40 -0800 | [diff] [blame] | 724 | debugf3("%s()\n", __func__); |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 725 | down(&mem_ctls_mutex); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 726 | |
| 727 | list_for_each(item, &mc_devices) { |
| 728 | mci = list_entry(item, struct mem_ctl_info, link); |
| 729 | |
| 730 | if (mci->edac_check != NULL) |
| 731 | mci->edac_check(mci); |
| 732 | } |
| 733 | |
Dave Peterson | 18dbc33 | 2006-03-26 01:38:50 -0800 | [diff] [blame] | 734 | up(&mem_ctls_mutex); |
Alan Cox | da9bb1d | 2006-01-18 17:44:13 -0800 | [diff] [blame] | 735 | } |