All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
@ 2017-03-18 23:35 Hans de Goede
  2017-03-19  0:25 ` Rafael J. Wysocki
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Hans de Goede @ 2017-03-18 23:35 UTC (permalink / raw)
  To: Mika Westerberg, Linus Walleij, Alexandre Courbot
  Cc: Hans de Goede, linux-acpi, Andy Shevchenko, linux-gpio

On baytrail / cherrytrail 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.

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>
---
 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] 8+ messages in thread

* Re: [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-18 23:35 [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
@ 2017-03-19  0:25 ` Rafael J. Wysocki
  2017-03-20 17:24   ` Hans de Goede
  2017-03-19 15:25 ` Andy Shevchenko
  2017-03-20 10:17 ` Mika Westerberg
  2 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2017-03-19  0:25 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mika Westerberg, Linus Walleij, Alexandre Courbot,
	ACPI Devel Maling List, Andy Shevchenko, linux-gpio

On Sun, Mar 19, 2017 at 12:35 AM, Hans de Goede <hdegoede@redhat.com> wrote:
> On baytrail / cherrytrail 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.
>
> 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>

Thanks for taking care of this, the changes look OK to me.

Do I guess correctly that this is about wakeups from suspend-to-idle?

If so, it would be good to note in the changelog that this is the case
and that 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.

> ---
>  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

Thanks,
Rafael

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

* Re: [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-18 23:35 [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
  2017-03-19  0:25 ` Rafael J. Wysocki
@ 2017-03-19 15:25 ` Andy Shevchenko
  2017-03-19 19:48   ` Rafael J. Wysocki
  2017-03-20 17:20   ` Hans de Goede
  2017-03-20 10:17 ` Mika Westerberg
  2 siblings, 2 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-03-19 15:25 UTC (permalink / raw)
  To: Hans de Goede, Mika Westerberg, Linus Walleij, Alexandre Courbot
  Cc: linux-acpi, linux-gpio

On Sun, 2017-03-19 at 00:35 +0100, Hans de Goede wrote:
> On baytrail / cherrytrail 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.
> 
> 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.

I perhaps give up on my nits against Capital Letters :-), though for
consistency, please, use Baytrail, Cherry Trail.
 
> +		if (event->irq_wake_enabled)

You may use irqd_is_wakeup_set() instead. IRQ framework keeps this state
already.

> +			disable_irq_wake(event->irq);


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

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

* Re: [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-19 15:25 ` Andy Shevchenko
@ 2017-03-19 19:48   ` Rafael J. Wysocki
  2017-03-20 17:20   ` Hans de Goede
  1 sibling, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2017-03-19 19:48 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, Mika Westerberg, Linus Walleij, Alexandre Courbot,
	ACPI Devel Maling List, linux-gpio

On Sun, Mar 19, 2017 at 4:25 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Sun, 2017-03-19 at 00:35 +0100, Hans de Goede wrote:
>> On baytrail / cherrytrail 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.
>>
>> 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.
>
> I perhaps give up on my nits against Capital Letters :-), though for
> consistency, please, use Baytrail, Cherry Trail.
>
>> +             if (event->irq_wake_enabled)
>
> You may use irqd_is_wakeup_set() instead. IRQ framework keeps this state
> already.
>
>> +                     disable_irq_wake(event->irq);

Good point!

Thanks,
Rafael

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

* Re: [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-18 23:35 [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
  2017-03-19  0:25 ` Rafael J. Wysocki
  2017-03-19 15:25 ` Andy Shevchenko
@ 2017-03-20 10:17 ` Mika Westerberg
  2 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2017-03-20 10:17 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Linus Walleij, Alexandre Courbot, linux-acpi, Andy Shevchenko,
	linux-gpio

On Sun, Mar 19, 2017 at 12:35:24AM +0100, Hans de Goede wrote:
> On baytrail / cherrytrail 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.
> 
> 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>

After you have addressed comments from Andy you can add my,

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>

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

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

Hi,

On 19-03-17 16:25, Andy Shevchenko wrote:
> On Sun, 2017-03-19 at 00:35 +0100, Hans de Goede wrote:
>> On baytrail / cherrytrail 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.
>>
>> 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.
>
> I perhaps give up on my nits against Capital Letters :-), though for
> consistency, please, use Baytrail, Cherry Trail.

Will fix for v2.

>
>> +		if (event->irq_wake_enabled)
>
> You may use irqd_is_wakeup_set() instead. IRQ framework keeps this state
> already.

That requires having irq_data which is only (normally) available to
irq_chip drivers, so that is not going to work here.

Regards,

Hans

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

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

Hi,

On 19-03-17 01:25, Rafael J. Wysocki wrote:
> On Sun, Mar 19, 2017 at 12:35 AM, Hans de Goede <hdegoede@redhat.com> wrote:
>> On baytrail / cherrytrail 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.
>>
>> 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>
>
> Thanks for taking care of this, the changes look OK to me.
>
> Do I guess correctly that this is about wakeups from suspend-to-idle?

Yes.

> If so, it would be good to note in the changelog that this is the case
> and that 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.

Ack will do.

Regards,

Hans


>
>> ---
>>  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
>
> Thanks,
> Rafael
>

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

* Re: [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set
  2017-03-20 17:20   ` Hans de Goede
@ 2017-03-21 12:21     ` Andy Shevchenko
  0 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2017-03-21 12:21 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:20 +0100, Hans de Goede wrote:
> Hi,
> 
> On 19-03-17 16:25, Andy Shevchenko wrote:
> > On Sun, 2017-03-19 at 00:35 +0100, Hans de Goede wrote:
> > > On baytrail / cherrytrail 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.
> > > 
> > > 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.
> > 
> > I perhaps give up on my nits against Capital Letters :-), though for
> > consistency, please, use Baytrail, Cherry Trail.
> 
> Will fix for v2.
> 
> > 
> > > +		if (event->irq_wake_enabled)
> > 
> > You may use irqd_is_wakeup_set() instead. IRQ framework keeps this
> > state
> > already.
> 
> That requires having irq_data which is only (normally) available to
> irq_chip drivers, so that is not going to work here.

Which you can get easily from IRQ line number.

  data = irq_get_irq_data(irq);
  if (irqd_is_wakeup_set(data))

Would this work?

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

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-18 23:35 [PATCH] gpio: acpi: Call enable_irq_wake for _IAE GpioInts with Wake set Hans de Goede
2017-03-19  0:25 ` Rafael J. Wysocki
2017-03-20 17:24   ` Hans de Goede
2017-03-19 15:25 ` Andy Shevchenko
2017-03-19 19:48   ` Rafael J. Wysocki
2017-03-20 17:20   ` Hans de Goede
2017-03-21 12:21     ` Andy Shevchenko
2017-03-20 10:17 ` Mika Westerberg

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.