From patchwork Tue Jun 26 17:01:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10489965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A63E6023A for ; Tue, 26 Jun 2018 18:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EA2F27FB0 for ; Tue, 26 Jun 2018 18:08:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02DA5286E1; Tue, 26 Jun 2018 18:08:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 875B7286B1 for ; Tue, 26 Jun 2018 18:08:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gMfVaNTgbcUsvdFcapolAtS26b3axWvmib3q3PsqjdE=; b=JGI7C36zBmngAzHl8VB+wVDH76 p5QO9437dSA3MkqFRlrulRv+K+xMJm7GryI/pddnHO9urM/F0BmEda6Z06laklgdX03D1smnMIYek crixwbAlVzjZzwduMEsfEp8T+WUBW6rbLzufLmAWyBZqn1pnqx9PzMvHyA7wJkhfq4PPd7ZleiZSG cwCdRHmjIrHvukIiI+sSRHXr5ISDMWJ4j5emRTIRvxK/7FsI9ZHdCYfcEl3fKONZ5g6otsTbCNFki QAnl12j//2cKnxD/9VmXeIz+uPlbPzJt6vrvNbU0To52myuC1rFOWlVmscPDgxEtwUSktibXy8V6h enudJaag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXsNa-00075K-GH; Tue, 26 Jun 2018 18:07:50 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXsLM-0005zW-0S for linux-arm-kernel@bombadil.infradead.org; Tue, 26 Jun 2018 18:05:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rSIvBvv5cbZQG6Pn2NW2dd8jTAdkjmqCudoKILuTNRg=; b=j1dWlcHEiSrR6232VuIbM/mOH sPaU0HJBdb7NRnrGkKiYVUA1hq2Q2saK4Hocl+Tu7T23HLhIVsoy0M9nv4EvuyaFuTDIjGWTDGYWv jzqaqiXBst/ZXsE6eXCK5G69yBtXL/k1BpaMP5IURaJ+veyp2mnlrx3KrpqheT+/b0g+zPVlIWaP6 YpfqH95Q8/mk6CTtBm/f+LBKFqaLEJMhs8dMHfHuHK+rI1iIpMBUDLuCC8UxzwIf6LnSebdtuX8uf EWNumBGX0pgDH6kr1YfbF1ut17UzznrUMI7sjEib63QV16jo/RX0ktkZI95M+bEPp4IwX2P234k1s pGNXxo4WA==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fXrMz-0003dd-Tu for linux-arm-kernel@lists.infradead.org; Tue, 26 Jun 2018 17:03:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5435922BE; Tue, 26 Jun 2018 10:02:59 -0700 (PDT) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.206.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14E133F318; Tue, 26 Jun 2018 10:02:55 -0700 (PDT) From: James Morse To: linux-acpi@vger.kernel.org Subject: [PATCH v5 17/20] firmware: arm_sdei: Add ACPI GHES registration helper Date: Tue, 26 Jun 2018 18:01:13 +0100 Message-Id: <20180626170116.25825-18-james.morse@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626170116.25825-1-james.morse@arm.com> References: <20180626170116.25825-1-james.morse@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180626_130310_135207_75505E0F X-CRM114-Status: GOOD ( 23.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jonathan.zhang@cavium.com, Rafael Wysocki , Tony Luck , Punit Agrawal , Xie XiuQi , Marc Zyngier , Catalin Marinas , Tyler Baicar , Will Deacon , Christoffer Dall , Dongjiu Geng , linux-mm@kvack.org, Borislav Petkov , James Morse , Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Len Brown MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP APEI's Generic Hardware Error Source structures do not describe whether the SDEI event is shared or private, as this information is discoverable via the API. GHES needs to know whether an event is normal or critical to avoid sharing locks or fixmap entries, but we don't want GHES to have to know much about the SDEI API. Add a helper to register the GHES using the appropriate normal or critical callback. Signed-off-by: James Morse --- Changes since v4: * Moved normal/critical callbacks into the helper, as APEI needs to know. * Dropped Punit's Reviewed-by. Changes since v3: * Removed acpi_disabled() checks that aren't necessary after v2s #ifdef change. Changes since v2: * Added header file, thanks kbuild-robot! * changed ifdef to the GHES version to match the fixmap definition Changes since v1: * ghes->fixmap_idx variable rename --- arch/arm64/include/asm/fixmap.h | 4 ++ drivers/firmware/arm_sdei.c | 66 +++++++++++++++++++++++++++++++++ include/linux/arm_sdei.h | 6 +++ 3 files changed, 76 insertions(+) diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h index c3974517c2cb..e2b423a5feaf 100644 --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -58,6 +58,10 @@ enum fixed_addresses { #ifdef CONFIG_ACPI_APEI_SEA FIX_APEI_GHES_SEA, #endif +#ifdef CONFIG_ARM_SDE_INTERFACE + FIX_APEI_GHES_SDEI_NORMAL, + FIX_APEI_GHES_SDEI_CRITICAL, +#endif #endif /* CONFIG_ACPI_APEI_GHES */ #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c index 1ea71640fdc2..c1b6591f2183 100644 --- a/drivers/firmware/arm_sdei.c +++ b/drivers/firmware/arm_sdei.c @@ -2,6 +2,7 @@ // Copyright (C) 2017 Arm Ltd. #define pr_fmt(fmt) "sdei: " fmt +#include #include #include #include @@ -32,6 +33,8 @@ #include #include +#include + /* * The call to use to reach the firmware. */ @@ -887,6 +890,69 @@ static void sdei_smccc_hvc(unsigned long function_id, arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4, 0, 0, res); } +#ifdef CONFIG_ACPI_APEI_GHES +int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb, + sdei_event_callback *critical_cb) +{ + int err; + u64 result; + u32 event_num; + sdei_event_callback *cb; + + event_num = ghes->generic->notify.vector; + if (event_num == 0) { + /* + * Event 0 is reserved by the specification for + * SDEI_EVENT_SIGNAL. + */ + return -EINVAL; + } + + err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_PRIORITY, + &result); + if (err) + return err; + + if (result == SDEI_EVENT_PRIORITY_CRITICAL) + cb = critical_cb; + else + cb = normal_cb; + + err = sdei_event_register(event_num, cb, ghes); + if (!err) + err = sdei_event_enable(event_num); + + return err; +} + +int sdei_unregister_ghes(struct ghes *ghes) +{ + int i; + int err; + u32 event_num = ghes->generic->notify.vector; + + might_sleep(); + + /* + * The event may be running on another CPU. Disable it + * to stop new events, then try to unregister a few times. + */ + err = sdei_event_disable(event_num); + if (err) + return err; + + for (i = 0; i < 3; i++) { + err = sdei_event_unregister(event_num); + if (err != -EINPROGRESS) + break; + + schedule(); + } + + return err; +} +#endif /* CONFIG_ACPI_APEI_GHES */ + static int sdei_get_conduit(struct platform_device *pdev) { const char *method; diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h index 942afbd544b7..393899192906 100644 --- a/include/linux/arm_sdei.h +++ b/include/linux/arm_sdei.h @@ -11,6 +11,7 @@ enum sdei_conduit_types { CONDUIT_HVC, }; +#include #include /* Arch code should override this to set the entry point from firmware... */ @@ -39,6 +40,11 @@ int sdei_event_unregister(u32 event_num); int sdei_event_enable(u32 event_num); int sdei_event_disable(u32 event_num); +/* GHES register/unregister helpers */ +int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb, + sdei_event_callback *critical_cb); +int sdei_unregister_ghes(struct ghes *ghes); + #ifdef CONFIG_ARM_SDE_INTERFACE /* For use by arch code when CPU hotplug notifiers are not appropriate. */ int sdei_mask_local_cpu(void);