From patchwork Thu Jan 20 02:57:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 12718230 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 5C49BC433EF for ; Thu, 20 Jan 2022 03:00:26 +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=Ur9xPaorC/ukcwScOir6b0emJoToKSWAsHQEvcKKUt8=; b=V1I9ieIACCqCQr tQ0N6l8GVDP1RDivDBb8SRl+mkCIB15mOIUpJBo2LxB55CQlRvyUPX9tfTBDK2H/xvNCb57KnlrpN DT3Rf6OgklTsWar6Wku3I/Rl2AOgOv0C4ICmZjHvzdVcaSL+hEUMxa2szYARo0kjqDgUiU8vCIGEt 5OPWYQfTAju3nqNFc+P1uFJm3t1klxfuBfCeWtzlCddGUnV4InaqKvnQCEByRFiNelXMKCOyJmi/A A2SBqC112/QIZ/YDKGZfZ0J0q/QkbvYLjKLZdrrv8YwwTA3ZowecA5IvbClt8dRSmuJpmXeeQQznr hIbqWotcrQIANeXa+y5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nANfF-008Mq4-4i; Thu, 20 Jan 2022 02:59:05 +0000 Received: from mail-bn8nam11on2124.outbound.protection.outlook.com ([40.107.236.124] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nANeu-008Min-Em for linux-arm-kernel@lists.infradead.org; Thu, 20 Jan 2022 02:58:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PEG9Iuw8otjg3fiSCt5EVaMpQlW4lIObGvagioxJdTcFCfaGfbk7gT2TL/XP6QIDTPuspG4v5/XpTTRr0d3J+GonqS9tLHQOt6+VnHunYlYQzkIfRRBjIDidqtPfOsquKfdUocfArfLeuoXgC5owiBtpndOZvJ/0lbHN+sQhTdt7CIoOXQQN1aR7m/BnhqRbDmUcbVi6DR45BYHgQRxX5jdNf+exJ5uPvwsIr353/g6hBisiF4+EWzFGI7SXcGZHiuzgaDRSezoonKP8q82ddR0uBuoK6W00LnhCFzDNXF0ZBi9Uref1Oi6cMxzB4gACRf1KyaNLTd+/ytk+lWJSOw== 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=I7SZZoMWg5bmQdiLrooB7tRgKvs4sbk1MutYbJ93VWU=; b=asupHADw2rsJSopXPADNejqBtst37ftLL1UKW1FpUuHIjZlab1vPXAnkkRHC1RvaaZC1hqNVpBuLFosKYklDhTPJvgI3pwRdns3J6lT3L7cYX/PIpKKR+gB1QQhmAp4X3X96kpO9ZjUfBy3dSrycZ2Xm1HmxfSkmiwqvcaOHt9rthTk803smO9dkrZeLWPhf3Uv6LELvjA1Gz0zCQuKpxduDD5Nm7wflVlXE9vVK91R/GafukzQNwc5VDOBPwe5APnacvQdOu7hiTAXy1l9I5sg3G5IZDRV5N5Nbus3nUYYfS/VKq2xdKtWyi6ezhNPPohjtTHN/ig9hMAmQE+kvBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=I7SZZoMWg5bmQdiLrooB7tRgKvs4sbk1MutYbJ93VWU=; b=HbrBe3RV2a9GJYU93syrxexSM3LOJiiNv2wp/zm5KtgNyOTIAs/pplLdNEmQgOsAKsw6k/tWKwoOc891nJlf3+181BKtL+23GXFsBY/fNn6koEVkS07sumzO60yHg1q8Iecg3hyx7ll84a3BAA2NNsuTjXKLZFLzuJS398m+tRo= 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 BY5PR01MB5827.prod.exchangelabs.com (2603:10b6:a03:1c9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Thu, 20 Jan 2022 02:58:38 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::c4f4:4df1:380a:2ad8]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::c4f4:4df1:380a:2ad8%5]) with mapi id 15.20.4909.008; Thu, 20 Jan 2022 02:58:38 +0000 From: Ilkka Koskinen To: lorenzo.pieralisi@arm.com, guohanjun@huawei.com, sudeep.holla@arm.com, rafael@kernel.org, linux@armlinux.org.uk Cc: lenb@kernel.org, robert.moore@intel.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, patches@amperecomputing.com, scott@os.amperecomputing.com, darren@os.amperecomputing.com, james.morse@arm.com Subject: [PATCH v4 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Date: Wed, 19 Jan 2022 18:57:59 -0800 Message-Id: <20220120025759.8630-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220120025759.8630-1-ilkka@os.amperecomputing.com> References: <20220120025759.8630-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0337.namprd03.prod.outlook.com (2603:10b6:610:11a::27) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5933904-1b4f-4379-9fd8-08d9dbc0c1c5 X-MS-TrafficTypeDiagnostic: BY5PR01MB5827: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: TIFc6zTL954KO51yk/W0ADpb2iqM1LkcYABGxps5In7wIOourq5LMYdDLuz03BaS/7e5u3cta4Fw1lGEG5HZs3/HCyUZUcdr1Gxv4Z2+rjAmsfwnpntEQfBdj0ISPMCdBjpOTELB+C7oGsjGYxu3mtcxrsnZ62gT524+CsHk8ZQv51X/YmFUTMElHj2f2FXxUts8uUEKEbMi/SA8jgyU8kIu/eQxeMVMChjgT/vhwBV2B2DHY/cA8ETgR1ihSLdW3/v5X9g1f8+CS58N4X377qfNh7mvp8VJVIC7GawPwywjIj5NjdeBID5XC99Bjv6Igqr/TP+Uz5PoLgH/PVblHM2mwF66T/f1uPhc5PclWeT3/OflbJZ1Zs8//6NpUtC1772QLsbl5niay8XypD1PrY5Nm4N1NRvQvFFJmqiAJyPF0MWDiaZsrAD9O5/NezPDEbvC8UsRkurvztSRbvVXtezbpe/Y3XijX0YCGxGO/LrOyjZHInNcTaTgI5Ou66iWWRhysBTUqwSK+B2wTYqdD3WQA5Zu8hraM/pxrUXnEeyyhWO7T/LEV5oSk674w3ojIZ4z/Nv3ix99SnErkzpZ4Qdn4klldvvoKsEU3JpFRSkVuGXduXW2exBmoNvMcGzMC5RApK6HVvWggtNYflnyKq7BqWmdgPeu7w0hcDLHrhPDMhkKfqjFmLv4jQvkEW03aUN4cFJO7nlP1dgSjYpy2j1TD1pahhpvYGSjNrHusrGDvMI5wK7SBQiQjXYh9EZ/4wu8VFAX/ea7qSmYDrxLE7kLPvZZHC5A8Mh9waMjnqWxBtx7h5OfChpIiPm/HT0m 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)(1076003)(66946007)(66556008)(66476007)(6512007)(38350700002)(86362001)(38100700002)(316002)(6506007)(5660300002)(2906002)(508600001)(2616005)(52116002)(4326008)(7416002)(966005)(186003)(83380400001)(6666004)(8936002)(8676002)(6486002)(26005)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NCVD2ehVEAKCFfGshaaux3d0X+BuiLhtPzjmkzX/rEau8sqhTzAat2vMR/PUj993WhVKGzaTZOJm2S6vKisMOn8nC39evoGxlmziMjj45WSH9N3oAWZeKMvJMmLvhFus+6Z8vDgnWEgNX6+3Gmf6/16Bd019OQFXSQz8f6G+nrFkFem9GCxK83wMgT0bmo34H16uUHFjev6MxekE9I3JQ89mSK26bhYLNgJXlGJi4a17ymOsFbI4bR2SKgSdB7dz9SUsvYsLcPFtDY1G5a56Gfi++ZXD0Xhr94uDULCBvXpb9Ce+QAAmhJ03GOFtmAv6lPmWh5QYvjKV1qD9X2DVCq+eyg6r+Eg/ZZH8yZFM4YFtFOypZ2vciLgnzsGcX6uIs2xAYLaTZLcMTzQSuX2HKiiEhKO9M/n2RPF4dTTJUmgN+zGnp11V+l0hAd6SyA3O5fzw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aAy93yWM5Ex2wBaPWJ1igz93ZDfsLHnFnCQlO5Ff9HQKgPJzFQXZLm63PCphKkKvfusNmS/fbYfhoIcW3hhJKjO7LZgO7UOCQqd6Q/p61cmftgy1LcAGEbt68l+BjdKy6GOCROJfMzkm4ACZwlRptfVmfcExdlT5IknpiYJu7kPlYIrl8gRGAgS+z2Feob2NE1T/iGwkaYa5Ac20+R/NhA== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5933904-1b4f-4379-9fd8-08d9dbc0c1c5 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2022 02:58:38.3606 (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: hoTRfFFgA4Vq1N89BvGSeWxzmCVoYa+vIr4yre/uUuZnobhi4+Q2YtMABHGs/zEgORjYzZ653QJBaOdrYqmb63XQ5FFq3yepxiuzZXALLlvuz2Hh+L1of6aPsOGV/9Yd X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR01MB5827 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220119_185844_533845_7C8ACD2E X-CRM114-Status: GOOD ( 18.77 ) 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 Reviewed-by: Russell King (Oracle) --- drivers/acpi/arm64/Kconfig | 8 +++ drivers/acpi/arm64/Makefile | 1 + drivers/acpi/arm64/agdi.c | 122 ++++++++++++++++++++++++++++++++++++ 3 files changed, 131 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..28f16b95ba12 --- /dev/null +++ b/drivers/acpi/arm64/agdi.c @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * This file implements handling of + * Arm Generic Diagnostic Dump and Reset Interface table (AGDI) + * + * Copyright (c) 2022, Ampere Computing LLC + */ + +#define pr_fmt(fmt) "ACPI: AGDI: " fmt + +#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);