From patchwork Wed May 16 16:28:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10404429 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 A3C36602C2 for ; Wed, 16 May 2018 16:45:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DF6028643 for ; Wed, 16 May 2018 16:45:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A8D4285D8; Wed, 16 May 2018 16:45:17 +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 4F1BC286F3 for ; Wed, 16 May 2018 16:42:37 +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=xZNDqK65D6fiyYTD7C8kvJ7tQDoDie2bXeIBq+sCqjc=; b=HdzwsSyPofJc4u+vanxQd4+Rca lGuXkr116LYGJvknevtci0V8G9J76x1nwn2yotEljMvd9iUIFeGmmrK3aX10bGUZE53sX4SOk7rn4 Z/sK6K3L+Q+xQN3h75oAhqLYZZ0Qo7EAq+7HtTJUn66DZjSDn9MWYagEQeVRCCVNxb15W8SqJOPmK xw5wsxnmkSVkqDDMKJhSuTlqRBZmf6lfveDcuRBRTXj2yfcMRUmKPz573l3yG+ZOjUlCIhIssb4sH xNrbvtxklQ25Ld+LjrRwBpC8uxefqSXX4Eh93tveTfK3AYHpKTV8jqKm/wgY/TTGpyeEBDJMGoBdq 246rsnNA==; 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 1fIzVP-0002cg-7C; Wed, 16 May 2018 16:42:23 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fIzLq-0003sD-PW for linux-arm-kernel@lists.infradead.org; Wed, 16 May 2018 16:32:36 +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 5431515BF; Wed, 16 May 2018 09:32:20 -0700 (PDT) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.207.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2A05B3F24A; Wed, 16 May 2018 09:32:17 -0700 (PDT) From: James Morse To: linux-acpi@vger.kernel.org Subject: [PATCH v4 09/12] firmware: arm_sdei: Add ACPI GHES registration helper Date: Wed, 16 May 2018 17:28:26 +0100 Message-Id: <20180516162829.14348-10-james.morse@arm.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180516162829.14348-1-james.morse@arm.com> References: <20180516162829.14348-1-james.morse@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180516_093230_859767_4AAD3BF2 X-CRM114-Status: GOOD ( 18.83 ) 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 , inux-mm@kvack.org, Xie XiuQi , Marc Zyngier , Catalin Marinas , Tyler Baicar , Will Deacon , Christoffer Dall , Dongjiu Geng , Punit Agrawal , 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. Add a helper to ask firmware for this information so it can initialise the struct ghes and register then enable the event. Signed-off-by: James Morse Reviewed-by: Punit Agrawal --- 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 | 67 +++++++++++++++++++++++++++++++++++++++++ include/linux/arm_sdei.h | 5 +++ 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..7c304ebb6282 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,70 @@ 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 +static DEFINE_GHES_NMI_FIXMAP(sde_normal, FIX_APEI_GHES_SDEI_NORMAL); +static DEFINE_GHES_NMI_FIXMAP(sde_critical, FIX_APEI_GHES_SDEI_CRITICAL); + +int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *cb) +{ + int err; + u32 event_num; + u64 result; + + 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) + ghes->nmi_fixmap = &sde_critical; + else + ghes->nmi_fixmap = &sde_normal; + + 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..5fdf799be026 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,10 @@ 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 *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);