From 8550117b01bb5ad3a1aa24dccdb00656986f2ee2 Mon Sep 17 00:00:00 2001 From: zhushengle Date: Mon, 28 Mar 2022 15:54:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=8E=E5=8A=9F=E8=80=97tick=20timer?= =?UTF-8?q?=E4=BC=91=E7=9C=A0=E6=97=B6=E9=97=B4=E8=AE=A1=E7=AE=97=E6=9C=89?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhushengle Change-Id: I3dfa2a8ec7562a1182dae74cc706c7a660ae867a --- components/power/los_pm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/power/los_pm.c b/components/power/los_pm.c index f5662019..500d882b 100644 --- a/components/power/los_pm.c +++ b/components/power/los_pm.c @@ -101,7 +101,7 @@ STATIC VOID OsPmTickTimerStart(LosPmCB *pm) } #if (LOSCFG_BASE_CORE_TICK_WTIMER == 0) - if (tickTimer->timerStop != NULL) { + if ((tickTimer->timerStop != NULL) && (pm->enterSleepTime != 0)) { /* Restore the main CPU frequency */ sleepTime = tickTimer->timerCycleGet(); tickTimer->timerStop(); @@ -123,8 +123,9 @@ STATIC VOID OsPmTickTimerStart(LosPmCB *pm) STATIC BOOL OsPmTickTimerStop(LosPmCB *pm) { #if (LOSCFG_BASE_CORE_TICK_WTIMER == 0) - UINT64 sleepCycle; - UINT64 realSleepTime = OsSchedGetNextExpireTime(OsGetCurrSchedTimeCycle()); + UINT64 sleepCycle, realSleepTime; + UINT64 currTime = OsGetCurrSchedTimeCycle(); + UINT64 expireTime = OsSchedGetNextExpireTime(currTime); #endif LosPmTickTimer *tickTimer = pm->tickTimer; @@ -134,10 +135,9 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm) #if (LOSCFG_BASE_CORE_TICK_WTIMER == 0) if (tickTimer->timerStart != NULL) { - if (realSleepTime == 0) { - return FALSE; - } + LOS_ASSERT(expireTime > currTime); + realSleepTime = expireTime - currTime; sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock); sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);