Replies: 1 comment 3 replies
-
Thanks for working on this. A central registry for reserving DMA channels is a good idea to allow disparate drivers to work together. However, I worry that a useful DMA abstraction isn't worth the complexity. For example, your proposed API doesn't cover
In particular, your go-wspr example doesn't seem to fit your API because it uses control block chaining of DMA channels. Even if the API was sufficient, go-wspr is already platform-specific (because of pio) so won't gain much from a generic DMA API. I propose adding just the central channel registry and add efficient bulk transfer API to each device (I2C, UART etc.) and driver, backed by the platform's DMA. That's a smaller API, and can serve as inspiration for a generic DMA abstraction later on.
I'm not convinced by this argument. Goroutines are supposed to be lightweight enough that APIs can block and let the caller decide whether to introduce concurrency through extra goroutines and channel. With an async API you need a way to expose interrupt-based waiting, otherwise the IsBusy+Gosched loop probably (much of) eats the efficiency gains of using DMA in the first place. |
Beta Was this translation helpful? Give feedback.
-
Background
TinyGo has long had non-standard DMA APIs for interacting with peripherals on MCUs. One example which has received attention recently is the implementation on the PIO library here:
Due to these current events I have begun researching DMA APIs by asking my coworkers about DMA (many thanks to @ydnatag) and finding out interesting things about Linux's DMA API which is documented here:
Proposal details
While having a DMA engine like Linux's would be useful I believe it is too early to work our way into something of the sort. I'd argue we can eventually get there (if we really want that) by building a common low level DMA channel API that is shared in part by Linux's DMA Engine. A couple things about the API:
dma_request_channel
. This is how piolib also does it and it seems to have worked for our users. Below is an API for a lightweight DMAArbiter implementation much like the one in piolib.DMAScatterGatherConfig
type and corresponding function callProposed DMA Channel API
Proposed DMA channel Arbiter API
@tdunning @aykevl @deadprogram
Beta Was this translation helpful? Give feedback.
All reactions