Skip to contentSkip to conversation

gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set

PATCH In review Hans de Goede 3 participants 4 messages Mar 24, 2017 – Mar 28, 2017

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

PATCH v3 1/1 gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set

On Bay Trail / Cherry Trail systems with a LID switch, the LID switch is often connect to a gpioint handled by an _IAE event handler. Before this commit such systems would not wake up when opening the lid, requiring the powerbutton to be pressed after opening the lid to wakeup.

Note that Bay Trail / Cherry Trail systems use suspend-to-idle, so the interrupts are generated anyway on those lines on lid switch changes, but they are treated by the IRQ subsystem as spurious while suspended if not marked as wakeup IRQs.

This commit calls enable_irq_wake() for _IAE GpioInts with a valid event handler which have their Wake flag set. This fixes such systems not waking up when opening the lid.

---
Changes in v2:
-Improve commit msg
-Add Mika's Acked-by
Changes in v3:
-Use irqd_is_wakeup_set rather then tracking this ourselves

---
 drivers/gpio/gpiolib-acpi.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpio/gpiolib-acpi.c +6 -0
index 8cd3f66..2972cad 100644
@@ -266,6 +266,9 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
 		goto fail_free_event;
 	}
 
+	if (agpio->wake_capable == ACPI_WAKE_CAPABLE)
+		enable_irq_wake(irq);
+
 	list_add_tail(&event->node, &acpi_gpio->events);
 	return AE_OK;
 
@@ -339,6 +342,9 @@ void acpi_gpiochip_free_interrupts(struct gpio_chip *chip)
 	list_for_each_entry_safe_reverse(event, ep, &acpi_gpio->events, node) {
 		struct gpio_desc *desc;
 
+		if (irqd_is_wakeup_set(irq_get_irq_data(event->irq)))
+			disable_irq_wake(event->irq);
+
 		free_irq(event->irq, event);
 		desc = event->desc;
 		if (WARN_ON(IS_ERR(desc)))
Signature · 1 line
2.9.3
Reviewed-by on v3 1/1
#1 lore raw
Quoted 15 lines · Hans de Goede

On Bay Trail / Cherry Trail systems with a LID switch, the LID switch is
often connect to a gpioint handled by an _IAE event handler. Before this commit such systems would not wake up when opening the lid,
requiring the powerbutton to be pressed after opening the lid to wakeup.

Note that Bay Trail / Cherry Trail systems use suspend-to-idle, so the interrupts are generated anyway on those lines on lid switch changes,
but they are treated by the IRQ subsystem as spurious while suspended if
not marked as wakeup IRQs.

Quoted 4 lines

This commit calls enable_irq_wake() for _IAE GpioInts with a valid event handler which have their Wake flag set. This fixes such systems not waking up when opening the lid.

FWIW:

Quoted 39 lines

---
Changes in v2:

(quoted diff) +0 -2
-Improve commit msg
-Add Mika's Acked-by

Changes in v3:
-Use irqd_is_wakeup_set rather then tracking this ourselves
---
 drivers/gpio/gpiolib-acpi.c | 6 ++++++

 1 file changed, 6 insertions(+)
drivers/gpio/gpiolib-acpi.c +0 -0
index 8cd3f66..2972cad 100644
@@ -266,6 +266,9 @@ static acpi_status
 acpi_gpiochip_request_interrupt(struct acpi_resource *ares,
  		goto fail_free_event;
  	}

drivers/gpio/gpiolib-acpi.c +3 -0
+	if (agpio->wake_capable == ACPI_WAKE_CAPABLE)
+		enable_irq_wake(irq);
+

  list_add_tail(&event->node, &acpi_gpio->events); return AE_OK;

drivers/gpio/gpiolib-acpi.c +0 -0
@@ -339,6 +342,9 @@ void acpi_gpiochip_free_interrupts(struct
 gpio_chip *chip)

  list_for_each_entry_safe_reverse(event, ep, &acpi_gpio-

Quoted 1 line

events, node) {

  struct gpio_desc *desc;

drivers/gpio/gpiolib-acpi.c +3 -0
+		if (irqd_is_wakeup_set(irq_get_irq_data(event->irq)))
+			disable_irq_wake(event->irq);
+

  free_irq(event->irq, event);
  desc = event->desc;
  if (WARN_ON(IS_ERR(desc)))

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#2 lore raw
In reply to Hans de Goede
Quoted 20 lines · Hans de Goede

On Bay Trail / Cherry Trail systems with a LID switch, the LID switch is often connect to a gpioint handled by an _IAE event handler. Before this commit such systems would not wake up when opening the lid, requiring the powerbutton to be pressed after opening the lid to wakeup.

Note that Bay Trail / Cherry Trail systems use suspend-to-idle, so the interrupts are generated anyway on those lines on lid switch changes, but they are treated by the IRQ subsystem as spurious while suspended if not marked as wakeup IRQs.

This commit calls enable_irq_wake() for _IAE GpioInts with a valid event handler which have their Wake flag set. This fixes such systems not waking up when opening the lid.

---
Changes in v2:

(quoted diff) +0 -2
-Improve commit msg
-Add Mika's Acked-by
Quoted 2 lines

Changes in v3:
-Use irqd_is_wakeup_set rather then tracking this ourselves

This looks like it should be applied for fixes and tagged for stable.

Patch applied.

Yours,
Linus Walleij

#3 lore raw

Hi,

Quoted 16 lines · Linus Walleij
Quoted 14 lines · Hans de Goede

On Bay Trail / Cherry Trail systems with a LID switch, the LID switch is often connect to a gpioint handled by an _IAE event handler. Before this commit such systems would not wake up when opening the lid, requiring the powerbutton to be pressed after opening the lid to wakeup.

Note that Bay Trail / Cherry Trail systems use suspend-to-idle, so the interrupts are generated anyway on those lines on lid switch changes, but they are treated by the IRQ subsystem as spurious while suspended if not marked as wakeup IRQs.

This commit calls enable_irq_wake() for _IAE GpioInts with a valid event handler which have their Wake flag set. This fixes such systems not waking up when opening the lid.

Quoted 10 lines
Quoted 8 lines

---
Changes in v2:

(quoted diff) +0 -2
-Improve commit msg
-Add Mika's Acked-by

Changes in v3:
-Use irqd_is_wakeup_set rather then tracking this ourselves

This looks like it should be applied for fixes and tagged for stable.

In theory this is a fix, but I'm afraid it may have undesirable side-effects on some systems (I hope not but you never know) so I'm not sure it should get tagged for stable, going into 4.11-rc# as fix seems fine to me.

Quoted 1 line

Patch applied.

Thank you.

Regards,

Hans