Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp144457ybz; Tue, 21 Apr 2020 06:25:19 -0700 (PDT) X-Google-Smtp-Source: APiQypKGrSS8QfP4Di8OXPQEH7XLaHi4Z79Q1xaSbUmjXs14FGDbCrSLkIIRpnQQkYopApU3N7qr X-Received: by 2002:a17:906:5045:: with SMTP id e5mr21708720ejk.325.1587475518851; Tue, 21 Apr 2020 06:25:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587475518; cv=none; d=google.com; s=arc-20160816; b=kj4JZKJxbqwQ18FISDsdSlIWI36sGlzObI+J9IoEncXXgJazZk6zfgj4h0IMtXhhod OAKGtncfw49QYeYW+lNtgqHrXh6ej+j4gpdHYLOjkv0RuzXLtLjMCr0FHb4VEO5GnzuI m9Dq+YP0ELmSigkMDQGp6bZAwvsqAXORwJ5TZGEi/twKqN+4y1fOUIQc8+mGEI0c0jCc E5LoGAt9H2SUTq5+l+lK0JJdTyCncc/Vun5fIMEjrPj5YPXHlGJ5LY35m4ZXVIuGsb7L k89YaHA+UQPjW4xKKXMSrKj+r3kwvDSAe52L8ZXPFLyHvI72ZEKbHcVx3VtYQc8DfjVC qv4g== 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=3sC1E+q5tlzIzkCoHHJiXExAUu9WFvKf2o6jpfxBtv4=; b=k52ct6W9M0qmYplUv3kO+5SkiUI3z0S0DfiK78rvgKif3gVPBLDdlVBCg1zK7B3zMJ lWPwCNZTItCmLbS0YrqkoSFGdGwd6ANxWhutuXUOQfzwhhROczRq4LUWLoqrxCz3JtZn Os/9VbsDxlLV2Wik85nT5CWFlt6LY84GvKKErgYcYFCWHxbF6Dj9QAI/YRAU21ocpJyk WWiA1Fde3gUy0iBs9/BugIgurL/tWRfJ+IMTgz6wxFrWMYYBaSaaJK5uQkcF5jOHpnAE 6jxGxxZ8osOdHZMe0fZIxOzYI3pqHS8XzmK7W51IZhMXC1SvwP+iUMWWijJNoyn0/LPg VjGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pv24si1680398ejb.244.2020.04.21.06.24.55; Tue, 21 Apr 2020 06:25:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729053AbgDUNXo (ORCPT + 99 others); Tue, 21 Apr 2020 09:23:44 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2822 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728864AbgDUNXn (ORCPT ); Tue, 21 Apr 2020 09:23:43 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0F239F6509CB6C65CFB; Tue, 21 Apr 2020 21:23:41 +0800 (CST) Received: from DESKTOP-6T4S3DQ.china.huawei.com (10.47.83.77) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Tue, 21 Apr 2020 21:23:34 +0800 From: Shiju Jose To: , , , , , , , , , , , , CC: , , , , Shiju Jose Subject: [RESEND PATCH v7 2/6] ACPI / APEI: Add callback for memory errors to the GHES notifier Date: Tue, 21 Apr 2020 14:21:32 +0100 Message-ID: <20200421132136.1595-3-shiju.jose@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200421132136.1595-1-shiju.jose@huawei.com> References: <20200421132136.1595-1-shiju.jose@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.47.83.77] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add callback function for handling the memory errors to the GHES notifier. Signed-off-by: Shiju Jose --- drivers/acpi/apei/ghes.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 5c0ab5422311..053c4a2ed96c 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -471,23 +471,33 @@ static void ghes_clear_estatus(struct ghes *ghes, ghes_ack_error(ghes->generic_v2); } -static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev) +static int ghes_handle_memory_failure(struct notifier_block *nb, + unsigned long event, void *data) { #ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE unsigned long pfn; int flags = -1; + int sev = event; + struct acpi_hest_generic_data *gdata = data; int sec_sev = ghes_severity(gdata->error_severity); struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata); + if (!guid_equal((guid_t *)gdata->section_type, &CPER_SEC_PLATFORM_MEM)) + return NOTIFY_DONE; + + ghes_edac_report_mem_error(sev, mem_err); + + arch_apei_report_mem_error(sev, mem_err); + if (!(mem_err->validation_bits & CPER_MEM_VALID_PA)) - return; + return NOTIFY_STOP; pfn = mem_err->physical_addr >> PAGE_SHIFT; if (!pfn_valid(pfn)) { pr_warn_ratelimited(FW_WARN GHES_PFX "Invalid address in generic error data: %#llx\n", mem_err->physical_addr); - return; + return NOTIFY_STOP; } /* iff following two events can be handled properly by now */ @@ -500,6 +510,7 @@ static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int if (flags != -1) memory_failure_queue(pfn, flags); #endif + return NOTIFY_STOP; } /* @@ -547,6 +558,22 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata) #endif } +static struct notifier_block ghes_notifier_mem_error = { + .notifier_call = ghes_handle_memory_failure, +}; + +struct ghes_error_handler_list { + const char *name; + struct notifier_block *nb; +}; + +static const struct ghes_error_handler_list ghes_error_handler_list[] = { + { + .name = "ghes_notifier_mem_error", + .nb = &ghes_notifier_mem_error, + }, +}; + static BLOCKING_NOTIFIER_HEAD(ghes_event_notify_list); /** @@ -630,15 +657,7 @@ static void ghes_do_proc(struct ghes *ghes, break; } - if (guid_equal(sec_type, &CPER_SEC_PLATFORM_MEM)) { - struct cper_sec_mem_err *mem_err = acpi_hest_get_payload(gdata); - - ghes_edac_report_mem_error(sev, mem_err); - - arch_apei_report_mem_error(sev, mem_err); - ghes_handle_memory_failure(gdata, sev); - } - else if (guid_equal(sec_type, &CPER_SEC_PCIE)) { + if (guid_equal(sec_type, &CPER_SEC_PCIE)) { ghes_handle_aer(gdata); } else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) { @@ -1431,7 +1450,7 @@ static struct platform_driver ghes_platform_driver = { static int __init ghes_init(void) { - int rc; + int rc, i; if (acpi_disabled) return -ENODEV; @@ -1473,6 +1492,16 @@ static int __init ghes_init(void) goto err; } + for (i = 0; i < ARRAY_SIZE(ghes_error_handler_list); i++) { + const struct ghes_error_handler_list *list = + &ghes_error_handler_list[i]; + rc = ghes_register_event_notifier(list->nb); + if (rc) { + pr_warn(GHES_PFX "fail to register %s\n", list->name); + goto err; + } + } + return 0; err: return rc; -- 2.17.1