1MB alignment dma_alloc question

Arnd Bergmann arnd at arndb.de
Sat Sep 6 07:31:36 EST 2008


On Friday 05 September 2008, Russell McGuire wrote:

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


More information about the Linuxppc-embedded mailing list