Skip to content
Advertisement

Resubmitting DMA Engine transactions

I’m writing a custom high-speed Linux SPI driver for an embedded SoC. To send data to the SPI peripheral (DMA_MEM_TO_DEV) I’m the Linux DMA Engine API.

https://www.kernel.org/doc/Documentation/dmaengine/client.txt

Based on the documentation, the steps for setting up and executing a DMA transaction are:

  1. Allocate a DMA slave channel : dma_request_channel
  2. Set slave and controller specific parameters : dmaengine_slave_config
  3. Get a descriptor for tranesaction : dmaengine_prep_slave_single
  4. Submit the transaction : dmaengine_submit
  5. Issue pending requests and wait for callback notification : dma_async_issue_pending

I have this working for single DMA transactions. But I need to send multiple DMA transactions from the same memory location (dma_addr_t buf) of the same size (size_t len) based on some hardware flow control (GPIOs).

For starters, I tried to redo step 1-5 for every DMA transaction. So every time the flow control GPIO IRQ triggers, I reallocate a DMA slave channel, re-set the slave and controller specific parameters, …

This seems to work too, but I am not sure if it’s the most efficient way.

I am wondering if I can just re-submit the transaction again (dmaengine_submit) and issue again (dma_async_issue_pending)? Would this be more efficient?

I can’t seem to find any information on how to resubmit the exact same DMA request anywhere in the kernel documentation.

Advertisement

Answer

Steps 1 and 2 need not be repeated. Steps 3 to 5 can be repeated for multiple transactions. For example, see the patch here. dspi_dma_xfer function can call dspi_next_xfer_dma_submit multiple times and steps 3 to 5 are redone. Since you want the dma_addr_t buf to be the same, as far as I understand this is what you want.

Advertisement