pm: irq should disable before sched locked

If sched lock before irq save, and irq handler do post, scheduler will
be delayed after WFI until next sched unlock. which is not acceptable.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
buxiasen 2024-05-17 21:16:41 +08:00 committed by Xiang Xiao
parent 317afc5ab7
commit 47b2e00d51
1 changed files with 7 additions and 3 deletions

View File

@ -50,10 +50,12 @@ void pm_idle(pm_idle_handler_t handler)
irqstate_t flags;
int ret;
/* Disable IRQ and lock sched */
/* If sched lock before irq save, and irq handler do post, scheduler will
* be delayed after WFI until next sched unlock. which is not acceptable.
*/
sched_lock();
flags = up_irq_save();
sched_lock();
newstate = pm_checkstate(PM_IDLE_DOMAIN);
ret = pm_changestate(PM_IDLE_DOMAIN, newstate);
@ -66,7 +68,9 @@ void pm_idle(pm_idle_handler_t handler)
pm_changestate(PM_IDLE_DOMAIN, PM_RESTORE);
/* Unlock sched and enable IRQ */
/* If there is pending irq, enable irq make handlers finish all execution
* will be better decrease scheduler context switch times.
*/
up_irq_restore(flags);
sched_unlock();