1MB alignment dma_alloc question
A message that is not in the archive (sent off-list or not yet received): [email protected]
Anyone,
Putting together a driver, IMA for ATM in a MPC83xx. Anyway the manual states that one of the data structures for the QE needs to be allocated on a 1MB boundary in external memory.
Normally these come in 128/64/32byte boundaries and are easy to self align, with some bit logic. However, after reading up on dma_alloc_coherent I see that a limitation is that dma cannot span 64K page boundaries.
So this begs a question is their a better way to get a 1MB aligned table? Other than allocating almost 2MB of memory and then trying to mask off the LSBs? Seems like an awful waste of memory. I guess the real question is there a better kernel call that returns already aligned DMA memory?
Thanks,
-Russ
Quoted 4 lines · Russell McGuire
So this begs a question is their a better way to get a 1MB aligned table? Other than allocating almost 2MB of memory and then trying to mask off the LSBs? Seems like an awful waste of memory. I guess the real question is there a better kernel call that returns already aligned DMA memory?
__get_free_pages() will allocate naturally aligned pages from the buddy allocator, so that should do just what you need. If you don't do it at boot time though, you might not be able to get a full unfragmented megabyte any more.
Another option would be to call alloc_bootmem() first, align the buffer and call free_bootmem() on the areas that you do not need. This has to be done *very* early in the boot process.
Arnd <><
Quoted 7 lines · Russell McGuire
Putting together a driver, IMA for ATM in a MPC83xx. Anyway the manual states that one of the data structures for the QE needs to be allocated on a 1MB boundary in external memory.
Normally these come in 128/64/32byte boundaries and are easy to self align, with some bit logic. However, after reading up on
dma_alloc_coherentI see that a limitation is that dma cannot span 64K page boundaries.
That sounds like something related to legacy PC DMA. I doubt there's any such limitation in the API itself.
Quoted 4 lines
So this begs a question is their a better way to get a 1MB aligned table? Other than allocating almost 2MB of memory and then trying to mask off the LSBs? Seems like an awful waste of memory. I guess the real question is there a better kernel call that returns already aligned DMA memory?
It looks like allocations will be naturally aligned on powerpc (due to coming straight from alloc_pages), though it's probably not guaranteed by the API.
-Scott