edac: move EDAC device definitions to drivers/edac/edac_device.h
[linux-2.6-block.git] / drivers / edac / edac_device.c
1
2 /*
3  * edac_device.c
4  * (C) 2007 www.douglaskthompson.com
5  *
6  * This file may be distributed under the terms of the
7  * GNU General Public License.
8  *
9  * Written by Doug Thompson <norsk5@xmission.com>
10  *
11  * edac_device API implementation
12  * 19 Jan 2007
13  */
14
15 #include <asm/page.h>
16 #include <asm/uaccess.h>
17 #include <linux/ctype.h>
18 #include <linux/highmem.h>
19 #include <linux/init.h>
20 #include <linux/jiffies.h>
21 #include <linux/module.h>
22 #include <linux/slab.h>
23 #include <linux/smp.h>
24 #include <linux/spinlock.h>
25 #include <linux/sysctl.h>
26 #include <linux/timer.h>
27
28 #include "edac_device.h"
29 #include "edac_module.h"
30
31 /* lock for the list: 'edac_device_list', manipulation of this list
32  * is protected by the 'device_ctls_mutex' lock
33  */
34 static DEFINE_MUTEX(device_ctls_mutex);
35 static LIST_HEAD(edac_device_list);
36
37 #ifdef CONFIG_EDAC_DEBUG
38 static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev)
39 {
40         edac_dbg(3, "\tedac_dev = %p dev_idx=%d\n",
41                  edac_dev, edac_dev->dev_idx);
42         edac_dbg(4, "\tedac_dev->edac_check = %p\n", edac_dev->edac_check);
43         edac_dbg(3, "\tdev = %p\n", edac_dev->dev);
44         edac_dbg(3, "\tmod_name:ctl_name = %s:%s\n",
45                  edac_dev->mod_name, edac_dev->ctl_name);
46         edac_dbg(3, "\tpvt_info = %p\n\n", edac_dev->pvt_info);
47 }
48 #endif                          /* CONFIG_EDAC_DEBUG */
49
50
51 /*
52  * edac_device_alloc_ctl_info()
53  *      Allocate a new edac device control info structure
54  *
55  *      The control structure is allocated in complete chunk
56  *      from the OS. It is in turn sub allocated to the
57  *      various objects that compose the structure
58  *
59  *      The structure has a 'nr_instance' array within itself.
60  *      Each instance represents a major component
61  *              Example:  L1 cache and L2 cache are 2 instance components
62  *
63  *      Within each instance is an array of 'nr_blocks' blockoffsets
64  */
65 struct edac_device_ctl_info *edac_device_alloc_ctl_info(
66         unsigned sz_private,
67         char *edac_device_name, unsigned nr_instances,
68         char *edac_block_name, unsigned nr_blocks,
69         unsigned offset_value,          /* zero, 1, or other based offset */
70         struct edac_dev_sysfs_block_attribute *attrib_spec, unsigned nr_attrib,
71         int device_index)
72 {
73         struct edac_device_ctl_info *dev_ctl;
74         struct edac_device_instance *dev_inst, *inst;
75         struct edac_device_block *dev_blk, *blk_p, *blk;
76         struct edac_dev_sysfs_block_attribute *dev_attrib, *attrib_p, *attrib;
77         unsigned total_size;
78         unsigned count;
79         unsigned instance, block, attr;
80         void *pvt, *p;
81         int err;
82
83         edac_dbg(4, "instances=%d blocks=%d\n", nr_instances, nr_blocks);
84
85         /* Calculate the size of memory we need to allocate AND
86          * determine the offsets of the various item arrays
87          * (instance,block,attrib) from the start of an  allocated structure.
88          * We want the alignment of each item  (instance,block,attrib)
89          * to be at least as stringent as what the compiler would
90          * provide if we could simply hardcode everything into a single struct.
91          */
92         p = NULL;
93         dev_ctl = edac_align_ptr(&p, sizeof(*dev_ctl), 1);
94
95         /* Calc the 'end' offset past end of ONE ctl_info structure
96          * which will become the start of the 'instance' array
97          */
98         dev_inst = edac_align_ptr(&p, sizeof(*dev_inst), nr_instances);
99
100         /* Calc the 'end' offset past the instance array within the ctl_info
101          * which will become the start of the block array
102          */
103         count = nr_instances * nr_blocks;
104         dev_blk = edac_align_ptr(&p, sizeof(*dev_blk), count);
105
106         /* Calc the 'end' offset past the dev_blk array
107          * which will become the start of the attrib array, if any.
108          */
109         /* calc how many nr_attrib we need */
110         if (nr_attrib > 0)
111                 count *= nr_attrib;
112         dev_attrib = edac_align_ptr(&p, sizeof(*dev_attrib), count);
113
114         /* Calc the 'end' offset past the attributes array */
115         pvt = edac_align_ptr(&p, sz_private, 1);
116
117         /* 'pvt' now points to where the private data area is.
118          * At this point 'pvt' (like dev_inst,dev_blk and dev_attrib)
119          * is baselined at ZERO
120          */
121         total_size = ((unsigned long)pvt) + sz_private;
122
123         /* Allocate the amount of memory for the set of control structures */
124         dev_ctl = kzalloc(total_size, GFP_KERNEL);
125         if (dev_ctl == NULL)
126                 return NULL;
127
128         /* Adjust pointers so they point within the actual memory we
129          * just allocated rather than an imaginary chunk of memory
130          * located at address 0.
131          * 'dev_ctl' points to REAL memory, while the others are
132          * ZERO based and thus need to be adjusted to point within
133          * the allocated memory.
134          */
135         dev_inst = (struct edac_device_instance *)
136                 (((char *)dev_ctl) + ((unsigned long)dev_inst));
137         dev_blk = (struct edac_device_block *)
138                 (((char *)dev_ctl) + ((unsigned long)dev_blk));
139         dev_attrib = (struct edac_dev_sysfs_block_attribute *)
140                 (((char *)dev_ctl) + ((unsigned long)dev_attrib));
141         pvt = sz_private ? (((char *)dev_ctl) + ((unsigned long)pvt)) : NULL;
142
143         /* Begin storing the information into the control info structure */
144         dev_ctl->dev_idx = device_index;
145         dev_ctl->nr_instances = nr_instances;
146         dev_ctl->instances = dev_inst;
147         dev_ctl->pvt_info = pvt;
148
149         /* Default logging of CEs and UEs */
150         dev_ctl->log_ce = 1;
151         dev_ctl->log_ue = 1;
152
153         /* Name of this edac device */
154         snprintf(dev_ctl->name,sizeof(dev_ctl->name),"%s",edac_device_name);
155
156         edac_dbg(4, "edac_dev=%p next after end=%p\n",
157                  dev_ctl, pvt + sz_private);
158
159         /* Initialize every Instance */
160         for (instance = 0; instance < nr_instances; instance++) {
161                 inst = &dev_inst[instance];
162                 inst->ctl = dev_ctl;
163                 inst->nr_blocks = nr_blocks;
164                 blk_p = &dev_blk[instance * nr_blocks];
165                 inst->blocks = blk_p;
166
167                 /* name of this instance */
168                 snprintf(inst->name, sizeof(inst->name),
169                          "%s%u", edac_device_name, instance);
170
171                 /* Initialize every block in each instance */
172                 for (block = 0; block < nr_blocks; block++) {
173                         blk = &blk_p[block];
174                         blk->instance = inst;
175                         snprintf(blk->name, sizeof(blk->name),
176                                  "%s%d", edac_block_name, block+offset_value);
177
178                         edac_dbg(4, "instance=%d inst_p=%p block=#%d block_p=%p name='%s'\n",
179                                  instance, inst, block, blk, blk->name);
180
181                         /* if there are NO attributes OR no attribute pointer
182                          * then continue on to next block iteration
183                          */
184                         if ((nr_attrib == 0) || (attrib_spec == NULL))
185                                 continue;
186
187                         /* setup the attribute array for this block */
188                         blk->nr_attribs = nr_attrib;
189                         attrib_p = &dev_attrib[block*nr_instances*nr_attrib];
190                         blk->block_attributes = attrib_p;
191
192                         edac_dbg(4, "THIS BLOCK_ATTRIB=%p\n",
193                                  blk->block_attributes);
194
195                         /* Initialize every user specified attribute in this
196                          * block with the data the caller passed in
197                          * Each block gets its own copy of pointers,
198                          * and its unique 'value'
199                          */
200                         for (attr = 0; attr < nr_attrib; attr++) {
201                                 attrib = &attrib_p[attr];
202
203                                 /* populate the unique per attrib
204                                  * with the code pointers and info
205                                  */
206                                 attrib->attr = attrib_spec[attr].attr;
207                                 attrib->show = attrib_spec[attr].show;
208                                 attrib->store = attrib_spec[attr].store;
209
210                                 attrib->block = blk;    /* up link */
211
212                                 edac_dbg(4, "alloc-attrib=%p attrib_name='%s' attrib-spec=%p spec-name=%s\n",
213                                          attrib, attrib->attr.name,
214                                          &attrib_spec[attr],
215                                          attrib_spec[attr].attr.name
216                                         );
217                         }
218                 }
219         }
220
221         /* Mark this instance as merely ALLOCATED */
222         dev_ctl->op_state = OP_ALLOC;
223
224         /*
225          * Initialize the 'root' kobj for the edac_device controller
226          */
227         err = edac_device_register_sysfs_main_kobj(dev_ctl);
228         if (err) {
229                 kfree(dev_ctl);
230                 return NULL;
231         }
232
233         /* at this point, the root kobj is valid, and in order to
234          * 'free' the object, then the function:
235          *      edac_device_unregister_sysfs_main_kobj() must be called
236          * which will perform kobj unregistration and the actual free
237          * will occur during the kobject callback operation
238          */
239
240         return dev_ctl;
241 }
242 EXPORT_SYMBOL_GPL(edac_device_alloc_ctl_info);
243
244 /*
245  * edac_device_free_ctl_info()
246  *      frees the memory allocated by the edac_device_alloc_ctl_info()
247  *      function
248  */
249 void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info)
250 {
251         edac_device_unregister_sysfs_main_kobj(ctl_info);
252 }
253 EXPORT_SYMBOL_GPL(edac_device_free_ctl_info);
254
255 /*
256  * find_edac_device_by_dev
257  *      scans the edac_device list for a specific 'struct device *'
258  *
259  *      lock to be held prior to call:  device_ctls_mutex
260  *
261  *      Return:
262  *              pointer to control structure managing 'dev'
263  *              NULL if not found on list
264  */
265 static struct edac_device_ctl_info *find_edac_device_by_dev(struct device *dev)
266 {
267         struct edac_device_ctl_info *edac_dev;
268         struct list_head *item;
269
270         edac_dbg(0, "\n");
271
272         list_for_each(item, &edac_device_list) {
273                 edac_dev = list_entry(item, struct edac_device_ctl_info, link);
274
275                 if (edac_dev->dev == dev)
276                         return edac_dev;
277         }
278
279         return NULL;
280 }
281
282 /*
283  * add_edac_dev_to_global_list
284  *      Before calling this function, caller must
285  *      assign a unique value to edac_dev->dev_idx.
286  *
287  *      lock to be held prior to call:  device_ctls_mutex
288  *
289  *      Return:
290  *              0 on success
291  *              1 on failure.
292  */
293 static int add_edac_dev_to_global_list(struct edac_device_ctl_info *edac_dev)
294 {
295         struct list_head *item, *insert_before;
296         struct edac_device_ctl_info *rover;
297
298         insert_before = &edac_device_list;
299
300         /* Determine if already on the list */
301         rover = find_edac_device_by_dev(edac_dev->dev);
302         if (unlikely(rover != NULL))
303                 goto fail0;
304
305         /* Insert in ascending order by 'dev_idx', so find position */
306         list_for_each(item, &edac_device_list) {
307                 rover = list_entry(item, struct edac_device_ctl_info, link);
308
309                 if (rover->dev_idx >= edac_dev->dev_idx) {
310                         if (unlikely(rover->dev_idx == edac_dev->dev_idx))
311                                 goto fail1;
312
313                         insert_before = item;
314                         break;
315                 }
316         }
317
318         list_add_tail_rcu(&edac_dev->link, insert_before);
319         return 0;
320
321 fail0:
322         edac_printk(KERN_WARNING, EDAC_MC,
323                         "%s (%s) %s %s already assigned %d\n",
324                         dev_name(rover->dev), edac_dev_name(rover),
325                         rover->mod_name, rover->ctl_name, rover->dev_idx);
326         return 1;
327
328 fail1:
329         edac_printk(KERN_WARNING, EDAC_MC,
330                         "bug in low-level driver: attempt to assign\n"
331                         "    duplicate dev_idx %d in %s()\n", rover->dev_idx,
332                         __func__);
333         return 1;
334 }
335
336 /*
337  * del_edac_device_from_global_list
338  */
339 static void del_edac_device_from_global_list(struct edac_device_ctl_info
340                                                 *edac_device)
341 {
342         list_del_rcu(&edac_device->link);
343
344         /* these are for safe removal of devices from global list while
345          * NMI handlers may be traversing list
346          */
347         synchronize_rcu();
348         INIT_LIST_HEAD(&edac_device->link);
349 }
350
351 /*
352  * edac_device_workq_function
353  *      performs the operation scheduled by a workq request
354  *
355  *      this workq is embedded within an edac_device_ctl_info
356  *      structure, that needs to be polled for possible error events.
357  *
358  *      This operation is to acquire the list mutex lock
359  *      (thus preventing insertation or deletion)
360  *      and then call the device's poll function IFF this device is
361  *      running polled and there is a poll function defined.
362  */
363 static void edac_device_workq_function(struct work_struct *work_req)
364 {
365         struct delayed_work *d_work = to_delayed_work(work_req);
366         struct edac_device_ctl_info *edac_dev = to_edac_device_ctl_work(d_work);
367
368         mutex_lock(&device_ctls_mutex);
369
370         /* If we are being removed, bail out immediately */
371         if (edac_dev->op_state == OP_OFFLINE) {
372                 mutex_unlock(&device_ctls_mutex);
373                 return;
374         }
375
376         /* Only poll controllers that are running polled and have a check */
377         if ((edac_dev->op_state == OP_RUNNING_POLL) &&
378                 (edac_dev->edac_check != NULL)) {
379                         edac_dev->edac_check(edac_dev);
380         }
381
382         mutex_unlock(&device_ctls_mutex);
383
384         /* Reschedule the workq for the next time period to start again
385          * if the number of msec is for 1 sec, then adjust to the next
386          * whole one second to save timers firing all over the period
387          * between integral seconds
388          */
389         if (edac_dev->poll_msec == 1000)
390                 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
391         else
392                 edac_queue_work(&edac_dev->work, edac_dev->delay);
393 }
394
395 /*
396  * edac_device_workq_setup
397  *      initialize a workq item for this edac_device instance
398  *      passing in the new delay period in msec
399  */
400 static void edac_device_workq_setup(struct edac_device_ctl_info *edac_dev,
401                                     unsigned msec)
402 {
403         edac_dbg(0, "\n");
404
405         /* take the arg 'msec' and set it into the control structure
406          * to used in the time period calculation
407          * then calc the number of jiffies that represents
408          */
409         edac_dev->poll_msec = msec;
410         edac_dev->delay = msecs_to_jiffies(msec);
411
412         INIT_DELAYED_WORK(&edac_dev->work, edac_device_workq_function);
413
414         /* optimize here for the 1 second case, which will be normal value, to
415          * fire ON the 1 second time event. This helps reduce all sorts of
416          * timers firing on sub-second basis, while they are happy
417          * to fire together on the 1 second exactly
418          */
419         if (edac_dev->poll_msec == 1000)
420                 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
421         else
422                 edac_queue_work(&edac_dev->work, edac_dev->delay);
423 }
424
425 /*
426  * edac_device_workq_teardown
427  *      stop the workq processing on this edac_dev
428  */
429 static void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev)
430 {
431         if (!edac_dev->edac_check)
432                 return;
433
434         edac_dev->op_state = OP_OFFLINE;
435
436         edac_stop_work(&edac_dev->work);
437 }
438
439 /*
440  * edac_device_reset_delay_period
441  *
442  *      need to stop any outstanding workq queued up at this time
443  *      because we will be resetting the sleep time.
444  *      Then restart the workq on the new delay
445  */
446 void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
447                                         unsigned long value)
448 {
449         unsigned long jiffs = msecs_to_jiffies(value);
450
451         if (value == 1000)
452                 jiffs = round_jiffies_relative(value);
453
454         edac_dev->poll_msec = value;
455         edac_dev->delay     = jiffs;
456
457         edac_mod_work(&edac_dev->work, jiffs);
458 }
459
460 /*
461  * edac_device_alloc_index: Allocate a unique device index number
462  *
463  * Return:
464  *      allocated index number
465  */
466 int edac_device_alloc_index(void)
467 {
468         static atomic_t device_indexes = ATOMIC_INIT(0);
469
470         return atomic_inc_return(&device_indexes) - 1;
471 }
472 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
473
474 /**
475  * edac_device_add_device: Insert the 'edac_dev' structure into the
476  * edac_device global list and create sysfs entries associated with
477  * edac_device structure.
478  * @edac_device: pointer to the edac_device structure to be added to the list
479  * 'edac_device' structure.
480  *
481  * Return:
482  *      0       Success
483  *      !0      Failure
484  */
485 int edac_device_add_device(struct edac_device_ctl_info *edac_dev)
486 {
487         edac_dbg(0, "\n");
488
489 #ifdef CONFIG_EDAC_DEBUG
490         if (edac_debug_level >= 3)
491                 edac_device_dump_device(edac_dev);
492 #endif
493         mutex_lock(&device_ctls_mutex);
494
495         if (add_edac_dev_to_global_list(edac_dev))
496                 goto fail0;
497
498         /* set load time so that error rate can be tracked */
499         edac_dev->start_time = jiffies;
500
501         /* create this instance's sysfs entries */
502         if (edac_device_create_sysfs(edac_dev)) {
503                 edac_device_printk(edac_dev, KERN_WARNING,
504                                         "failed to create sysfs device\n");
505                 goto fail1;
506         }
507
508         /* If there IS a check routine, then we are running POLLED */
509         if (edac_dev->edac_check != NULL) {
510                 /* This instance is NOW RUNNING */
511                 edac_dev->op_state = OP_RUNNING_POLL;
512
513                 /*
514                  * enable workq processing on this instance,
515                  * default = 1000 msec
516                  */
517                 edac_device_workq_setup(edac_dev, 1000);
518         } else {
519                 edac_dev->op_state = OP_RUNNING_INTERRUPT;
520         }
521
522         /* Report action taken */
523         edac_device_printk(edac_dev, KERN_INFO,
524                 "Giving out device to module %s controller %s: DEV %s (%s)\n",
525                 edac_dev->mod_name, edac_dev->ctl_name, edac_dev->dev_name,
526                 edac_op_state_to_string(edac_dev->op_state));
527
528         mutex_unlock(&device_ctls_mutex);
529         return 0;
530
531 fail1:
532         /* Some error, so remove the entry from the lsit */
533         del_edac_device_from_global_list(edac_dev);
534
535 fail0:
536         mutex_unlock(&device_ctls_mutex);
537         return 1;
538 }
539 EXPORT_SYMBOL_GPL(edac_device_add_device);
540
541 /**
542  * edac_device_del_device:
543  *      Remove sysfs entries for specified edac_device structure and
544  *      then remove edac_device structure from global list
545  *
546  * @dev:
547  *      Pointer to 'struct device' representing edac_device
548  *      structure to remove.
549  *
550  * Return:
551  *      Pointer to removed edac_device structure,
552  *      OR NULL if device not found.
553  */
554 struct edac_device_ctl_info *edac_device_del_device(struct device *dev)
555 {
556         struct edac_device_ctl_info *edac_dev;
557
558         edac_dbg(0, "\n");
559
560         mutex_lock(&device_ctls_mutex);
561
562         /* Find the structure on the list, if not there, then leave */
563         edac_dev = find_edac_device_by_dev(dev);
564         if (edac_dev == NULL) {
565                 mutex_unlock(&device_ctls_mutex);
566                 return NULL;
567         }
568
569         /* mark this instance as OFFLINE */
570         edac_dev->op_state = OP_OFFLINE;
571
572         /* deregister from global list */
573         del_edac_device_from_global_list(edac_dev);
574
575         mutex_unlock(&device_ctls_mutex);
576
577         /* clear workq processing on this instance */
578         edac_device_workq_teardown(edac_dev);
579
580         /* Tear down the sysfs entries for this instance */
581         edac_device_remove_sysfs(edac_dev);
582
583         edac_printk(KERN_INFO, EDAC_MC,
584                 "Removed device %d for %s %s: DEV %s\n",
585                 edac_dev->dev_idx,
586                 edac_dev->mod_name, edac_dev->ctl_name, edac_dev_name(edac_dev));
587
588         return edac_dev;
589 }
590 EXPORT_SYMBOL_GPL(edac_device_del_device);
591
592 static inline int edac_device_get_log_ce(struct edac_device_ctl_info *edac_dev)
593 {
594         return edac_dev->log_ce;
595 }
596
597 static inline int edac_device_get_log_ue(struct edac_device_ctl_info *edac_dev)
598 {
599         return edac_dev->log_ue;
600 }
601
602 static inline int edac_device_get_panic_on_ue(struct edac_device_ctl_info
603                                         *edac_dev)
604 {
605         return edac_dev->panic_on_ue;
606 }
607
608 /*
609  * edac_device_handle_ce
610  *      perform a common output and handling of an 'edac_dev' CE event
611  */
612 void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
613                         int inst_nr, int block_nr, const char *msg)
614 {
615         struct edac_device_instance *instance;
616         struct edac_device_block *block = NULL;
617
618         if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) {
619                 edac_device_printk(edac_dev, KERN_ERR,
620                                 "INTERNAL ERROR: 'instance' out of range "
621                                 "(%d >= %d)\n", inst_nr,
622                                 edac_dev->nr_instances);
623                 return;
624         }
625
626         instance = edac_dev->instances + inst_nr;
627
628         if ((block_nr >= instance->nr_blocks) || (block_nr < 0)) {
629                 edac_device_printk(edac_dev, KERN_ERR,
630                                 "INTERNAL ERROR: instance %d 'block' "
631                                 "out of range (%d >= %d)\n",
632                                 inst_nr, block_nr,
633                                 instance->nr_blocks);
634                 return;
635         }
636
637         if (instance->nr_blocks > 0) {
638                 block = instance->blocks + block_nr;
639                 block->counters.ce_count++;
640         }
641
642         /* Propagate the count up the 'totals' tree */
643         instance->counters.ce_count++;
644         edac_dev->counters.ce_count++;
645
646         if (edac_device_get_log_ce(edac_dev))
647                 edac_device_printk(edac_dev, KERN_WARNING,
648                                 "CE: %s instance: %s block: %s '%s'\n",
649                                 edac_dev->ctl_name, instance->name,
650                                 block ? block->name : "N/A", msg);
651 }
652 EXPORT_SYMBOL_GPL(edac_device_handle_ce);
653
654 /*
655  * edac_device_handle_ue
656  *      perform a common output and handling of an 'edac_dev' UE event
657  */
658 void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
659                         int inst_nr, int block_nr, const char *msg)
660 {
661         struct edac_device_instance *instance;
662         struct edac_device_block *block = NULL;
663
664         if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) {
665                 edac_device_printk(edac_dev, KERN_ERR,
666                                 "INTERNAL ERROR: 'instance' out of range "
667                                 "(%d >= %d)\n", inst_nr,
668                                 edac_dev->nr_instances);
669                 return;
670         }
671
672         instance = edac_dev->instances + inst_nr;
673
674         if ((block_nr >= instance->nr_blocks) || (block_nr < 0)) {
675                 edac_device_printk(edac_dev, KERN_ERR,
676                                 "INTERNAL ERROR: instance %d 'block' "
677                                 "out of range (%d >= %d)\n",
678                                 inst_nr, block_nr,
679                                 instance->nr_blocks);
680                 return;
681         }
682
683         if (instance->nr_blocks > 0) {
684                 block = instance->blocks + block_nr;
685                 block->counters.ue_count++;
686         }
687
688         /* Propagate the count up the 'totals' tree */
689         instance->counters.ue_count++;
690         edac_dev->counters.ue_count++;
691
692         if (edac_device_get_log_ue(edac_dev))
693                 edac_device_printk(edac_dev, KERN_EMERG,
694                                 "UE: %s instance: %s block: %s '%s'\n",
695                                 edac_dev->ctl_name, instance->name,
696                                 block ? block->name : "N/A", msg);
697
698         if (edac_device_get_panic_on_ue(edac_dev))
699                 panic("EDAC %s: UE instance: %s block %s '%s'\n",
700                         edac_dev->ctl_name, instance->name,
701                         block ? block->name : "N/A", msg);
702 }
703 EXPORT_SYMBOL_GPL(edac_device_handle_ue);