Allow DMA buffer disassociation to prevent memory duplication #3125
Labels
performance
Performance seems to be not as good as it could be
peripheral:dma
DMA Peripheral
peripheral:spi
SPI peripheral
Motivations
I will be using esp32-c6 for this example since that's how I found out about this.
Right now, using DMA buffers with SPI requires passing them into the
SpiDma
struct in order to obtain aSpiBus/SpiDevice
capable handle, using.with_buffers()
. This means that drivers, such as display drivers (e.g. mipidsi) cannot buffer their draw operations directly into the DMA tx buffer, but need to essentially duplicate buffers and do an unnecessary copy.Solution
If
SpiDma
itself was an implementor ofSpiBus
such that it was aware of the buffer descriptors and metadata but would not hold the actual&mut [u8]
buffer pointer, it'd allow drivers to obtain access to that buffer directly and avoid the copy and additional buffer allocation.Alternatives
It might be possible to "expose" the internalized buffer reference but that would require locking which is probably more expensive than the copy in this case.
Additional context
Manual reimplementation of Spi does allow this usage pattern.
The text was updated successfully, but these errors were encountered: