minimum guaranteed alignment of dma_alloc_coherent?
ppc6dev at digitaldans.com
Sat Feb 5 13:56:08 EST 2011
On Feb 4, 2011, at 6:04 PM, Tabi Timur-B04825 wrote:
> I guess I'm not clear. I was wondering why an API called
> "dma_alloc_coherent" (that has the word "dma" in it) needs to be
> told to allocate DMA-safe memory.
I understood your question, and I indicated this is used in a
platform specific manner.
> When would it make sense to call dma_alloc_cohernet without
> GFP_DMA? If you don't want DMA-able memory, then you shouldn't be
> calling dma_alloc_anything.
So, I did a little research. It appears in the case of PowerPC,
the GFP_DMA can change the way the allocation operates.
Since the coherent allocator works with pages of memory,
in the case of a system with highmem, not using GFP_DMA
could hand you a physical page out of the highmem pool.
If your device is capable of doing a DMA to that physical
location, all is good. If your device has some addressing
restriction to low memory buffers, you should specify GFP_DMA.
I think for all architectures, GFP_DMA will guarantee a DMA
buffer for any device in a system. If your device can relax that
constraint, you can elect to not use this flag and conserve
the DMA pool for those devices that require the restrictions.
This behavior is modified if you specify a restricted DMA
mask for the device. In this case, dma_alloc_coherent
will force GFP_DMA on your behalf (on PowerPC).
More information about the Linuxppc-dev