From b1d79776c7b67407404fbecf63f5686927e909a5 Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Wed, 21 Apr 2021 17:19:34 +0300 Subject: [PATCH] edac: ibecc: Simplify NMI handling Refactor NMI handling making it clearer and fix return code for other NMI source. Signed-off-by: Andrei Emeltchenko --- drivers/edac/edac_ibecc.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/edac/edac_ibecc.c b/drivers/edac/edac_ibecc.c index a3555234a1..8d1e6556a4 100644 --- a/drivers/edac/edac_ibecc.c +++ b/drivers/edac/edac_ibecc.c @@ -453,20 +453,14 @@ static bool handle_nmi(void) uint8_t status; status = sys_in8(NMI_STS_CNT_REG); - - if (status & NMI_STS_SRC_SERR == 0) { - LOG_DBG("Skip NMI, NMI_STS_CNT: 0x%x", status); - /** - * We should be able to find that this NMI we - * should not handle and return false. However this - * does not work for some older SKUs + if ((status & NMI_STS_SRC_SERR) == 0) { + /* For other NMI sources return false to handle it by + * Zephyr exception handler */ - return true; + return false; } - LOG_DBG("core: %d status 0x%x", arch_curr_cpu()->id, status); - - /* Re-enable */ + /* Re-enable SERR# NMI sources */ status = (status & NMI_STS_MASK_EN) | NMI_STS_SERR_EN; sys_out8(status, NMI_STS_CNT_REG); @@ -488,18 +482,18 @@ bool z_x86_do_kernel_nmi(const z_arch_esf_t *esf) key = k_spin_lock(&nmi_lock); - if (!handle_nmi()) { - /* Indicate that we do not handle this NMI */ - ret = false; - goto out; - } - /* Skip the same NMI handling for other cores and return handled */ if (arch_curr_cpu()->id != 0) { ret = true; goto out; } + if (!handle_nmi()) { + /* Indicate that we do not handle this NMI */ + ret = false; + goto out; + } + if (edac_ecc_error_log_get(dev, &ecclog) != 0) { goto out; }