All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
@ 2017-03-20 17:32 Hans de Goede
  2017-03-20 21:59 ` Rafael J. Wysocki
  2017-03-21 12:30 ` Andy Shevchenko
  0 siblings, 2 replies; 7+ messages in thread
From: Hans de Goede @ 2017-03-20 17:32 UTC (permalink / raw)
  To: Mika Westerberg, Linus Walleij, Alexandre Courbot
  Cc: Hans de Goede, linux-acpi, 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
---
 drivers/gpio/gpiolib-acpi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 8cd3f66..18207b2 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -28,6 +28,7 @@ struct acpi_gpio_event {
 	acpi_handle handle;
 	unsigned int pin;
 	unsigned int irq;
+	bool irq_wake_enabled;
 	struct gpio_desc *desc;
 };
 
@@ -266,6 +267,11 @@ 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);
+		event->irq_wake_enabled = true;
+	}
+
 	list_add_tail(&event->node, &acpi_gpio->events);
 	return AE_OK;
 
@@ -339,6 +345,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 (event->irq_wake_enabled)
+			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] 7+ messages in thread

* Re: [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-20 17:32 [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
@ 2017-03-20 21:59 ` Rafael J. Wysocki
  2017-03-24  9:51   ` Hans de Goede
  2017-03-21 12:30 ` Andy Shevchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2017-03-20 21:59 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mika Westerberg, Linus Walleij, Alexandre Courbot, linux-acpi,
	Andy Shevchenko, linux-gpio

On Monday, March 20, 2017 06:32:21 PM 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.
> 
> 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
> ---
>  drivers/gpio/gpiolib-acpi.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index 8cd3f66..18207b2 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -28,6 +28,7 @@ struct acpi_gpio_event {
>  	acpi_handle handle;
>  	unsigned int pin;
>  	unsigned int irq;
> +	bool irq_wake_enabled;
>  	struct gpio_desc *desc;
>  };
>  
> @@ -266,6 +267,11 @@ 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);
> +		event->irq_wake_enabled = true;
> +	}
> +
>  	list_add_tail(&event->node, &acpi_gpio->events);
>  	return AE_OK;
>  
> @@ -339,6 +345,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 (event->irq_wake_enabled)

It has just occurred to me that if the event is in the list, the IRQ will be
enabled to wake up as long as agpio->wake_capable == ACPI_WAKE_CAPABLE, so it
looks like it should be sufficient to check

	if (agpio->wake_capable == ACPI_WAKE_CAPABLE)

here and the new flag is not necessary.  Or is it?

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

Thanks,
Rafael


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

* Re: [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-20 17:32 [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
  2017-03-20 21:59 ` Rafael J. Wysocki
@ 2017-03-21 12:30 ` Andy Shevchenko
  2017-03-21 12:36   ` Rafael J. Wysocki
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-21 12:30 UTC (permalink / raw)
  To: Hans de Goede, Mika Westerberg, Linus Walleij, Alexandre Courbot
  Cc: linux-acpi, linux-gpio

On Mon, 2017-03-20 at 18:32 +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.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> 

> +	bool irq_wake_enabled;
> 

> +		if (event->irq_wake_enabled)
> 

Same (new) comment as in v1.

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

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

* Re: [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-21 12:30 ` Andy Shevchenko
@ 2017-03-21 12:36   ` Rafael J. Wysocki
  2017-03-21 12:40     ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2017-03-21 12:36 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, Mika Westerberg, Linus Walleij, Alexandre Courbot,
	ACPI Devel Maling List, linux-gpio

On Tue, Mar 21, 2017 at 1:30 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Mon, 2017-03-20 at 18:32 +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.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>>
>
>> +     bool irq_wake_enabled;
>>
>
>> +             if (event->irq_wake_enabled)
>>
>
> Same (new) comment as in v1.

Why not just check for agpio->wake_capable == ACPI_WAKE_CAPABLE
instead as I said?

Thanks,
Rafael

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

* Re: [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-21 12:36   ` Rafael J. Wysocki
@ 2017-03-21 12:40     ` Andy Shevchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2017-03-21 12:40 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Hans de Goede, Mika Westerberg, Linus Walleij, Alexandre Courbot,
	ACPI Devel Maling List, linux-gpio

On Tue, 2017-03-21 at 13:36 +0100, Rafael J. Wysocki wrote:
> On Tue, Mar 21, 2017 at 1:30 PM, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Mon, 2017-03-20 at 18:32 +0100, Hans de Goede wrote:

> > > +     bool irq_wake_enabled;
> > > 
> > > +             if (event->irq_wake_enabled)
> > > 
> > 
> > Same (new) comment as in v1.
> 
> Why not just check for agpio->wake_capable == ACPI_WAKE_CAPABLE
> instead as I said?

Ah, yes, it could work as well as far as I can see from the code point
of view.

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

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

* Re: [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-20 21:59 ` Rafael J. Wysocki
@ 2017-03-24  9:51   ` Hans de Goede
  2017-03-24 15:16     ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2017-03-24  9:51 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Mika Westerberg, Linus Walleij, Alexandre Courbot, linux-acpi,
	Andy Shevchenko, linux-gpio

Hi,

On 20-03-17 22:59, Rafael J. Wysocki wrote:
> On Monday, March 20, 2017 06:32:21 PM 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.
>>
>> 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
>> ---
>>  drivers/gpio/gpiolib-acpi.c | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
>> index 8cd3f66..18207b2 100644
>> --- a/drivers/gpio/gpiolib-acpi.c
>> +++ b/drivers/gpio/gpiolib-acpi.c
>> @@ -28,6 +28,7 @@ struct acpi_gpio_event {
>>  	acpi_handle handle;
>>  	unsigned int pin;
>>  	unsigned int irq;
>> +	bool irq_wake_enabled;
>>  	struct gpio_desc *desc;
>>  };
>>
>> @@ -266,6 +267,11 @@ 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);
>> +		event->irq_wake_enabled = true;
>> +	}
>> +
>>  	list_add_tail(&event->node, &acpi_gpio->events);
>>  	return AE_OK;
>>
>> @@ -339,6 +345,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 (event->irq_wake_enabled)
>
> It has just occurred to me that if the event is in the list, the IRQ will be
> enabled to wake up as long as agpio->wake_capable == ACPI_WAKE_CAPABLE, so it
> looks like it should be sufficient to check
>
> 	if (agpio->wake_capable == ACPI_WAKE_CAPABLE)
>
> here and the new flag is not necessary.  Or is it?

We don't have (readily available) access to the acpi_resource_gpio struct
in acpi_gpiochip_free_interrupts, so I'm going to go with Andy's suggestion
instead and change the if to:

                 if (irqd_is_wakeup_set(irq_get_irq_data(event->irq)))
                         disable_irq_wake(event->irq);

Still need to run some quick tests and then I will send v3 with this
change.

Regards,

Hans

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

* Re: [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-24  9:51   ` Hans de Goede
@ 2017-03-24 15:16     ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2017-03-24 15:16 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mika Westerberg, Linus Walleij, Alexandre Courbot, linux-acpi,
	Andy Shevchenko, linux-gpio

On Friday, March 24, 2017 10:51:53 AM Hans de Goede wrote:
> Hi,
> 
> On 20-03-17 22:59, Rafael J. Wysocki wrote:
> > On Monday, March 20, 2017 06:32:21 PM 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.
> >>
> >> 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
> >> ---
> >>  drivers/gpio/gpiolib-acpi.c | 9 +++++++++
> >>  1 file changed, 9 insertions(+)
> >>
> >> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> >> index 8cd3f66..18207b2 100644
> >> --- a/drivers/gpio/gpiolib-acpi.c
> >> +++ b/drivers/gpio/gpiolib-acpi.c
> >> @@ -28,6 +28,7 @@ struct acpi_gpio_event {
> >>  	acpi_handle handle;
> >>  	unsigned int pin;
> >>  	unsigned int irq;
> >> +	bool irq_wake_enabled;
> >>  	struct gpio_desc *desc;
> >>  };
> >>
> >> @@ -266,6 +267,11 @@ 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);
> >> +		event->irq_wake_enabled = true;
> >> +	}
> >> +
> >>  	list_add_tail(&event->node, &acpi_gpio->events);
> >>  	return AE_OK;
> >>
> >> @@ -339,6 +345,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 (event->irq_wake_enabled)
> >
> > It has just occurred to me that if the event is in the list, the IRQ will be
> > enabled to wake up as long as agpio->wake_capable == ACPI_WAKE_CAPABLE, so it
> > looks like it should be sufficient to check
> >
> > 	if (agpio->wake_capable == ACPI_WAKE_CAPABLE)
> >
> > here and the new flag is not necessary.  Or is it?
> 
> We don't have (readily available) access to the acpi_resource_gpio struct
> in acpi_gpiochip_free_interrupts, so I'm going to go with Andy's suggestion
> instead and change the if to:
> 
>                  if (irqd_is_wakeup_set(irq_get_irq_data(event->irq)))
>                          disable_irq_wake(event->irq);
> 
> Still need to run some quick tests and then I will send v3 with this
> change.

OK, fair enough.

Thanks,
Rafael


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

end of thread, other threads:[~2017-03-24 15:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-20 17:32 [PATCH v2] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
2017-03-20 21:59 ` Rafael J. Wysocki
2017-03-24  9:51   ` Hans de Goede
2017-03-24 15:16     ` Rafael J. Wysocki
2017-03-21 12:30 ` Andy Shevchenko
2017-03-21 12:36   ` Rafael J. Wysocki
2017-03-21 12:40     ` Andy Shevchenko

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.