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

core: Warn about using irq_enable #17433

Merged

Conversation

chrysn
Copy link
Member

@chrysn chrysn commented Dec 21, 2021

Contribution description

Setting the system in a state with more interrupts enabled than expected by the caller is generally unexpected -- if this were allowed unchecked, many components would need to revisit and tighten their synchronization efforts making them less efficient. (I didn't do a precise check, but I expect that ztimer might not tolerate interrupts to be enabled by the callback, especially as that means that unrelated interrupts might manipulate ztimer again).

One offending user was found in the implementations (motor_driver) and changed to use irq_restore. All others have some justification for using enable (eg. it's done in an ISR).

Testing procedure

  • Look at whether you agree with the doc change.
  • Test the motor example. (I didn't, and don't have the hardware -- but what could go wrong?).

Issues/PRs references

This came up looking at the synchronization necessary around Rust code. If arbitrary callbacks can enable interrupts just like that without responsibility, code in critical sections just needs way more severe locking and precautions.

[edit: since when does GitHub accept submissions with plain Enter? Sucks...]

@github-actions github-actions bot added Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: drivers Area: Device drivers labels Dec 21, 2021
@chrysn chrysn added the Area: doc Area: Documentation label Dec 21, 2021
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 21, 2021
Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@chrysn chrysn added the Process: needs >1 ACK Integration Process: This PR requires more than one ACK label Dec 21, 2021
@kaspar030 kaspar030 merged commit debb2d5 into RIOT-OS:master Dec 21, 2021
@chrysn chrysn deleted the irq_enable-considered-harmful branch January 17, 2022 16:34
@fjmolinas fjmolinas added this to the Release 2022.01 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: core Area: RIOT kernel. Handle PRs marked with this with care! Area: doc Area: Documentation Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: needs >1 ACK Integration Process: This PR requires more than one ACK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants