I always use dma_alloc_coherent() to allocate DMA buffer with flag GFP_KERNEL and haven't observed problem so far, my understanding is both flags allow the caller to sleep as well..
So I am just curious if GFP_DMA option is really useful in this case? Also the flag is available for kmalloc(), however are we not supposed to use kmalloc() to allocate DMA buffer but only dma apis?
dma_alloc_coherent() returns address range for which proper memory attributes are already set so cache effect is handled naturally. We need not to do any cache operation for these addresses.
If we use address allocated by kmalloc() for DMA operation then we need to do extra cache operation like cache clean and cache invalidate based on direction of transfer.
GFP_DMA flag just allocates memory from DMA Zone on 32-bit machine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With