forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/drivers/edac/edac_device.c
....@@ -34,6 +34,9 @@
3434 static DEFINE_MUTEX(device_ctls_mutex);
3535 static LIST_HEAD(edac_device_list);
3636
37
+/* Default workqueue processing interval on this instance, in msecs */
38
+#define DEFAULT_POLL_INTERVAL 1000
39
+
3740 #ifdef CONFIG_EDAC_DEBUG
3841 static void edac_device_dump_device(struct edac_device_ctl_info *edac_dev)
3942 {
....@@ -366,7 +369,7 @@
366369 * whole one second to save timers firing all over the period
367370 * between integral seconds
368371 */
369
- if (edac_dev->poll_msec == 1000)
372
+ if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
370373 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
371374 else
372375 edac_queue_work(&edac_dev->work, edac_dev->delay);
....@@ -396,7 +399,7 @@
396399 * timers firing on sub-second basis, while they are happy
397400 * to fire together on the 1 second exactly
398401 */
399
- if (edac_dev->poll_msec == 1000)
402
+ if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
400403 edac_queue_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
401404 else
402405 edac_queue_work(&edac_dev->work, edac_dev->delay);
....@@ -424,17 +427,16 @@
424427 * Then restart the workq on the new delay
425428 */
426429 void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
427
- unsigned long value)
430
+ unsigned long msec)
428431 {
429
- unsigned long jiffs = msecs_to_jiffies(value);
432
+ edac_dev->poll_msec = msec;
433
+ edac_dev->delay = msecs_to_jiffies(msec);
430434
431
- if (value == 1000)
432
- jiffs = round_jiffies_relative(value);
433
-
434
- edac_dev->poll_msec = value;
435
- edac_dev->delay = jiffs;
436
-
437
- edac_mod_work(&edac_dev->work, jiffs);
435
+ /* See comment in edac_device_workq_setup() above */
436
+ if (edac_dev->poll_msec == DEFAULT_POLL_INTERVAL)
437
+ edac_mod_work(&edac_dev->work, round_jiffies_relative(edac_dev->delay));
438
+ else
439
+ edac_mod_work(&edac_dev->work, edac_dev->delay);
438440 }
439441
440442 int edac_device_alloc_index(void)
....@@ -473,11 +475,7 @@
473475 /* This instance is NOW RUNNING */
474476 edac_dev->op_state = OP_RUNNING_POLL;
475477
476
- /*
477
- * enable workq processing on this instance,
478
- * default = 1000 msec
479
- */
480
- edac_device_workq_setup(edac_dev, 1000);
478
+ edac_device_workq_setup(edac_dev, edac_dev->poll_msec ?: DEFAULT_POLL_INTERVAL);
481479 } else {
482480 edac_dev->op_state = OP_RUNNING_INTERRUPT;
483481 }
....@@ -555,11 +553,15 @@
555553 return edac_dev->panic_on_ue;
556554 }
557555
558
-void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
559
- int inst_nr, int block_nr, const char *msg)
556
+void edac_device_handle_ce_count(struct edac_device_ctl_info *edac_dev,
557
+ unsigned int count, int inst_nr, int block_nr,
558
+ const char *msg)
560559 {
561560 struct edac_device_instance *instance;
562561 struct edac_device_block *block = NULL;
562
+
563
+ if (!count)
564
+ return;
563565
564566 if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) {
565567 edac_device_printk(edac_dev, KERN_ERR,
....@@ -582,26 +584,30 @@
582584
583585 if (instance->nr_blocks > 0) {
584586 block = instance->blocks + block_nr;
585
- block->counters.ce_count++;
587
+ block->counters.ce_count += count;
586588 }
587589
588590 /* Propagate the count up the 'totals' tree */
589
- instance->counters.ce_count++;
590
- edac_dev->counters.ce_count++;
591
+ instance->counters.ce_count += count;
592
+ edac_dev->counters.ce_count += count;
591593
592594 if (edac_device_get_log_ce(edac_dev))
593595 edac_device_printk(edac_dev, KERN_WARNING,
594
- "CE: %s instance: %s block: %s '%s'\n",
595
- edac_dev->ctl_name, instance->name,
596
- block ? block->name : "N/A", msg);
596
+ "CE: %s instance: %s block: %s count: %d '%s'\n",
597
+ edac_dev->ctl_name, instance->name,
598
+ block ? block->name : "N/A", count, msg);
597599 }
598
-EXPORT_SYMBOL_GPL(edac_device_handle_ce);
600
+EXPORT_SYMBOL_GPL(edac_device_handle_ce_count);
599601
600
-void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
601
- int inst_nr, int block_nr, const char *msg)
602
+void edac_device_handle_ue_count(struct edac_device_ctl_info *edac_dev,
603
+ unsigned int count, int inst_nr, int block_nr,
604
+ const char *msg)
602605 {
603606 struct edac_device_instance *instance;
604607 struct edac_device_block *block = NULL;
608
+
609
+ if (!count)
610
+ return;
605611
606612 if ((inst_nr >= edac_dev->nr_instances) || (inst_nr < 0)) {
607613 edac_device_printk(edac_dev, KERN_ERR,
....@@ -624,22 +630,22 @@
624630
625631 if (instance->nr_blocks > 0) {
626632 block = instance->blocks + block_nr;
627
- block->counters.ue_count++;
633
+ block->counters.ue_count += count;
628634 }
629635
630636 /* Propagate the count up the 'totals' tree */
631
- instance->counters.ue_count++;
632
- edac_dev->counters.ue_count++;
637
+ instance->counters.ue_count += count;
638
+ edac_dev->counters.ue_count += count;
633639
634640 if (edac_device_get_log_ue(edac_dev))
635641 edac_device_printk(edac_dev, KERN_EMERG,
636
- "UE: %s instance: %s block: %s '%s'\n",
637
- edac_dev->ctl_name, instance->name,
638
- block ? block->name : "N/A", msg);
642
+ "UE: %s instance: %s block: %s count: %d '%s'\n",
643
+ edac_dev->ctl_name, instance->name,
644
+ block ? block->name : "N/A", count, msg);
639645
640646 if (edac_device_get_panic_on_ue(edac_dev))
641
- panic("EDAC %s: UE instance: %s block %s '%s'\n",
642
- edac_dev->ctl_name, instance->name,
643
- block ? block->name : "N/A", msg);
647
+ panic("EDAC %s: UE instance: %s block %s count: %d '%s'\n",
648
+ edac_dev->ctl_name, instance->name,
649
+ block ? block->name : "N/A", count, msg);
644650 }
645
-EXPORT_SYMBOL_GPL(edac_device_handle_ue);
651
+EXPORT_SYMBOL_GPL(edac_device_handle_ue_count);