From patchwork Wed Oct 21 20:14:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loc Ho X-Patchwork-Id: 7460141 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EE6F4BEEA4 for ; Wed, 21 Oct 2015 20:17:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB5732089C for ; Wed, 21 Oct 2015 20:17:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDCB220824 for ; Wed, 21 Oct 2015 20:17:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zozn2-0008NI-D9; Wed, 21 Oct 2015 20:15:16 +0000 Received: from mail-ob0-x22d.google.com ([2607:f8b0:4003:c01::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zozmz-00077S-Je for linux-arm-kernel@lists.infradead.org; Wed, 21 Oct 2015 20:15:14 +0000 Received: by obctp1 with SMTP id tp1so24360146obc.2 for ; Wed, 21 Oct 2015 13:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id; bh=DytJQnxHAeWKmCqs7fhv35JbNWByMH6RV0maaiJ2fq8=; b=AVEwsyiFNxnYr8ho5ID9i8clF4XfMNwpIdbQAfbI4DqCvHoeGrQwYDiYbnBiERYIlJ RfSAKb2PdTAQgVSsYp0uYbyN3Bz/KMIsE4WqosEJCqVoB3dUrePaapvje6UG87rs/2So X5f4tQy2h6mda8piYJOIwpF0clSWLlPbp69Io= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DytJQnxHAeWKmCqs7fhv35JbNWByMH6RV0maaiJ2fq8=; b=J3QXnvFD8Ool8hYZ4mPW8hQNboWzydsMdgb65YRHuzR/KdYIaTDbQCtC9ihn6wRUi3 C62YGEqoxTmI+gQQKR9b9I64B8yOyT15cpguLyRsIGiotVl0272Aufl0bpnwQWHCFp0E uRiEnRvcbkl+I9ZI8yvmfb2RiYlUeLjgBMvvnsd6CKU40vO0wzrbFfIySzQoxG4oiAg6 cB3y5Z2ZlmC6u5j7y81Rj+b56cuWTXje1TzksRQNrdqpWykLvTT4lNErOJqYEkjJuPg7 mOSJQnnmIVvAxYOP6heKgcCvLiph4lQ2fxdRM+xTTe11tojNUutMBudqjMny0/HhGHCw IxSg== X-Gm-Message-State: ALoCoQnoGpnr5cr+1Twd4gyg5GHiO6Uzzpbfp+3JrONrJhCp6JW1fW8IdvKaYILwHhFyzpveH4xQ X-Received: by 10.182.104.130 with SMTP id ge2mr7675413obb.79.1445458492110; Wed, 21 Oct 2015 13:14:52 -0700 (PDT) Received: from localhost.localdomain ([198.137.200.11]) by smtp.gmail.com with ESMTPSA id kp8sm4261516oeb.10.2015.10.21.13.14.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Oct 2015 13:14:50 -0700 (PDT) From: Loc Ho To: bp@alien8.de, mchehab@osg.samsung.com, tomasz.nowicki@linaro.org, fu.wei@linaro.org Subject: [PATCH RFC v2] apei: Add ACPI APEI event notification support Date: Wed, 21 Oct 2015 14:14:40 -0600 Message-Id: <1445458480-6493-1-git-send-email-lho@apm.com> X-Mailer: git-send-email 1.7.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151021_131513_722705_FB02C472 X-CRM114-Status: GOOD ( 21.47 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jcm@redhat.com, patches@apm.com, Loc Ho , linux-arm-kernel@lists.infradead.org, linux-edac@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add ACPI APEI event notification support for ARMv8 SoC under the following conditions: 1. Without EL3 support and no GPIO PIN available 2. With EL3 support but no mean to notify the OS v2 * Make all code more generic naming * Still waiting for comment from Linaro folks on APEI Signed-off-by: Loc Ho --- drivers/edac/Kconfig | 7 +++ drivers/edac/Makefile | 2 + drivers/edac/edac_apei.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 0 deletions(-) create mode 100644 drivers/edac/edac_apei.c -- 1.7.1 diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index ef25000..62c2bb2 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -95,6 +95,13 @@ config EDAC_GHES In doubt, say 'Y'. +config EDAC_APEI + tristate "ACPI APEI errors notification" + depends on ACPI_APEI && (ARM64 || COMPILE_TEST) + help + APEI interface support for error notification via interrupt based + for ARMv8 64-bit SOCs. + config EDAC_AMD64 tristate "AMD64 (Opteron, Athlon64)" depends on EDAC_MM_EDAC && AMD_NB && EDAC_DECODE_MCE diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile index dbf53e0..9f91ff3 100644 --- a/drivers/edac/Makefile +++ b/drivers/edac/Makefile @@ -19,6 +19,7 @@ edac_core-y += edac_pci.o edac_pci_sysfs.o endif obj-$(CONFIG_EDAC_GHES) += ghes_edac.o +obj-$(CONFIG_EDAC_APEI) += edac_apei.o edac_mce_amd-y := mce_amd.o obj-$(CONFIG_EDAC_DECODE_MCE) += edac_mce_amd.o @@ -70,3 +71,4 @@ obj-$(CONFIG_EDAC_OCTEON_PCI) += octeon_edac-pci.o obj-$(CONFIG_EDAC_ALTERA_MC) += altera_edac.o obj-$(CONFIG_EDAC_SYNOPSYS) += synopsys_edac.o obj-$(CONFIG_EDAC_XGENE) += xgene_edac.o + diff --git a/drivers/edac/edac_apei.c b/drivers/edac/edac_apei.c new file mode 100644 index 0000000..fd066f0 --- /dev/null +++ b/drivers/edac/edac_apei.c @@ -0,0 +1,114 @@ +/* + * APEI notification support for ARM 64-bit Soc's + * + * Copyright (c) 2015, Applied Micro Circuits Corporation + * Author: Tuan Phan + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This driver provides APEI error notification via interrupt with the UEFI + * FW for SoC processors under the following conditions: + * + * 1. No interrupt GPIO available or don't want to use one and no EL3 support + * 2. With EL3 support but no mean to interrupt the Linux OS that an event + * has occurred. + * + */ +#include +#include +#include +#include + +struct edac_apei_dev { + void __iomem *csr_base; + struct device *dev; + u32 irq; + acpi_handle evt_handle; +}; + +static const struct acpi_device_id edac_apei_match[] = { + { "APMC0D51", 0}, + {}, +}; +MODULE_DEVICE_TABLE(acpi, edac_apei_match); + +static irqreturn_t edac_apei_irq_handler(int irq, void *data) +{ + struct edac_apei_dev *ctx = (struct edac_apei_dev *) data; + + /* Clear the interrupt */ + writel(readl(ctx->csr_base), ctx->csr_base); + + /* Send error event */ + acpi_execute_simple_method(ctx->evt_handle, NULL, 0); + + return IRQ_HANDLED; +} + +static int edac_apei_probe(struct platform_device *pdev) +{ + struct edac_apei_dev *ctx; + struct resource *res; + acpi_handle evt_handle; + int rc; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->dev = &pdev->dev; + platform_set_drvdata(pdev, ctx); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ctx->csr_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(ctx->csr_base)) { + dev_err(&pdev->dev, "No CSR resource\n"); + return PTR_ERR(ctx->csr_base); + } + + ctx->irq = platform_get_irq(pdev, 0); + if (ctx->irq < 0) { + dev_err(&pdev->dev, "No IRQ resource\n"); + return ctx->irq; + } + + rc = devm_request_irq(&pdev->dev, ctx->irq, edac_apei_irq_handler, 0, + dev_name(&pdev->dev), ctx); + if (rc) { + dev_err(&pdev->dev, "Could not request IRQ %d\n", ctx->irq); + return rc; + } + + if (!ACPI_SUCCESS(acpi_get_handle(ACPI_HANDLE(ctx->dev), "_EVT", + &evt_handle))) + return AE_BAD_PARAMETER; + + ctx->evt_handle = evt_handle; + + return rc; +} + +static struct platform_driver edac_apei_driver = { + .probe = edac_apei_probe, + .driver = { + .name = "edac-apei", + .acpi_match_table = ACPI_PTR(edac_apei_match), + }, +}; +module_platform_driver(edac_apei_driver); + +MODULE_DESCRIPTION("EDAC APEI driver"); +MODULE_AUTHOR("Tuan Phan "); +MODULE_LICENSE("GPL"); +MODULE_VERSION("0.1");