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