Skip to contentSkip to conversation

ACPI: Arm Generic Diagnostic Dump and Reset device

PATCH In review Ilkka Koskinen 3 participants 8 messages Mar 9, 2022 – Mar 10, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v6 cover ACPI: Arm Generic Diagnostic Dump and Reset device

Arm Generic Diagnostic Dump and Reset device enables a maintainer to request OS to perform a diagnostic dump and reset a system via SDEI event or an interrupt. This patchset adds support for the SDEI path.

I do have a patch to enable the interrupt path as well but I'm holding it back since AGDI table is missing interrupt configuration fields (trigger type etc.).

The recently published specification is available at
https://developer.arm.com/documentation/den0093/latest

The patchset was tested on Ampere Altra/Mt. Jade.

The patchset applies on top of
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm bleeding-edge (dd54258fbf6c)

Requires commit 27e932a31496 ("ACPI: APEI: rename ghes_init() with an "acpi_" prefix")

From v1:
* Moved pdata to the stack and dropped unnecessary kzalloc() in agdi_init()
* Changed the ACPICA patch upstreaming order comment in the paragraph above

From v2:
* The first patch was split. The most of it was merged to ACPICA project at first and later ported to linux-acpi (fd919e37cb15914c6fe13e13d530a4f732407c6d). The rest are in the first patch.

From v3:
Fixed:
* Moved header files in alphabetical order and removed unnecessary ones

From v4:
* Platform device/driver stuff removed
* acpi_agdi_init() call moved from device_initcall to acpi_init()
* Slightly modified Kconfig text to keep checkpatch happy

From v5:
* Brought back platform device/driver
* Fixed remove() function

Ilkka Koskinen (2):
ACPI: tables: Add AGDI to the list of known table signatures
ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset
device

 drivers/acpi/arm64/Kconfig  |  10 ++++
 drivers/acpi/arm64/Makefile |   1 +
 drivers/acpi/arm64/agdi.c   | 116 ++++++++++++++++++++++++++++++++++++
 drivers/acpi/bus.c          |   2 +
 drivers/acpi/tables.c       |   2 +-
 include/linux/acpi_agdi.h   |  13 ++++
 6 files changed, 143 insertions(+), 1 deletion(-)
 create mode 100644 drivers/acpi/arm64/agdi.c
 create mode 100644 include/linux/acpi_agdi.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH v6 1/2 ACPI: tables: Add AGDI to the list of known table signatures

Add AGDI to the list of known ACPI table signatures to allow the kernel to recognize it when upgrading tables via initrd.

---
 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +1 -1
index 369eb998c3d1..ceee808f7f2a 100644
@@ -545,7 +545,7 @@ static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
 	ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
 	ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
 	ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
-	ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT };
+	ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI };
 
 #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
 
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures

Quoted 15 lines · Ilkka Koskinen

Add AGDI to the list of known ACPI table signatures to allow the kernel to recognize it when upgrading tables via initrd.

---
 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +0 -0
index 369eb998c3d1..ceee808f7f2a 100644

drivers/acpi/tables.c static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = { · line 550

Quoted 7 lines
drivers/acpi/tables.c +1 -1
@@ -545,7 +545,7 @@ static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
        ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
        ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
        ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
-       ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT };
+       ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI };
 
 #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)

I'm noticing that this depends on the linux-next-only commit 783dedf41b79ac7a3a68b51cf6f88cbfd6dc3292, so it is probably better if I apply it and the other patch in the series can be routed via ARM64.

#3 lore raw

Re: [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures

Hi Rafael,

Quoted 23 lines · Rafael J. Wysocki
Quoted 21 lines · Ilkka Koskinen

Add AGDI to the list of known ACPI table signatures to allow the kernel to recognize it when upgrading tables via initrd.

---
 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +1 -1
index 369eb998c3d1..ceee808f7f2a 100644
@@ -545,7 +545,7 @@ static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
        ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
        ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
        ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
-       ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT };
+       ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI };
 
Quoted 5 lines

drivers/acpi/tables.c static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = { · line 550

Quoted 1 line
drivers/acpi/tables.c +0 -0
 #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)

I'm noticing that this depends on the linux-next-only commit 783dedf41b79ac7a3a68b51cf6f88cbfd6dc3292, so it is probably better if I apply it and the other patch in the series can be routed via ARM64.

Sounds good to me, thanks. The other patch needs commit dc4e8c07e9e2 ("ACPI: APEI: explicit init of HEST and GHES in apci_init()") in your bleeding edge branch to work but it hasn't been acked yet anyway.

Cheers, Ilkka

#4 lore raw

Re: [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures

Quoted 33 lines · Ilkka Koskinen

Hi Rafael,

Quoted 23 lines · Rafael J. Wysocki
Quoted 21 lines · Ilkka Koskinen

Add AGDI to the list of known ACPI table signatures to allow the kernel to recognize it when upgrading tables via initrd.

---
 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +1 -1
index 369eb998c3d1..ceee808f7f2a 100644
@@ -545,7 +545,7 @@ static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
        ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
        ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
        ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
-       ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT };
+       ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI };
 
Quoted 5 lines

drivers/acpi/tables.c static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = { · line 550

Quoted 1 line
drivers/acpi/tables.c +0 -0
 #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)

I'm noticing that this depends on the linux-next-only commit 783dedf41b79ac7a3a68b51cf6f88cbfd6dc3292, so it is probably better if I apply it and the other patch in the series can be routed via ARM64.

Quoted 3 lines

Sounds good to me, thanks. The other patch needs commit dc4e8c07e9e2 ("ACPI:
APEI: explicit init of HEST and GHES in apci_init()") in your bleeding edge branch to work but it hasn't been acked yet anyway.

It is best for both patches to go via Rafael's tree, given the dependency above. I acked patch (2).

Thanks,
Lorenzo

#5 lore raw

PATCH v6 2/2 ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device

In reply to Ilkka Koskinen

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/

---
 drivers/acpi/arm64/Kconfig  |  10 ++++
 drivers/acpi/arm64/Makefile |   1 +
 drivers/acpi/arm64/agdi.c   | 116 ++++++++++++++++++++++++++++++++++++
 drivers/acpi/bus.c          |   2 +
 include/linux/acpi_agdi.h   |  13 ++++
 5 files changed, 142 insertions(+)
 create mode 100644 drivers/acpi/arm64/agdi.c
 create mode 100644 include/linux/acpi_agdi.h
drivers/acpi/arm64/Kconfig +10 -0
index 6dba187f4f2e..d4a72835f328 100644
@@ -8,3 +8,13 @@ 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.
+
+	  If set, the kernel parses AGDI table and listens for the command.
drivers/acpi/arm64/Makefile +1 -0
index 66acbe77f46e..7b9e4045659d 100644
@@ -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
drivers/acpi/arm64/agdi.c new file +116 -0

116 lines not on this page · raw message

drivers/acpi/bus.c +2 -0
index eaa511fc9c66..87b93f4df0cf 100644
@@ -26,6 +26,7 @@
 #include <asm/mpspec.h>
 #include <linux/dmi.h>
 #endif
+#include <linux/acpi_agdi.h>
 #include <linux/acpi_iort.h>
 #include <linux/acpi_viot.h>
 #include <linux/pci.h>
@@ -1386,6 +1387,7 @@ static int __init acpi_init(void)
 	acpi_debugger_init();
 	acpi_setup_sb_notify_handler();
 	acpi_viot_init();
+	acpi_agdi_init();
 	return 0;
 }
 
include/linux/acpi_agdi.h new file +13 -0
new file mode 100644
index 000000000000..f477f0b452fa
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ACPI_AGDI_H__
+#define __ACPI_AGDI_H__
+
+#include <linux/acpi.h>
+
+#ifdef CONFIG_ACPI_AGDI
+void __init acpi_agdi_init(void);
+#else
+static inline void acpi_agdi_init(void) {}
+#endif
+#endif /* __ACPI_AGDI_H__ */
Signature · 1 line
2.17.1
Acked-by on v6 2/2
#6 lore raw

Re: [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device

Quoted 9 lines · Ilkka Koskinen

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/

Quoted 9 lines
---
 drivers/acpi/arm64/Kconfig  |  10 ++++
 drivers/acpi/arm64/Makefile |   1 +
 drivers/acpi/arm64/agdi.c   | 116 ++++++++++++++++++++++++++++++++++++
 drivers/acpi/bus.c          |   2 +
 include/linux/acpi_agdi.h   |  13 ++++
 5 files changed, 142 insertions(+)
 create mode 100644 drivers/acpi/arm64/agdi.c
 create mode 100644 include/linux/acpi_agdi.h
Quoted 193 lines
drivers/acpi/arm64/Kconfig +10 -0
index 6dba187f4f2e..d4a72835f328 100644
@@ -8,3 +8,13 @@ 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.
+
+	  If set, the kernel parses AGDI table and listens for the command.
drivers/acpi/arm64/Makefile +1 -0
index 66acbe77f46e..7b9e4045659d 100644
@@ -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
drivers/acpi/arm64/agdi.c new file +116 -0
new file mode 100644
index 000000000000..4df337d545b7
@@ -0,0 +1,116 @@
+// 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 <linux/acpi.h>
+#include <linux/arm_sdei.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+
+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 = 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 = dev_get_platdata(&pdev->dev);
+	int err, i;
+
+	err = sdei_event_disable(adata->sdei_event);
+	if (err)
+		return err;
+
+	for (i = 0; i < 3; i++) {
+		err = sdei_event_unregister(adata->sdei_event);
+		if (err != -EINPROGRESS)
+			break;
+
+		schedule();
+	}
+
+	return err;
+}
+
+static struct platform_driver agdi_driver = {
+	.driver = {
+		.name = "agdi",
+	},
+	.probe = agdi_probe,
+	.remove = agdi_remove,
+};
+
+void __init acpi_agdi_init(void)
+{
+	struct acpi_table_agdi *agdi_table;
+	struct agdi_data pdata;
+	struct platform_device *pdev;
+	acpi_status status;
+
+	status = acpi_get_table(ACPI_SIG_AGDI, 0,
+				(struct acpi_table_header **) &agdi_table);
+	if (ACPI_FAILURE(status))
+		return;
+
+	if (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE) {
+		pr_warn("Interrupt signaling is not supported");
+		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))
+		goto err_put_table;
+
+	if (platform_driver_register(&agdi_driver))
+		platform_device_unregister(pdev);
+
+err_put_table:
+	acpi_put_table((struct acpi_table_header *)agdi_table);
+}
drivers/acpi/bus.c +2 -0
index eaa511fc9c66..87b93f4df0cf 100644
@@ -26,6 +26,7 @@
 #include <asm/mpspec.h>
 #include <linux/dmi.h>
 #endif
