October 2017
Intermediate to advanced
586 pages
14h 8m
English
The following function sets up a coherent mapping:
void *dma_alloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
This function handles both the allocation and the mapping of the buffer, and returns a kernel virtual address for that buffer, which is size bytes-wide and accessible by the CPU. dev is your device structure. The third argument is an output parameter that points to the associated bus address. Memory allocated for the mapping is guaranteed to be physically contiguous, and flag determines how memory should be allocated, which is usually by GFP_KERNEL, or GFP_ATOMIC (if we are in an atomic context).
Do note that this mapping is said to be: