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

[DMA 3/8] Remove ChannelCreator types, temporarily disable burst mode #2403

Merged
merged 8 commits into from
Nov 21, 2024

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Oct 24, 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

This PR removes the ChannelCreator types, and instead provides the initialized DMA channels immediately. The PR further removes the channel-wide burst mode setting, and pushes the responsibility to the DMA buffer APIs. As a consequence, some peripherals currently don't support burst DMA transfers.

@bugadani
Copy link
Contributor Author

bugadani commented Oct 24, 2024

Draft for a reason, I want to see where CI breaks.

@MabezDev
Copy link
Member

I'm liking the direction of this a lot, I think if we choose to treat channels like peripherals and apply the same config method to drivers (whatever that may be from discussions in #2416) it should work quite nicely I think.

@bugadani bugadani force-pushed the dma branch 2 times, most recently from a8bd163 to 2752db1 Compare November 4, 2024 13:53
@bugadani
Copy link
Contributor Author

bugadani commented Nov 4, 2024

I'm not happy that Channel/ChannelTx/ChannelRx would need to become Peripheral instances. The problem is that they currently have mutable state (as in, their configuration) and I'm not sure how that interacts with PeripheralRef. Most likely in a subtly surprising way because into_ref clones the inner peripheral. That's not a big deal as peripherals don't unusally configure the DMA channel, but once they do, releasing the channel would mean that the config changes become lost.

@bugadani bugadani force-pushed the dma branch 3 times, most recently from cedeb69 to 210f29b Compare November 11, 2024 12:45
@bugadani
Copy link
Contributor Author

bugadani commented Nov 11, 2024

My idea is to move burst mode config to Tx/RxBuffer (and consequently, Preparation if I need to, although burst length is still nebulous to me a bit). This allows us more flexibility (burst mode becomes a property of the transaction, essentially), and it allows us to remove in-memory configuration from the DMA channels.

@Dominaezzz
Copy link
Collaborator

Dominaezzz commented Nov 11, 2024

Did you manage to figure out the bandwidth thing?
i.e. Are there any consequences for running all 10 DMA channels in burst mode at the full 40 MB/sec? (Or 5 channels at 80MB/sec)

If there are consequences, then (long term) users need some way to turn it off in some subset of channels and/or transactions.

EDIT: For future reference, I found this.

@bugadani
Copy link
Contributor Author

Did you manage to figure out the bandwidth thing?

No, I mean I'd put this into the user's hands, so that they can enable burst transfer of buffers. There is very little clear documentation what burst mode actually means for internal SRAM, so I'd try not to be more clever than necessary.

i.e. Are there any consequences for running all 10 DMA channels in burst mode at the full 40 MB/sec? (Or 5 channels at 80MB/sec)

Only a single transfer can happen at any one time anyway, I think burst mode just prevents the arbiter from giving bus access to a different channel. I assume the DMA takes care of using aligned word access if it can, and I hope it doesn't need burst mode to be enabled for it.

@bugadani bugadani force-pushed the dma branch 5 times, most recently from da573e8 to 747d131 Compare November 13, 2024 09:08
@bugadani bugadani changed the title Remove ChannelCreator types Apply Peripheral pattern to DMA Nov 13, 2024
@bugadani bugadani changed the title Apply Peripheral pattern to DMA [DMA 3/N] Apply Peripheral pattern to DMA Nov 13, 2024
@bugadani bugadani force-pushed the dma branch 2 times, most recently from 6240d7f to cf7c76d Compare November 14, 2024 13:14
esp-hal/src/dma/buffers.rs Show resolved Hide resolved
esp-hal/src/dma/buffers.rs Outdated Show resolved Hide resolved
esp-hal/src/dma/buffers.rs Show resolved Hide resolved
esp-hal/src/dma/gdma.rs Outdated Show resolved Hide resolved
esp-hal/src/dma/buffers.rs Show resolved Hide resolved
esp-hal/src/dma/buffers.rs Show resolved Hide resolved
@bugadani bugadani changed the title [DMA 3/N] Remove ChannelCreator types, temporarily disable burst mode [DMA 3/8] Remove ChannelCreator types, temporarily disable burst mode Nov 15, 2024
@bugadani bugadani force-pushed the dma branch 3 times, most recently from c4bd7c3 to e516a87 Compare November 21, 2024 09:31
@bugadani bugadani marked this pull request as ready for review November 21, 2024 09:31
@bugadani bugadani force-pushed the dma branch 2 times, most recently from 6b5d172 to 03fcf43 Compare November 21, 2024 10:18
@bjoernQ
Copy link
Contributor

bjoernQ commented Nov 21, 2024

Cannot comment on the line:

There is the ChannelCreator struct left in gdma.rs

esp-hal\src\dma\gdma.rs
574:pub struct ChannelCreator<const N: u8> {}

esp-hal/CHANGELOG.md Outdated Show resolved Hide resolved
esp-hal/src/dma/buffers.rs Show resolved Hide resolved
esp-hal/src/dma/buffers.rs Outdated Show resolved Hide resolved
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

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

LGTM, glad to see the creator types go!

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.

Thought I already approved - apparently not. Looking forward to the next PRs

@bjoernQ bjoernQ added this pull request to the merge queue Nov 21, 2024
Merged via the queue into esp-rs:main with commit 973671c Nov 21, 2024
28 checks passed
@bugadani bugadani deleted the dma branch November 21, 2024 15:20
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