From: Ilkka Koskinen <ilkka@os.amperecomputing.com>
To: Kazuhiro Abe <fj1078ii@aa.jp.fujitsu.com>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
Hanjun Guo <guohanjun@huawei.com>,
Sudeep Holla <sudeep.holla@arm.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ACPI: AGDI: Add interrupt signaling mode support
Date: Wed, 20 Aug 2025 20:51:18 -0700 (PDT) [thread overview]
Message-ID: <a6d5d830-b1f2-c14b-7753-82f35baec8b4@os.amperecomputing.com> (raw)
In-Reply-To: <20250818065437.85905-1-fj1078ii@aa.jp.fujitsu.com>
Hi Kazuhiro
On Mon, 18 Aug 2025, Kazuhiro Abe wrote:
> AGDI has two types of signaling modes: SDEI and interrupt.
> Currently, the AGDI driver only supports SDEI.
> Therefore, add support for interrupt singaling mode
> The interrupt vector is retrieved from the AGDI table, and call panic
> function when an interrupt occurs.
> SDEI & Interrupt mode is not supported.
>
> Signed-off-by: Kazuhiro Abe <fj1078ii@aa.jp.fujitsu.com>
> ---
> drivers/acpi/arm64/agdi.c | 114 +++++++++++++++++++++++++++++++++++---
> include/acpi/actbl2.h | 4 +-
> 2 files changed, 110 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/acpi/arm64/agdi.c b/drivers/acpi/arm64/agdi.c
> index e0df3daa4abf0..c514bb874c5d3 100644
> --- a/drivers/acpi/arm64/agdi.c
> +++ b/drivers/acpi/arm64/agdi.c
> @@ -16,7 +16,11 @@
> #include "init.h"
>
> struct agdi_data {
> + unsigned char flags;
> int sdei_event;
> + unsigned int gsiv;
> + bool use_nmi;
> + int irq;
> };
>
> static int agdi_sdei_handler(u32 sdei_event, struct pt_regs *regs, void *arg)
> @@ -48,6 +52,55 @@ static int agdi_sdei_probe(struct platform_device *pdev,
> return 0;
> }
>
> +static irqreturn_t agdi_interrupt_handler_nmi(int irq, void *dev_id)
> +{
> + nmi_panic(NULL, "Arm Generic Diagnostic Dump and Reset NMI Interrupt event issued\n");
> + return IRQ_HANDLED;
> +}
> +
> +static irqreturn_t agdi_interrupt_handler_irq(int irq, void *dev_id)
> +{
> + panic("Arm Generic Diagnostic Dump and Reset Interrupt event issued\n");
> + return IRQ_HANDLED;
> +}
> +
> +static int agdi_interrupt_probe(struct platform_device *pdev,
> + struct agdi_data *adata)
> +{
> + unsigned long irq_flags;
> + int ret;
> + int irq;
> +
> + irq = acpi_register_gsi(NULL, adata->gsiv, ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH);
> + if (irq < 0) {
> + dev_err(&pdev->dev, "cannot register GSI#%d (%d)\n", adata->gsiv, irq);
> + return irq;
> + }
> +
> + irq_flags = IRQF_PERCPU | IRQF_NOBALANCING | IRQF_NO_AUTOEN |
> + IRQF_NO_THREAD;
> + /* try NMI first */
> + ret = request_nmi(irq, &agdi_interrupt_handler_nmi, irq_flags,
> + "agdi_interrupt_nmi", NULL);
> + if (ret) {
> + ret = request_irq(irq, &agdi_interrupt_handler_irq,
> + irq_flags, "agdi_interrupt_irq", NULL);
> + if (ret) {
> + dev_err(&pdev->dev, "cannot register IRQ %d\n", ret);
> + acpi_unregister_gsi(adata->gsiv);
> + return ret;
> + }
> + enable_irq(irq);
> + adata->irq = irq;
> + } else {
> + enable_nmi(irq);
> + adata->irq = irq;
> + adata->use_nmi = true;
> + }
> +
> + return 0;
> +}
> +
> static int agdi_probe(struct platform_device *pdev)
> {
> struct agdi_data *adata = dev_get_platdata(&pdev->dev);
> @@ -55,12 +108,20 @@ static int agdi_probe(struct platform_device *pdev)
> if (!adata)
> return -EINVAL;
>
> - return agdi_sdei_probe(pdev, adata);
> + switch (adata->flags & ACPI_AGDI_SIGNALING_MODE_MASK) {
> + case ACPI_AGDI_SIGNALING_MODE_SDEI:
> + return agdi_sdei_probe(pdev, adata);
> +
> + case ACPI_AGDI_SIGNALING_MODE_INTERRUPT:
> + return agdi_interrupt_probe(pdev, adata);
> + }
> +
> + return 0;
> }
>
> -static void agdi_remove(struct platform_device *pdev)
> +static void agdi_sdei_remove(struct platform_device *pdev,
> + struct agdi_data *adata)
> {
> - struct agdi_data *adata = dev_get_platdata(&pdev->dev);
> int err, i;
>
> err = sdei_event_disable(adata->sdei_event);
> @@ -83,6 +144,34 @@ static void agdi_remove(struct platform_device *pdev)
> adata->sdei_event, ERR_PTR(err));
> }
>
> +static void agdi_interrupt_remove(struct platform_device *pdev,
> + struct agdi_data *adata)
> +{
> + if (adata->irq != -1) {
> + if (adata->use_nmi)
> + free_nmi(adata->irq, NULL);
> + else
> + free_irq(adata->irq, NULL);
> +
> + acpi_unregister_gsi(adata->gsiv);
> + }
> +}
> +
> +static void agdi_remove(struct platform_device *pdev)
> +{
> + struct agdi_data *adata = dev_get_platdata(&pdev->dev);
> +
> + switch (adata->flags & ACPI_AGDI_SIGNALING_MODE_MASK) {
> + case ACPI_AGDI_SIGNALING_MODE_SDEI:
> + agdi_sdei_remove(pdev, adata);
> + break;
> +
> + case ACPI_AGDI_SIGNALING_MODE_INTERRUPT:
> + agdi_interrupt_remove(pdev, adata);
> + break;
> + }
> +}
> +
> static struct platform_driver agdi_driver = {
> .driver = {
> .name = "agdi",
> @@ -94,7 +183,7 @@ static struct platform_driver agdi_driver = {
> void __init acpi_agdi_init(void)
> {
> struct acpi_table_agdi *agdi_table;
> - struct agdi_data pdata;
> + struct agdi_data pdata = {0};
> struct platform_device *pdev;
> acpi_status status;
>
> @@ -103,12 +192,23 @@ void __init acpi_agdi_init(void)
> if (ACPI_FAILURE(status))
> return;
>
> - if (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE) {
> - pr_warn("Interrupt signaling is not supported");
> + switch (agdi_table->flags & ACPI_AGDI_SIGNALING_MODE_MASK) {
> + case ACPI_AGDI_SIGNALING_MODE_SDEI:
> + pdata.sdei_event = agdi_table->sdei_event;
> + break;
> +
> + case ACPI_AGDI_SIGNALING_MODE_INTERRUPT:
> + pdata.gsiv = agdi_table->gsiv;
> + break;
> +
> + default:
> + pr_warn("Signaling mode(%d) is not supported",
> + agdi_table->flags & ACPI_AGDI_SIGNALING_MODE_MASK);
> goto err_put_table;
> }
>
> - pdata.sdei_event = agdi_table->sdei_event;
> + pdata.irq = -1;
> + pdata.flags = agdi_table->flags;
>
> pdev = platform_device_register_data(NULL, "agdi", 0, &pdata, sizeof(pdata));
> if (IS_ERR(pdev))
> diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
> index 048f5f47f8b88..9ddbdd772f139 100644
> --- a/include/acpi/actbl2.h
> +++ b/include/acpi/actbl2.h
> @@ -339,7 +339,9 @@ struct acpi_table_agdi {
>
> /* Mask for Flags field above */
>
> -#define ACPI_AGDI_SIGNALING_MODE (1)
> +#define ACPI_AGDI_SIGNALING_MODE_MASK (3)
> +#define ACPI_AGDI_SIGNALING_MODE_SDEI (0)
> +#define ACPI_AGDI_SIGNALING_MODE_INTERRUPT (1)
>
> /*******************************************************************************
> *
Like Hanjun mentioned, these should go through ACPICA project. When you do
that could you also add the SDEI flag to the other places, which are
needed for iasl to be able to decode AGDI tables. You can find them if you
take a look at my patch in ACPICA project.
Cheers, Ilkka
> --
> 2.43.0
>
>
>
next prev parent reply other threads:[~2025-08-21 3:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 6:54 Kazuhiro Abe
2025-08-19 14:47 ` Hanjun Guo
2025-08-25 8:22 ` Kazuhiro Abe (Fujitsu)
2025-08-21 3:51 ` Ilkka Koskinen [this message]
2025-08-25 8:23 ` Kazuhiro Abe (Fujitsu)
2025-08-29 10:21 ` Kazuhiro Abe (Fujitsu)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a6d5d830-b1f2-c14b-7753-82f35baec8b4@os.amperecomputing.com \
--to=ilkka@os.amperecomputing.com \
--cc=fj1078ii@aa.jp.fujitsu.com \
--cc=guohanjun@huawei.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=rafael@kernel.org \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®