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

Memory safe DMA API #36

Merged
merged 9 commits into from
Jan 22, 2019
Merged

Memory safe DMA API #36

merged 9 commits into from
Jan 22, 2019

Conversation

japaric
Copy link
Member

@japaric japaric commented Jan 4, 2019

This is a first draft on building memory safe DMA abstractions.

r? @rust-embedded/resources
cc @korken89 @jamesmunns

@japaric japaric added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-resources labels Jan 4, 2019
@japaric japaric requested a review from a team as a code owner January 4, 2019 19:15
src/dma.md Show resolved Hide resolved
ci/dma/examples/seven.rs Outdated Show resolved Hide resolved
ci/dma/examples/four.rs Outdated Show resolved Hide resolved
ci/dma/examples/five.rs Outdated Show resolved Hide resolved
ci/dma/examples/eight.rs Outdated Show resolved Hide resolved
ci/dma/examples/six.rs Outdated Show resolved Hide resolved
src/dma.md Show resolved Hide resolved
src/dma.md Show resolved Hide resolved
@korken89
Copy link
Contributor

Great first go at it!

@adamgreig
Copy link
Member

adamgreig commented Jan 15, 2019

It's worth mentioning you also need a memory barrier (DMB/DSB) when using devices with caches such as Cortex-M7's DCACHE, since the main SRAM is in general not coherent between the CPU and DMA.

Edit: You could also use explicit cache management to only invalidate the buffer in question instead of the whole memory, but it requires more careful management.

@japaric
Copy link
Member Author

japaric commented Jan 21, 2019

@adamgreig added a note about caches

If there are no more questions or requests then I think we can land this first version of this chapter.

@rj-xy
Copy link

rj-xy commented Jan 21, 2019

Good write-up - Thanks

@japaric
Copy link
Member Author

japaric commented Jan 22, 2019

bors r=adamgreig

bors bot added a commit that referenced this pull request Jan 22, 2019
36: Memory safe DMA API r=adamgreig a=japaric

This is a first draft on building memory safe DMA abstractions.

r? @rust-embedded/resources
cc @korken89 @jamesmunns


Co-authored-by: Jorge Aparicio <[email protected]>
Co-authored-by: Emil Fresk <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jan 22, 2019

Build succeeded

@bors bors bot merged commit 828228b into master Jan 22, 2019
@bors bors bot deleted the dma branch January 22, 2019 08:39
{{#include ../ci/dma/examples/six.rs:91:101}}
```

## `'static` bound
Copy link

Choose a reason for hiding this comment

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

If we have a 'static lifetime, do we still need to Pin the buffers? It seems like adding 'static lifetime solves the original problem of using stack-based buffers, which don't live long enough.

If you can provide an example of an issue that would occur when you only have 'static without Pin, I think that would help me understand better.

Thank you!

Copy link
Member

Choose a reason for hiding this comment

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

We recently discovered that not even 'static + Pin is enough, see #64, we are working on a new documentation for this, see https://github.com/ra-kete/dma-poc for more details.

Copy link

Choose a reason for hiding this comment

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

Thank you for the response. The links where very helpful, and I think the new documentation is very clear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-resources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants