From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: Mario Limonciello <superm1@kernel.org>,
Marco Scardovi <mscardovi95@gmail.com>,
Hans de Goede <hansg@kernel.org>,
Francesco Lauritano <francesco.lauritano1@protonmail.com>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"open list:GPIO ACPI SUPPORT" <linux-gpio@vger.kernel.org>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>,
"westeri@kernel.org" <westeri@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>
Subject: Re: [BUG] 36-second boot delay due to by acpi_gpio_handle_deferred_request_irqs on ASUS ROG Strix G16 (2025)
Date: Tue, 28 Apr 2026 09:59:41 +0200 [thread overview]
Message-ID: <20260428075941.GQ557136@black.igk.intel.com> (raw)
In-Reply-To: <92b504d2-3d6e-4380-883c-be6b50eec25d@gmx.de>
Hi,
On Tue, Apr 28, 2026 at 12:09:10AM +0200, Armin Wolf wrote:
> Am 27.04.26 um 06:57 schrieb Mika Westerberg:
>
> > On Sat, Apr 25, 2026 at 10:41:46PM +0200, Armin Wolf wrote:
> > > > > according to the Microsoft documentation
> > > > > (https://learn.microsoft.com/
> > > > > en-us/windows-hardware/drivers/bringup/general-purpose-i-o--gpio-,
> > > > > section "GPIO controllers and ActiveBoth interrupts"), triggering
> > > > > GPIO interrupts marked as ActiveBoth during initialization is
> > > > > correct as long as the associated GPIO line is already "asserted"
> > > > > (aka logic level low). I think the problem is that we also trigger
> > > > > edge-based GPIO interrupts _not_ marked as ActiveBoth.
> > > > >
> > > > > Based on this i agree with Hans, except that we should continue you
> > > > > trigger ActiveBoth GPIO interrupts as long as the above
> > > > > condition applies.
> > > > >
> > > > > Thanks,
> > > > > Armin Wolf
> > > > >
> > > > So maybe something like this (attached)?
> > > Yes, exactly.
> > This is good information and definitely scales better than the quirk list.
> > The linked document also mentions that there is _DSM under GPIO device that
> > could be used to override the asserted state:
> >
> > https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/gpio-controller-device-specific-method---dsm-
> >
> > I wonder if we should implement that as well?
>
> I already did some work in this area, but i kind of forgot about it
> because i have no suitable device for testing this. Maybe someone has a
> device that uses this _DSM and can check if the attached patch works?
I don't have devices with the _DSM but few comments on the code (thanks BTW
for doing this!).
>
> Thanks,
> Armin Wolf
> From 2e1dc51c864802c05c3a9e6b745dd8c34b4b615b Mon Sep 17 00:00:00 2001
> From: Armin Wolf <W_Armin@gmx.de>
> Date: Thu, 5 Feb 2026 22:39:35 +0100
> Subject: [PATCH] gpiolib: acpi: Add support for Microsoft GPIO _DSM
>
> Microsoft has defined a ACPI device specific method for determining
> the logic level for which a given ActiveBoth GPIO interrupt should be
> considered "asserted". Such GPIO interrupts are normally considered to
> be "asserted" when being logic level low.
> Being able to override this assumption might be important for firmware
> implementations where a ActiveBoth GPIO interrupt is asserted at logic
> level high.
>
> Link: https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/gpio-controller-device-specific-method---dsm-
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> drivers/gpio/gpiolib-acpi-core.c | 67 ++++++++++++++++++++++++++++++--
> 1 file changed, 64 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib-acpi-core.c b/drivers/gpio/gpiolib-acpi-core.c
> index eb8a40cfb7a9..f7c58ae4d423 100644
> --- a/drivers/gpio/gpiolib-acpi-core.c
> +++ b/drivers/gpio/gpiolib-acpi-core.c
> @@ -15,6 +15,8 @@
> #include <linux/irq.h>
> #include <linux/mutex.h>
> #include <linux/pinctrl/pinctrl.h>
> +#include <linux/printk.h>
> +#include <linux/uuid.h>
>
> #include <linux/gpio/consumer.h>
> #include <linux/gpio/driver.h>
> @@ -23,6 +25,14 @@
> #include "gpiolib.h"
> #include "gpiolib-acpi.h"
>
> +/*
> + * Defined by Microsoft at https://learn.microsoft.com/en-us/windows-hardware/drivers/bringup/
> + * gpio-controller-device-specific-method---dsm-.
> + */
> +static const guid_t acpi_gpio_microsoft_guid = GUID_INIT(0x4F248F40, 0xD5E2, 0x499F, 0x83, 0x4C,
> + 0x27, 0x75, 0x8E, 0xA1, 0xCD, 0x3F);
> +#define ACPI_GPIO_DSM_ACTIVE_BOTH_POLARITY 1
> +
> /**
> * struct acpi_gpio_event - ACPI GPIO event handler data
> *
> @@ -216,9 +226,11 @@ bool acpi_gpio_get_io_resource(struct acpi_resource *ares,
> EXPORT_SYMBOL_GPL(acpi_gpio_get_io_resource);
>
> static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio,
> - struct acpi_gpio_event *event)
> + struct acpi_gpio_event *event,
> + union acpi_object *obj)
> {
> struct device *parent = acpi_gpio->chip->parent;
> + bool active_low = true;
> int ret, value;
>
> ret = request_threaded_irq(event->irq, NULL, event->handler,
> @@ -248,18 +260,67 @@ static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio,
> if (acpi_gpio_need_run_edge_events_on_boot() &&
> ((event->irqflags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) ==
> (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING))) {
> + if (obj) {
> + for (u32 i = 0; i < obj->package.count; i++) {
> + if (obj->package.elements[i].integer.value == event->pin) {
> + active_low = false;
> + break;
> + }
> + }
> + }
> +
> value = gpiod_get_raw_value_cansleep(event->desc);
> - if (value == 0)
> + if ((active_low && value == 0) || (!active_low && value == 1))
> event->handler(event->irq, event);
> }
> }
>
> +static union acpi_object *acpi_gpiochip_evaluate_dsm(struct acpi_gpio_chip *acpi_gpio)
> +{
> + struct device *parent = acpi_gpio->chip->parent;
> + union acpi_object dummy = {
> + .package = {
> + .type = ACPI_TYPE_PACKAGE,
> + .count = 0,
> + .elements = NULL,
> + },
> + };
> + acpi_handle handle = ACPI_HANDLE(parent);
> + union acpi_object *obj;
> +
> + if (!acpi_check_dsm(handle, &acpi_gpio_microsoft_guid, 0,
> + BIT(ACPI_GPIO_DSM_ACTIVE_BOTH_POLARITY)))
> + return NULL;
> +
> + obj = acpi_evaluate_dsm_typed(handle, &acpi_gpio_microsoft_guid, 0,
> + ACPI_GPIO_DSM_ACTIVE_BOTH_POLARITY,
> + &dummy, ACPI_TYPE_PACKAGE);
> + if (obj) {
> + for (u32 i = 0; i < obj->package.count; i++) {
> + if (obj->package.elements[i].type == ACPI_TYPE_INTEGER)
> + continue;
> +
> + dev_err(parent, FW_BUG "Ignoring GPIO _DSM due to invalid data\n");
> + ACPI_FREE(obj);
> + return NULL;
> + }
> + }
> +
> + return obj;
> +}
> +
> static void acpi_gpiochip_request_irqs(struct acpi_gpio_chip *acpi_gpio)
> {
> struct acpi_gpio_event *event;
> + union acpi_object *obj;
> +
> + obj = acpi_gpiochip_evaluate_dsm(acpi_gpio);
>
So intead of here I think it should be called from
acpi_gpiochip_request_interrupts() after acpi_walk_resources() and make it
fill new field active_low in struct acpi_gpio_event.
Then use that field in acpi_gpiochip_request_irq().
> list_for_each_entry(event, &acpi_gpio->events, node)
> - acpi_gpiochip_request_irq(acpi_gpio, event);
> + acpi_gpiochip_request_irq(acpi_gpio, event, obj);
> +
> + if (obj)
> + ACPI_FREE(obj);
> }
>
> static enum gpiod_flags
> --
> 2.39.5
>
next prev parent reply other threads:[~2026-04-28 7:59 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2kSCn4XaoXsXJ3EUR0syTdmip8Z1cBuUr0Br4sFVnwnsA8q4GlhiHOmsJkeBxvxYoLnetp4r44wIPXw42yTAFl-BtMROnIwR-NkckKgA5EY=@protonmail.com>
[not found] ` <6iFCwGH2vssb7NRUTWGpkubGMNbgIlBHSz40z8ZsezjxngXpoiiRiJaijviNvhiDAGIr43bfUmdxLmxYoHDjyft4DgwFc3Pnu5hzPguTa0s=@protonmail.com>
2025-12-17 12:01 ` [PATCH] gpiolib: acpi: Disable edge events on boot on ASUS ROG Strix G16 G614PP francesco.lauritano1
2025-12-17 13:08 ` Mika Westerberg
2025-12-17 14:01 ` Francesco Lauritano
2025-12-28 20:15 ` Andy Shevchenko
2025-12-17 14:23 ` [BUG] 36-second boot delay due to by acpi_gpio_handle_deferred_request_irqs on ASUS ROG Strix G16 (2025) Mario Limonciello
2025-12-17 15:12 ` Francesco Lauritano
2025-12-17 16:57 ` Francesco Lauritano
2025-12-17 18:01 ` Mario Limonciello
2025-12-17 19:19 ` Francesco Lauritano
2025-12-18 6:39 ` Mika Westerberg
2025-12-18 10:33 ` Hans de Goede
2025-12-18 10:38 ` Mika Westerberg
2026-04-22 7:51 ` Marco Scardovi
2026-04-22 9:07 ` Mika Westerberg
2026-04-22 9:45 ` Marco Scardovi
2026-04-22 9:55 ` Mika Westerberg
2026-04-22 12:08 ` Marco Scardovi
2026-04-23 4:42 ` Mika Westerberg
2026-04-23 5:15 ` Mario Limonciello
2026-04-23 17:46 ` Marco Scardovi
2026-04-24 20:02 ` Armin Wolf
2026-04-25 15:15 ` Mario Limonciello
2026-04-25 20:41 ` Armin Wolf
2026-04-27 4:57 ` Mika Westerberg
2026-04-27 22:09 ` Armin Wolf
2026-04-28 7:59 ` Mika Westerberg [this message]
2026-04-27 11:46 ` Hans de Goede
2026-04-27 11:46 ` Hans de Goede
2026-04-27 12:28 ` Mika Westerberg
2026-04-27 12:41 ` Marco Scardovi
2026-04-27 15:30 ` Hans de Goede
2026-04-27 16:10 ` Marco Scardovi
2026-04-27 16:14 ` Marco Scardovi
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=20260428075941.GQ557136@black.igk.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=W_Armin@gmx.de \
--cc=bentiss@kernel.org \
--cc=francesco.lauritano1@protonmail.com \
--cc=hansg@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mscardovi95@gmail.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=superm1@kernel.org \
--cc=westeri@kernel.org \
/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