linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/2] ACPI: Arm Generic Diagnostic Dump and Reset device
@ 2022-03-09  2:07 Ilkka Koskinen
  2022-03-09  2:07 ` [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures Ilkka Koskinen
  2022-03-09  2:07 ` [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Ilkka Koskinen
  0 siblings, 2 replies; 8+ messages in thread
From: Ilkka Koskinen @ 2022-03-09  2:07 UTC (permalink / raw)
  To: lorenzo.pieralisi, guohanjun, sudeep.holla, rafael, linux
  Cc: lenb, robert.moore, james.morse, linux-acpi, linux-arm-kernel,
	linux-kernel, patches, scott, darren

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

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures
  2022-03-09  2:07 [PATCH v6 0/2] ACPI: Arm Generic Diagnostic Dump and Reset device Ilkka Koskinen
@ 2022-03-09  2:07 ` Ilkka Koskinen
  2022-03-09 18:45   ` Rafael J. Wysocki
  2022-03-09  2:07 ` [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Ilkka Koskinen
  1 sibling, 1 reply; 8+ messages in thread
From: Ilkka Koskinen @ 2022-03-09  2:07 UTC (permalink / raw)
  To: lorenzo.pieralisi, guohanjun, sudeep.holla, rafael, linux
  Cc: lenb, robert.moore, james.morse, linux-acpi, linux-arm-kernel,
	linux-kernel, patches, scott, darren

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

Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 369eb998c3d1..ceee808f7f2a 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -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)
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device
  2022-03-09  2:07 [PATCH v6 0/2] ACPI: Arm Generic Diagnostic Dump and Reset device Ilkka Koskinen
  2022-03-09  2:07 ` [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures Ilkka Koskinen
@ 2022-03-09  2:07 ` Ilkka Koskinen
  2022-03-10  9:11   ` Lorenzo Pieralisi
  1 sibling, 1 reply; 8+ messages in thread
From: Ilkka Koskinen @ 2022-03-09  2:07 UTC (permalink / raw)
  To: lorenzo.pieralisi, guohanjun, sudeep.holla, rafael, linux
  Cc: lenb, robert.moore, james.morse, linux-acpi, linux-arm-kernel,
	linux-kernel, patches, scott, darren

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 <ilkka@os.amperecomputing.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 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

diff --git a/drivers/acpi/arm64/Kconfig b/drivers/acpi/arm64/Kconfig
index 6dba187f4f2e..d4a72835f328 100644
--- a/drivers/acpi/arm64/Kconfig
+++ b/drivers/acpi/arm64/Kconfig
@@ -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.
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..4df337d545b7
--- /dev/null
+++ b/drivers/acpi/arm64/agdi.c
@@ -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);
+}
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index eaa511fc9c66..87b93f4df0cf 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -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;
 }
 
diff --git a/include/linux/acpi_agdi.h b/include/linux/acpi_agdi.h
new file mode 100644
index 000000000000..f477f0b452fa
--- /dev/null
+++ b/include/linux/acpi_agdi.h
@@ -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__ */
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures
  2022-03-09  2:07 ` [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures Ilkka Koskinen
@ 2022-03-09 18:45   ` Rafael J. Wysocki
  2022-03-09 20:41     ` Ilkka Koskinen
  0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2022-03-09 18:45 UTC (permalink / raw)
  To: Ilkka Koskinen
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Russell King - ARM Linux, Len Brown, Robert Moore, James Morse,
	ACPI Devel Maling List, Linux ARM, Linux Kernel Mailing List,
	patches, scott, Darren Hart

On Wed, Mar 9, 2022 at 3:08 AM Ilkka Koskinen
<ilkka@os.amperecomputing.com> wrote:
>
> Add AGDI to the list of known ACPI table signatures to allow the
> kernel to recognize it when upgrading tables via initrd.
>
> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/acpi/tables.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index 369eb998c3d1..ceee808f7f2a 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -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.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures
  2022-03-09 18:45   ` Rafael J. Wysocki
@ 2022-03-09 20:41     ` Ilkka Koskinen
  2022-03-10  9:14       ` Lorenzo Pieralisi
  0 siblings, 1 reply; 8+ messages in thread
From: Ilkka Koskinen @ 2022-03-09 20:41 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Ilkka Koskinen, Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla,
	Russell King - ARM Linux, Len Brown, Robert Moore, James Morse,
	ACPI Devel Maling List, Linux ARM, Linux Kernel Mailing List,
	patches, scott, Darren Hart


Hi Rafael,

On Wed, 9 Mar 2022, Rafael J. Wysocki wrote:
> On Wed, Mar 9, 2022 at 3:08 AM Ilkka Koskinen
> <ilkka@os.amperecomputing.com> wrote:
>>
>> Add AGDI to the list of known ACPI table signatures to allow the
>> kernel to recognize it when upgrading tables via initrd.
>>
>> Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
>> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>> ---
>>  drivers/acpi/tables.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
>> index 369eb998c3d1..ceee808f7f2a 100644
>> --- a/drivers/acpi/tables.c
>> +++ b/drivers/acpi/tables.c
>> @@ -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.

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device
  2022-03-09  2:07 ` [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Ilkka Koskinen
@ 2022-03-10  9:11   ` Lorenzo Pieralisi
  2022-03-10 19:19     ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: Lorenzo Pieralisi @ 2022-03-10  9:11 UTC (permalink / raw)
  To: Ilkka Koskinen
  Cc: guohanjun, sudeep.holla, rafael, linux, lenb, robert.moore,
	james.morse, linux-acpi, linux-arm-kernel, linux-kernel, patches,
	scott, darren

On Tue, Mar 08, 2022 at 06:07:50PM -0800, Ilkka Koskinen wrote:
> 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 <ilkka@os.amperecomputing.com>
> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  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

Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

> 
> diff --git a/drivers/acpi/arm64/Kconfig b/drivers/acpi/arm64/Kconfig
> index 6dba187f4f2e..d4a72835f328 100644
> --- a/drivers/acpi/arm64/Kconfig
> +++ b/drivers/acpi/arm64/Kconfig
> @@ -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.
> 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..4df337d545b7
> --- /dev/null
> +++ b/drivers/acpi/arm64/agdi.c
> @@ -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);
> +}
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index eaa511fc9c66..87b93f4df0cf 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -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;
>  }
>  
> diff --git a/include/linux/acpi_agdi.h b/include/linux/acpi_agdi.h
> new file mode 100644
> index 000000000000..f477f0b452fa
> --- /dev/null
> +++ b/include/linux/acpi_agdi.h
> @@ -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__ */
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures
  2022-03-09 20:41     ` Ilkka Koskinen
@ 2022-03-10  9:14       ` Lorenzo Pieralisi
  0 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Pieralisi @ 2022-03-10  9:14 UTC (permalink / raw)
  To: Ilkka Koskinen
  Cc: Rafael J. Wysocki, Hanjun Guo, Sudeep Holla,
	Russell King - ARM Linux, Len Brown, Robert Moore, James Morse,
	ACPI Devel Maling List, Linux ARM, Linux Kernel Mailing List,
	patches, scott, Darren Hart

On Wed, Mar 09, 2022 at 12:41:27PM -0800, Ilkka Koskinen wrote:
> 
> Hi Rafael,
> 
> On Wed, 9 Mar 2022, Rafael J. Wysocki wrote:
> > On Wed, Mar 9, 2022 at 3:08 AM Ilkka Koskinen
> > <ilkka@os.amperecomputing.com> wrote:
> > > 
> > > Add AGDI to the list of known ACPI table signatures to allow the
> > > kernel to recognize it when upgrading tables via initrd.
> > > 
> > > Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
> > > Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > > ---
> > >  drivers/acpi/tables.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> > > index 369eb998c3d1..ceee808f7f2a 100644
> > > --- a/drivers/acpi/tables.c
> > > +++ b/drivers/acpi/tables.c
> > > @@ -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.
> 
> 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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device
  2022-03-10  9:11   ` Lorenzo Pieralisi
@ 2022-03-10 19:19     ` Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2022-03-10 19:19 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Ilkka Koskinen
  Cc: Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Russell King - ARM Linux, Len Brown, Robert Moore, James Morse,
	ACPI Devel Maling List, Linux ARM, Linux Kernel Mailing List,
	patches, scott, Darren Hart

On Thu, Mar 10, 2022 at 10:11 AM Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
>
> On Tue, Mar 08, 2022 at 06:07:50PM -0800, Ilkka Koskinen wrote:
> > 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 <ilkka@os.amperecomputing.com>
> > Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> > ---
> >  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
>
> Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-03-10 19:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-09  2:07 [PATCH v6 0/2] ACPI: Arm Generic Diagnostic Dump and Reset device Ilkka Koskinen
2022-03-09  2:07 ` [PATCH v6 1/2] ACPI: tables: Add AGDI to the list of known table signatures Ilkka Koskinen
2022-03-09 18:45   ` Rafael J. Wysocki
2022-03-09 20:41     ` Ilkka Koskinen
2022-03-10  9:14       ` Lorenzo Pieralisi
2022-03-09  2:07 ` [PATCH v6 2/2] ACPI: AGDI: Add driver for Arm Generic Diagnostic Dump and Reset device Ilkka Koskinen
2022-03-10  9:11   ` Lorenzo Pieralisi
2022-03-10 19:19     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).