2

I have read the Linux Device Driver LDD3 , the DMA-API.txt, DMA-HOWTO.txt also took a look at the drivers/dma/dmatest.c but I could not figure out how you initiate a dma transfer. All of the discuss about mapping memory but none on how to initiate a transaction. The PCI example driver has a transfer function but it uses "specific" DMA operations and I am trying to figure out a more generic/portable implementation that is not hardware depended

I am trying to make something like

  1. dma_map_single()
  2. initiate a read/write transaction
  3. interrupt that transaction has finished , use a handler, or wait_event_freezable_timeout
  4. dma_unmap_single()

Do I just read/write to the memory I mapped? How do I register a callback handler?

EDIT: To give a bit more detail I am working on a ARM platform.

akarapatis
  • 852
  • 8
  • 18
  • A DMA operation is usually setup prior to an I/O operation, and it's the peripheral that coordinates with the DMA controller to perform the transfers. The ARM arch has no generic/standard DMA controller. Unlikely you can come up with DMA code that is hardware independent. Since most ARM SoCs do not have an IOMMU, the driver will have a buffer with a virtual address, but the DMA controller will have to be provided with a physical address. The virtual memory will have to be "locked down" (i.e. cannot be swapped out) to a physical page for the duration of the I/O. Beware of page boundaries! – sawdust Dec 04 '12 at 20:34
  • Thank you for your reply. I am interested in the PL330 and SDMA controller that come with two chips. I was looking for a generic API layer for those. I see there is the DMA engine API that can apply to both. But it is still not clear to me how to work with DMA-API and how to use dma_map_single/dma_unmap_single – akarapatis Dec 05 '12 at 09:47

1 Answers1

1

Maybe an example from Xilinx can help: http://www.wiki.xilinx.com/Zynq+Linux+pl330+DMA

And driver from Samsung (already contained in linux kernel): http://lxr.free-electrons.com/source/drivers/dma/pl330.c

Konstantin Utkin
  • 478
  • 1
  • 5
  • 16
  • 1
    Thanks for posting your answer! Please note that you should post the essential parts of the answer here, on this site, or your post risks being deleted [See the FAQ where it mentions answers that are 'barely more than a link'.](http://stackoverflow.com/faq#deletion) You may still include the link if you wish, but only as a 'reference'. The answer should stand on its own without needing the link. – Taryn Mar 26 '14 at 18:38