From a18e4e85e9c02f4f229d7e42208803a2ccc5de36 Mon Sep 17 00:00:00 2001 From: buxiasen Date: Mon, 5 Aug 2024 19:54:56 +0800 Subject: [PATCH] pm_activity: fix deadlock with spinlock and critcal_section critical_section is not compatible with irq disabled, have to delay the wd_start after spin_unlock_irqrestore. Signed-off-by: buxiasen --- drivers/power/pm/pm_activity.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/power/pm/pm_activity.c b/drivers/power/pm/pm_activity.c index 2398cd25b5..aaa92ebfad 100644 --- a/drivers/power/pm/pm_activity.c +++ b/drivers/power/pm/pm_activity.c @@ -440,6 +440,7 @@ void pm_wakelock_staytimeout(FAR struct pm_wakelock_s *wakelock, int ms) FAR struct pm_domain_s *pdom; FAR struct dq_queue_s *dq; FAR struct wdog_s *wdog; + bool wdstart = false; irqstate_t flags; int domain; @@ -466,10 +467,14 @@ void pm_wakelock_staytimeout(FAR struct pm_wakelock_s *wakelock, int ms) if (TICK2MSEC(wd_gettime(wdog)) < ms) { - wd_start(wdog, MSEC2TICK(ms), pm_waklock_cb, (wdparm_t)wakelock); + wdstart = true; } spin_unlock_irqrestore(&pdom->lock, flags); + if (wdstart) + { + wd_start(wdog, MSEC2TICK(ms), pm_waklock_cb, (wdparm_t)wakelock); + } pm_auto_updatestate(domain); }