Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys_pm_ctrl: fragility in managing state control #20775

Closed
pabigot opened this issue Nov 18, 2019 · 1 comment
Closed

sys_pm_ctrl: fragility in managing state control #20775

pabigot opened this issue Nov 18, 2019 · 1 comment
Assignees
Labels
area: Power Management bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale

Comments

@pabigot
Copy link
Collaborator

pabigot commented Nov 18, 2019

subsys/power supports the option (via CONFIG_SYS_PM_STATE_LOCK) to enable and disable specific power states. State is managed with an array of atomic_t instances.

A request to disable a state corresponds to an atomic increment.

A request to enable a state corresponds to an atomic decrement.

The state is considered enabled when the counter is zero, which is the initial condition.

This approach results in some unusual behavior:

  • sys_pm_ctrl_enable_state(S) when S is enabled decrements the counter to -1 thereby disabling the state.

  • sys_pm_ctrl_disable_state(S) when S is disabled means that a subsequent sys_pm_ctrl_enable_state(S) may not enable the state.

The code has asserts to detect for underflow and overflow but since assertions are not generally enabled "misuse" is unlikely to be found.

It may be that this behavior is intended. If so it needs to be documented.

@pabigot pabigot added bug The issue is a bug, or the PR is fixing a bug area: Power Management labels Nov 18, 2019
@dleach02 dleach02 added the priority: low Low impact/importance bug label Nov 19, 2019
@pabigot pabigot self-assigned this Jul 7, 2020
@github-actions
Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Power Management bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants