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

Async: !Send #2980

Merged
merged 2 commits into from
Jan 20, 2025
Merged

Async: !Send #2980

merged 2 commits into from
Jan 20, 2025

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Jan 16, 2025

This PR adds the inherent functions meant by #2905 to the stabilized drivers and I2S.

This PR marks Async: !Send so that async drivers can't be sent to a different core with an interrupt handler in place. Sync-ness of driver should be a separate concern that should be evaluated on a per-driver basis.

Implementations that are both Async and safe to Send can unsafely implement Send.

Closes #1525

@bugadani bugadani changed the title Async Async: !Send Jan 16, 2025
@bugadani bugadani marked this pull request as draft January 16, 2025 12:33
@bugadani bugadani force-pushed the async branch 2 times, most recently from b2dcb47 to c728cca Compare January 17, 2025 09:19
@bugadani bugadani marked this pull request as ready for review January 17, 2025 09:19
@bugadani bugadani marked this pull request as draft January 17, 2025 10:03
@bugadani bugadani force-pushed the async branch 2 times, most recently from 32b6be9 to 3189e14 Compare January 17, 2025 13:36
@bugadani bugadani marked this pull request as ready for review January 17, 2025 13:39
@bugadani
Copy link
Contributor Author

Okay I've given this PR more thought, and I think the Sendness and Syncness of driver are separate concern. We're mostly taking &mut self anyway so the Sync-ness of drivers shouldn't matter much, but they'll need to be reviewed anyway - e.g. configuring GPIOs needs some more care. Probably a lot more care.

Blocking drivers are probably fine to be Send, but they should be !Sync, so that the interrupt handlers can't cause a data race with them. We could then introduce the split interrupt handler struct along with a SyncBlocking mode, that separates the interrupt setup/handling parts from the blocking driver, and allows interrupts to be handled without locking the driver itself. I'm not convinced it's a good idea to do, but it would be possible.

Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

LGTM

@bugadani bugadani added this pull request to the merge queue Jan 20, 2025
Merged via the queue into esp-rs:main with commit 04ba779 Jan 20, 2025
28 checks passed
@bugadani bugadani deleted the async branch January 20, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible interrupt footgun on multicore systems
3 participants