Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2243575ybv; Fri, 14 Feb 2020 14:30:10 -0800 (PST) X-Google-Smtp-Source: APXvYqyZLBYEOiY7li0P1QFY527IwKmL3/Hvx2GhJ4IhV5XNBlNB40qHV89n26uk0k9EQPjlqmGG X-Received: by 2002:a9d:7f11:: with SMTP id j17mr4233545otq.281.1581719410525; Fri, 14 Feb 2020 14:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581719410; cv=none; d=google.com; s=arc-20160816; b=CXhDN8zeoo2+gN+GZisixv8kc9cGjSWYFE5AeDW9SdRhpytOohGNmsStgAWHwMf3DQ Dum1661HmTSGZpC66nqKFr7HjZwCtN5+pVS4LiOCIBbDvi1sfqKHqdwM7+0BJ/I4hl8L h9wUS8jvYevr+TTqjZwjaP9WsVmY8wXtNSb+352c21M1ZgG2SQyJGLhKoty8rmyf81kL aU2lU03iqeHFMSUhLWG+xB1gtfncIry8VOyPqN5lnki2eyIA1i3UMRiQZAvXZ3sZhrBs u5I0d5TM5ga4licgJQY1NPABUk4V+i3tu7UL2lTfNnux0ykmDrCToAUzjUgsLEg2DUHM T1fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=U5sI9NI3ktyXEqnZF04zdxjEaNq+xYXenje+K0I0Ar4=; b=SBWkI9iJha2nPIzaAOXCeagoCQlLvNQh8MAWuVGorYRXl+gMuGpdJxpRo0VN5TzWvK uDtNv7WYT1jcKQJ+ei1SAS7hWDu89eQ2S+mMtVowaToFPtCRjw8EwSwK808d/BNKFgVc YSfaifC1/VBzAhNvRE+m7ZUq5g/PjrPrt5W8YxEwltAbUOoKYbpB/vUSfn1F7oyHgWLk kz6wDTp2vdMyGJmjay48qytLE2jg2U3x4PCW2qXndIn6rAprdorE2cPLnt4jdI6h3a8l dh9qLrQiVrafkoXQPuzkAL+pOG8z1G4a9ubZz7obg4fJBJir6xAyFVTdibEWXLZLsRl8 Ma3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si3450922otp.200.2020.02.14.14.29.57; Fri, 14 Feb 2020 14:30:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727912AbgBNW2d (ORCPT + 99 others); Fri, 14 Feb 2020 17:28:33 -0500 Received: from mga05.intel.com ([192.55.52.43]:5120 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727940AbgBNW1X (ORCPT ); Fri, 14 Feb 2020 17:27:23 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2020 14:27:22 -0800 X-IronPort-AV: E=Sophos;i="5.70,442,1574150400"; d="scan'208";a="227756432" Received: from agluck-desk2.sc.intel.com ([10.3.52.68]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2020 14:27:21 -0800 From: Tony Luck To: Borislav Petkov Cc: Tony Luck , x86@kernel.org, Andy Lutomirski , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] x86/mce: Convert corrected error collector to use mce notifier Date: Fri, 14 Feb 2020 14:27:15 -0800 Message-Id: <20200214222720.13168-3-tony.luck@intel.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200214222720.13168-1-tony.luck@intel.com> References: <20200212204652.1489-1-tony.luck@intel.com> <20200214222720.13168-1-tony.luck@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/mce/core.c | 19 ------------------- drivers/ras/cec.c | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 3366807d8e58..06240cbe6f3e 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -542,21 +542,6 @@ bool mce_is_correctable(struct mce *m) } EXPORT_SYMBOL_GPL(mce_is_correctable); -static bool cec_add_mce(struct mce *m) -{ - if (!m) - return false; - - /* We eat only correctable DRAM errors with usable addresses. */ - if (mce_is_memory_error(m) && - mce_is_correctable(m) && - mce_usable_address(m)) - if (!cec_add_elem(m->addr >> PAGE_SHIFT)) - return true; - - return false; -} - static int mce_early_notifier(struct notifier_block *nb, unsigned long val, void *data) { @@ -565,9 +550,6 @@ static int mce_early_notifier(struct notifier_block *nb, unsigned long val, if (!m) return NOTIFY_DONE; - if (cec_add_mce(m)) - return NOTIFY_STOP; - /* Emit the trace record: */ trace_mce_record(m); @@ -2588,7 +2570,6 @@ static int __init mcheck_late_init(void) static_branch_inc(&mcsafe_key); mcheck_debugfs_init(); - cec_init(); /* * Flush out everything that has been logged during early boot, now that diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c index c09cf55e2d20..d7f6718cbf8d 100644 --- a/drivers/ras/cec.c +++ b/drivers/ras/cec.c @@ -527,6 +527,29 @@ static int __init create_debugfs_nodes(void) return 1; } +static int cec_notifier(struct notifier_block *nb, unsigned long val, + void *data) +{ + struct mce *m = (struct mce *)data; + + if (!m) + return NOTIFY_DONE; + + /* We eat only correctable DRAM errors with usable addresses. */ + if (mce_is_memory_error(m) && + mce_is_correctable(m) && + mce_usable_address(m)) + if (!cec_add_elem(m->addr >> PAGE_SHIFT)) + return NOTIFY_STOP; + + return NOTIFY_DONE; +} + +static struct notifier_block cec_nb = { + .notifier_call = cec_notifier, + .priority = MCE_PRIO_CEC, +}; + void __init cec_init(void) { if (ce_arr.disabled) @@ -546,8 +569,11 @@ void __init cec_init(void) INIT_DELAYED_WORK(&cec_work, cec_work_fn); schedule_delayed_work(&cec_work, CEC_DECAY_DEFAULT_INTERVAL); + mce_register_decode_chain(&cec_nb); + pr_info("Correctable Errors collector initialized.\n"); } +late_initcall(cec_init); int __init parse_cec_param(char *str) { -- 2.21.1