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
wasteful.

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
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to