mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
* [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system
@ 2026-10-07 21:55 Igor Velkov via B4 Relay
  2026-10-07 22:05 ` sashiko-bot
  2026-10-08  8:36 ` Neil Armstrong
  0 siblings, 2 replies; 6+ messages in thread
From: Igor Velkov via B4 Relay @ 2026-10-07 21:55 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Radu Rendec, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, linux-arm-kernel, linux-amlogic,
	linux-kernel, Igor Velkov

From: Igor Velkov <iav@iav.lv>

meson_gpio_irq_chip has neither .irq_set_wake nor IRQCHIP_SKIP_SET_WAKE,
so enable_irq_wake() fails with -ENXIO for every interrupt routed through
it. Such an interrupt cannot wake the system from suspend.

Set IRQCHIP_SKIP_SET_WAKE, like the other hierarchical irqchips with a
GIC parent. The GIC sets the same flag, so irq_chip_set_wake_parent()
would end there anyway.

Tested on ODROID-HC4 with the PCF8563 alarm interrupt routed through this
controller: the alarm wakes the board from s2idle 4/4, and 0/1 without
this change.

Assisted-by: LLM
Signed-off-by: Igor Velkov <iav@iav.lv>
---
 drivers/irqchip/irq-meson-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c
index 91a9c337fe6d..e0329ef5e4a2 100644
--- a/drivers/irqchip/irq-meson-gpio.c
+++ b/drivers/irqchip/irq-meson-gpio.c
@@ -538,7 +538,7 @@ static struct irq_chip meson_gpio_irq_chip = {
 #ifdef CONFIG_SMP
 	.irq_set_affinity	= irq_chip_set_affinity_parent,
 #endif
-	.flags			= IRQCHIP_SET_TYPE_MASKED,
+	.flags			= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE,
 };
 
 static int meson_gpio_irq_domain_translate(struct irq_domain *domain,

---
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
change-id: 20261008-meson-gpio-wake-f3bfa3bb2e5a

Best regards,
-- 
Igor Velkov <iav@iav.lv>



_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system
  2026-10-07 21:55 [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system Igor Velkov via B4 Relay
@ 2026-10-07 22:05 ` sashiko-bot
  2026-10-08  8:36 ` Neil Armstrong
  1 sibling, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-10-07 22:05 UTC (permalink / raw)
  To: Igor Velkov; +Cc: linux-amlogic, neil.armstrong

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] irqchip/meson-gpio: missing IRQCHIP_MASK_ON_SUSPEND causes spurious wakeups
--

commit 5ce5a9f356d882f5bc4432c0009be7fd0adbb0fd
Author: Igor Velkov <iav@iav.lv>

irqchip/meson-gpio: Allow the GPIO interrupts to wake the system

This commit adds the IRQCHIP_SKIP_SET_WAKE flag to meson_gpio_irq_chip.
This allows enable_irq_wake() to succeed and GPIO interrupts to wake the
system from suspend.

> diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c
> index 91a9c337fe6d9..e0329ef5e4a21 100644
> --- a/drivers/irqchip/irq-meson-gpio.c
> +++ b/drivers/irqchip/irq-meson-gpio.c
> @@ -538,7 +538,7 @@ static struct irq_chip meson_gpio_irq_chip = {
>  #ifdef CONFIG_SMP
>  	.irq_set_affinity	= irq_chip_set_affinity_parent,
>  #endif
> -	.flags			= IRQCHIP_SET_TYPE_MASKED,
> +	.flags			= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE,

[Severity: Medium]
Since this patch modifies meson_gpio_irq_chip.flags to fix suspend wakeup
behavior, should it also add IRQCHIP_MASK_ON_SUSPEND to properly mask
non-wakeup interrupts at the GIC level?

During system suspend, suspend_device_irq() checks the top-level irqchip's
flags for IRQCHIP_MASK_ON_SUSPEND. Because meson_gpio_irq_chip lacks this
flag, non-wakeup interrupts are only lazily disabled but not explicitly
masked at the hardware level.

Since meson_gpio_irq_chip delegates masking directly to its GIC parent, and
the GIC requires explicit masking to prevent wakeups, will the unmasked
non-wakeup interrupts remain enabled in the GIC and spuriously wake the CPU
from suspend?

>  };
>  
>  static int meson_gpio_irq_domain_translate(struct irq_domain *domain,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261008-meson-gpio-wake-v1-1-b0af1598d469@iav.lv?part=1

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system
  2026-10-07 21:55 [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system Igor Velkov via B4 Relay
  2026-10-07 22:05 ` sashiko-bot
@ 2026-10-08  8:36 ` Neil Armstrong
  2026-10-08 14:19   ` Igor Velkov
  1 sibling, 1 reply; 6+ messages in thread
From: Neil Armstrong @ 2026-10-08  8:36 UTC (permalink / raw)
  To: iav, Thomas Gleixner
  Cc: Radu Rendec, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	linux-arm-kernel, linux-amlogic, linux-kernel

On 10/7/26 23:55, Igor Velkov via B4 Relay wrote:
> From: Igor Velkov <iav@iav.lv>
> 
> meson_gpio_irq_chip has neither .irq_set_wake nor IRQCHIP_SKIP_SET_WAKE,
> so enable_irq_wake() fails with -ENXIO for every interrupt routed through
> it. Such an interrupt cannot wake the system from suspend.
> 
> Set IRQCHIP_SKIP_SET_WAKE, like the other hierarchical irqchips with a
> GIC parent. The GIC sets the same flag, so irq_chip_set_wake_parent()
> would end there anyway.
> 
> Tested on ODROID-HC4 with the PCF8563 alarm interrupt routed through this
> controller: the alarm wakes the board from s2idle 4/4, and 0/1 without
> this change.
> 

The code sound valid but the this paragraph means nothing, adding or removing
IRQCHIP_SKIP_SET_WAKE should not change the fact PCF8563 would wake up the ODROID-HC4
since the BL301 firmware hardcodes which gpio can wakeup.

I guess this flag simply removes an error when setting the gpio as wakeup source
which means nothing in this platform anyway. So please rephrase.

Neil

> Assisted-by: LLM
> Signed-off-by: Igor Velkov <iav@iav.lv>
> ---
>   drivers/irqchip/irq-meson-gpio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c
> index 91a9c337fe6d..e0329ef5e4a2 100644
> --- a/drivers/irqchip/irq-meson-gpio.c
> +++ b/drivers/irqchip/irq-meson-gpio.c
> @@ -538,7 +538,7 @@ static struct irq_chip meson_gpio_irq_chip = {
>   #ifdef CONFIG_SMP
>   	.irq_set_affinity	= irq_chip_set_affinity_parent,
>   #endif
> -	.flags			= IRQCHIP_SET_TYPE_MASKED,
> +	.flags			= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE,
>   };
>   
>   static int meson_gpio_irq_domain_translate(struct irq_domain *domain,
> 
> ---
> base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
> change-id: 20261008-meson-gpio-wake-f3bfa3bb2e5a
> 
> Best regards,


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system
  2026-10-08  8:36 ` Neil Armstrong
@ 2026-10-08 14:19   ` Igor Velkov
  0 siblings, 0 replies; 6+ messages in thread
From: Igor Velkov @ 2026-10-08 14:19 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Thomas Gleixner, Radu Rendec, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, linux-arm-kernel, linux-amlogic,
	linux-kernel, iav

On 08.10.2026 10:36, Neil Armstrong wrote:
> The code sound valid but the this paragraph means nothing, adding or removing
> IRQCHIP_SKIP_SET_WAKE should not change the fact PCF8563 would wake up the ODROID-HC4
> since the BL301 firmware hardcodes which gpio can wakeup.

The test was suspend-to-idle, not mem. The SoC never enters the firmware
suspend there, so BL301 does not pick the wakeup source: the CPUs sit in
cpuidle and any interrupt left enabled in the GIC brings them out.

Whether that wakes the *system* is decided by genirq. suspend_device_irqs()
keeps an interrupt enabled only when irqd_is_wakeup_set(), and that is what
enable_irq_wake() sets. Without the flag enable_irq_wake() fails with
-ENXIO, the interrupt is suspended, and when it fires the flow handler
masks it (irq_can_handle_actions(): irqd_irq_disabled -> IRQS_PENDING,
mask_irq()). The alarm fires once, nothing calls pm_system_irq_wakeup(),
s2idle carries on and the board stays asleep until a power cycle. With the
flag the interrupt is armed, pm_system_irq_wakeup() ends s2idle, and
/sys/power/pm_wakeup_irq shows the alarm. That is the 4/4 against 0/1.

> I guess this flag simply removes an error when setting the gpio as wakeup source
> which means nothing in this platform anyway. So please rephrase.

For mem you are right: the firmware chooses the wakeup sources and this
flag changes nothing there. v2 will say s2idle explicitly and describe the
mechanism above.

Igor

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* Re: [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system
  2026-10-07 21:55 Igor Velkov via B4 Relay
@ 2026-10-07 22:04 ` sashiko-bot
  0 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-10-07 22:04 UTC (permalink / raw)
  To: Igor Velkov; +Cc: neil.armstrong, linux-amlogic

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] irqchip: meson-gpio: spurious wakeups due to missing IRQCHIP_MASK_ON_SUSPEND
--

commit 39ce695188f00617d3597fd256c103a4df7428f7
Author: Igor Velkov <iav@iav.lv>

irqchip/meson-gpio: Allow the GPIO interrupts to wake the system

This commit adds the IRQCHIP_SKIP_SET_WAKE flag to the meson_gpio_irq_chip
definition. This prevents enable_irq_wake() from failing and allows GPIO
interrupts routed through this controller to wake the system from suspend.

> diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c
> index 91a9c337fe6d9..e0329ef5e4a21 100644
> --- a/drivers/irqchip/irq-meson-gpio.c
> +++ b/drivers/irqchip/irq-meson-gpio.c
> @@ -538,7 +538,7 @@ static struct irq_chip meson_gpio_irq_chip = {
>  #ifdef CONFIG_SMP
>  	.irq_set_affinity	= irq_chip_set_affinity_parent,
>  #endif
> -	.flags			= IRQCHIP_SET_TYPE_MASKED,
> +	.flags			= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE,

[Severity: Medium]
Will this cause spurious wakeups from non-wakeup GPIO interrupts during
system suspend?

During suspend, suspend_device_irqs() lazily disables non-wakeup interrupts
by setting IRQD_IRQ_DISABLED, but without calling .irq_mask() because the
parent GIC lacks an .irq_disable() callback. The core IRQ power management
code only physically masks the interrupt if the top-level irq_chip provides
the IRQCHIP_MASK_ON_SUSPEND flag.

Since meson_gpio_irq_chip does not set IRQCHIP_MASK_ON_SUSPEND, non-wakeup
GPIO interrupts might remain unmasked at the GIC level. If a non-wakeup
interrupt triggers while the system is asleep, the GIC will forward it to
the CPU, potentially leading to an unintended wakeup and power drain.

Does this flag definition need to include IRQCHIP_MASK_ON_SUSPEND as well?

>  };
>  
>  static int meson_gpio_irq_domain_translate(struct irq_domain *domain,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261008-meson-gpio-wake-v1-1-fec8a1f5d830@iav.lv?part=1

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

* [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system
@ 2026-10-07 21:55 Igor Velkov via B4 Relay
  2026-10-07 22:04 ` sashiko-bot
  0 siblings, 1 reply; 6+ messages in thread
From: Igor Velkov via B4 Relay @ 2026-10-07 21:55 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Radu Rendec, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, linux-arm-kernel, linux-amlogic,
	linux-kernel, Igor Velkov

From: Igor Velkov <iav@iav.lv>

meson_gpio_irq_chip has neither .irq_set_wake nor IRQCHIP_SKIP_SET_WAKE,
so enable_irq_wake() fails with -ENXIO for every interrupt routed through
it. Such an interrupt cannot wake the system from suspend.

Set IRQCHIP_SKIP_SET_WAKE, like the other hierarchical irqchips with a
GIC parent. The GIC sets the same flag, so irq_chip_set_wake_parent()
would end there anyway.

Tested on ODROID-HC4 with the PCF8563 alarm interrupt routed through this
controller: the alarm wakes the board from s2idle 4/4, and 0/1 without
this change.

Assisted-by: LLM
Signed-off-by: Igor Velkov <iav@iav.lv>
---
 drivers/irqchip/irq-meson-gpio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-meson-gpio.c b/drivers/irqchip/irq-meson-gpio.c
index 91a9c337fe6d..e0329ef5e4a2 100644
--- a/drivers/irqchip/irq-meson-gpio.c
+++ b/drivers/irqchip/irq-meson-gpio.c
@@ -538,7 +538,7 @@ static struct irq_chip meson_gpio_irq_chip = {
 #ifdef CONFIG_SMP
 	.irq_set_affinity	= irq_chip_set_affinity_parent,
 #endif
-	.flags			= IRQCHIP_SET_TYPE_MASKED,
+	.flags			= IRQCHIP_SET_TYPE_MASKED | IRQCHIP_SKIP_SET_WAKE,
 };
 
 static int meson_gpio_irq_domain_translate(struct irq_domain *domain,

---
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
change-id: 20261008-meson-gpio-wake-f3bfa3bb2e5a

Best regards,
-- 
Igor Velkov <iav@iav.lv>



_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

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

end of thread, other threads:[~2026-10-08 14:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07 21:55 [PATCH] irqchip/meson-gpio: Allow the GPIO interrupts to wake the system Igor Velkov via B4 Relay
2026-10-07 22:05 ` sashiko-bot
2026-10-08  8:36 ` Neil Armstrong
2026-10-08 14:19   ` Igor Velkov
2026-10-07 21:55 Igor Velkov via B4 Relay
2026-10-07 22:04 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®