You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2024/05/15 19:32:47 UTC
(nuttx) branch master updated: PM: change domain field state after callback done
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 6ef6d75840 PM: change domain field state after callback done
6ef6d75840 is described below
commit 6ef6d75840be86591eecaf4fab114fbc59f27f8e
Author: buxiasen <bu...@xiaomi.com>
AuthorDate: Fri Apr 12 23:47:19 2024 +0800
PM: change domain field state after callback done
Swap the sequence of domain state update and statechanged callback,
Make sure inside statechanged callback can get the old domain state.
Signed-off-by: buxiasen <bu...@xiaomi.com>
---
drivers/power/pm/activity_governor.c | 15 +++++++--------
drivers/power/pm/pm_changestate.c | 11 +++++++----
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/drivers/power/pm/activity_governor.c b/drivers/power/pm/activity_governor.c
index 64b8eb0fd1..c3fbf0cb4d 100644
--- a/drivers/power/pm/activity_governor.c
+++ b/drivers/power/pm/activity_governor.c
@@ -141,7 +141,7 @@ static void governor_initialize(void);
static void governor_statechanged(int domain, enum pm_state_e newstate);
static enum pm_state_e governor_checkstate(int domain);
static void governor_activity(int domain, int count);
-static void governor_timer(int domain);
+static void governor_timer(int domain, enum pm_state_e newstate);
static void governor_update(int domain, int16_t accum);
/****************************************************************************
@@ -526,7 +526,7 @@ static void governor_statechanged(int domain, enum pm_state_e newstate)
{
/* Start PM timer to decrease PM state */
- governor_timer(domain);
+ governor_timer(domain, newstate);
}
}
@@ -543,18 +543,18 @@ static void governor_timer_cb(wdparm_t arg)
* state level.
*
* Input Parameters:
- * domain - The PM domain associated with the accumulator
+ * domain - The PM domain associated with the accumulator
+ * newstate - The PM domain newstate
*
* Returned Value:
* None.
*
****************************************************************************/
-static void governor_timer(int domain)
+static void governor_timer(int domain, enum pm_state_e newstate)
{
FAR struct pm_domain_state_s *pdomstate;
FAR struct pm_domain_s *pdom;
- uint8_t state;
static const int pmtick[3] =
{
@@ -565,11 +565,10 @@ static void governor_timer(int domain)
pdom = &g_pmglobals.domain[domain];
pdomstate = &g_pm_activity_governor.domain_states[domain];
- state = pdom->state;
- if (state < PM_SLEEP && dq_empty(&pdom->wakelock[state]))
+ if (newstate < PM_SLEEP && dq_empty(&pdom->wakelock[newstate]))
{
- sclock_t delay = pmtick[state] +
+ sclock_t delay = pmtick[newstate] +
pdomstate->btime -
clock_systime_ticks();
sclock_t left = wd_gettime(&pdomstate->wdog);
diff --git a/drivers/power/pm/pm_changestate.c b/drivers/power/pm/pm_changestate.c
index 412edf43f1..17b17030fc 100644
--- a/drivers/power/pm/pm_changestate.c
+++ b/drivers/power/pm/pm_changestate.c
@@ -272,10 +272,6 @@ int pm_changestate(int domain, enum pm_state_e newstate)
*/
pm_changeall(domain, newstate);
- if (newstate != PM_RESTORE)
- {
- g_pmglobals.domain[domain].state = newstate;
- }
/* Notify governor of (possible) state change */
@@ -284,6 +280,13 @@ int pm_changestate(int domain, enum pm_state_e newstate)
g_pmglobals.domain[domain].governor->statechanged(domain, newstate);
}
+ /* Domain state update after statechanged done */
+
+ if (newstate != PM_RESTORE)
+ {
+ g_pmglobals.domain[domain].state = newstate;
+ }
+
/* Restore the interrupt state */
pm_domain_unlock(domain, flags);