-
Notifications
You must be signed in to change notification settings - Fork 6
DMA Futures #65
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 Futures #65
Conversation
564a91b
to
36701a2
Compare
34418a0
to
fe59cf0
Compare
fe59cf0
to
48acbcd
Compare
src/gpdma/future.rs
Outdated
DmaTransfer, Error, Instance, Word, | ||
}; | ||
|
||
// This trait is defined to be bound by ChannelWaker when futures are enabled via the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are those supposed to be //
and not ///
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it also needs a ///
block for public consumption. This was a note differentiating the definition with and without the gpdma-future
feature flag
// This creates a DmaChannelRef instance for channel N, which is be a duplicate to the | ||
// DmaChannelRef instance that is held as a mutable reference in the DmaTransfer struct | ||
// while a transfer is in progress. However, it is only used to disable the transfer | ||
// interrupts for the channel and wake up the task that is waiting for the transfer to | ||
// complete, which can be done safely. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like the the motivation of an unsafe block. Should DmaChannelRef::new
be made unsafe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking the same while writing it, so I think it makes sense to mark new as unsafe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool stuff!
This looks good to me now as far as I can tell :)
This implements futures for GPDMA transfers by adding a wrapper for
DmaTransfer
,DmaTransferFuture
, implementing Future forDmaTransferFuture
in thegpdma::future
module, which is created when aDmaTransfer
is awaited via theIntoFuture
trait. Under the hood, the implementation uses anAtomicWaker
from thefutures-util
crate and channel interrupts to drive the future. Because the wakers need to be defined statically in order to be accessible from the channel interrupts, and to prevent accidental colliding implementations of interrupt handlers for the DMA channels, the futures implementation is hidden behind thegpdma-future
feature flag.