Linux ACPI
 help / color / mirror / Atom feed
* [PATCH] ACPI: x86: Work around AMD CPM _L05 notifying a missing dGPU on ASUS G513QY
@ 2026-11-22 18:14 Mario Limonciello
  2026-11-26 14:54 ` Rafael J. Wysocki (Intel)
  0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2026-11-22 18:14 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown
  Cc: linux-kernel, linux-acpi, Mike Lothian, Mario Limonciello

The AMD CPM D3cold SSDT (OEM table ID "CPMD3CLD") on the ASUS ROG Strix
G513QY (BIOS G513QY.335) handles the dGPU hotplug GPE with:

  Scope (\_GPE) { Method (_L05) { Notify (\_SB.PCI0.GPP0.VGA, 0x81) } }

On this board the Navi 22 sits behind an on-package PCIe switch and is
\_SB.PCI0.GPP0.SWUS.SWDS.VGA; \_SB.PCI0.GPP0.VGA is not defined by any
table.  The interpreter correctly aborts the method:

  ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GPP0.VGA], AE_NOT_FOUND
  ACPI Error: Aborting method \_GPE._L05 due to previous error (AE_NOT_FOUND)
  ACPI Error: AE_NOT_FOUND, while evaluating GPE method [_L05]

so the Notify is lost and a dGPU in D3cold is never woken for the
hotplug.  Other firmware on the same board (the _L00 handler and the
ATIF dispatchers) guards both the GPP0.VGA and GPP0.SWUS.SWDS.VGA paths
with CondRefOf(), so only this method was missed.

Aliasing the missing name is not an option: those guarded branches would
then both resolve and dispatch to the dGPU twice.  Instead, load a small
built-in SSDT with a method that notifies the real node and replace _L05
with a GPE handler that runs it.  The handler defers to a workqueue, as
AML can't run in interrupt context, and re-arms the level-triggered GPE
behind the notify queue as ACPICA does for _Lxx methods.

Match the DMI for the G513QY and introduce a new quirk behind a new
ACPI_AML_QUIRKS option.

Reported-by: Mike Lothian <mike@fireburn.co.uk>
Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/6061
Tested-by: Mike Lothian <mike@fireburn.co.uk>
Link: https://lore.kernel.org/amd-gfx/20261029151422.56791-1-mike@fireburn.co.uk/
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/acpi/Kconfig          |  16 +++++
 drivers/acpi/x86/Makefile     |   1 +
 drivers/acpi/x86/cpm_d3cold.c | 161 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 178 insertions(+)

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index fa3eb52b22cd8..70a8d3c79a1b5 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -393,6 +393,22 @@ config ACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD
 
 	  See Documentation/admin-guide/acpi/initrd_table_override.rst for details
 
+config ACPI_AML_QUIRKS
+	bool "Workarounds for known AML bugs in system firmware"
+	depends on X86
+	help
+	  Some systems ship AML that cannot work as written, for example a
+	  method that notifies a device which does not exist in the namespace.
+	  This option builds workarounds for such firmware bugs. Each one is
+	  enabled only on the specific systems it is known to be needed on
+	  (matched by DMI), and loads small built-in tables and/or takes over
+	  an ACPI event from the firmware's own method on those systems.
+
+	  Currently this covers the AMD CPM D3cold dGPU hotplug GPE on the
+	  ASUS ROG Strix G513QY.
+
+	  Systems that are not on the list are unaffected. If unsure, say N.
+
 config ACPI_DEBUG
 	bool "Debug Statements"
 	default y
diff --git a/drivers/acpi/x86/Makefile b/drivers/acpi/x86/Makefile
index 63c99509ed9de..04c2c7ffc3a1c 100644
--- a/drivers/acpi/x86/Makefile
+++ b/drivers/acpi/x86/Makefile
@@ -4,5 +4,6 @@ acpi-x86-y		+= cmos_rtc.o
 acpi-x86-$(CONFIG_PCI)	+= lpss.o
 acpi-x86-y		+= s2idle.o
 acpi-x86-y		+= utils.o
+acpi-x86-$(CONFIG_ACPI_AML_QUIRKS) += cpm_d3cold.o
 
 obj-$(CONFIG_X86)	+= blacklist.o
diff --git a/drivers/acpi/x86/cpm_d3cold.c b/drivers/acpi/x86/cpm_d3cold.c
new file mode 100644
index 0000000000000..8db5d5ba1a2af
--- /dev/null
+++ b/drivers/acpi/x86/cpm_d3cold.c
@@ -0,0 +1,161 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * cpm_d3cold.c - Work around AMD CPM D3cold tables that notify a missing dGPU
+ *
+ * The AMD CPM D3cold SSDT (OEM table ID "CPMD3CLD") handles the dGPU hotplug
+ * GPE with:
+ *
+ *	Scope (\_GPE) { Method (_L05) { Notify (\_SB.PCI0.GPP0.VGA, 0x81) } }
+ *
+ * On boards where the dGPU sits behind an on-package PCIe switch the device is
+ * \_SB.PCI0.GPP0.SWUS.SWDS.VGA and \_SB.PCI0.GPP0.VGA does not exist.  The
+ * interpreter correctly aborts _L05 with AE_NOT_FOUND, the Notify is lost and
+ * a dGPU in D3cold is never woken for the hotplug.  Other tables from the same
+ * firmware (e.g. the _L00 handler) already guard both paths with CondRefOf().
+ *
+ * Aliasing the missing name is not an option: those other tables would then
+ * see both paths and dispatch to the dGPU twice.  Instead, on boards known to
+ * be affected, load a small SSDT that notifies the real node and run it from a
+ * GPE handler that replaces _L05.
+ *
+ * The built-in SSDT is the following, compiled with iasl:
+ *
+ *	DefinitionBlock ("", "SSDT", 2, "LINUX", "CPML05FX", 1)
+ *	{
+ *	    External (\_GPE, DeviceObj)
+ *	    External (\_SB.PCI0.GPP0.SWUS.SWDS.VGA, DeviceObj)
+ *
+ *	    Scope (\_GPE)
+ *	    {
+ *	        Method (FX05, 0, NotSerialized)
+ *	        {
+ *	            Notify (\_SB.PCI0.GPP0.SWUS.SWDS.VGA, 0x81)
+ *	        }
+ *	    }
+ *	}
+ */
+
+#define pr_fmt(fmt) "ACPI: CPM: " fmt
+
+#include <linux/acpi.h>
+#include <linux/dmi.h>
+#include <linux/init.h>
+#include <linux/printk.h>
+#include <linux/slab.h>
+
+#define CPM_D3COLD_GPE		0x05
+
+#define CPM_L05_PATH		"\\_GPE._L05"
+#define CPM_FIX_PATH		"\\_GPE.FX05"
+#define CPM_MISSING_PATH	"\\_SB.PCI0.GPP0.VGA"
+#define CPM_DGPU_PATH		"\\_SB.PCI0.GPP0.SWUS.SWDS.VGA"
+
+static const u8 cpm_l05_ssdt[] __initconst = {
+	0x53, 0x53, 0x44, 0x54, 0x79, 0x00, 0x00, 0x00, 0x02, 0x7e, 0x4c, 0x49,
+	0x4e, 0x55, 0x58, 0x00, 0x43, 0x50, 0x4d, 0x4c, 0x30, 0x35, 0x46, 0x58,
+	0x01, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x28, 0x06, 0x23, 0x20,
+	0xa0, 0x28, 0x00, 0x15, 0x5c, 0x5f, 0x47, 0x50, 0x45, 0x06, 0x00, 0x15,
+	0x5c, 0x2f, 0x06, 0x5f, 0x53, 0x42, 0x5f, 0x50, 0x43, 0x49, 0x30, 0x47,
+	0x50, 0x50, 0x30, 0x53, 0x57, 0x55, 0x53, 0x53, 0x57, 0x44, 0x53, 0x56,
+	0x47, 0x41, 0x5f, 0x06, 0x00, 0x10, 0x2b, 0x5c, 0x5f, 0x47, 0x50, 0x45,
+	0x14, 0x24, 0x46, 0x58, 0x30, 0x35, 0x00, 0x86, 0x5c, 0x2f, 0x06, 0x5f,
+	0x53, 0x42, 0x5f, 0x50, 0x43, 0x49, 0x30, 0x47, 0x50, 0x50, 0x30, 0x53,
+	0x57, 0x55, 0x53, 0x53, 0x57, 0x44, 0x53, 0x56, 0x47, 0x41, 0x5f, 0x0a,
+	0x81
+};
+
+static const struct dmi_system_id cpm_l05_dmi_table[] __initconst = {
+	{
+		.ident = "ASUS ROG Strix G513QY",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_BOARD_NAME, "G513QY"),
+		},
+	},
+	{}
+};
+
+static acpi_handle cpm_fix_handle;
+
+static void cpm_l05_rearm(void *unused)
+{
+	acpi_finish_gpe(NULL, CPM_D3COLD_GPE);
+}
+
+static void cpm_l05_work(void *unused)
+{
+	acpi_status status;
+
+	status = acpi_evaluate_object(cpm_fix_handle, NULL, NULL, NULL);
+	if (ACPI_FAILURE(status))
+		pr_err("%s failed: %s\n", CPM_FIX_PATH,
+		       acpi_format_exception(status));
+
+	/*
+	 * Notify() handlers run from the notify workqueue.  As for a firmware
+	 * _Lxx method, only clear and re-enable the level-triggered GPE once
+	 * they have been dispatched so it can't storm while the dGPU resumes.
+	 */
+	if (ACPI_FAILURE(acpi_os_execute(OSL_NOTIFY_HANDLER, cpm_l05_rearm,
+					 NULL)))
+		cpm_l05_rearm(NULL);
+}
+
+static u32 cpm_l05_gpe_handler(acpi_handle gpe_device, u32 gpe_number,
+			       void *context)
+{
+	/*
+	 * Interrupt context, AML can't run here.  Don't return
+	 * ACPI_REENABLE_GPE: the GPE stays disabled until cpm_l05_rearm().
+	 */
+	if (ACPI_FAILURE(acpi_os_execute(OSL_GPE_HANDLER, cpm_l05_work, NULL)))
+		pr_err("unable to queue GPE %02X handler\n", gpe_number);
+
+	return ACPI_INTERRUPT_HANDLED;
+}
+
+static int __init cpm_d3cold_l05_init(void)
+{
+	struct acpi_table_header *ssdt;
+	acpi_status status;
+
+	if (!dmi_check_system(cpm_l05_dmi_table))
+		return 0;
+
+	/* ACPICA keeps using the table, so it must never be freed */
+	ssdt = kmemdup(cpm_l05_ssdt, sizeof(cpm_l05_ssdt), GFP_KERNEL);
+	if (!ssdt)
+		return -ENOMEM;
+
+	status = acpi_load_table(ssdt, NULL);
+	if (ACPI_FAILURE(status)) {
+		pr_err("unable to load fixup table: %s\n",
+		       acpi_format_exception(status));
+		kfree(ssdt);
+		return -ENODEV;
+	}
+
+	status = acpi_get_handle(NULL, CPM_FIX_PATH, &cpm_fix_handle);
+	if (ACPI_FAILURE(status))
+		return -ENODEV;
+
+	status = acpi_install_gpe_handler(NULL, CPM_D3COLD_GPE,
+					  ACPI_GPE_LEVEL_TRIGGERED,
+					  cpm_l05_gpe_handler, NULL);
+	if (ACPI_FAILURE(status)) {
+		pr_err("unable to install GPE %02X handler: %s\n",
+		       CPM_D3COLD_GPE, acpi_format_exception(status));
+		return -ENODEV;
+	}
+
+	/* Installing the handler dropped the reference taken for _L05 */
+	status = acpi_enable_gpe(NULL, CPM_D3COLD_GPE);
+	if (ACPI_FAILURE(status))
+		pr_err("unable to enable GPE %02X: %s\n", CPM_D3COLD_GPE,
+		       acpi_format_exception(status));
+
+	pr_info("%s notifies missing %s, using %s instead\n", CPM_L05_PATH,
+		CPM_MISSING_PATH, CPM_DGPU_PATH);
+	return 0;
+}
+subsys_initcall_sync(cpm_d3cold_l05_init);

---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261122-fdo-gitlab-6061-d6cbed847dbc

Best regards,
--  
Mario Limonciello <mario.limonciello@amd.com>


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

* Re: [PATCH] ACPI: x86: Work around AMD CPM _L05 notifying a missing dGPU on ASUS G513QY
  2026-11-22 18:14 [PATCH] ACPI: x86: Work around AMD CPM _L05 notifying a missing dGPU on ASUS G513QY Mario Limonciello
@ 2026-11-26 14:54 ` Rafael J. Wysocki (Intel)
  2026-11-29  3:49   ` Mario Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki (Intel) @ 2026-11-26 14:54 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Rafael J. Wysocki, Len Brown, linux-kernel, linux-acpi,
	Mike Lothian

On Sun, Nov 22, 2026 at 7:14 PM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> The AMD CPM D3cold SSDT (OEM table ID "CPMD3CLD") on the ASUS ROG Strix
> G513QY (BIOS G513QY.335) handles the dGPU hotplug GPE with:
>
>   Scope (\_GPE) { Method (_L05) { Notify (\_SB.PCI0.GPP0.VGA, 0x81) } }
>
> On this board the Navi 22 sits behind an on-package PCIe switch and is
> \_SB.PCI0.GPP0.SWUS.SWDS.VGA; \_SB.PCI0.GPP0.VGA is not defined by any
> table.  The interpreter correctly aborts the method:
>
>   ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GPP0.VGA], AE_NOT_FOUND
>   ACPI Error: Aborting method \_GPE._L05 due to previous error (AE_NOT_FOUND)
>   ACPI Error: AE_NOT_FOUND, while evaluating GPE method [_L05]
>
> so the Notify is lost and a dGPU in D3cold is never woken for the
> hotplug.

Which presumably doesn't happen in Windows.

Do you know what the difference is?

> Other firmware on the same board (the _L00 handler and the
> ATIF dispatchers) guards both the GPP0.VGA and GPP0.SWUS.SWDS.VGA paths
> with CondRefOf(), so only this method was missed.
>
> Aliasing the missing name is not an option: those guarded branches would
> then both resolve and dispatch to the dGPU twice.  Instead, load a small
> built-in SSDT with a method that notifies the real node and replace _L05
> with a GPE handler that runs it.  The handler defers to a workqueue, as
> AML can't run in interrupt context, and re-arms the level-triggered GPE
> behind the notify queue as ACPICA does for _Lxx methods.
>
> Match the DMI for the G513QY and introduce a new quirk behind a new
> ACPI_AML_QUIRKS option.

I'm totally not a fan of adding AML blobs to the kernel.

It would be better to avoid putting the device in question into D3cold
on the affected system IMV.

> Reported-by: Mike Lothian <mike@fireburn.co.uk>
> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/6061
> Tested-by: Mike Lothian <mike@fireburn.co.uk>
> Link: https://lore.kernel.org/amd-gfx/20261029151422.56791-1-mike@fireburn.co.uk/
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/acpi/Kconfig          |  16 +++++
>  drivers/acpi/x86/Makefile     |   1 +
>  drivers/acpi/x86/cpm_d3cold.c | 161 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 178 insertions(+)
>
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index fa3eb52b22cd8..70a8d3c79a1b5 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -393,6 +393,22 @@ config ACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD
>
>           See Documentation/admin-guide/acpi/initrd_table_override.rst for details
>
> +config ACPI_AML_QUIRKS
> +       bool "Workarounds for known AML bugs in system firmware"
> +       depends on X86
> +       help
> +         Some systems ship AML that cannot work as written, for example a
> +         method that notifies a device which does not exist in the namespace.
> +         This option builds workarounds for such firmware bugs. Each one is
> +         enabled only on the specific systems it is known to be needed on
> +         (matched by DMI), and loads small built-in tables and/or takes over
> +         an ACPI event from the firmware's own method on those systems.
> +
> +         Currently this covers the AMD CPM D3cold dGPU hotplug GPE on the
> +         ASUS ROG Strix G513QY.
> +
> +         Systems that are not on the list are unaffected. If unsure, say N.
> +
>  config ACPI_DEBUG
>         bool "Debug Statements"
>         default y
> diff --git a/drivers/acpi/x86/Makefile b/drivers/acpi/x86/Makefile
> index 63c99509ed9de..04c2c7ffc3a1c 100644
> --- a/drivers/acpi/x86/Makefile
> +++ b/drivers/acpi/x86/Makefile
> @@ -4,5 +4,6 @@ acpi-x86-y              += cmos_rtc.o
>  acpi-x86-$(CONFIG_PCI) += lpss.o
>  acpi-x86-y             += s2idle.o
>  acpi-x86-y             += utils.o
> +acpi-x86-$(CONFIG_ACPI_AML_QUIRKS) += cpm_d3cold.o
>
>  obj-$(CONFIG_X86)      += blacklist.o
> diff --git a/drivers/acpi/x86/cpm_d3cold.c b/drivers/acpi/x86/cpm_d3cold.c
> new file mode 100644
> index 0000000000000..8db5d5ba1a2af
> --- /dev/null
> +++ b/drivers/acpi/x86/cpm_d3cold.c
> @@ -0,0 +1,161 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * cpm_d3cold.c - Work around AMD CPM D3cold tables that notify a missing dGPU
> + *
> + * The AMD CPM D3cold SSDT (OEM table ID "CPMD3CLD") handles the dGPU hotplug
> + * GPE with:
> + *
> + *     Scope (\_GPE) { Method (_L05) { Notify (\_SB.PCI0.GPP0.VGA, 0x81) } }
> + *
> + * On boards where the dGPU sits behind an on-package PCIe switch the device is
> + * \_SB.PCI0.GPP0.SWUS.SWDS.VGA and \_SB.PCI0.GPP0.VGA does not exist.  The
> + * interpreter correctly aborts _L05 with AE_NOT_FOUND, the Notify is lost and
> + * a dGPU in D3cold is never woken for the hotplug.  Other tables from the same
> + * firmware (e.g. the _L00 handler) already guard both paths with CondRefOf().
> + *
> + * Aliasing the missing name is not an option: those other tables would then
> + * see both paths and dispatch to the dGPU twice.  Instead, on boards known to
> + * be affected, load a small SSDT that notifies the real node and run it from a
> + * GPE handler that replaces _L05.
> + *
> + * The built-in SSDT is the following, compiled with iasl:
> + *
> + *     DefinitionBlock ("", "SSDT", 2, "LINUX", "CPML05FX", 1)
> + *     {
> + *         External (\_GPE, DeviceObj)
> + *         External (\_SB.PCI0.GPP0.SWUS.SWDS.VGA, DeviceObj)
> + *
> + *         Scope (\_GPE)
> + *         {
> + *             Method (FX05, 0, NotSerialized)
> + *             {
> + *                 Notify (\_SB.PCI0.GPP0.SWUS.SWDS.VGA, 0x81)
> + *             }
> + *         }
> + *     }
> + */
> +
> +#define pr_fmt(fmt) "ACPI: CPM: " fmt
> +
> +#include <linux/acpi.h>
> +#include <linux/dmi.h>
> +#include <linux/init.h>
> +#include <linux/printk.h>
> +#include <linux/slab.h>
> +
> +#define CPM_D3COLD_GPE         0x05
> +
> +#define CPM_L05_PATH           "\\_GPE._L05"
> +#define CPM_FIX_PATH           "\\_GPE.FX05"
> +#define CPM_MISSING_PATH       "\\_SB.PCI0.GPP0.VGA"
> +#define CPM_DGPU_PATH          "\\_SB.PCI0.GPP0.SWUS.SWDS.VGA"
> +
> +static const u8 cpm_l05_ssdt[] __initconst = {
> +       0x53, 0x53, 0x44, 0x54, 0x79, 0x00, 0x00, 0x00, 0x02, 0x7e, 0x4c, 0x49,
> +       0x4e, 0x55, 0x58, 0x00, 0x43, 0x50, 0x4d, 0x4c, 0x30, 0x35, 0x46, 0x58,
> +       0x01, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x28, 0x06, 0x23, 0x20,
> +       0xa0, 0x28, 0x00, 0x15, 0x5c, 0x5f, 0x47, 0x50, 0x45, 0x06, 0x00, 0x15,
> +       0x5c, 0x2f, 0x06, 0x5f, 0x53, 0x42, 0x5f, 0x50, 0x43, 0x49, 0x30, 0x47,
> +       0x50, 0x50, 0x30, 0x53, 0x57, 0x55, 0x53, 0x53, 0x57, 0x44, 0x53, 0x56,
> +       0x47, 0x41, 0x5f, 0x06, 0x00, 0x10, 0x2b, 0x5c, 0x5f, 0x47, 0x50, 0x45,
> +       0x14, 0x24, 0x46, 0x58, 0x30, 0x35, 0x00, 0x86, 0x5c, 0x2f, 0x06, 0x5f,
> +       0x53, 0x42, 0x5f, 0x50, 0x43, 0x49, 0x30, 0x47, 0x50, 0x50, 0x30, 0x53,
> +       0x57, 0x55, 0x53, 0x53, 0x57, 0x44, 0x53, 0x56, 0x47, 0x41, 0x5f, 0x0a,
> +       0x81
> +};
> +
> +static const struct dmi_system_id cpm_l05_dmi_table[] __initconst = {
> +       {
> +               .ident = "ASUS ROG Strix G513QY",
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> +                       DMI_MATCH(DMI_BOARD_NAME, "G513QY"),
> +               },
> +       },
> +       {}
> +};
> +
> +static acpi_handle cpm_fix_handle;
> +
> +static void cpm_l05_rearm(void *unused)
> +{
> +       acpi_finish_gpe(NULL, CPM_D3COLD_GPE);
> +}
> +
> +static void cpm_l05_work(void *unused)
> +{
> +       acpi_status status;
> +
> +       status = acpi_evaluate_object(cpm_fix_handle, NULL, NULL, NULL);
> +       if (ACPI_FAILURE(status))
> +               pr_err("%s failed: %s\n", CPM_FIX_PATH,
> +                      acpi_format_exception(status));
> +
> +       /*
> +        * Notify() handlers run from the notify workqueue.  As for a firmware
> +        * _Lxx method, only clear and re-enable the level-triggered GPE once
> +        * they have been dispatched so it can't storm while the dGPU resumes.
> +        */
> +       if (ACPI_FAILURE(acpi_os_execute(OSL_NOTIFY_HANDLER, cpm_l05_rearm,
> +                                        NULL)))
> +               cpm_l05_rearm(NULL);
> +}
> +
> +static u32 cpm_l05_gpe_handler(acpi_handle gpe_device, u32 gpe_number,
> +                              void *context)
> +{
> +       /*
> +        * Interrupt context, AML can't run here.  Don't return
> +        * ACPI_REENABLE_GPE: the GPE stays disabled until cpm_l05_rearm().
> +        */
> +       if (ACPI_FAILURE(acpi_os_execute(OSL_GPE_HANDLER, cpm_l05_work, NULL)))
> +               pr_err("unable to queue GPE %02X handler\n", gpe_number);
> +
> +       return ACPI_INTERRUPT_HANDLED;
> +}
> +
> +static int __init cpm_d3cold_l05_init(void)
> +{
> +       struct acpi_table_header *ssdt;
> +       acpi_status status;
> +
> +       if (!dmi_check_system(cpm_l05_dmi_table))
> +               return 0;
> +
> +       /* ACPICA keeps using the table, so it must never be freed */
> +       ssdt = kmemdup(cpm_l05_ssdt, sizeof(cpm_l05_ssdt), GFP_KERNEL);
> +       if (!ssdt)
> +               return -ENOMEM;
> +
> +       status = acpi_load_table(ssdt, NULL);
> +       if (ACPI_FAILURE(status)) {
> +               pr_err("unable to load fixup table: %s\n",
> +                      acpi_format_exception(status));
> +               kfree(ssdt);
> +               return -ENODEV;
> +       }
> +
> +       status = acpi_get_handle(NULL, CPM_FIX_PATH, &cpm_fix_handle);
> +       if (ACPI_FAILURE(status))
> +               return -ENODEV;
> +
> +       status = acpi_install_gpe_handler(NULL, CPM_D3COLD_GPE,
> +                                         ACPI_GPE_LEVEL_TRIGGERED,
> +                                         cpm_l05_gpe_handler, NULL);
> +       if (ACPI_FAILURE(status)) {
> +               pr_err("unable to install GPE %02X handler: %s\n",
> +                      CPM_D3COLD_GPE, acpi_format_exception(status));
> +               return -ENODEV;
> +       }
> +
> +       /* Installing the handler dropped the reference taken for _L05 */
> +       status = acpi_enable_gpe(NULL, CPM_D3COLD_GPE);
> +       if (ACPI_FAILURE(status))
> +               pr_err("unable to enable GPE %02X: %s\n", CPM_D3COLD_GPE,
> +                      acpi_format_exception(status));
> +
> +       pr_info("%s notifies missing %s, using %s instead\n", CPM_L05_PATH,
> +               CPM_MISSING_PATH, CPM_DGPU_PATH);
> +       return 0;
> +}
> +subsys_initcall_sync(cpm_d3cold_l05_init);
>
> ---
> base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
> change-id: 20261122-fdo-gitlab-6061-d6cbed847dbc
>
> Best regards,
> --
> Mario Limonciello <mario.limonciello@amd.com>
>
>

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

* Re: [PATCH] ACPI: x86: Work around AMD CPM _L05 notifying a missing dGPU on ASUS G513QY
  2026-11-26 14:54 ` Rafael J. Wysocki (Intel)
@ 2026-11-29  3:49   ` Mario Limonciello
  0 siblings, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2026-11-29  3:49 UTC (permalink / raw)
  To: Rafael J. Wysocki (Intel)
  Cc: Len Brown, linux-kernel, linux-acpi, Mike Lothian



On 11/26/26 08:54, Rafael J. Wysocki (Intel) wrote:
> On Sun, Nov 22, 2026 at 7:14 PM Mario Limonciello
> <mario.limonciello@amd.com> wrote:
>>
>> The AMD CPM D3cold SSDT (OEM table ID "CPMD3CLD") on the ASUS ROG Strix
>> G513QY (BIOS G513QY.335) handles the dGPU hotplug GPE with:
>>
>>    Scope (\_GPE) { Method (_L05) { Notify (\_SB.PCI0.GPP0.VGA, 0x81) } }
>>
>> On this board the Navi 22 sits behind an on-package PCIe switch and is
>> \_SB.PCI0.GPP0.SWUS.SWDS.VGA; \_SB.PCI0.GPP0.VGA is not defined by any
>> table.  The interpreter correctly aborts the method:
>>
>>    ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.GPP0.VGA], AE_NOT_FOUND
>>    ACPI Error: Aborting method \_GPE._L05 due to previous error (AE_NOT_FOUND)
>>    ACPI Error: AE_NOT_FOUND, while evaluating GPE method [_L05]
>>
>> so the Notify is lost and a dGPU in D3cold is never woken for the
>> hotplug.
> 
> Which presumably doesn't happen in Windows.
> 
> Do you know what the difference is?

Mike,

Can you try on Windows and confirm this behavior doesn't happen in Windows?

> 
>> Other firmware on the same board (the _L00 handler and the
>> ATIF dispatchers) guards both the GPP0.VGA and GPP0.SWUS.SWDS.VGA paths
>> with CondRefOf(), so only this method was missed.
>>
>> Aliasing the missing name is not an option: those guarded branches would
>> then both resolve and dispatch to the dGPU twice.  Instead, load a small
>> built-in SSDT with a method that notifies the real node and replace _L05
>> with a GPE handler that runs it.  The handler defers to a workqueue, as
>> AML can't run in interrupt context, and re-arms the level-triggered GPE
>> behind the notify queue as ACPICA does for _Lxx methods.
>>
>> Match the DMI for the G513QY and introduce a new quirk behind a new
>> ACPI_AML_QUIRKS option.
> 
> I'm totally not a fan of adding AML blobs to the kernel.

Yeah it's a really slippery slope; understood.

> 
> It would be better to avoid putting the device in question into D3cold
> on the affected system IMV.

The problem with avoiding putting it into D3cold is that it's a dGPU  - 
it's going to burn tons of power when it could otherwise be idle.

> 
>> Reported-by: Mike Lothian <mike@fireburn.co.uk>
>> Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/6061
>> Tested-by: Mike Lothian <mike@fireburn.co.uk>
>> Link: https://lore.kernel.org/amd-gfx/20261029151422.56791-1-mike@fireburn.co.uk/
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>>   drivers/acpi/Kconfig          |  16 +++++
>>   drivers/acpi/x86/Makefile     |   1 +
>>   drivers/acpi/x86/cpm_d3cold.c | 161 ++++++++++++++++++++++++++++++++++++++++++
>>   3 files changed, 178 insertions(+)
>>
>> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
>> index fa3eb52b22cd8..70a8d3c79a1b5 100644
>> --- a/drivers/acpi/Kconfig
>> +++ b/drivers/acpi/Kconfig
>> @@ -393,6 +393,22 @@ config ACPI_TABLE_OVERRIDE_VIA_BUILTIN_INITRD
>>
>>            See Documentation/admin-guide/acpi/initrd_table_override.rst for details
>>
>> +config ACPI_AML_QUIRKS
>> +       bool "Workarounds for known AML bugs in system firmware"
>> +       depends on X86
>> +       help
>> +         Some systems ship AML that cannot work as written, for example a
>> +         method that notifies a device which does not exist in the namespace.
>> +         This option builds workarounds for such firmware bugs. Each one is
>> +         enabled only on the specific systems it is known to be needed on
>> +         (matched by DMI), and loads small built-in tables and/or takes over
>> +         an ACPI event from the firmware's own method on those systems.
>> +
>> +         Currently this covers the AMD CPM D3cold dGPU hotplug GPE on the
>> +         ASUS ROG Strix G513QY.
>> +
>> +         Systems that are not on the list are unaffected. If unsure, say N.
>> +
>>   config ACPI_DEBUG
>>          bool "Debug Statements"
>>          default y
>> diff --git a/drivers/acpi/x86/Makefile b/drivers/acpi/x86/Makefile
>> index 63c99509ed9de..04c2c7ffc3a1c 100644
>> --- a/drivers/acpi/x86/Makefile
>> +++ b/drivers/acpi/x86/Makefile
>> @@ -4,5 +4,6 @@ acpi-x86-y              += cmos_rtc.o
>>   acpi-x86-$(CONFIG_PCI) += lpss.o
>>   acpi-x86-y             += s2idle.o
>>   acpi-x86-y             += utils.o
>> +acpi-x86-$(CONFIG_ACPI_AML_QUIRKS) += cpm_d3cold.o
>>
>>   obj-$(CONFIG_X86)      += blacklist.o
>> diff --git a/drivers/acpi/x86/cpm_d3cold.c b/drivers/acpi/x86/cpm_d3cold.c
>> new file mode 100644
>> index 0000000000000..8db5d5ba1a2af
>> --- /dev/null
>> +++ b/drivers/acpi/x86/cpm_d3cold.c
>> @@ -0,0 +1,161 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * cpm_d3cold.c - Work around AMD CPM D3cold tables that notify a missing dGPU
>> + *
>> + * The AMD CPM D3cold SSDT (OEM table ID "CPMD3CLD") handles the dGPU hotplug
>> + * GPE with:
>> + *
>> + *     Scope (\_GPE) { Method (_L05) { Notify (\_SB.PCI0.GPP0.VGA, 0x81) } }
>> + *
>> + * On boards where the dGPU sits behind an on-package PCIe switch the device is
>> + * \_SB.PCI0.GPP0.SWUS.SWDS.VGA and \_SB.PCI0.GPP0.VGA does not exist.  The
>> + * interpreter correctly aborts _L05 with AE_NOT_FOUND, the Notify is lost and
>> + * a dGPU in D3cold is never woken for the hotplug.  Other tables from the same
>> + * firmware (e.g. the _L00 handler) already guard both paths with CondRefOf().
>> + *
>> + * Aliasing the missing name is not an option: those other tables would then
>> + * see both paths and dispatch to the dGPU twice.  Instead, on boards known to
>> + * be affected, load a small SSDT that notifies the real node and run it from a
>> + * GPE handler that replaces _L05.
>> + *
>> + * The built-in SSDT is the following, compiled with iasl:
>> + *
>> + *     DefinitionBlock ("", "SSDT", 2, "LINUX", "CPML05FX", 1)
>> + *     {
>> + *         External (\_GPE, DeviceObj)
>> + *         External (\_SB.PCI0.GPP0.SWUS.SWDS.VGA, DeviceObj)
>> + *
>> + *         Scope (\_GPE)
>> + *         {
>> + *             Method (FX05, 0, NotSerialized)
>> + *             {
>> + *                 Notify (\_SB.PCI0.GPP0.SWUS.SWDS.VGA, 0x81)
>> + *             }
>> + *         }
>> + *     }
>> + */
>> +
>> +#define pr_fmt(fmt) "ACPI: CPM: " fmt
>> +
>> +#include <linux/acpi.h>
>> +#include <linux/dmi.h>
>> +#include <linux/init.h>
>> +#include <linux/printk.h>
>> +#include <linux/slab.h>
>> +
>> +#define CPM_D3COLD_GPE         0x05
>> +
>> +#define CPM_L05_PATH           "\\_GPE._L05"
>> +#define CPM_FIX_PATH           "\\_GPE.FX05"
>> +#define CPM_MISSING_PATH       "\\_SB.PCI0.GPP0.VGA"
>> +#define CPM_DGPU_PATH          "\\_SB.PCI0.GPP0.SWUS.SWDS.VGA"
>> +
>> +static const u8 cpm_l05_ssdt[] __initconst = {
>> +       0x53, 0x53, 0x44, 0x54, 0x79, 0x00, 0x00, 0x00, 0x02, 0x7e, 0x4c, 0x49,
>> +       0x4e, 0x55, 0x58, 0x00, 0x43, 0x50, 0x4d, 0x4c, 0x30, 0x35, 0x46, 0x58,
>> +       0x01, 0x00, 0x00, 0x00, 0x49, 0x4e, 0x54, 0x4c, 0x28, 0x06, 0x23, 0x20,
>> +       0xa0, 0x28, 0x00, 0x15, 0x5c, 0x5f, 0x47, 0x50, 0x45, 0x06, 0x00, 0x15,
>> +       0x5c, 0x2f, 0x06, 0x5f, 0x53, 0x42, 0x5f, 0x50, 0x43, 0x49, 0x30, 0x47,
>> +       0x50, 0x50, 0x30, 0x53, 0x57, 0x55, 0x53, 0x53, 0x57, 0x44, 0x53, 0x56,
>> +       0x47, 0x41, 0x5f, 0x06, 0x00, 0x10, 0x2b, 0x5c, 0x5f, 0x47, 0x50, 0x45,
>> +       0x14, 0x24, 0x46, 0x58, 0x30, 0x35, 0x00, 0x86, 0x5c, 0x2f, 0x06, 0x5f,
>> +       0x53, 0x42, 0x5f, 0x50, 0x43, 0x49, 0x30, 0x47, 0x50, 0x50, 0x30, 0x53,
>> +       0x57, 0x55, 0x53, 0x53, 0x57, 0x44, 0x53, 0x56, 0x47, 0x41, 0x5f, 0x0a,
>> +       0x81
>> +};
>> +
>> +static const struct dmi_system_id cpm_l05_dmi_table[] __initconst = {
>> +       {
>> +               .ident = "ASUS ROG Strix G513QY",
>> +               .matches = {
>> +                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
>> +                       DMI_MATCH(DMI_BOARD_NAME, "G513QY"),
>> +               },
>> +       },
>> +       {}
>> +};
>> +
>> +static acpi_handle cpm_fix_handle;
>> +
>> +static void cpm_l05_rearm(void *unused)
>> +{
>> +       acpi_finish_gpe(NULL, CPM_D3COLD_GPE);
>> +}
>> +
>> +static void cpm_l05_work(void *unused)
>> +{
>> +       acpi_status status;
>> +
>> +       status = acpi_evaluate_object(cpm_fix_handle, NULL, NULL, NULL);
>> +       if (ACPI_FAILURE(status))
>> +               pr_err("%s failed: %s\n", CPM_FIX_PATH,
>> +                      acpi_format_exception(status));
>> +
>> +       /*
>> +        * Notify() handlers run from the notify workqueue.  As for a firmware
>> +        * _Lxx method, only clear and re-enable the level-triggered GPE once
>> +        * they have been dispatched so it can't storm while the dGPU resumes.
>> +        */
>> +       if (ACPI_FAILURE(acpi_os_execute(OSL_NOTIFY_HANDLER, cpm_l05_rearm,
>> +                                        NULL)))
>> +               cpm_l05_rearm(NULL);
>> +}
>> +
>> +static u32 cpm_l05_gpe_handler(acpi_handle gpe_device, u32 gpe_number,
>> +                              void *context)
>> +{
>> +       /*
>> +        * Interrupt context, AML can't run here.  Don't return
>> +        * ACPI_REENABLE_GPE: the GPE stays disabled until cpm_l05_rearm().
>> +        */
>> +       if (ACPI_FAILURE(acpi_os_execute(OSL_GPE_HANDLER, cpm_l05_work, NULL)))
>> +               pr_err("unable to queue GPE %02X handler\n", gpe_number);
>> +
>> +       return ACPI_INTERRUPT_HANDLED;
>> +}
>> +
>> +static int __init cpm_d3cold_l05_init(void)
>> +{
>> +       struct acpi_table_header *ssdt;
>> +       acpi_status status;
>> +
>> +       if (!dmi_check_system(cpm_l05_dmi_table))
>> +               return 0;
>> +
>> +       /* ACPICA keeps using the table, so it must never be freed */
>> +       ssdt = kmemdup(cpm_l05_ssdt, sizeof(cpm_l05_ssdt), GFP_KERNEL);
>> +       if (!ssdt)
>> +               return -ENOMEM;
>> +
>> +       status = acpi_load_table(ssdt, NULL);
>> +       if (ACPI_FAILURE(status)) {
>> +               pr_err("unable to load fixup table: %s\n",
>> +                      acpi_format_exception(status));
>> +               kfree(ssdt);
>> +               return -ENODEV;
>> +       }
>> +
>> +       status = acpi_get_handle(NULL, CPM_FIX_PATH, &cpm_fix_handle);
>> +       if (ACPI_FAILURE(status))
>> +               return -ENODEV;
>> +
>> +       status = acpi_install_gpe_handler(NULL, CPM_D3COLD_GPE,
>> +                                         ACPI_GPE_LEVEL_TRIGGERED,
>> +                                         cpm_l05_gpe_handler, NULL);
>> +       if (ACPI_FAILURE(status)) {
>> +               pr_err("unable to install GPE %02X handler: %s\n",
>> +                      CPM_D3COLD_GPE, acpi_format_exception(status));
>> +               return -ENODEV;
>> +       }
>> +
>> +       /* Installing the handler dropped the reference taken for _L05 */
>> +       status = acpi_enable_gpe(NULL, CPM_D3COLD_GPE);
>> +       if (ACPI_FAILURE(status))
>> +               pr_err("unable to enable GPE %02X: %s\n", CPM_D3COLD_GPE,
>> +                      acpi_format_exception(status));
>> +
>> +       pr_info("%s notifies missing %s, using %s instead\n", CPM_L05_PATH,
>> +               CPM_MISSING_PATH, CPM_DGPU_PATH);
>> +       return 0;
>> +}
>> +subsys_initcall_sync(cpm_d3cold_l05_init);
>>
>> ---
>> base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
>> change-id: 20261122-fdo-gitlab-6061-d6cbed847dbc
>>
>> Best regards,
>> --
>> Mario Limonciello <mario.limonciello@amd.com>
>>
>>


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

end of thread, other threads:[~2026-11-29  3:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 18:14 [PATCH] ACPI: x86: Work around AMD CPM _L05 notifying a missing dGPU on ASUS G513QY Mario Limonciello
2026-11-26 14:54 ` Rafael J. Wysocki (Intel)
2026-11-29  3:49   ` Mario Limonciello

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox