linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* 1MB alignment dma_alloc question
       [not found] <mailman.1.1220580004.22796.linuxppc-embedded@ozlabs.org>
@ 2008-09-05 21:11 ` Russell McGuire
  2008-09-05 21:30   ` Scott Wood
  2008-09-05 21:31   ` Arnd Bergmann
  0 siblings, 2 replies; 3+ messages in thread
From: Russell McGuire @ 2008-09-05 21:11 UTC (permalink / raw)
  To: linuxppc-embedded

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 1MB alignment dma_alloc question
  2008-09-05 21:11 ` 1MB alignment dma_alloc question Russell McGuire
@ 2008-09-05 21:30   ` Scott Wood
  2008-09-05 21:31   ` Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: Scott Wood @ 2008-09-05 21:30 UTC (permalink / raw)
  To: rmcguire; +Cc: linuxppc-embedded

Russell McGuire wrote:
> 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.

That sounds like something related to legacy PC DMA.  I doubt there's 
any such limitation in the API itself.

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 1MB alignment dma_alloc question
  2008-09-05 21:11 ` 1MB alignment dma_alloc question Russell McGuire
  2008-09-05 21:30   ` Scott Wood
@ 2008-09-05 21:31   ` Arnd Bergmann
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2008-09-05 21:31 UTC (permalink / raw)
  To: linuxppc-embedded, rmcguire

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-09-05 21:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1.1220580004.22796.linuxppc-embedded@ozlabs.org>
2008-09-05 21:11 ` 1MB alignment dma_alloc question Russell McGuire
2008-09-05 21:30   ` Scott Wood
2008-09-05 21:31   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).