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

into_async #2430

Merged
merged 13 commits into from
Nov 4, 2024
Merged

into_async #2430

merged 13 commits into from
Nov 4, 2024

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Oct 30, 2024

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs API guidelines

Extra:

Pull Request Details 📖

Description

Closes (almost) #2321. Not closing the issue because of timers.

I'm ignoring timers because they aren't in our core peripheral set and I don't want to deal with them just now.

@bugadani bugadani force-pushed the asyncify branch 3 times, most recently from cf609a1 to 58034a8 Compare October 30, 2024 09:58
@bugadani bugadani changed the title Remove configure_for_async into_async Oct 30, 2024
@bugadani bugadani force-pushed the asyncify branch 5 times, most recently from c78da49 to 53438f4 Compare October 30, 2024 16:58
@bugadani bugadani marked this pull request as ready for review October 30, 2024 16:59
Comment on lines 83 to 85
crate::interrupt::disable(Cpu::ProCpu, Interrupt::RSA);
#[cfg(multi_core)]
crate::interrupt::disable(Cpu::AppCpu, Interrupt::RSA);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why disable on both cores? Just the current one should suffice, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The drivers are currently Send, so it's possible to drop one on the other core. We don't assume where a driver was created (except to bind its interrupts in the first place, which is problematic as it is).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Considering the interrupt handlers are not written to handle cross core setups, the async drivers should be marked at !Send. If folks wants to move the drivers, they should do so in blocking mode.

Copy link
Member

Choose a reason for hiding this comment

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

Considering the interrupt handlers are not written to handle cross core setups, the async drivers should be marked at !Send. If folks wants to move the drivers, they should do so in blocking mode.

This is a nice idea and I think resolves #1525 properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do this separately, there are weird edge cases with split peripherals.

@bugadani bugadani force-pushed the asyncify branch 3 times, most recently from 377cb06 to 9815f07 Compare October 31, 2024 08:18
@bugadani bugadani mentioned this pull request Oct 31, 2024
esp-hal/src/i2c.rs Show resolved Hide resolved
Comment on lines 83 to 85
crate::interrupt::disable(Cpu::ProCpu, Interrupt::RSA);
#[cfg(multi_core)]
crate::interrupt::disable(Cpu::AppCpu, Interrupt::RSA);
Copy link
Member

Choose a reason for hiding this comment

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

Considering the interrupt handlers are not written to handle cross core setups, the async drivers should be marked at !Send. If folks wants to move the drivers, they should do so in blocking mode.

This is a nice idea and I think resolves #1525 properly.

esp-hal/src/uart.rs Show resolved Hide resolved
{
const CHANNEL: u8;
#[doc(hidden)]
pub trait TxChannelInternal<M>
Copy link
Contributor

Choose a reason for hiding this comment

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

now a user could implement TxChannelInternal (and TxChannel) etc. - when removing the private mod we need to seal the internal traits, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These traits shouldn't even exist in the first place, so I don't think this is a big deal.


/// Converts a blocking channel to an async channel.
pub fn into_async(mut self) -> Channel<'d, C, Async> {
self.set_interrupt_handler(C::async_handler(&self));
Copy link
Collaborator

Choose a reason for hiding this comment

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

In general, there should probably be more clean up work when converting to async, since who knows which core the user setup the interrupt handlers on, or if they still have some interrupt pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I've done some of it but I guess we'll have more edge cases. Since users were able to shoot themselves in the foot previously anyway, I'm fine with the current state - which mostly just neglects peripheral interrupts bits.

@bugadani bugadani force-pushed the asyncify branch 6 times, most recently from 83ea4b4 to 67394ce Compare October 31, 2024 17:10
@bugadani bugadani added this pull request to the merge queue Nov 4, 2024
Merged via the queue into esp-rs:main with commit 40c0a69 Nov 4, 2024
28 checks passed
@bugadani bugadani deleted the asyncify branch November 4, 2024 09:55
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.

4 participants