From patchwork Mon Dec 3 18:06:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10710295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDF50109C for ; Mon, 3 Dec 2018 18:08:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFCC32B47E for ; Mon, 3 Dec 2018 18:08:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1D282B495; Mon, 3 Dec 2018 18:08:27 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F6BC2B47E for ; Mon, 3 Dec 2018 18:08:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D3AC6B6A9D; Mon, 3 Dec 2018 13:08:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3A1D16B6A9F; Mon, 3 Dec 2018 13:08:04 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2681B6B6AA0; Mon, 3 Dec 2018 13:08:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by kanga.kvack.org (Postfix) with ESMTP id E94C86B6A9D for ; Mon, 3 Dec 2018 13:08:03 -0500 (EST) Received: by mail-oi1-f197.google.com with SMTP id h85so8764435oib.9 for ; Mon, 03 Dec 2018 10:08:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gMemP6CVYESD7JPOg7f7tWzOngUpBjOLmcBn3e9J/LM=; b=mYB07iDKBlzmcHx/G4HE/bf85K0M2N6xoFuZ5ejhcaRfswwU80TTqnp+dfLAgluwyo v11kiMUiQOcuT80SJY/fDZFWAyeCyo6ikYSr44c53E5tzz5nlOYoOuQyZq+OZkxdxBZV b3JmeKsFYfscBoGt8jGFx8ZJWcgoXIg9D8+/9Diqq3jFXU/OTVGVLFcMx/n5enyvK5au D1YFul2obR9hrKQw/xKLCX3o1fLKSxsZXGNzbrvYZ+M2Ka+U7lORv1UG/3yTk+Qfx2bb 37q9LWxxzoCXMAiHyHzm1VxObHFREFqzMWkdvW+kumkJLCFHEOFQxkFhyUJIEzqcbLnZ wTbA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com X-Gm-Message-State: AA+aEWZMsAWgTY7QygtI/XxvnYA4oY5NueMN3giJRWQtCPR0aMKqb7IN zBWk3zrcUY6LmR3KzKuhLThmjuFA/MxdD32jJK5i6eEKirdL8XCZ2I16m5qqeEa+5DD7fYjP8Su iHIJfNe2zCF8BD00ykpozsyiBZ9Mw9yIcZ3NXOHxHVAfCk/sSfcMpIQuLA6rrtnWOUA== X-Received: by 2002:aca:de03:: with SMTP id v3mr10749890oig.152.1543860483707; Mon, 03 Dec 2018 10:08:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uan2bdZHCacknetf/oeV1pkP6c2nOV8emeYmWEeJR6TW/Ts49XdnI6uSrGzUXnkY2Vk6Ug X-Received: by 2002:aca:de03:: with SMTP id v3mr10749856oig.152.1543860482937; Mon, 03 Dec 2018 10:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860482; cv=none; d=google.com; s=arc-20160816; b=wC7eh45a8iGUr8t1SM5jtZ/F1iwRkxxdevokHvO/6DfYfEBjDzXtE30Egv1OaVxIlg 50J6KXBJ+L++GyW6zuoAGXpHtOMCL0gk9+au27bvuigw9+4fRvoA7ZlspfZUzhxcCMgL hVRyh6vdUC7LxiK2YeEuGOHLuOLq77xGxSJoVogBzIEjaNzPP1lPbFNU4noMNgSh2/hl PobonvAuTNpVI38VWe63ajiGVAogfhpTvZsnRRBvtPCnvNGW4nywEbzn7YiP6q2vpw9n brfmns9YPAduducrDcrUQ30AlFn+U1l12bwBctEyd/UJN6MWWeSVJ0sCuFPqXv88EtZM duAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=gMemP6CVYESD7JPOg7f7tWzOngUpBjOLmcBn3e9J/LM=; b=ueaUGBz040q8UzSkX1SYD81eg0epQxQzwz6lRx1N4isAFBbXkbReGP1hPmSlujjUTW MRDBE9ZHRfQ72f5FIMnjh4qzqwtXbxMhCHm27se4geWUZnLD9aoHPmdQJ02rKJOxeyku zwwGQKRp3XRHyITkzduGRU6p+SPyynWW8PLt6WdMVrLdOD2WBEeBejQQv3jXmijsH+Ln aiw/OVrqdppJqe3OPJheJjsxttzOp4qLX9LOFoWokv5trfr7YAZJQX9Un3Bg362tj+jZ ooL9lbH28685AazMNyloI5UZZApekdHdMl/n8281Zrjcand4OaXQ4ky9y+d3foiEh4eJ HAAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id f36si6885153otf.163.2018.12.03.10.08.02 for ; Mon, 03 Dec 2018 10:08:02 -0800 (PST) Received-SPF: pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com 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 660F71713; Mon, 3 Dec 2018 10:08:02 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 950123F59C; Mon, 3 Dec 2018 10:07:59 -0800 (PST) From: James Morse To: linux-acpi@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Borislav Petkov , Marc Zyngier , Christoffer Dall , Will Deacon , Catalin Marinas , Naoya Horiguchi , Rafael Wysocki , Len Brown , Tony Luck , Dongjiu Geng , Xie XiuQi , Fan Wu , James Morse Subject: [PATCH v7 24/25] firmware: arm_sdei: Add ACPI GHES registration helper Date: Mon, 3 Dec 2018 18:06:12 +0000 Message-Id: <20181203180613.228133-25-james.morse@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181203180613.228133-1-james.morse@arm.com> References: <20181203180613.228133-1-james.morse@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 GHES shouldn't have to know about the SDEI API. Add a helper to register the GHES using the appropriate normal or critical callback. Signed-off-by: James Morse Acked-by: Catalin Marinas --- Changes since v4: * Moved normal/critical callbacks into the helper, as APEI needs to know. * Tinkered with the commit message. * 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 | 70 +++++++++++++++++++++++++++++++++ include/linux/arm_sdei.h | 6 +++ 3 files changed, 80 insertions(+) diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h index 966dd4bb23f2..f987b8a8f325 100644 --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -56,6 +56,10 @@ enum fixed_addresses { /* Used for GHES mapping from assorted contexts */ FIX_APEI_GHES_IRQ, FIX_APEI_GHES_SEA, +#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..4bcbe3a3f597 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,73 @@ static void sdei_smccc_hvc(unsigned long function_id, arm_smccc_hvc(function_id, arg0, arg1, arg2, arg3, arg4, 0, 0, res); } +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; + + if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) + return -EOPNOTSUPP; + + 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(); + + if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES)) + 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; +} + 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);