From patchwork Thu Feb 15 18:56:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10223383 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 CDFA6602CB for ; Thu, 15 Feb 2018 19:05:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE11929406 for ; Thu, 15 Feb 2018 19:05:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B263D29485; Thu, 15 Feb 2018 19:05:23 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID 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 3ADC629406 for ; Thu, 15 Feb 2018 19:05:23 +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=ALj22qI6GXni+gapvArmTHHINs1DMjw11xbzZXmUtxE=; b=S6cNOQ1gGOBEfdz0QcgRyObty5 3uR0UfQHynLVTEWP/NzuHr7rQpBED3wMBPkJTm/LsQqBVEzOe84k9qgAkasjH4UQueTiGvKhAO9pE txIqBdFkGxrsbRhkQ6u2E+WYZTi2OXp7dJGAuB3JCjrSMetfy9tGvCDWyTfzIkVGt1T2D0cwt5GrX zb6qirRelkG4Gvltb+V6mvdpP/N1FoK4IcSOeLNKr0xblatguRihblG8ZZFfsv9eQlkJfA79F7K6H I1ohmIOFbqLnq+sZThUPHQuqwHp30UNSn19m8D0Kx0A0ifEWBaF5oyk3ht+PRPHLq5EC9kHP6rLSO BzkBZbbA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1emOqM-00021I-AT; Thu, 15 Feb 2018 19:05:18 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1emOka-0005A6-8G for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2018 18:59:45 +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 A8CA3165C; Thu, 15 Feb 2018 10:59:17 -0800 (PST) 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 B65953F487; Thu, 15 Feb 2018 10:59:14 -0800 (PST) From: James Morse To: linux-acpi@vger.kernel.org Subject: [PATCH 08/11] firmware: arm_sdei: Add ACPI GHES registration helper Date: Thu, 15 Feb 2018 18:56:03 +0000 Message-Id: <20180215185606.26736-9-james.morse@arm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180215185606.26736-1-james.morse@arm.com> References: <20180215185606.26736-1-james.morse@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180215_105920_651797_B5124AA5 X-CRM114-Status: GOOD ( 16.99 ) 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: Rafael Wysocki , Tony Luck , Punit Agrawal , Xie XiuQi , Marc Zyngier , Catalin Marinas , Tyler Baicar , Will Deacon , Dongjiu Geng , linux-mm@kvack.org, Borislav Petkov , linux-arm-kernel@lists.infradead.org, James Morse , Naoya Horiguchi , kvmarm@lists.cs.columbia.edu, Christoffer Dall , 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 --- arch/arm64/include/asm/fixmap.h | 4 +++ drivers/firmware/arm_sdei.c | 75 +++++++++++++++++++++++++++++++++++++++++ include/linux/arm_sdei.h | 5 +++ 3 files changed, 84 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..9b6e140cf6cb 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 @@ -887,6 +888,80 @@ 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 +/* These stop private notifications using the fixmap entries simultaneously */ +static DEFINE_RAW_SPINLOCK(sdei_ghes_fixmap_lock_normal); +static DEFINE_RAW_SPINLOCK(sdei_ghes_fixmap_lock_critical); + +int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *cb) +{ + int err; + u32 event_num; + u64 result; + + if (acpi_disabled) + return -EOPNOTSUPP; + + event_num = ghes->generic->notify.vector; + if (event_num == 0) { + /* + * Event 0 is the 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_lock = &sdei_ghes_fixmap_lock_critical; + ghes->fixmap_idx = FIX_APEI_GHES_SDEI_CRITICAL; + } else { + ghes->nmi_fixmap_lock = &sdei_ghes_fixmap_lock_normal; + ghes->fixmap_idx = FIX_APEI_GHES_SDEI_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(); + + if (acpi_disabled) + return -EOPNOTSUPP; + + /* + * 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 */ + 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);