+#include <linux/acpi_agdi.h>
 #include <linux/acpi_iort.h>
 #include <linux/acpi_viot.h>
 #include <linux/pci.h>
@@ -1386,6 +1387,7 @@ static int __init acpi_init(void)
 	acpi_debugger_init();
 	acpi_setup_sb_notify_handler();
 	acpi_viot_init();
+	acpi_agdi_init();
 	return 0;
 }
 
include/linux/acpi_agdi.h new file +13 -0
new file mode 100644
index 000000000000..f477f0b452fa
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ACPI_AGDI_H__
+#define __ACPI_AGDI_H__
+
+#include <linux/acpi.h>
+
+#ifdef CONFIG_ACPI_AGDI
+void __init acpi_agdi_init(void);
+#else
+static inline void acpi_agdi_init(void) {}
+#endif
+#endif /* __ACPI_AGDI_H__ */
Signature · 1 line
2.17.1
#7 lore raw

Re: [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device

Quoted 21 lines · Lorenzo Pieralisi
Quoted 9 lines · Ilkka Koskinen

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/

Quoted 9 lines
---
 drivers/acpi/arm64/Kconfig  |  10 ++++
 drivers/acpi/arm64/Makefile |   1 +
 drivers/acpi/arm64/agdi.c   | 116 ++++++++++++++++++++++++++++++++++++
 drivers/acpi/bus.c          |   2 +
 include/linux/acpi_agdi.h   |  13 ++++
 5 files changed, 142 insertions(+)
 create mode 100644 drivers/acpi/arm64/agdi.c
 create mode 100644 include/linux/acpi_agdi.h
Quoted 1 line

Both patches in the series applied as 5.18 material, thanks!