[PATCH 2/2] PM / wakeirq: Fix spurious wake-up events for dedicated wakeirqs
From: Tony Lindgren
Date: Fri Feb 10 2017 - 17:25:24 EST
From: Grygorii Strashko <grygorii.strashko@xxxxxx>
Dedicated wakeirq is a one time event to wake-up the system from
low-power state and then call pm_runtime_resume() on the device wired
with the dedicated wakeirq.
Sometimes dedicated wakeirqs can get deferred if they trigger after we
call disable_irq_nosync() in dev_pm_disable_wake_irq(). This can happen
if pm_runtime_get() is called around the same time a wakeirq fires.
If an interrupt fires after disable_irq_nosync(), by default it will get
tagged with IRQS_PENDING and will run later on when the interrupt is
Deferred wakeirqs usually just produce pointless wake-up events. But they
can also cause suspend to fail if the deferred wakeirq fires during
dpm_suspend_noirq() for example. So we really don't want to see the
deferred wakeirqs triggering after the device has resumed.
Let's fix the issue by setting IRQ_DISABLE_UNLAZY flag for the dedicated
wakeirqs. The other option would be to implement irq_disable() in the
dedicated wakeirq controller, but that's not a generic solution.
For reference below is what happens with a IRQ_TYPE_EDGE_BOTH IRQ
- resume by dedicated IRQ (EDGE_FALLING)
|- dedicated IRQ armed and fired
|- disarm, disable IRQ and mark as IRQS_PENDING
|- dedicated IRQ processed
!-> dedicated IRQ (EDGE_RISING)
|- IRQ disabled: mask_ack_irq and mark as IRQS_PENDING
- subsequent suspend
(a) |- handle_threaded_wake_irq()
|- pm_wakeup_event() --> abort suspend
|- dedicated IRQ armed
(b) |- resend_irqs
|- IRQ armed -> abort suspend
because of pending IRQ System suspend can be aborted at points
(a)-not armed or (b)-armed.
Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ
Signed-off-by: Grygorii Strashko <grygorii.strashko@xxxxxx>
[tony@xxxxxxxxxxx: added a comment, updated the description]
Tested-by: Tony Lindgren <tony@xxxxxxxxxxx>
Signed-off-by: Tony Lindgren <tony@xxxxxxxxxxx>
drivers/base/power/wakeirq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
@@ -183,6 +183,9 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
wirq->irq = irq;
+ /* Prevent deferred spurious wakeirqs with disable_irq_nosync() */
+ irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY);
* Consumer device may need to power up and restore state
* so we use a threaded irq.