From patchwork Tue Dec 14 04:40:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 12696034 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 3EA21C433F5 for ; Tue, 14 Dec 2021 04:43:17 +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=xncX0Mv6azkRFX97pDq3Ght0i+cT995LsEdxvTAyipM=; b=kR9f6ZmGewIw45 x1PMmwGqfC6MhlxcaccllMdvPJlB05h8/nY09hHWCJAUtnaQpM3jUUFXupB8aDDwrABsVMOrs88fG M3cjK3XdCP6un6aKnZNgmxo5yo9mcigi39tcfh47GZMCSpIdFTVf95NpPo8ofyjuc0w6JBYxgavnh sqdY10ANSkP7pudYiwhaMcAfzORUD87IogtsBSnq6SgtkVVGs6ZpouqYdFeAFzTob7Qy9etar26bC jc39kjHl6iko04rS12/gCTxVqDkAhOcPICdE4ryr7C0vqlk+onSYVVQMmFsqAWxg2u5OrA2pkNKwI YvN4E7ARSjx6IZR9cSIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwzd4-00CYUf-7X; Tue, 14 Dec 2021 04:41:30 +0000 Received: from mail-bn8nam12on2128.outbound.protection.outlook.com ([40.107.237.128] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwzcf-00CYOO-HY for linux-arm-kernel@lists.infradead.org; Tue, 14 Dec 2021 04:41:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JH85nqoXgmvq+jWen+B+RRmCsCWt+GGVAVa5mM6jyxyfH7w9+ywnV840g9XG1/YqFzalnb4D3K0ZeB33gzanb4y7QGHVzwmbW4hNjWAP1hOnTgwZLOa6+YC7V3foSySQgAGTtoI4kcH5/DAvIXsOHK7wkAge6WQVhSuUWxagfc/FiBJGJ3F/ZcJ/arNDQM+C0TSLl5fYMs7cn5UMdWYF7el0MPV/3rzboM+4WPcUGjY9rKsijmIe0IhiQj8nM99MGGJ4JjUhfBJPYGDHrL77AQ7gb6bE5QUc0c63RSuEunBvWEoF6qGGsY7vMpKiItNhNUetyEXtICzDZ9v4+RWu7w== 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=KbAkhrQB8e00n7Lfgi9b6VumYWZ7vNWCYET9PxfwR7o=; b=VHmlYs4riZ/lu8JWurWXD8CdflFWGLGKQzCFMntnCdod3USziHJJDRJ3c/9e74zKM4GoHkbVsPNWpoHNMmBycN58R3pRTByqkNR3TAXngKrsygpvP39c3G/wRbFLyESK1wByLjP7R9kv04lcJY6TEoEbdDxotpbOatZA+I6/H9G/hZpaCMsWXZwaY4m11mBy8XBQE+Higj611DJo53qBLkp0FQA4Oy1Dp0VxXSUl6jsYW6ATmg2k9Zgne+KVE1DGXeQh176YG5qQIEV9PTRIis2uXOF9T3M90HPgkXk9IBQ/JDL0dUZInEtHjGEBDyNUS14+d50nSO2yvW34g/PDXg== 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=KbAkhrQB8e00n7Lfgi9b6VumYWZ7vNWCYET9PxfwR7o=; b=eG2NAsywWPkW0mKlx9aN9WP/PAzIcRCsEzq9njQJ5L/9CYXrr+HCg5UqUx68/Fpn3bpFWqAIY3A7BPP+MYnvqJ8M/Tr81UhEJVGa6ktd7o+Lb+/5r69SpPusYqz9MU011toVr6+Vjmfa601hohaZZ52Y9XM7MUxgdZnySViZZug= 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 DM6PR01MB4826.prod.exchangelabs.com (2603:10b6:5:64::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4778.18; Tue, 14 Dec 2021 04:40:58 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::38e1:cab:501d:6b96]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::38e1:cab:501d:6b96%4]) with mapi id 15.20.4778.017; Tue, 14 Dec 2021 04:40:58 +0000 From: Ilkka Koskinen To: lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, linux@armlinux.org.uk 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 v2 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Date: Mon, 13 Dec 2021 20:40:36 -0800 Message-Id: <20211214044036.48245-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211214044036.48245-1-ilkka@os.amperecomputing.com> References: <20211214044036.48245-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0063.namprd03.prod.outlook.com (2603:10b6:610:cc::8) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d2b255f8-55b4-4039-30c1-08d9bebbec80 X-MS-TrafficTypeDiagnostic: DM6PR01MB4826:EE_ 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: fKh8f8JTI1An9G4dURfNLnp+KTVF56ShkKtGL2IukRRKf1lIR65RDd5GEO4TWSWDk361/g7SYeoLIKAehmpf8SqoXFwjBHwOt861ARGvy2GaGUKuOxko8fq4QqjdgEaKfs55o2EBkUvtHRY6oTqlq+Wafi62O9Tdx263WqDWUj6sZk5INSzXhe8lEd8Tvs8t2uFPmRPu3YBBUCq+GhfAv5LEo+H4B0e2OfICM8vHQF27aEz9yYS1kJgckN4FCRJou9ysWeyiqvx3sdTHtWbzDO7+iD/gAEoW8/Lxlh9rmKaMPWjwiW3en6S6ufjUHpzb6yAEZmFkjcV5EHwTl6nTpgs3Sp/610j0dIcEAJ9NNjBdjPJdxR0rWRadGksMwXBVsOIoJkrFt0LdpOFQ/dX2nVjnAObBC+AsVWOiUKFgDoybzcdmr3JPZrptqFEXUPQaVbN4YhgGniolMekC6AVW1GTbxZ+0QZjiztIUbw5xBGohrfX5T2294VfZ7WkPfVJ3X5+boVBiRqQ+fZttn7LQxLGJW404DK4Zwj1myqze+dILHkOL9a611oM9D/r5/mQfZK8JMmtvF+Gqz1ZNKHHI0r7EPA4y5ugc8hqrxXDszGmFwLfiX+1MPP+qXBt5BD0tFr1jjucpUDz218jCheMWTU+hBvjluVW78o5t10EYw1qjnTKmzu8foUFkZqhMZTHN9XP4Z90lZOWV3s+SmKdaodSyiJGw3hWEEz/FZjFkQI9aoxEMQ8LVfIUnhmfZ0+Fmxh6d6mShrh43Er6wveoBoN3vEGfEl84YCognllRvlziKhnebYVsT5386bN0Rsinb 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)(107886003)(2616005)(66946007)(66476007)(66556008)(186003)(26005)(1076003)(316002)(6666004)(4326008)(6506007)(86362001)(52116002)(8936002)(2906002)(7416002)(6512007)(5660300002)(38100700002)(38350700002)(6486002)(8676002)(508600001)(83380400001)(966005)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zIdFMrxNubwvvcviH1GCMHOQz2mONyKynoxLi4Q+zr6MXHgR/4+rS03rI2nRtu0RTvs4zTce4ay39nheHfoTECrW2nR/mCYPsdwNS1n73WxkHagoPZYOHmCuBIXie7lCGzWpvuUokFmFxBSgo1DKf+JYH96vcZXNSI4M9aBiAlcUzSb9CsM0w/pK9k74OB9z+2GSvVHN/0YS+rtz2v57OCA0Xqm6pHQQN2Z8l+RjeAU0OfpfbQzlVQTUM/BZMDkU/keCvUL3Z2sJhsg4DlGEchAU8YRiRFbhRNUZnWt18d5fISxd1H6FftPLw6wOBGnu+myJvTFm98xQ6B2Zb69jWMTMSyPwO0NJOoCV3csmVwcT0vrz8+vGFR9+q7GJ/T5225890MqGeO9YiBCPD7Abk2Dtt5aZ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+/ZcBDmEVzUOWJvw69IjW9xMhHNL3YQRWd9qqczNfmjiQfZpb0y3qgBL1AkfODFzSJnOdkV1jJciDkqDq5h3sncCt+C4OdMvzKSSKrnZJNJ2FsREDyiWGo8VldDQEUQFZJWNd5isuYL4ob8u1B3LXJty1Z7qZuQ7hUXE/FSXVnuvSduQ4VWnUT5DMFCbX13Cemu5Ta45kZ8llbCu3SJ2C68R4doCxHnzJqvBRu6JDSoI4PYmnRoh9mrc4IsEsLLPA== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2b255f8-55b4-4039-30c1-08d9bebbec80 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2021 04:40:58.8746 (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: VuoEDoMm+A24KnMrgBZzf/9heBRpvQoKOYdPtjbvDBt4sbozR0ksAgYWKRWHXPPKWUdGQ7mFRcRQUOokj026Wl0m9GTVNjDJYkN6gfVrGIBIjEuLx6lv111kdQCF2fSx X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4826 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_204105_612445_2C9EED0E X-CRM114-Status: GOOD ( 17.98 ) 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 | 125 ++++++++++++++++++++++++++++++++++++ 3 files changed, 134 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..6525ccbae5c1 --- /dev/null +++ b/drivers/acpi/arm64/agdi.c @@ -0,0 +1,125 @@ +// 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; + + if (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE) { + pr_warn("Interrupt signaling is not supported"); + ret = -ENODEV; + goto err_put_table; + } + + 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_put_table; + } + + 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_put_table: + acpi_put_table((struct acpi_table_header *)agdi_table); + return ret; +} +device_initcall(agdi_init);