Subject: Re: 1MB alignment dma_alloc question

From: Arnd Bergmann <[email-masked]>
Date: Fri, 5 Sep 2008 23:31:36 +0200

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