minimum guaranteed alignment of dma_alloc_coherent?

Timur Tabi timur at
Sat Feb 5 11:14:44 EST 2011

Is there any official statement on what the minimum alignment is for
memory returned by dma_alloc_coherent?  I know that since it uses a
page allocator to do the actual allocation, that the memory is page
aligned (at least on PowerPC).  Is this something I can rely on?

Would anyone have a complaint if I did this:

vaddr = dma_alloc_coherent(dev, ssize, &paddr, GFP_DMA | __GFP_ZERO);
BUG_ON(paddr & (alignment - 1));

'alignment' will always be 32 or less.

The reason I ask is that I currently have code that ensures an
alignment, but it does so by allocating extra memory, and that seems

On a side note, do I really need to pass GFP_DMA when calling
dma_alloc_coherent?  That seems redundant, but I don't see the code
force it to be set.  Should it be forced on?

Timur Tabi
Linux kernel developer at Freescale

More information about the Linuxppc-dev mailing list