PM / wakeirq: support enabling wake-up irq after runtime_suspend called
Subsystems (8)
Chunfeng Yun
maintainerPATCH RESEND v3 1/2 PM / wakeirq: support enabling wake-up irq after runtime_suspend called
When the dedicated wake-irq is level trigger, and it uses the consumer's sleep status as the wakeup source, that means if the consumer is not in sleep state, the wake-irq will be triggered when enable it; For this case, need enable the wake-irq after invoking the consumer's runtime_suspend() which make the consumer enter sleep state.
e.g.
Assume the wake-irq is a low level trigger type, and the wakeup signal comes from the sleep status of consumer.
The wakeup signal is low level at running time (0), and becomes high level when the consumer enters sleep state (runtime_suspend
(1) is called), a wakeup event at (2) make the consumer exit sleep state, then the wakeup signal also becomes low level.
------------------
| ^ ^|
---------------- | | --------------
|<---(0)--->|<--(1)--| (3) (2) (4)
if enable the wake-irq before calling runtime_suspend during (0), an interrupt will arise, it causes resume immediately; it works if enable wake-irq ( e.g. at (3) or (4)) after calling runtime_suspend.
This patch introduces a new status WAKE_IRQ_DEDICATED_LATE_ENABLED to optionally support enabling wake-irq after calling runtime_suspend().
---
v3: add new status suggested by Rafael
v2: add more commit message
Use the falling edge trigger interrupt suggested by Ikjoon [1], it
works well at firstly when only use this related wakeup source, but encounter issues if use other wakeup sources to wakeup platform as below steps:
1. use another wakeup source to wake up the suspended system;
2. the consumer's resume() will be called, and exits sleep state;
3. the consumer's wakeup signal will fall into low level, due to currently the wakeup irq is disabled, the wake-irq is pending;
4. the consumer tries to enter runtime suspend, but there is a pending wakeup irq, so will resume again, this will repeat endlessly.
Send out the patch again for further discussion.
[1]: https://patchwork.kernel.org/patch/12190407
--- drivers/base/power/power.h | 7 ++++-- drivers/base/power/runtime.c | 6 +++-- drivers/base/power/wakeirq.c | 49 +++++++++++++++++++++++++++++++++--- include/linux/pm_wakeirq.h | 5 ++++ 4 files changed, 60 insertions(+), 7 deletions(-)
drivers/base/power/power.h +5 -2
@@ -25,8 +25,10 @@ extern u64 pm_runtime_active_time(struct device *dev);#define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0)#define WAKE_IRQ_DEDICATED_MANAGED BIT(1) +#define WAKE_IRQ_DEDICATED_LATE_ENABLED BIT(2)#define WAKE_IRQ_DEDICATED_MASK (WAKE_IRQ_DEDICATED_ALLOCATED | \ - WAKE_IRQ_DEDICATED_MANAGED) + WAKE_IRQ_DEDICATED_MANAGED | \ + WAKE_IRQ_DEDICATED_LATE_ENABLED)struct wake_irq {struct device *dev;
@@ -39,7 +41,8 @@ extern void dev_pm_arm_wake_irq(struct wake_irq *wirq);extern void dev_pm_disarm_wake_irq (struct wake_irq *wirq);extern void dev_pm_enable_wake_irq_check (struct device *dev,bool can_change_status); -extern void dev_pm_disable_wake_irq_check (struct device *dev); +extern void dev_pm_disable_wake_irq_check (struct device *dev,bool skip_enable_late); +extern void dev_pm_enable_wake_irq_complete (struct device *dev);#ifdef CONFIG_PM_SLEEP
drivers/base/power/runtime.c +4 -2
@@ -645,6 +645,8 @@ static int rpm_suspend(struct device *dev, int rpmflags)if (retval) goto fail; +dev_pm_enable_wake_irq_complete (dev); + no_callback:__update_runtime_status (dev,RPM_SUSPENDED );pm_runtime_deactivate_timer (dev);
@@ -690,7 +692,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)return retval; fail: -dev_pm_disable_wake_irq_check (dev); +dev_pm_disable_wake_irq_check (dev, false);__update_runtime_status (dev,RPM_ACTIVE ); dev->power.deferred_resume = false;wake_up_all (&dev->power.wait_queue);
@@ -873,7 +875,7 @@ static int rpm_resume(struct device *dev, int rpmflags) callback =RPM_GET_CALLBACK (dev, runtime_resume); -dev_pm_disable_wake_irq_check (dev); +dev_pm_disable_wake_irq_check (dev, true); retval =rpm_callback (callback, dev);if (retval) {__update_runtime_status (dev,RPM_SUSPENDED );
drivers/base/power/wakeirq.c +46 -3
79 lines not on this page · raw message
include/linux/pm_wakeirq.h +5 -0
@@ -22,6 +22,7 @@ extern int dev_pm_set_dedicated_wake_irq(struct device *dev,extern void dev_pm_clear_wake_irq (struct device *dev);extern void dev_pm_enable_wake_irq (struct device *dev);extern void dev_pm_disable_wake_irq (struct device *dev); +extern void dev_pm_wake_irq_set_late_enabled_status (struct device *dev);#else /* !CONFIG_PM */
@@ -47,5 +48,9 @@ static inline void dev_pm_disable_wake_irq(struct device *dev) { } +static inline void dev_pm_wake_irq_set_late_enabled_status (struct device *dev) +{ +} +#endif /* CONFIG_PM */ #endif /* _LINUX_PM_WAKEIRQ_H */
Signature · 1 line
2.25.1
Chunfeng Yun
maintainerPATCH RESEND v3 2/2 usb: xhci-mtk: enable wake-up interrupt after runtime_suspend called
Use new function dev_pm_wake_irq_set_late_enabled_status() to enable dedicated wake-up interrupt after xhci_mtk_runtime_suspend() is called.
---
v3: new patch
--- drivers/usb/host/xhci-mtk.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/host/xhci-mtk.c +1 -0
@@ -611,6 +611,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)dev_err (dev,"set wakeup irq %d failed\n" , wakeup_irq); goto dealloc_usb3_hcd; } +dev_pm_wake_irq_set_late_enabled_status (dev);dev_info (dev,"wakeup irq %d\n" , wakeup_irq); }
Signature · 1 line
2.25.1