PM policy: Separate default policy and events #80576
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default policy currently directly references the private variable
next_event
from policy_events.c
:zephyr/subsys/pm/policy/policy_default.c
Line 12 in e1389fa
to then convert the cycle of said event (if exists) to a cycle in the future:
zephyr/subsys/pm/policy/policy_default.c
Lines 33 to 52 in e1389fa
something
policy_events.c
already implements quite similarly and exposes throughpm_policy_next_event_ticks()
:zephyr/subsys/pm/policy/policy_events.c
Lines 56 to 69 in e1389fa
Additionally, the implementation of
pm_policy_next_state()
inpolicy_default.c
already gets the nearest kernel tick, wherein the next event has already been accounted for, see implementation ofpm_system_suspend()
:zephyr/subsys/pm/pm.c
Lines 155 to 156 in e1389fa
zephyr/subsys/pm/pm.c
Line 165 in e1389fa
This commit removes the redundant and layer violating computation of the tick of the next event from
policy_default.c
and updates the testtest_pm_policy_events
to not use default policy to determine ifpm_policy_next_event_ticks()
is correct.This PR updates the test suite to actually be able to detect the incorrect argument handling of
pm_policy_event_register()
fixed with PR #80556 so this PR includes said fix, to be dropped from here when fix is merged :)