From patchwork Fri Dec 3 02:43:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 12694575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74B76C433F5 for ; Fri, 3 Dec 2021 02:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wuQKO6Fywp4e0ohIQ26OdRQ92Af+uJ9rBuGztr+GaVY=; b=WaWYpGy0LQnzM3 oHOt4Q+iCHuLh0Pi6DmJqpOPTdpFOK5yo4vrwry97au1a9GRkgENCiOXrZw/I4lLOf2KEjoLOk0lG cpZ5sNIKpsHq8VdbTR/jDbuAci2rwA4wZcom8Vz44qctOMWtbRLBkxPPRdYkik3/06Y9JQXBIMXiq VFokYk8swReugGBhWIOcPmBADf8tXy+LSzkH6fvTqqsqv0l5mtLvJcRlTtGUJ2r1E9sSmHDbcgnLC U+tICC+UA4gbW4BJ7SQoy/Zmno5Ayzki4wjOk9pQOs8hjcq8hTy+a1f2260mFKY6O5VaKPV+nKuh0 95BymOp4SPoom2iYlPBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1msyYk-00E698-Ms; Fri, 03 Dec 2021 02:44:27 +0000 Received: from mail-bn8nam11on2133.outbound.protection.outlook.com ([40.107.236.133] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1msyYO-00E640-3m for linux-arm-kernel@lists.infradead.org; Fri, 03 Dec 2021 02:44:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ISooEFm8Jj6FQEE/Bh5qtOl75iOIzSrIe4rmxD/B7Jv7v9isBXe+QrFqYjxLcKgu4PSdDhCAUEDYXvUtAkFNGRcW3/kz724pgvC9TOUR0s0C6EBrSy4dhAzJVul/hyT2P2Eg1FoYkmAw+kUqYBx9GSMfh/OdAOTxfYZTuvYdop8D2DEzXRQ/qh1RoOBcxWIkY+Xf+OO+EGiwhUtO538sAn+sMrm0wNKygJJ1bXSly+7Q6e6kOnMwQaVIraG/sUFEuxDpzGvrm3KQoAXWez10Mcyz59Z0VwyTkySxhl9mJB9AT5OhLJX/k7qHZ6fQ8kyYL0UX5HgRr3YIeQwryyBRVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WJ+r+fpiBqIlURQpo8CHFrUdKco8Vdl/9kuKXY7RBQU=; b=XCAF7RafIR30A7TFLGn/WJdOFFgynI1hvEQi0Y1kl8Yme8JeV7eyhUossZWs5ORDjhNP3Tn6dr9JDuZ4MY4Acd01kf9tB6OhLkFmkTGSZIm1Z1iVyHuWO5t8eVxsNTPkelO5jQ156Q370kanGt9civAXYj1JpSyM6la4RYBHGOLrMYfVkLISt1ntj9+ZhbrF8KJ5zovgRyDDIuMlvXJApITCYt1UqbmyfQt6xRssdHjRGJ7iSY3BYPW1T9OUsn+0FCEE0eYKG07a5YEnkTbTxmKMeoAKi0RmrO1j0evSIXSId7TpbgkVoR8M6pdrgWrN+gLrW+hZpNKpBB9uOw4vew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WJ+r+fpiBqIlURQpo8CHFrUdKco8Vdl/9kuKXY7RBQU=; b=fVhcsJP164UJqrMn2hIrUE0Z3TzMjXmJmEmHgE9evoPw+VFUdXnu3SSJHdHsu20Y5CEz06ItToa05eAJrsBJWEdD3oMAoVJCnBOv706jWP3y1JQxIvBPsipqyKb8nIxQq5whEEkdrYYdER1BrrB1WrogVC6tMKohhnrarxtPXi8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) by DM5PR01MB2412.prod.exchangelabs.com (2603:10b6:3:3e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.14; Fri, 3 Dec 2021 02:43:59 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::d93b:cd3c:bb56:33a2]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::d93b:cd3c:bb56:33a2%5]) with mapi id 15.20.4734.028; Fri, 3 Dec 2021 02:43:59 +0000 From: Ilkka Koskinen To: lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com Cc: rafael@kernel.org, lenb@kernel.org, robert.moore@intel.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devel@acpica.org, patches@amperecomputing.com, scott@os.amperecomputing.com, darren@os.amperecomputing.com Subject: [PATCH 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Date: Thu, 2 Dec 2021 18:43:11 -0800 Message-Id: <20211203024311.49865-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211203024311.49865-1-ilkka@os.amperecomputing.com> References: <20211203024311.49865-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0312.namprd03.prod.outlook.com (2603:10b6:610:118::21) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 Received: from eng01sys-r111.scc-lab.amperecomputing.com (4.28.12.214) by CH0PR03CA0312.namprd03.prod.outlook.com (2603:10b6:610:118::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.17 via Frontend Transport; Fri, 3 Dec 2021 02:43:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82d54e2a-c148-4ba2-1cbf-08d9b606c1e0 X-MS-TrafficTypeDiagnostic: DM5PR01MB2412: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3OYuP116UM7SKUmOHDGr/iZI50UxbhF2qiXyXvl6H+HYshCI/nirNsEWbgwbqkSei+DhhTUCqxIX2VfH4WDtIvIPq3+MgPLIn5iT7wI9FXtcj0OyXjX9WcMCN0LBW9nug0oeoMr6eyHkfVbYzkQXuy06nSCK4qNlqi6C0lyAprisQPNuRZsWZJMZut+4xuOg4ohOVij+O3rT+biLgMt1gVaGDgxkO/FDcrzEPLlyaxHUfmxrzh5S1csnRguGRAvLbagkdWiSz0G3z5swhLNONGP3LQkw5pBYSJYCYJDtJ2mordC2T1wd5B+2rKD4n/EyQiCfITuqrKt9F168u8LnpMI1YdZ8EfsCE+W2vIOP3cH+OAgLFpzUoSdk4nqA6gNqUNUxPDbwH8yoWZUwKyRrJC/IxPSxxgbfO1ugO8Rmn2/T4hjs5OhbZfQI+xKR7XPMkUUNAoKrK5xNIvJ3z4n3rYNZRzUXTg2CNew0IT+9LCreBO7dvVswk3D13JKXLFpjXfddz595x7pXe3DVd7n9yj9Vt8hX+BK1CWkgF9hHpk6UrxfvnbftW4SvTouYo48dzdJbFp2vfAG9aP4+F1sldRvJ6BRYNElUQaPuYt6CBBsBMZOJUDjHmVwJuJ4MYlLmZez8O2xvLmnbDcGPsl9honXBndh4WtvTOcJU27SKY0qtIRM3iA8rM6d998OIYbSLWNI8jJYbjzgNpCv4FyEs3q2FSuXrqTkrovP5PKeULtFNSQ00RvATby7CEoD2zQksBQJPmKitiFeXxLXsPQSedMILHtITSDZV0UkkSBX1Nt1WDg6xdwodJLbqhUT5ZBGf X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR0102MB3590.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8676002)(2616005)(966005)(6506007)(6666004)(66476007)(66946007)(6486002)(7416002)(1076003)(956004)(2906002)(8936002)(5660300002)(508600001)(26005)(66556008)(86362001)(4326008)(52116002)(186003)(38100700002)(6512007)(316002)(83380400001)(38350700002)(107886003)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vij9g5atelKtp8dDs92hrr8wypuZOuJwZwCQY5VtPBl/7TArojMZmyfJUJkZ9wh7sXfCUIFmgQk0jw3Nmqm7ODhhkrGpl1GqLW9+rSoCvD7QCvb3iFpZRJLA6YHV8FSWepUplBysY/ygyCKTlAoSX5jDKex2qvCBiDgCRZBeENkCZSqGN3zppCpD8S/aF9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6+uA63N6Hz+zJlQCjVb0BAyPt6I0MunavKrdBW0XoXxZUFR+pt3i5wSCNJifR+LvTZcNHMQcNQT5znmLFZSfGyuQbFSHPlUC8aQf64ozI0dOHuW8J5vqWsRp3/4z9+UrO1n0HR1V2np2Tu1o9CzGgys6jg45ai7Ajjrzu6HhuczRvJIPvdTHn3u/EiPOJbDVrXZUqz5zJPXswMPzq4Jori1D2k+flA3LpSK415v0TaV//DpeyTMsNhTmOXCZHFEa1FuqcdBfAw9QJxzwiUzCjLY+W/p4pVoeRs3+q39fhwZrk7COIFzzBNUYGSWEixc1fvXZHXqtNX736qHHQ6J+PiKDYYlVewqZ5vOiA4DWfTDDXxuImGhlY00C14SKH25Gp+FP5F+9ikrf+ddIqnvKqJOt8OKyQPHp4VbawMwXXn8oNKTJIfAlTZPPh1UAjdppgv5RZKqlgDaEyc4IIqb3EfmWg== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82d54e2a-c148-4ba2-1cbf-08d9b606c1e0 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2021 02:43:59.1813 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2iprQxTKMEQmHipb6VwXAiAtq1w8BDLXS/60rLB/+pgG1/YZmUZQe+ty3wLoUxqW7KAI1i5NozA5JWw81txXtLtX266x47YlKV/yyiI8le2ptLp1RsYLhStteU67kqK7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR01MB2412 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211202_184404_196450_A8CC0F20 X-CRM114-Status: GOOD ( 19.03 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ACPI for Arm Components 1.1 Platform Design Document v1.1 [0] specifices Arm Generic Diagnostic Device Interface (AGDI). It allows an admin to issue diagnostic dump and reset via an SDEI event or an interrupt. This patch implements SDEI path. [0] https://developer.arm.com/documentation/den0093/latest/ Signed-off-by: Ilkka Koskinen --- drivers/acpi/arm64/Kconfig | 8 +++ drivers/acpi/arm64/Makefile | 1 + drivers/acpi/arm64/agdi.c | 133 ++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 drivers/acpi/arm64/agdi.c diff --git a/drivers/acpi/arm64/Kconfig b/drivers/acpi/arm64/Kconfig index 6dba187f4f2e..24869ba5b365 100644 --- a/drivers/acpi/arm64/Kconfig +++ b/drivers/acpi/arm64/Kconfig @@ -8,3 +8,11 @@ config ACPI_IORT config ACPI_GTDT bool + +config ACPI_AGDI + bool "Arm Generic Diagnostic Dump and Reset Device Interface" + depends on ARM_SDE_INTERFACE + help + Arm Generic Diagnostic Dump and Reset Device Interface (AGDI) is + a standard that enables issuing a non-maskable diagnostic dump and + reset command. diff --git a/drivers/acpi/arm64/Makefile b/drivers/acpi/arm64/Makefile index 66acbe77f46e..7b9e4045659d 100644 --- a/drivers/acpi/arm64/Makefile +++ b/drivers/acpi/arm64/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_ACPI_AGDI) += agdi.o obj-$(CONFIG_ACPI_IORT) += iort.o obj-$(CONFIG_ACPI_GTDT) += gtdt.o obj-y += dma.o diff --git a/drivers/acpi/arm64/agdi.c b/drivers/acpi/arm64/agdi.c new file mode 100644 index 000000000000..cdd8811df3d5 --- /dev/null +++ b/drivers/acpi/arm64/agdi.c @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * This file implements handling of + * Arm Generic Diagnostic Dump and Reset Interface table (AGDI) + * + * Copyright (c) 2021, Ampere Computing LLC + */ + +#define pr_fmt(fmt) "ACPI: AGDI: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +struct agdi_data { + int sdei_event; +}; + +static int agdi_sdei_handler(u32 sdei_event, struct pt_regs *regs, void *arg) +{ + nmi_panic(regs, "Arm Generic Diagnostic Dump and Reset SDEI event issued"); + return 0; +} + +static int agdi_sdei_probe(struct platform_device *pdev, + struct agdi_data *adata) +{ + int err; + + err = sdei_event_register(adata->sdei_event, agdi_sdei_handler, pdev); + if (err) { + dev_err(&pdev->dev, "Failed to register for SDEI event %d", + adata->sdei_event); + return err; + } + + err = sdei_event_enable(adata->sdei_event); + if (err) { + sdei_event_unregister(adata->sdei_event); + dev_err(&pdev->dev, "Failed to enable event %d\n", + adata->sdei_event); + return err; + } + + return 0; +} + +static int agdi_probe(struct platform_device *pdev) +{ + struct agdi_data *adata; + + adata = dev_get_platdata(&pdev->dev); + if (!adata) + return -EINVAL; + + return agdi_sdei_probe(pdev, adata); +} + +static int agdi_remove(struct platform_device *pdev) +{ + struct agdi_data *adata = platform_get_drvdata(pdev); + + sdei_event_disable(adata->sdei_event); + sdei_event_unregister(adata->sdei_event); + + return 0; +} + +static struct platform_driver agdi_driver = { + .driver = { + .name = "agdi", + }, + .probe = agdi_probe, + .remove = agdi_remove, +}; + +static int __init agdi_init(void) +{ + int ret; + acpi_status status; + struct acpi_table_agdi *agdi_table; + struct agdi_data *pdata; + struct platform_device *pdev; + + if (acpi_disabled) + return 0; + + status = acpi_get_table(ACPI_SIG_AGDI, 0, + (struct acpi_table_header **) &agdi_table); + if (ACPI_FAILURE(status)) + return -ENODEV; + + pdata = kzalloc(sizeof(*pdata), GFP_ATOMIC); + if (!pdata) { + ret = -ENOMEM; + goto err_put_table; + } + + if (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE) { + pr_warn("Interrupt signaling is not supported"); + ret = -ENODEV; + goto err_free_pdata; + } + + pdata->sdei_event = agdi_table->sdei_event; + + pdev = platform_device_register_data(NULL, "agdi", 0, pdata, sizeof(*pdata)); + if (IS_ERR(pdev)) { + ret = PTR_ERR(pdev); + goto err_free_pdata; + } + + ret = platform_driver_register(&agdi_driver); + if (ret) + goto err_device_unregister; + + acpi_put_table((struct acpi_table_header *)agdi_table); + return 0; + +err_device_unregister: + platform_device_unregister(pdev); +err_free_pdata: + kfree(pdata); +err_put_table: + acpi_put_table((struct acpi_table_header *)agdi_table); + return ret; +} +device_initcall(agdi_init);