We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b861607 + 91f6426 commit 3d4118aCopy full SHA for 3d4118a
1 file changed
ports/raspberrypi/common-hal/busio/SPI.c
@@ -182,7 +182,10 @@ static bool _transfer(busio_spi_obj_t *self,
182
chan_tx = dma_claim_unused_channel(false);
183
chan_rx = dma_claim_unused_channel(false);
184
}
185
- bool use_dma = chan_rx >= 0 && chan_tx >= 0;
+ bool has_dma_channels = chan_rx >= 0 && chan_tx >= 0;
186
+ // Only use DMA if both data buffers are in SRAM. Otherwise, we'll stall the DMA with PSRAM or flash cache misses.
187
+ bool data_in_sram = data_in >= (uint8_t *)SRAM_BASE && data_out >= (uint8_t *)SRAM_BASE;
188
+ bool use_dma = has_dma_channels && data_in_sram;
189
if (use_dma) {
190
dma_channel_config c = dma_channel_get_default_config(chan_tx);
191
channel_config_set_transfer_data_size(&c, DMA_SIZE_8);
0 commit comments