Received: by 10.192.165.156 with SMTP id m28csp1141367imm; Mon, 16 Apr 2018 15:00:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx49aEhBbeUhAMaRasBHlPo4+wkVULGitRLiSUGyIBtNYLP72oHBkygQgn4SfBart3NOe+L9d X-Received: by 10.98.77.2 with SMTP id a2mr6079923pfb.213.1523916048475; Mon, 16 Apr 2018 15:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523916048; cv=none; d=google.com; s=arc-20160816; b=PrdwjjZPoqPgtt3P102tQNONVGauvKXGqtLUcar6ESOu8YrJcWERXNj+zhO5lrtP9t jH2YindBPh79SpLkyX5O2lFxoKF2wuMQzAcdzLcGPcYhD+jNN6yYShbLZskX3cvsmkKn Au6TrnIy5PnWJ1/H+r/mqhcu48ciOX5dhhHdteXTAHqSne46xRGqKpYgIbBrnPdDp5rq P99rqVw8JJDToDbne1XRI8iHcOj1SPH+suSd8gGuX8XbMmjmaPeDZ/rkEypZ5c/XV1mq qOj0/7KXTq/fvQH0eOo9zwHpzcXXar5DumwAhgPBtI81brxMpancQVliY/3Hn8w3rODi ADwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=2RDwh5py4YQQxkSj2jVQILJ7gw7PRKjHriMOI/CA2pk=; b=H60CGlkSUDXXGeOeAteWfvqm41QThHdd25t+LCp9wZIRVio2xJMcISxbreXknLHH48 tfGD2hHt1wpvbDOX20kPFrEI6AxAmzwD10jebZYBKx/OpCkUcpEbxQcWQKSZdPjoQX6Z kgGJQzxe2SPUns1QzedQU3/GLtt8KiZqHhajfoqcgnwG24FSIeKFV8eYipeutI12Hhyt 3TtW6aDY3TmsADcMC2iZMqjjukilTgh+KOx5Jed/DPomjZJS+f4X8ejYyLg3MVs344S2 01qxipJMLlQQUtor8HZhsNkuek0D5eTFuA2vqqt2zdv2QEpG0Dh3+InHR/heXgsTS5UA dAEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o2/z3gxJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4si10092941pgs.94.2018.04.16.15.00.33; Mon, 16 Apr 2018 15:00:48 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o2/z3gxJ; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753014AbeDPV7X (ORCPT + 99 others); Mon, 16 Apr 2018 17:59:23 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:35954 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbeDPV7S (ORCPT ); Mon, 16 Apr 2018 17:59:18 -0400 Received: by mail-oi0-f68.google.com with SMTP id h11-v6so6723999oic.3; Mon, 16 Apr 2018 14:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2RDwh5py4YQQxkSj2jVQILJ7gw7PRKjHriMOI/CA2pk=; b=o2/z3gxJfV2zwYvJSaBGacdXRSY2kWZySaa9XR2s+0vyNR8GAY+kQo05dqbeqT93sJ ag6wPVFBCc4OG3+uQTm+GpeQEKa5l1xSf6vaWaGsh4NB9Wd6Kvhoemf1Sx6aXT1vlKbT pAHk43c8s1BF227Zo8l3nVdQsxFryZm7pYQeAbRNpITG5rAzQN2SFD6p94K8MDc+azW+ pZLEw+oXMTPHMxc3IgGnzXVmMdLLa1Z22/owX2mDjQILj7zIowZljkm14fQ9fU191r2G 0DqzZ26mXbAnew/fLEZ2bQfBUFNr4aPoLFAFzzNYScZ13aJBKBvfgspjLhbjp4ofw4cR EsrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2RDwh5py4YQQxkSj2jVQILJ7gw7PRKjHriMOI/CA2pk=; b=BTvfvGRiYpYup+/ZbDPfrUkRmKl69fZSRdxuCkRrDP1l4lmQFVHw9Z3+Sjg7XdXVXh BZKLrsjCtQEuCdT7ecIiWrZGCw+mZ0GuN5kuDBRBQUj+tITAi2Ra0r/XrHTiu3KpV6TC zK58oXhmibovaGLqPi+oVpI5NHWhPJtQDxLb+amVaiqwq2jeGUkGTSgsIDCcbi8eOtbx QnhLslmU6+yBBZMSfMprL2s0aoicNnukHsDrN2BpSCyroLX6Ujnj3nU8hIBssVjnLnIQ bQ9bKYZUecpM+idJeuFpwe6o5PSzo4Xh1+fd/CTK+hgLbA6PEHAZUABxlqZDtKNDYCyO wvgQ== X-Gm-Message-State: ALQs6tBVqnHlPVZfFooY18T2HpDgwdFcLbptJQQsjnjYBSLMmPKE1Ntf dhY7AK6PS5Bw72LlltTY1DqTL0Hx X-Received: by 2002:aca:b2c3:: with SMTP id b186-v6mr14991477oif.337.1523915957229; Mon, 16 Apr 2018 14:59:17 -0700 (PDT) Received: from nuclearis2_1.lan (c-98-197-2-30.hsd1.tx.comcast.net. [98.197.2.30]) by smtp.gmail.com with ESMTPSA id j23-v6sm8219960oiy.22.2018.04.16.14.59.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Apr 2018 14:59:16 -0700 (PDT) From: Alexandru Gagniuc To: linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org Cc: rjw@rjwysocki.net, lenb@kernel.org, tony.luck@intel.com, bp@alien8.de, tbaicar@codeaurora.org, will.deacon@arm.com, james.morse@arm.com, shiju.jose@huawei.com, zjzhang@codeaurora.org, gengdongjiu@huawei.com, linux-kernel@vger.kernel.org, alex_gagniuc@dellteam.com, austin_bolen@dell.com, shyam_iyer@dell.com, devel@acpica.org, mchehab@kernel.org, robert.moore@intel.com, erik.schmauss@intel.com, Alexandru Gagniuc Subject: [RFC PATCH v2 2/4] acpi: apei: Split GHES handlers outside of ghes_do_proc Date: Mon, 16 Apr 2018 16:59:01 -0500 Message-Id: <20180416215903.7318-3-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180416215903.7318-1-mr.nuke.me@gmail.com> References: <20180416215903.7318-1-mr.nuke.me@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use a mapping from CPER UUID to get the correct handler for a given GHES error. This is in preparation of splitting some handlers into irq safe and regular parts. Signed-off-by: Alexandru Gagniuc --- drivers/acpi/apei/ghes.c | 78 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index f9b53a6f55f3..2119c51b4a9e 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -414,6 +414,25 @@ static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int #endif } +static int ghes_handle_arm(struct acpi_hest_generic_data *gdata, int sev) +{ + struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata); + + log_arm_hw_error(err); + return ghes_severity(gdata->error_severity); +} + +static int ghes_handle_mem(struct acpi_hest_generic_data *gdata, int sev) +{ + 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); + + return ghes_severity(gdata->error_severity); +} + /* * PCIe AER errors need to be sent to the AER driver for reporting and * recovery. The GHES severities map to the following AER severities and @@ -428,7 +447,7 @@ static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int * GHES_SEV_PANIC does not make it to this handling since the kernel must * panic. */ -static void ghes_handle_aer(struct acpi_hest_generic_data *gdata) +static int ghes_handle_aer(struct acpi_hest_generic_data *gdata, int sev) { #ifdef CONFIG_ACPI_APEI_PCIEAER struct cper_sec_pcie *pcie_err = acpi_hest_get_payload(gdata); @@ -456,14 +475,54 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata) (struct aer_capability_regs *) pcie_err->aer_info); } + + return GHES_SEV_CORRECTED; #endif + return ghes_severity(gdata->error_severity); } +/** + * ghes_handler - handler for ACPI APEI errors + * @error_uuid: UUID describing the error entry (See ACPI/EFI CPER for details) + * @handle: Handler for the GHES entry of type 'error_uuid'. The handler + * returns the severity of the error after handling. A handler is allowed + * to demote errors to correctable or corrected, as appropriate. + */ +static const struct ghes_handler { + const guid_t *error_uuid; + int (*handle_irqsafe)(struct acpi_hest_generic_data *gdata, int sev); + int (*handle)(struct acpi_hest_generic_data *gdata, int sev); +} ghes_handlers[] = { + { + .error_uuid = &CPER_SEC_PLATFORM_MEM, + .handle = ghes_handle_mem, + }, { + .error_uuid = &CPER_SEC_PCIE, + .handle = ghes_handle_aer, + }, { + .error_uuid = &CPER_SEC_PROC_ARM, + .handle = ghes_handle_arm, + } +}; + +static const struct ghes_handler *get_handler(const guid_t *type) +{ + size_t i; + + for (i = 0; i < ARRAY_SIZE(ghes_handlers); i++) { + if (guid_equal(type, ghes_handlers[i].error_uuid)) + return &ghes_handlers[i]; + } + return NULL; +} + + static void ghes_do_proc(struct ghes *ghes, const struct acpi_hest_generic_status *estatus) { int sev, sec_sev; struct acpi_hest_generic_data *gdata; + const struct ghes_handler *handler; guid_t *sec_type; guid_t *fru_id = &NULL_UUID_LE; char *fru_text = ""; @@ -478,21 +537,10 @@ static void ghes_do_proc(struct ghes *ghes, if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT) fru_text = gdata->fru_text; - 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)) { - ghes_handle_aer(gdata); - } - else if (guid_equal(sec_type, &CPER_SEC_PROC_ARM)) { - struct cper_sec_proc_arm *err = acpi_hest_get_payload(gdata); - log_arm_hw_error(err); + handler = get_handler(sec_type); + if (handler) { + sec_sev = handler->handle(gdata, sev); } else { void *err = acpi_hest_get_payload(gdata); -- 2.14.3