Skip to content

Conversation

astapleton
Copy link
Member

@astapleton astapleton commented Aug 2, 2025

This implements futures for GPDMA transfers by adding a wrapper for DmaTransfer, DmaTransferFuture, implementing Future for DmaTransferFuture in the gpdma::future module, which is created when a DmaTransfer is awaited via the IntoFuture trait. Under the hood, the implementation uses an AtomicWaker from the futures-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 the gpdma-future feature flag.

@astapleton astapleton mentioned this pull request Aug 2, 2025
Base automatically changed from as/gpdma to master August 7, 2025 18:54
@astapleton astapleton force-pushed the as/gpdma-async branch 5 times, most recently from 34418a0 to fe59cf0 Compare August 7, 2025 21:14
@astapleton astapleton marked this pull request as ready for review August 7, 2025 21:14
DmaTransfer, Error, Instance, Word,
};

// This trait is defined to be bound by ChannelWaker when futures are enabled via the
Copy link
Member

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 ///?

Copy link
Member Author

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

Comment on lines +153 to +157
// 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.
Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member

@usbalbin usbalbin left a 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 :)

@astapleton astapleton merged commit e7a4397 into master Aug 11, 2025
33 checks passed
@astapleton astapleton deleted the as/gpdma-async branch August 11, 2025 19:34
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.

2 participants