power: avoid sem_wait called in IRQ handler

error backrace:
_assert  --- assert again
sem_wait
pm_unregister
wdog_notifier
panic_notifier_call_chain
_assert
dataabort

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2022-12-30 12:34:52 +08:00 committed by Xiang Xiao
parent 38c6f20d17
commit 23d1d4c42a
4 changed files with 11 additions and 7 deletions

View File

@ -87,11 +87,11 @@ struct pm_domain_s
struct pm_global_s
{
/* This mutex manages mutually exclusive access to the power management
/* This rmutex manages mutually exclusive access to the power management
* registry. It must be initialized to the value 1.
*/
mutex_t reglock;
rmutex_t reglock;
/* registry is a doubly-linked list of registered power management
* callback structures. To ensure mutually exclusive access, this list

View File

@ -46,7 +46,7 @@
struct pm_global_s g_pmglobals =
{
NXMUTEX_INITIALIZER
NXRMUTEX_INITIALIZER
};
/****************************************************************************

View File

@ -56,13 +56,15 @@
int pm_register(FAR struct pm_callback_s *callbacks)
{
irqstate_t flags;
DEBUGASSERT(callbacks);
/* Add the new entry to the end of the list of registered callbacks */
nxmutex_lock(&g_pmglobals.reglock);
flags = pm_lock(&g_pmglobals.reglock);
dq_addlast(&callbacks->entry, &g_pmglobals.registry);
nxmutex_unlock(&g_pmglobals.reglock);
pm_unlock(&g_pmglobals.reglock, flags);
return 0;
}

View File

@ -55,13 +55,15 @@
int pm_unregister(FAR struct pm_callback_s *callbacks)
{
irqstate_t flags;
DEBUGASSERT(callbacks);
/* Remove entry from the list of registered callbacks. */
nxmutex_lock(&g_pmglobals.reglock);
flags = pm_lock(&g_pmglobals.reglock);
dq_rem(&callbacks->entry, &g_pmglobals.registry);
nxmutex_unlock(&g_pmglobals.reglock);
pm_unlock(&g_pmglobals.reglock, flags);
return 0;
}