All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
@ 2017-03-24 10:08 Hans de Goede
  2017-03-24 11:34 ` Andy Shevchenko
  2017-03-28 13:23 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Hans de Goede @ 2017-03-24 10:08 UTC (permalink / raw)
  To: Mika Westerberg, Linus Walleij, Alexandre Courbot
  Cc: Hans de Goede, linux-acpi, Takashi Iwai, Andy Shevchenko, linux-gpio

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.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
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(+)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 8cd3f66..2972cad 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -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)))
-- 
2.9.3


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

* Re: [PATCH v3] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-24 10:08 [PATCH v3] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
@ 2017-03-24 11:34 ` Andy Shevchenko
  2017-03-28 13:23 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2017-03-24 11:34 UTC (permalink / raw)
  To: Hans de Goede, Mika Westerberg, Linus Walleij, Alexandre Courbot
  Cc: linux-acpi, Takashi Iwai, linux-gpio

On Fri, 2017-03-24 at 11:08 +0100, Hans de Goede wrote:
> 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.
> 

FWIW:
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
> 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(+)
> 
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index 8cd3f66..2972cad 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -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)))

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v3] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-24 10:08 [PATCH v3] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
  2017-03-24 11:34 ` Andy Shevchenko
@ 2017-03-28 13:23 ` Linus Walleij
  2017-03-28 17:24   ` Hans de Goede
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2017-03-28 13:23 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mika Westerberg, Alexandre Courbot, ACPI Devel Maling List,
	Takashi Iwai, Andy Shevchenko, linux-gpio

On Fri, Mar 24, 2017 at 11:08 AM, Hans de Goede <hdegoede@redhat.com> wrote:

> 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.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
> Changes in v2:
> -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.

Patch applied.

Yours,
Linus Walleij

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

* Re: [PATCH v3] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-28 13:23 ` Linus Walleij
@ 2017-03-28 17:24   ` Hans de Goede
  0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2017-03-28 17:24 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Mika Westerberg, Alexandre Courbot, ACPI Devel Maling List,
	Takashi Iwai, Andy Shevchenko, linux-gpio

Hi,

On 03/28/2017 03:23 PM, Linus Walleij wrote:
> On Fri, Mar 24, 2017 at 11:08 AM, Hans de Goede <hdegoede@redhat.com> wrote:
>
>> 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.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>> ---
>> Changes in v2:
>> -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.

> Patch applied.

Thank you.

Regards,

Hans

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

end of thread, other threads:[~2017-03-28 17:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24 10:08 [PATCH v3] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
2017-03-24 11:34 ` Andy Shevchenko
2017-03-28 13:23 ` Linus Walleij
2017-03-28 17:24   ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.