Skip to content

Commit 94ae33c

Browse files
GTLin08carlescufi
authored andcommitted
ITE: soc/riscv/ite: policy: Add minimum residency time to enter sleep
Adding this condition will limit the minimum residency time to enter sleep mode. This will fix tests in test\kernel\sleep\usleep.c causing longer than expected test times due to going into sleep mode with no time limit. Signed-off-by: Tim Lin <[email protected]>
1 parent f2d1757 commit 94ae33c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

soc/riscv/riscv-ite/common/policy.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ __weak const struct pm_state_info *pm_policy_next_state(uint8_t cpu, int32_t tic
1717

1818
for (int16_t i = (int16_t)num_cpu_states - 1; i >= 0; i--) {
1919
const struct pm_state_info *state = &cpu_states[i];
20+
uint32_t min_residency;
2021

2122
/* check if there is a lock on state + substate */
2223
if (pm_policy_state_lock_is_active(
2324
state->state, state->substate_id)) {
2425
continue;
2526
}
2627

27-
return state;
28+
min_residency = k_us_to_ticks_ceil32(state->min_residency_us);
29+
/*
30+
* The tick interval for the system to enter sleep mode needs
31+
* to be longer than or equal to the minimum residency.
32+
*/
33+
if (ticks >= min_residency) {
34+
return state;
35+
}
2836
}
2937

3038
return NULL;

0 commit comments

Comments
 (0)