allocating memory at boot
sk.syed2
sk.syed2 at gmail.com
Fri Feb 18 13:42:56 EST 2011
> I have looked at the code for dma_alloc_coherent etc and it seems to me that
> it's returning null because there isn't the space available to allocate the
> requested memory.
You might have to increase the consistent(or dma) memory size. In
recent kernels its defined by CONSISTENT_DMA_SIZE
(ach/arm/include/asm/memory.h). Which kernel version are you using?
You might have to override this value to match your needs. Are there
any other drivers that allocate using dma_alloc_coherent?
> I was thinking that this might be the problem, but in order to do that I'd
> have to put the alloc_bootmem in core kernel code wouldn't I? This doesn't
> seem very appealing.
Yes. Nobody wants to do that. Best option is to use
dma_alloc_coherent. Alternatively you can use kmalloc in your driver
itself and then use dma_map_single/dma_unmap_single.
> Yes, I was aware that dma uses physical addresses, isn't that what
> alloc_bootmem returns? I'm not aware of dma_map_single etc I will look at
> that soon.
No alloc_bootmem doesnt return physical addresses. It returns virtual
address. That is the reason you need to use dma_map_single and
dma_unmap_single. These apis return physical address(dma_addr_t) for
the corresponding virtual address. Also they flush/invalidate the
cache so there are no side effects.
But dma_alloc_coherent gives you a memory whose cache lines are
disabled, so you wouldnt have to worry about caching side effects.
-syed
More information about the Kernelnewbies
mailing list