October 2017
Intermediate to advanced
586 pages
14h 8m
English
This is for occasional mapping. One can set up a single buffer with this:
dma_addr_t dma_map_single(struct device *dev, void *ptr,
size_t size, enum dma_data_direction direction);
The direction should be DMA_TO_DEVICE, DMA_FROM_DEVICE, or DMA_BIDIRECTIONAL, as described in the preceding code. ptr is the kernel virtual address of the buffer, and dma_addr_t is the returned bus address for the device. Make sure to use the direction that really fits your needs, not just always DMA_BIDIRECTIONAL.
One should free the mapping with this:
void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
size_t size, enum dma_data_direction direction);