From patchwork Mon Dec 3 18:06: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: 10710299 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 18A171057 for ; Mon, 3 Dec 2018 18:08:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DA952B47E for ; Mon, 3 Dec 2018 18:08:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00C802B495; Mon, 3 Dec 2018 18:08:32 +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 6E2322B487 for ; Mon, 3 Dec 2018 18:08:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE2776B6A9F; Mon, 3 Dec 2018 13:08:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B68106B6AA1; Mon, 3 Dec 2018 13:08:07 -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 9E6156B6AA2; Mon, 3 Dec 2018 13:08:07 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by kanga.kvack.org (Postfix) with ESMTP id 6D2D06B6A9F for ; Mon, 3 Dec 2018 13:08:07 -0500 (EST) Received: by mail-oi1-f200.google.com with SMTP id w128so8715539oie.20 for ; Mon, 03 Dec 2018 10:08:07 -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=xaMNalE2guwsyW9EtXo5sNk34iVUQAWFwG8Myi8K5JA=; b=ab4K2fKUf95OAXQwdtczcVRZy1hw+SXjxlUwRK5ehy8Pvi1WEgG+xVSGftVWI5llH2 yqzUQK7zVCRUjgh+aXswATB7G4Wusy4rcGrHgrgbScghn1c5cW/VVn2ypZSCwgbaI7+i Gf+MXL4mVck6H65VxsuvQzM4hxesG+t9zsnQmDqG7z9ZGEenYvcx6OojIiC8o4mP/8JV RA/DhxOm6l7BRMM8RnW1XNb8vAXn31K9NtvFMi1w4/paiFQpCWJLTuJBXaPEJM4m05VV SwxlsiNw42wxhTwrkEaudMu23yt6+loPuaA1CPzUMjOGCOKudjCyn/P7BrfJPf5Bgb0v Hf+A== 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+aEWbQ+G4Y1pYbSyzSYwKcVzKFnzHPsugPoQHYZ8vvWbzrldGtcDmG qaDQPIgZxujvc5oWcMdJglM/R+zFKRmUujZuXh0NzjFt97PvfWUHs9kr4uVW0zJ5zGYZjXGbeQq M9bPFrjtR79C2CUq2efL1yI2drCWDXPqlcGdPwwRX4cuD76Td1sFWOhrDs7g5SfAhXA== X-Received: by 2002:a54:4713:: with SMTP id k19mr9770703oik.241.1543860487200; Mon, 03 Dec 2018 10:08:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/W8dusHikM9zyocIGVXgkTDPPl5bWv7MylttoXwHpragR+IAsrYZ4WfOYHUMti3+/ycHOnv X-Received: by 2002:a54:4713:: with SMTP id k19mr9770675oik.241.1543860486399; Mon, 03 Dec 2018 10:08:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860486; cv=none; d=google.com; s=arc-20160816; b=oRW4atfiLgdBp8h8BFSQV2WPlG2UwmqqeWps+y5FGNOw+VQ5rbW8MSqMePzmanL2OI R3r0eb60Qb2Bt7kwE6CeiViSMC4nRDKQbjzWNdbOkjiYi50xUsWC8ss5KuROvhdfU0Su QUiCOh9x/M5lT8PSHVTVom82sdmlp0awI57XoC47ymUQ3Ws7INTfw0UI8CTu/OsFCOjW XslJg2q/8hmXXhBOj/95Iptcg/hPBGal2eABnnB/vXNdZs/H+Xdatfw9zxKkCW3y9U+W z98iANwukhcJ+s1t9COp47E40yW3DGuT2xxOZSf3IlxBt/GAAour2xagpaA7O0HnYOwe neUA== 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=xaMNalE2guwsyW9EtXo5sNk34iVUQAWFwG8Myi8K5JA=; b=ob+zSCM+1QE7GTb+sypAoxqDJcAMC9wKvHUVOdz5Zhj8ubAVa70vyMDJxjEOgUc0Vk K0DTb0qPQ287kRqaTjXYrHuo2JGLD04zR9O5YbgwKxENXNQuWLKvtlFugG3mnI2bPTv6 +bNBcL9YpexGRbROtRO7pBsoSPZforc3HkdeRhFZTkWvdoujjjPm9NxMB5HrvSZz7kH6 ILkZmIs5/MgeHnfx8lFVl91vRDYfup5Yr8SgTMdcx7k4/iK22yt0MUhm+K6RospGnZ5c FRKJUREajrLaMBJsWLyIT6S962FafRw11rOIoKE2iIHjqeO3XxDan3noYpYCYb/fbN7E XkZg== 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 j5si5986037oiw.131.2018.12.03.10.08.06 for ; Mon, 03 Dec 2018 10:08:06 -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 EA071169E; Mon, 3 Dec 2018 10:08:05 -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 25A843F59C; Mon, 3 Dec 2018 10:08:03 -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 25/25] ACPI / APEI: Add support for the SDEI GHES Notification type Date: Mon, 3 Dec 2018 18:06:13 +0000 Message-Id: <20181203180613.228133-26-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 If the GHES notification type is SDEI, register the provided event using the SDEI-GHES helper. SDEI may be one of two types of event, normal and critical. Critical events can interrupt normal events, so these must have separate fixmap slots and locks in case both event types are in use. Signed-off-by: James Morse --- Changes since v6: * Tinkering due to the absence of #ifdef * Added SDEI to the new ghes_is_synchronous() helper. --- drivers/acpi/apei/ghes.c | 82 +++++++++++++++++++++++++++++++++++++++- include/linux/arm_sdei.h | 3 ++ 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 3e7da9243153..6325f1d6d9df 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -25,6 +25,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -93,6 +94,10 @@ #ifndef CONFIG_ACPI_APEI_SEA #define FIX_APEI_GHES_SEA -1 #endif +#ifndef CONFIG_ARM_SDE_INTERFACE +#define FIX_APEI_GHES_SDEI_NORMAL -1 +#define FIX_APEI_GHES_SDEI_CRITICAL -1 +#endif static inline bool is_hest_type_generic_v2(struct ghes *ghes) { @@ -128,6 +133,8 @@ static DEFINE_MUTEX(ghes_list_mutex); * simultaneously. */ static DEFINE_SPINLOCK(ghes_notify_lock_irq); +static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sdei_normal); +static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sdei_critical); static struct gen_pool *ghes_estatus_pool; static unsigned long ghes_estatus_pool_size_request; @@ -141,7 +148,8 @@ static bool ghes_is_synchronous(struct ghes *ghes) { switch (ghes->generic->notify.type) { case ACPI_HEST_NOTIFY_NMI: /* fall through */ - case ACPI_HEST_NOTIFY_SEA: + case ACPI_HEST_NOTIFY_SEA: /* fall through */ + case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: /* * These notifications could be repeated if the interrupted * instruction is run again. e.g. a read of bad-memory causing @@ -1100,6 +1108,60 @@ static void ghes_nmi_init_cxt(void) init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq); } +static int __ghes_sdei_callback(struct ghes *ghes, int fixmap_idx) +{ + if (!_in_nmi_notify_one(ghes, fixmap_idx)) { + irq_work_queue(&ghes_proc_irq_work); + + return 0; + } + + return -ENOENT; +} + +static int ghes_sdei_normal_callback(u32 event_num, struct pt_regs *regs, + void *arg) +{ + int err; + struct ghes *ghes = arg; + + raw_spin_lock(&ghes_notify_lock_sdei_normal); + err = __ghes_sdei_callback(ghes, FIX_APEI_GHES_SDEI_NORMAL); + raw_spin_unlock(&ghes_notify_lock_sdei_normal); + + return err; +} + +static int ghes_sdei_critical_callback(u32 event_num, struct pt_regs *regs, + void *arg) +{ + int err; + struct ghes *ghes = arg; + + raw_spin_lock(&ghes_notify_lock_sdei_critical); + err = __ghes_sdei_callback(ghes, FIX_APEI_GHES_SDEI_CRITICAL); + raw_spin_unlock(&ghes_notify_lock_sdei_critical); + + return err; +} + +static int apei_sdei_register_ghes(struct ghes *ghes) +{ + if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) + return -EOPNOTSUPP; + + return sdei_register_ghes(ghes, ghes_sdei_normal_callback, + ghes_sdei_critical_callback); +} + +static int apei_sdei_unregister_ghes(struct ghes *ghes) +{ + if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) + return -EOPNOTSUPP; + + return sdei_unregister_ghes(ghes); +} + static int ghes_probe(struct platform_device *ghes_dev) { struct acpi_hest_generic *generic; @@ -1135,6 +1197,13 @@ static int ghes_probe(struct platform_device *ghes_dev) goto err; } break; + case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: + if (!IS_ENABLED(CONFIG_ARM_SDE_INTERFACE)) { + pr_warn(GHES_PFX "Generic hardware error source: %d notified via SDE Interface is not supported!\n", + generic->header.source_id); + goto err; + } + break; case ACPI_HEST_NOTIFY_LOCAL: pr_warning(GHES_PFX "Generic hardware error source: %d notified via local interrupt is not supported!\n", generic->header.source_id); @@ -1198,6 +1267,11 @@ static int ghes_probe(struct platform_device *ghes_dev) case ACPI_HEST_NOTIFY_NMI: ghes_nmi_add(ghes); break; + case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: + rc = apei_sdei_register_ghes(ghes); + if (rc) + goto err; + break; default: BUG(); } @@ -1223,6 +1297,7 @@ static int ghes_probe(struct platform_device *ghes_dev) static int ghes_remove(struct platform_device *ghes_dev) { + int rc; struct ghes *ghes; struct acpi_hest_generic *generic; @@ -1255,6 +1330,11 @@ static int ghes_remove(struct platform_device *ghes_dev) case ACPI_HEST_NOTIFY_NMI: ghes_nmi_remove(ghes); break; + case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: + rc = apei_sdei_unregister_ghes(ghes); + if (rc) + return rc; + break; default: BUG(); break; diff --git a/include/linux/arm_sdei.h b/include/linux/arm_sdei.h index 393899192906..3305ea7f9dc7 100644 --- a/include/linux/arm_sdei.h +++ b/include/linux/arm_sdei.h @@ -12,7 +12,10 @@ enum sdei_conduit_types { }; #include + +#ifdef CONFIG_ARM_SDE_INTERFACE #include +#endif /* Arch code should override this to set the entry point from firmware... */ #ifndef sdei_arch_get_entry_point