Skip to content

Commit 9554bfe

Browse files
aeglsuryasaimadhu
authored andcommitted
x86/mce: Convert the CEC to use the MCE notifier
The CEC code has its claws in a couple of routines in mce/core.c. Convert it to just register itself on the normal MCE notifier chain. [ bp: Make cec_add_elem() and cec_init() static. ] Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Tested-by: Tony Luck <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent c9c6d21 commit 9554bfe

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

arch/x86/kernel/cpu/mce/core.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -544,21 +544,6 @@ bool mce_is_correctable(struct mce *m)
544544
}
545545
EXPORT_SYMBOL_GPL(mce_is_correctable);
546546

547-
static bool cec_add_mce(struct mce *m)
548-
{
549-
if (!m)
550-
return false;
551-
552-
/* We eat only correctable DRAM errors with usable addresses. */
553-
if (mce_is_memory_error(m) &&
554-
mce_is_correctable(m) &&
555-
mce_usable_address(m))
556-
if (!cec_add_elem(m->addr >> PAGE_SHIFT))
557-
return true;
558-
559-
return false;
560-
}
561-
562547
static int mce_early_notifier(struct notifier_block *nb, unsigned long val,
563548
void *data)
564549
{
@@ -567,9 +552,6 @@ static int mce_early_notifier(struct notifier_block *nb, unsigned long val,
567552
if (!m)
568553
return NOTIFY_DONE;
569554

570-
if (cec_add_mce(m))
571-
return NOTIFY_STOP;
572-
573555
/* Emit the trace record: */
574556
trace_mce_record(m);
575557

@@ -2612,7 +2594,6 @@ static int __init mcheck_late_init(void)
26122594
static_branch_inc(&mcsafe_key);
26132595

26142596
mcheck_debugfs_init();
2615-
cec_init();
26162597

26172598
/*
26182599
* Flush out everything that has been logged during early boot, now that

drivers/ras/cec.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static bool sanity_check(struct ce_array *ca)
309309
return ret;
310310
}
311311

312-
int cec_add_elem(u64 pfn)
312+
static int cec_add_elem(u64 pfn)
313313
{
314314
struct ce_array *ca = &ce_arr;
315315
unsigned int to = 0;
@@ -527,7 +527,30 @@ static int __init create_debugfs_nodes(void)
527527
return 1;
528528
}
529529

530-
void __init cec_init(void)
530+
static int cec_notifier(struct notifier_block *nb, unsigned long val,
531+
void *data)
532+
{
533+
struct mce *m = (struct mce *)data;
534+
535+
if (!m)
536+
return NOTIFY_DONE;
537+
538+
/* We eat only correctable DRAM errors with usable addresses. */
539+
if (mce_is_memory_error(m) &&
540+
mce_is_correctable(m) &&
541+
mce_usable_address(m))
542+
if (!cec_add_elem(m->addr >> PAGE_SHIFT))
543+
return NOTIFY_STOP;
544+
545+
return NOTIFY_DONE;
546+
}
547+
548+
static struct notifier_block cec_nb = {
549+
.notifier_call = cec_notifier,
550+
.priority = MCE_PRIO_CEC,
551+
};
552+
553+
static void __init cec_init(void)
531554
{
532555
if (ce_arr.disabled)
533556
return;
@@ -546,8 +569,11 @@ void __init cec_init(void)
546569
INIT_DELAYED_WORK(&cec_work, cec_work_fn);
547570
schedule_delayed_work(&cec_work, CEC_DECAY_DEFAULT_INTERVAL);
548571

572+
mce_register_decode_chain(&cec_nb);
573+
549574
pr_info("Correctable Errors collector initialized.\n");
550575
}
576+
late_initcall(cec_init);
551577

552578
int __init parse_cec_param(char *str)
553579
{

include/linux/ras.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ static inline int ras_add_daemon_trace(void) { return 0; }
1717
#endif
1818

1919
#ifdef CONFIG_RAS_CEC
20-
void __init cec_init(void);
2120
int __init parse_cec_param(char *str);
22-
int cec_add_elem(u64 pfn);
23-
#else
24-
static inline void __init cec_init(void) { }
25-
static inline int cec_add_elem(u64 pfn) { return -ENODEV; }
2621
#endif
2722

2823
#ifdef CONFIG_RAS

0 commit comments

Comments
 (0)